Changeset 114079 in webkit
- Timestamp:
- Apr 12, 2012 9:19:42 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r114078 r114079 1 2012-04-12 Levi Weintraub <leviw@chromium.org> 2 3 Prepare functions in LengthFunctions.h for LayoutUnits 4 https://bugs.webkit.org/show_bug.cgi?id=83726 5 6 Reviewed by Eric Seidel. 7 8 Preparing the functions that live in LengthFunctions for sub-pixel layout, which entails 9 using and returning LayoutUnits instead of integers. There are a number of rendering 10 classes that are laid out using integers -- see https://trac.webkit.org/wiki/LayoutUnit 11 for details -- so this also adds integer-specific versions of the length functions for 12 explicit use in those classes. 13 14 No new tests. No change in behavior. 15 16 * css/LengthFunctions.h: 17 (WebCore): Using LayoutUnits for sub-pixel precision and adding integer-specific versions 18 of minimumValueForLength and valueForLength that truncate. 19 * css/LengthFunctions.cpp: 20 (WebCore): 21 * dom/Document.cpp: 22 (WebCore::Document::pageSizeAndMarginsInPixels): Document sizes are integral. 23 * rendering/RenderFrameSet.cpp: 24 (WebCore::RenderFrameSet::layOutAxis): The frame tree continues to be integral. 25 * rendering/RenderMarquee.cpp: 26 (WebCore::RenderMarquee::timerFired): RenderMarquee scrolling uses integral values. 27 * rendering/RenderTableSection.cpp: 28 (WebCore::RenderTableSection::calcRowLogicalHeight): Table layout is integral. 29 1 30 2012-04-12 Sheriff Bot <webkit.review.bot@gmail.com> 2 31 -
trunk/Source/WebCore/css/LengthFunctions.cpp
r113824 r114079 30 30 namespace WebCore { 31 31 32 int minimumValueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages) 32 int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages) 33 { 34 return static_cast<int>(minimumValueForLength(length, maximumValue, renderView, roundPercentages)); 35 } 36 37 int intValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages) 38 { 39 return static_cast<int>(valueForLength(length, maximumValue, renderView, roundPercentages)); 40 } 41 42 LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages) 33 43 { 34 44 switch (length.type()) { … … 37 47 case Percent: 38 48 if (roundPercentages) 39 return static_cast< int>(round(maximumValue * length.percent() / 100.0f));49 return static_cast<LayoutUnit>(round(maximumValue * length.percent() / 100.0f)); 40 50 // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack. 41 return static_cast< int>(static_cast<float>(maximumValue * length.percent() / 100.0f));51 return static_cast<LayoutUnit>(static_cast<float>(maximumValue * length.percent() / 100.0f)); 42 52 case Calculated: 43 53 return length.nonNanCalculatedValue(maximumValue); 44 54 case ViewportPercentageWidth: 45 55 if (renderView) 46 return static_cast< int>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f);47 return 0;56 return static_cast<LayoutUnit>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f); 57 return ZERO_LAYOUT_UNIT; 48 58 case ViewportPercentageHeight: 49 59 if (renderView) 50 return static_cast< int>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f);51 return 0;60 return static_cast<LayoutUnit>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f); 61 return ZERO_LAYOUT_UNIT; 52 62 case ViewportPercentageMin: 53 63 if (renderView) { 54 64 IntSize viewportSize = renderView->viewportSize(); 55 return static_cast< int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f);65 return static_cast<LayoutUnit>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f); 56 66 } 57 return 0;67 return ZERO_LAYOUT_UNIT; 58 68 case Auto: 59 return 0;69 return ZERO_LAYOUT_UNIT; 60 70 case Relative: 61 71 case Intrinsic: … … 63 73 case Undefined: 64 74 ASSERT_NOT_REACHED(); 65 return 0;75 return ZERO_LAYOUT_UNIT; 66 76 } 67 77 ASSERT_NOT_REACHED(); 68 return 0;78 return ZERO_LAYOUT_UNIT; 69 79 } 70 80 71 int valueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages)81 LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages) 72 82 { 73 83 switch (length.type()) { … … 84 94 case Relative: 85 95 ASSERT_NOT_REACHED(); 86 return 0;96 return ZERO_LAYOUT_UNIT; 87 97 case Intrinsic: 88 98 ASSERT_NOT_REACHED(); 89 return 0;99 return ZERO_LAYOUT_UNIT; 90 100 case MinIntrinsic: 91 101 ASSERT_NOT_REACHED(); 92 return 0;102 return ZERO_LAYOUT_UNIT; 93 103 case Undefined: 94 104 ASSERT_NOT_REACHED(); 95 return 0;105 return ZERO_LAYOUT_UNIT; 96 106 } 97 107 ASSERT_NOT_REACHED(); 98 return 0;108 return ZERO_LAYOUT_UNIT; 99 109 } 100 110 101 111 // FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143. 102 float floatValueForLength(const Length& length, int maximumValue, RenderView* renderView)112 float floatValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView) 103 113 { 104 114 switch (length.type()) { -
trunk/Source/WebCore/css/LengthFunctions.h
r112472 r114079 25 25 #define LengthFunctions_h 26 26 27 #include "LayoutTypes.h" 28 27 29 namespace WebCore { 28 30 … … 30 32 struct Length; 31 33 32 int minimumValueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false); 33 int valueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false); 34 float floatValueForLength(const Length&, int maximumValue, RenderView* = 0); 34 int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); 35 int intValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); 36 LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); 37 LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); 38 float floatValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0); 35 39 float floatValueForLength(const Length&, float maximumValue, RenderView* = 0); 36 40 -
trunk/Source/WebCore/dom/Document.cpp
r114059 r114079 1851 1851 // The percentage is calculated with respect to the width even for margin top and bottom. 1852 1852 // http://www.w3.org/TR/CSS2/box.html#margin-properties 1853 marginTop = style->marginTop().isAuto() ? marginTop : valueForLength(style->marginTop(), width, view);1854 marginRight = style->marginRight().isAuto() ? marginRight : valueForLength(style->marginRight(), width, view);1855 marginBottom = style->marginBottom().isAuto() ? marginBottom : valueForLength(style->marginBottom(), width, view);1856 marginLeft = style->marginLeft().isAuto() ? marginLeft : valueForLength(style->marginLeft(), width, view);1853 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(style->marginTop(), width, view); 1854 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLength(style->marginRight(), width, view); 1855 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLength(style->marginBottom(), width, view); 1856 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(style->marginLeft(), width, view); 1857 1857 } 1858 1858 -
trunk/Source/WebCore/rendering/RenderFrameSet.cpp
r111126 r114079 216 216 // Count the number of columns/rows which are fixed -> countFixed 217 217 if (grid[i].isFixed()) { 218 gridLayout[i] = max(grid[i]. value(), 0);218 gridLayout[i] = max(grid[i].intValue(), 0); 219 219 totalFixed += gridLayout[i]; 220 220 countFixed++; … … 224 224 // Count the number of columns/rows which are percentages -> countPercent 225 225 if (grid[i].isPercent()) { 226 gridLayout[i] = max( valueForLength(grid[i], availableLen), 0);226 gridLayout[i] = max(intValueForLength(grid[i], availableLen), 0); 227 227 totalPercent += gridLayout[i]; 228 228 countPercent++; … … 232 232 // Count the number of columns/rows which are relative -> countRelative 233 233 if (grid[i].isRelative()) { 234 totalRelative += max(grid[i]. value(), 1);234 totalRelative += max(grid[i].intValue(), 1); 235 235 countRelative++; 236 236 } … … 277 277 for (int i = 0; i < gridLen; ++i) { 278 278 if (grid[i].isRelative()) { 279 gridLayout[i] = (max(grid[i]. value(), 1) * remainingRelative) / totalRelative;279 gridLayout[i] = (max(grid[i].intValue(), 1) * remainingRelative) / totalRelative; 280 280 remainingLen -= gridLayout[i]; 281 281 lastRelative = i; -
trunk/Source/WebCore/rendering/RenderMarquee.cpp
r113665 r114079 290 290 bool positive = range > 0; 291 291 int clientSize = (isHorizontal() ? m_layer->renderBox()->clientWidth() : m_layer->renderBox()->clientHeight()); 292 int increment = abs( valueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize));292 int increment = abs(intValueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize)); 293 293 int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->scrollYOffset()); 294 294 newPos = currentPos + (addIncrement ? increment : -increment); -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r113738 r114079 335 335 336 336 // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells). 337 m_rowPos[r + 1] = max(m_rowPos[r] + minimum ValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);337 m_rowPos[r + 1] = max(m_rowPos[r] + minimumIntValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0); 338 338 339 339 Row& row = m_grid[r].row;
Note: See TracChangeset
for help on using the changeset viewer.