Changeset 111066 in webkit
- Timestamp:
- Mar 16, 2012 2:30:11 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r111064 r111066 1 2012-03-16 Emil A Eklund <eae@chromium.org> 2 3 Fix rounding and usage of LayoutUnits in RenderBoxModelObject 4 https://bugs.webkit.org/show_bug.cgi?id=81057 5 6 Reviewed by Julien Chaffraix. 7 8 No new tests. 9 10 (WebCore): 11 * rendering/RenderBoxModelObject.cpp: 12 (WebCore::RenderBoxModelObject::pixelSnappedOffsetWidth): 13 (WebCore::RenderBoxModelObject::pixelSnappedOffsetHeight): 14 Fix implementation of pixelSnappedOffsetWidth/Height. The location 15 parameter will be ignored until we enable subpixel support. 16 17 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 18 Use ints for border widths. 19 20 (WebCore::resolveWidthForRatio): 21 (WebCore::resolveHeightForRatio): 22 (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio): 23 (WebCore::resolveAgainstIntrinsicRatio): 24 Change resolve*Ratio methods to operate on IntSizes as none of the 25 callers need subpixel precision. 26 27 (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): 28 (WebCore::RenderBoxModelObject::paintNinePieceImage): 29 Pixel snap paintRect when computing image geometry. 30 1 31 2012-03-16 Terry Anderson <tdanderson@chromium.org> 2 32 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r110769 r111066 543 543 int RenderBoxModelObject::pixelSnappedOffsetWidth() const 544 544 { 545 return offsetWidth();545 return snapSizeToPixel(offsetWidth(), offsetLeft()); 546 546 } 547 547 548 548 int RenderBoxModelObject::pixelSnappedOffsetHeight() const 549 549 { 550 return offsetHeight();550 return snapSizeToPixel(offsetHeight(), offsetTop()); 551 551 } 552 552 … … 732 732 } 733 733 734 LayoutUnit bLeft = includeLeftEdge ? borderLeft() : zeroLayoutUnit;735 LayoutUnit bRight = includeRightEdge ? borderRight() : zeroLayoutUnit;734 int bLeft = includeLeftEdge ? borderLeft() : 0; 735 int bRight = includeRightEdge ? borderRight() : 0; 736 736 LayoutUnit pLeft = includeLeftEdge ? paddingLeft() : zeroLayoutUnit; 737 737 LayoutUnit pRight = includeRightEdge ? paddingRight() : zeroLayoutUnit; … … 880 880 } 881 881 882 static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const FloatSize& intrinsicRatio) 883 { 884 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 885 return static_cast<LayoutUnit>(ceilf(height * intrinsicRatio.width() / intrinsicRatio.height())); 886 } 887 888 static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize& intrinsicRatio) 889 { 890 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 891 return static_cast<LayoutUnit>(ceilf(width * intrinsicRatio.height() / intrinsicRatio.width())); 892 } 893 894 static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight) 882 static inline int resolveWidthForRatio(int height, const FloatSize& intrinsicRatio) 883 { 884 return ceilf(height * intrinsicRatio.width() / intrinsicRatio.height()); 885 } 886 887 static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRatio) 888 { 889 return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width()); 890 } 891 892 static inline IntSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const IntSize& size, const FloatSize& intrinsicRatio, int useWidth, int useHeight) 895 893 { 896 894 if (intrinsicRatio.isEmpty()) { 897 895 if (useWidth) 898 return LayoutSize(useWidth, size.height());899 return LayoutSize(size.width(), useHeight);896 return IntSize(useWidth, size.height()); 897 return IntSize(size.width(), useHeight); 900 898 } 901 899 902 900 if (useWidth) 903 return LayoutSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));904 return LayoutSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);905 } 906 907 static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize& size, const FloatSize& intrinsicRatio)901 return IntSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio)); 902 return IntSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight); 903 } 904 905 static inline IntSize resolveAgainstIntrinsicRatio(const IntSize& size, const FloatSize& intrinsicRatio) 908 906 { 909 907 // Two possible solutions: (size.width(), solutionHeight) or (solutionWidth, size.height()) 910 908 // "... must be assumed to be the largest dimensions..." = easiest answer: the rect with the largest surface area. 911 909 912 LayoutUnit solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);913 LayoutUnit solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);910 int solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio); 911 int solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio); 914 912 if (solutionWidth <= size.width()) { 915 913 if (solutionHeight <= size.height()) { 916 914 // If both solutions fit, choose the one covering the larger area. 917 LayoutUnit areaOne = solutionWidth * size.height();918 LayoutUnit areaTwo = size.width() * solutionHeight;915 int areaOne = solutionWidth * size.height(); 916 int areaTwo = size.width() * solutionHeight; 919 917 if (areaOne < areaTwo) 920 return LayoutSize(size.width(), solutionHeight);921 return LayoutSize(solutionWidth, size.height());918 return IntSize(size.width(), solutionHeight); 919 return IntSize(solutionWidth, size.height()); 922 920 } 923 921 924 922 // Only the first solution fits. 925 return LayoutSize(solutionWidth, size.height());923 return IntSize(solutionWidth, size.height()); 926 924 } 927 925 928 926 // Only the second solution fits, assert that. 929 927 ASSERT(solutionHeight <= size.height()); 930 return LayoutSize(size.width(), solutionHeight);928 return IntSize(size.width(), solutionHeight); 931 929 } 932 930 … … 1084 1082 LayoutUnit top = 0; 1085 1083 IntSize positioningAreaSize; 1084 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); 1086 1085 1087 1086 // Determine the background positioning area and set destRect to the background painting area. … … 1100 1099 1101 1100 if (!fixedAttachment) { 1102 geometry.setDestRect( paintRect);1101 geometry.setDestRect(snappedPaintRect); 1103 1102 1104 1103 LayoutUnit right = 0; … … 1122 1121 // the background positioning area. 1123 1122 if (isRoot()) { 1124 positioningAreaSize = LayoutSize(toRenderBox(this)->width() - left - right, toRenderBox(this)->height() - top - bottom); 1123 positioningAreaSize = IntSize(snapSizeToPixel(toRenderBox(this)->width() - left - right, toRenderBox(this)->x()), 1124 snapSizeToPixel(toRenderBox(this)->height() - top - bottom, toRenderBox(this)->y())); 1125 1125 left += marginLeft(); 1126 1126 top += marginTop(); 1127 1127 } else 1128 positioningAreaSize = LayoutSize(paintRect.width() - left - right, paintRect.height() - top - bottom); 1128 positioningAreaSize = IntSize(snapSizeToPixel(paintRect.width() - left - right, paintRect.x()), 1129 snapSizeToPixel(paintRect.height() - top - bottom, paintRect.y())); 1129 1130 } else { 1130 1131 geometry.setDestRect(pixelSnappedIntRect(viewRect())); … … 1141 1142 LayoutUnit xPosition = fillLayer->xPosition().calcMinValue(positioningAreaSize.width() - geometry.tileSize().width(), true); 1142 1143 if (backgroundRepeatX == RepeatFill) 1143 geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : LayoutUnit(0));1144 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() - (xPosition + left) % geometry.tileSize().width() : 0); 1144 1145 else 1145 1146 geometry.setNoRepeatX(xPosition + left); … … 1147 1148 LayoutUnit yPosition = fillLayer->yPosition().calcMinValue(positioningAreaSize.height() - geometry.tileSize().height(), true); 1148 1149 if (backgroundRepeatY == RepeatFill) 1149 geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : LayoutUnit(0));1150 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - (yPosition + top) % geometry.tileSize().height() : 0); 1150 1151 else 1151 1152 geometry.setNoRepeatY(yPosition + top); 1152 1153 1153 1154 if (fixedAttachment) 1154 geometry.useFixedAttachment( paintRect.location());1155 1156 geometry.clip( paintRect);1155 geometry.useFixedAttachment(snappedPaintRect.location()); 1156 1157 geometry.clip(snappedPaintRect); 1157 1158 geometry.setDestOrigin(geometry.destRect().location()); 1158 1159 } … … 1192 1193 LayoutUnit leftWithOutset = rect.x() - leftOutset; 1193 1194 LayoutUnit rightWithOutset = rect.maxX() + rightOutset; 1194 LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);1195 IntRect borderImageRect = pixelSnappedIntRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset); 1195 1196 1196 1197 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
Note: See TracChangeset
for help on using the changeset viewer.