Changeset 139329 in webkit
- Timestamp:
- Jan 10, 2013, 10:08:36 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r139328 r139329 1 2013-01-09 Ojan Vafai <ojan@chromium.org> 2 3 intrinsic min-widths don't override width for file upload controls 4 https://bugs.webkit.org/show_bug.cgi?id=106517 5 6 Reviewed by Tony Chang. 7 8 * fast/forms/file/intrinsic-min-width-overrides-width-expected.html: Added. 9 * fast/forms/file/intrinsic-min-width-overrides-width.html: Added. 10 1 11 2013-01-10 Florin Malita <fmalita@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r139326 r139329 1 2013-01-09 Ojan Vafai <ojan@chromium.org> 2 3 intrinsic min-widths don't override width for file upload controls 4 https://bugs.webkit.org/show_bug.cgi?id=106517 5 6 Reviewed by Tony Chang. 7 8 Separate out computing intrinsic width from perferred width so that 9 we can use the intrinsic width correctly when applying min-width/max-width. 10 The preferred width is the width used in its container's computation 11 of its intrinsic width. 12 13 This is the first in a series of patches making this work across 14 the render tree. 15 16 Test: fast/forms/file/intrinsic-min-width-overrides-width.html 17 18 * rendering/RenderBox.cpp: 19 (WebCore::RenderBox::minIntrinsicLogicalWidth): 20 (WebCore): 21 (WebCore::RenderBox::maxIntrinsicLogicalWidth): 22 (WebCore::RenderBox::computeIntrinsicLogicalWidths): 23 (WebCore::RenderBox::computeLogicalWidthInRegionUsing): 24 * rendering/RenderBox.h: 25 (RenderBox): 26 * rendering/RenderFileUploadControl.cpp: 27 (WebCore::RenderFileUploadControl::computeIntrinsicLogicalWidths): 28 (WebCore): 29 (WebCore::RenderFileUploadControl::computePreferredLogicalWidths): 30 * rendering/RenderFileUploadControl.h: 31 (RenderFileUploadControl): 32 1 33 2013-01-10 Victor Carbune <victor@rosedu.org> 2 34 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r139137 r139329 792 792 } 793 793 794 LayoutUnit RenderBox::minIntrinsicLogicalWidth() const 795 { 796 LayoutUnit minLogicalWidth = 0; 797 LayoutUnit maxLogicalWidth = 0; 798 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); 799 return minLogicalWidth + borderAndPaddingLogicalWidth(); 800 } 801 802 LayoutUnit RenderBox::maxIntrinsicLogicalWidth() const 803 { 804 LayoutUnit minLogicalWidth = 0; 805 LayoutUnit maxLogicalWidth = 0; 806 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); 807 return maxLogicalWidth + borderAndPaddingLogicalWidth(); 808 } 809 810 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const 811 { 812 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth(); 813 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth(); 814 } 815 794 816 LayoutUnit RenderBox::minPreferredLogicalWidth() const 795 817 { … … 1996 2018 1997 2019 if (logicalWidth.type() == MinContent) 1998 return min PreferredLogicalWidth();2020 return minIntrinsicLogicalWidth(); 1999 2021 if (logicalWidth.type() == MaxContent) 2000 return max PreferredLogicalWidth();2022 return maxIntrinsicLogicalWidth(); 2001 2023 2002 2024 RenderView* renderView = view(); -
trunk/Source/WebCore/rendering/RenderBox.h
r139044 r139329 295 295 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; 296 296 297 LayoutUnit minIntrinsicLogicalWidth() const; 298 LayoutUnit maxIntrinsicLogicalWidth() const; 299 297 300 virtual LayoutUnit minPreferredLogicalWidth() const; 298 301 virtual LayoutUnit maxPreferredLogicalWidth() const; … … 651 654 void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) const; 652 655 656 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const; 657 653 658 // This function calculates the minimum and maximum preferred widths for an object. 654 659 // These values are used in shrink-to-fit layout systems. -
trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp
r139216 r139329 165 165 } 166 166 167 void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const 168 { 169 // Figure out how big the filename space needs to be for a given number of characters 170 // (using "0" as the nominal character). 171 const UChar character = '0'; 172 const String characterAsString = String(&character, 1); 173 const Font& font = style()->font(); 174 // FIXME: Remove the need for this const_cast by making constructTextRun take a const RenderObject*. 175 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(this); 176 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructTextRun(renderer, font, characterAsString, style(), TextRun::AllowTrailingExpansion)); 177 178 const String label = theme()->fileListDefaultLabel(node()->toInputElement()->multiple()); 179 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label, style(), TextRun::AllowTrailingExpansion)); 180 if (HTMLInputElement* button = uploadButton()) 181 if (RenderObject* buttonRenderer = button->renderer()) 182 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + afterButtonSpacing; 183 maxLogicalWidth = static_cast<int>(ceilf(max(minDefaultLabelWidth, defaultLabelWidth))); 184 185 if (!style()->width().isPercent()) 186 minLogicalWidth = maxLogicalWidth; 187 } 188 167 189 void RenderFileUploadControl::computePreferredLogicalWidths() 168 190 { … … 172 194 m_maxPreferredLogicalWidth = 0; 173 195 174 RenderStyle* style = this->style(); 175 ASSERT(style); 176 177 const Font& font = style->font(); 178 if (style->width().isFixed() && style->width().value() > 0) 179 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style->width().value()); 180 else { 181 // Figure out how big the filename space needs to be for a given number of characters 182 // (using "0" as the nominal character). 183 const UChar character = '0'; 184 const String characterAsString = String(&character, 1); 185 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructTextRun(this, font, characterAsString, style, TextRun::AllowTrailingExpansion)); 186 187 const String label = theme()->fileListDefaultLabel(node()->toInputElement()->multiple()); 188 float defaultLabelWidth = font.width(constructTextRun(this, font, label, style, TextRun::AllowTrailingExpansion)); 189 if (HTMLInputElement* button = uploadButton()) 190 if (RenderObject* buttonRenderer = button->renderer()) 191 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + afterButtonSpacing; 192 m_maxPreferredLogicalWidth = static_cast<int>(ceilf(max(minDefaultLabelWidth, defaultLabelWidth))); 193 194 if (!style->width().isPercent()) 195 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 196 } 197 198 if (style->minWidth().isFixed() && style->minWidth().value() > 0) { 199 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->minWidth().value())); 200 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->minWidth().value())); 201 } 202 203 if (style->maxWidth().isFixed()) { 204 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->maxWidth().value())); 205 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->maxWidth().value())); 196 if (style()->width().isFixed() && style()->width().value() > 0) 197 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value()); 198 else 199 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); 200 201 if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { 202 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); 203 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); 204 } 205 206 if (style()->maxWidth().isFixed()) { 207 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); 208 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); 206 209 } 207 210 -
trunk/Source/WebCore/rendering/RenderFileUploadControl.h
r124556 r139329 47 47 virtual bool canBeReplacedWithInlineRunIn() const OVERRIDE; 48 48 virtual void updateFromElement(); 49 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE; 49 50 virtual void computePreferredLogicalWidths(); 50 51 virtual void paintObject(PaintInfo&, const LayoutPoint&);
Note:
See TracChangeset
for help on using the changeset viewer.