WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch for calcMinMaxWidth
patch_width_2_14.txt (text/plain), 5.56 KB, created by
Adele Peterson
on 2006-02-14 17:31:49 PST
(
hide
)
Description:
patch for calcMinMaxWidth
Filename:
MIME Type:
Creator:
Adele Peterson
Created:
2006-02-14 17:31:49 PST
Size:
5.56 KB
patch
obsolete
>Index: ChangeLog >=================================================================== >--- ChangeLog (revision 12807) >+++ ChangeLog (working copy) >@@ -1,3 +1,20 @@ >+2006-02-14 Adele Peterson <adele@apple.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * rendering/RenderTextField.cpp: >+ (WebCore::RenderTextField::createDivStyle): Remove fixed width for text field. >+ (WebCore::RenderTextField::calcMinMaxWidth): Added. This calls RenderBlock::calcMinMaxWidth and >+ then uses the size attribute to determine what the maxWidth should be. >+ * rendering/RenderTextField.h: Added calcMinMaxWidth. >+ * rendering/render_theme_mac.h: Added adjustTextFieldStyle. >+ * rendering/render_theme_mac.mm: >+ (WebCore::RenderThemeMac::adjustRepaintRect): Remove inflation of rect. This is no longer necessary. >+ (WebCore::RenderThemeMac::paintTextField): ditto. >+ (WebCore::RenderThemeMac::setTextFieldCellState): change true to YES. >+ (WebCore::RenderThemeMac::adjustTextFieldStyle): Added. This is the temporary home of the code to set the >+ right padding and margins. When we flip the switch, this will go in html4.css. >+ > 2006-02-14 Timothy Hatcher <timothy@apple.com> > > Reviewed by Justin. >Index: rendering/RenderTextField.h >=================================================================== >--- rendering/RenderTextField.h (revision 12803) >+++ rendering/RenderTextField.h (working copy) >@@ -49,6 +49,7 @@ > RenderTextField(NodeImpl* node); > virtual ~RenderTextField(); > >+ virtual void calcMinMaxWidth(); > virtual const char *renderName() const { return "RenderTextField"; } > virtual void removeLeftoverAnonymousBoxes() {}; > virtual void setStyle(RenderStyle* style); >Index: rendering/render_theme_mac.h >=================================================================== >--- rendering/render_theme_mac.h (revision 12803) >+++ rendering/render_theme_mac.h (working copy) >@@ -60,6 +60,7 @@ > virtual void setButtonSize(RenderStyle* style) const; > > virtual bool paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); >+ virtual void adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, ElementImpl* e) const; > > private: > IntRect inflateRect(const IntRect& r, const IntSize& size, const int* margins) const; >Index: rendering/render_theme_mac.mm >=================================================================== >--- rendering/render_theme_mac.mm (revision 12803) >+++ rendering/render_theme_mac.mm (working copy) >@@ -41,9 +41,7 @@ > bottomMargin, > leftMargin > }; >- >-static const int textFieldMargins[4] = { 3, 4, 3, 4 }; >- >+ > RenderTheme* theme() > { > static RenderThemeMac macTheme; >@@ -93,10 +91,6 @@ > case TextFieldAppearance: > // Since we query the prototype cell, we need to update its state to match. > setTextFieldCellState(o, r); >- >- // We inflate the rect as needed to account for padding. >- // We don't consider this part of the bounds of the control in WebKit. >- r = inflateRect(r, r.size(), textFieldMargins); > break; > default: > break; >@@ -527,10 +521,8 @@ > { > // Initialize text field and update state. > setTextFieldCellState(o, r); >- >- IntRect inflatedRect = inflateRect(r, r.size(), textFieldMargins); >- >- [textField drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()]; >+ >+ [textField drawWithFrame:NSRect(r) inView:o->canvas()->view()->getDocumentView()]; > [textField setControlView: nil]; > > return false; >@@ -543,9 +535,25 @@ > [textField setBezeled:YES]; > [textField setBezelStyle:NSTextFieldSquareBezel]; > [textField setDrawsBackground:NO]; >- [textField setEditable:true]; >+ [textField setEditable:YES]; > } > updateEnabledState(textField, o); > } > >+void RenderThemeMac::adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, ElementImpl* e) const >+{ >+ // FIXME: If the style has a border, then turn off the aqua appearance. >+ >+ // FIXME: This should be in html4.css when we flip the switch >+ style->setPaddingTop(Length(3, Fixed)); >+ style->setPaddingBottom(Length(3, Fixed)); >+ style->setPaddingRight(Length(3, Fixed)); >+ style->setPaddingLeft(Length(3, Fixed)); >+ >+ style->setMarginTop(Length(2, Fixed)); >+ style->setMarginBottom(Length(2, Fixed)); >+ style->setMarginLeft(Length(2, Fixed)); >+ style->setMarginRight(Length(2, Fixed)); > } >+ >+} >Index: rendering/RenderTextField.cpp >=================================================================== >--- rendering/RenderTextField.cpp (revision 12803) >+++ rendering/RenderTextField.cpp (working copy) >@@ -78,9 +78,6 @@ > divStyle->setWhiteSpace(NOWRAP); > divStyle->setUserModify(READ_WRITE); > >- // FIXME: Remove this once we calculate size correctly. >- divStyle->setWidth(Length(140, Fixed)); >- > return divStyle; > } > >@@ -173,4 +170,19 @@ > input->setValueFromRenderer(m_div->textContent()); > } > >+void RenderTextField::calcMinMaxWidth() >+{ >+ RenderBlock::calcMinMaxWidth(); >+ >+ // Figure out how big a text field needs to be for a given number of characters >+ // (using "w" as the nominal character). >+ int size = static_cast<HTMLInputElementImpl*>(element())->size(); >+ if (size <= 0) >+ size = 20; >+ const QFontMetrics &fm = style()->fontMetrics(); >+ m_maxWidth = fm.width("w", 0, 0, 1) * size + paddingLeft() + paddingRight() + borderLeft() + borderRight(); >+ >+ setMinMaxKnown(); > } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mjs
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 6815
:
6492
|
6493
| 6495