Changeset 99019 in webkit
- Timestamp:
- Nov 1, 2011 5:55:49 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99018 r99019 1 2011-11-01 Emil A Eklund <eae@chromium.org> 2 3 Switch background/border image back to Int 4 https://bugs.webkit.org/show_bug.cgi?id=71240 5 6 Reviewed by Darin Adler. 7 8 Switch background- and border-image rendering back to int to align with 9 device pixels. 10 11 No new tests. 12 13 * rendering/RenderBoxModelObject.cpp: 14 (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): 15 (WebCore::RenderBoxModelObject::calculateFillTileSize): 16 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment): 17 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip): 18 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase): 19 (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): 20 (WebCore::RenderBoxModelObject::paintNinePieceImage): 21 (WebCore::calculateAdjustedInnerBorder): 22 * rendering/RenderBoxModelObject.h: 23 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin): 24 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin): 25 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect): 26 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect): 27 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase): 28 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase): 29 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize): 30 (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize): 31 1 32 2011-11-01 Mark Hahnenberg <mhahnenberg@apple.com> 2 33 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r98852 r99019 834 834 } 835 835 836 LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize) const837 { 838 LayoutUnit resolvedWidth = 0;839 LayoutUnit resolvedHeight = 0;836 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize) const 837 { 838 int resolvedWidth = 0; 839 int resolvedHeight = 0; 840 840 FloatSize intrinsicRatio; 841 841 … … 851 851 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 852 852 if (intrinsicWidth.isFixed()) 853 resolvedWidth = static_cast< LayoutUnit>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));853 resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom())); 854 854 if (intrinsicHeight.isFixed()) 855 resolvedHeight = static_cast< LayoutUnit>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));855 resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom())); 856 856 } 857 857 … … 860 860 // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions. 861 861 if (resolvedWidth > 0 && resolvedHeight > 0) 862 return LayoutSize(resolvedWidth, resolvedHeight);862 return IntSize(resolvedWidth, resolvedHeight); 863 863 864 864 // If the image has one of either an intrinsic width or an intrinsic height: … … 880 880 } 881 881 882 LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const882 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const 883 883 { 884 884 StyleImage* image = fillLayer->image(); 885 885 EFillSizeType type = fillLayer->size().type; 886 886 887 LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);887 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize); 888 888 889 889 switch (type) { 890 890 case SizeLength: { 891 LayoutUnit w = positioningAreaSize.width();892 LayoutUnit h = positioningAreaSize.height();891 int w = positioningAreaSize.width(); 892 int h = positioningAreaSize.height(); 893 893 894 894 Length layerWidth = fillLayer->size().size.width(); … … 919 919 } 920 920 921 return LayoutSize(max<LayoutUnit>(1, w), max<LayoutUnit>(1, h));921 return IntSize(max(1, w), max(1, h)); 922 922 } 923 923 case SizeNone: { … … 936 936 ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height() : 1; 937 937 float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor); 938 return LayoutSize(max<LayoutUnit>(1, imageIntrinsicSize.width() * scaleFactor), max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor));938 return IntSize(max(1, static_cast<int>(imageIntrinsicSize.width() * scaleFactor)), max(1, static_cast<int>(imageIntrinsicSize.height() * scaleFactor))); 939 939 } 940 940 } 941 941 942 942 ASSERT_NOT_REACHED(); 943 return LayoutSize();943 return IntSize(); 944 944 } 945 945 … … 957 957 } 958 958 959 void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint) 960 { 961 m_phase.move(max<LayoutUnit>(attachmentPoint.x() - m_destRect.x(), 0), max<LayoutUnit>(attachmentPoint.y() - m_destRect.y(), 0)); 962 } 963 964 void RenderBoxModelObject::BackgroundImageGeometry::clip(const LayoutRect& clipRect) 959 void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const IntPoint& attachmentPoint) 960 { 961 IntPoint alignedPoint = attachmentPoint; 962 m_phase.move(max(alignedPoint.x() - m_destRect.x(), 0), max(alignedPoint.y() - m_destRect.y(), 0)); 963 } 964 965 void RenderBoxModelObject::BackgroundImageGeometry::clip(const IntRect& clipRect) 965 966 { 966 967 m_destRect.intersect(clipRect); 967 968 } 968 969 969 LayoutPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const970 { 971 LayoutPoint phase = m_phase;970 IntPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const 971 { 972 IntPoint phase = m_phase; 972 973 phase += m_destRect.location() - m_destOrigin; 973 974 return phase; … … 979 980 LayoutUnit left = 0; 980 981 LayoutUnit top = 0; 981 LayoutSize positioningAreaSize;982 IntSize positioningAreaSize; 982 983 983 984 // Determine the background positioning area and set destRect to the background painting area. … … 1028 1029 } 1029 1030 1030 LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);1031 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize); 1031 1032 fillLayer->image()->setContainerSizeForRenderer(this, fillTileSize, style()->effectiveZoom()); 1032 1033 geometry.setTileSize(fillTileSize); … … 1037 1038 LayoutUnit xPosition = fillLayer->xPosition().calcMinValue(positioningAreaSize.width() - geometry.tileSize().width(), true); 1038 1039 if (backgroundRepeatX == RepeatFill) 1039 geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : 0);1040 geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : LayoutUnit(0)); 1040 1041 else 1041 1042 geometry.setNoRepeatX(xPosition + left); … … 1043 1044 LayoutUnit yPosition = fillLayer->yPosition().calcMinValue(positioningAreaSize.height() - geometry.tileSize().height(), true); 1044 1045 if (backgroundRepeatY == RepeatFill) 1045 geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : 0);1046 geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : LayoutUnit(0)); 1046 1047 else 1047 1048 geometry.setNoRepeatY(yPosition + top); … … 1090 1091 LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset); 1091 1092 1092 LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());1093 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size()); 1093 1094 1094 1095 // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any. 1095 LayoutSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;1096 IntSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize; 1096 1097 styleImage->setContainerSizeForRenderer(this, containerSize, style->effectiveZoom()); 1097 1098 1098 LayoutUnit imageWidth = imageSize.width();1099 LayoutUnit imageHeight = imageSize.height();1100 1101 LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));1102 LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));1103 LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));1104 LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));1099 int imageWidth = imageSize.width(); 1100 int imageHeight = imageSize.height(); 1101 1102 int topSlice = min<int>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight)); 1103 int rightSlice = min<int>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth)); 1104 int bottomSlice = min<int>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight)); 1105 int leftSlice = min<int>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth)); 1105 1106 1106 1107 ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); … … 1116 1117 // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all W are reduced by 1117 1118 // multiplying them by f. 1118 int borderSideWidth = max(1, leftWidth + rightWidth);1119 int borderSideHeight = max(1, topWidth + bottomWidth);1119 LayoutUnit borderSideWidth = max<LayoutUnit>(1, leftWidth + rightWidth); 1120 LayoutUnit borderSideHeight = max<LayoutUnit>(1, topWidth + bottomWidth); 1120 1121 float borderSideScaleFactor = min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight); 1121 1122 if (borderSideScaleFactor < 1) { … … 1164 1165 // Paint the left edge. 1165 1166 // Have to scale and tile into the border rect. 1166 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,1167 graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth, 1167 1168 destinationHeight), 1168 LayoutRect(0, topSlice, leftSlice, sourceHeight),1169 IntRect(0, topSlice, leftSlice, sourceHeight), 1169 1170 FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op); 1170 1171 } … … 1185 1186 1186 1187 // Paint the right edge. 1187 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,1188 graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth, 1188 1189 destinationHeight), 1189 LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),1190 IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight), 1190 1191 FloatSize(rightSideScale, rightSideScale), 1191 1192 Image::StretchTile, (Image::TileRule)vRule, op); … … 1194 1195 // Paint the top edge. 1195 1196 if (drawTop) 1196 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),1197 LayoutRect(leftSlice, 0, sourceWidth, topSlice),1197 graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth), 1198 IntRect(leftSlice, 0, sourceWidth, topSlice), 1198 1199 FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op); 1199 1200 1200 1201 // Paint the bottom edge. 1201 1202 if (drawBottom) 1202 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,1203 graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth, 1203 1204 destinationWidth, bottomWidth), 1204 LayoutRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),1205 IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice), 1205 1206 FloatSize(bottomSideScale, bottomSideScale), 1206 1207 (Image::TileRule)hRule, Image::StretchTile, op); … … 1229 1230 1230 1231 graphicsContext->drawTiledImage(image.get(), colorSpace, 1231 LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),1232 LayoutRect(leftSlice, topSlice, sourceWidth, sourceHeight),1232 IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight), 1233 IntRect(leftSlice, topSlice, sourceWidth, sourceHeight), 1233 1234 middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op); 1234 1235 } … … 2347 2348 // for an edge is zero, so we can shift the arc towards the zero radius corner. 2348 2349 RoundedRect::Radii newRadii = innerBorder.radii(); 2349 LayoutRect newRect = innerBorder.rect();2350 IntRect newRect = innerBorder.rect(); 2350 2351 2351 2352 float overshoot; … … 2361 2362 newRect.move(-overshoot, 0); 2362 2363 } 2363 newRadii.setBottomLeft( LayoutSize(0, 0));2364 newRadii.setBottomRight( LayoutSize(0, 0));2365 maxRadii = max <LayoutUnit>(newRadii.topLeft().height(), newRadii.topRight().height());2364 newRadii.setBottomLeft(IntSize(0, 0)); 2365 newRadii.setBottomRight(IntSize(0, 0)); 2366 maxRadii = max(newRadii.topLeft().height(), newRadii.topRight().height()); 2366 2367 if (maxRadii > newRect.height()) 2367 2368 newRect.setHeight(maxRadii); … … 2376 2377 newRect.move(-overshoot, 0); 2377 2378 } 2378 newRadii.setTopLeft( LayoutSize(0, 0));2379 newRadii.setTopRight( LayoutSize(0, 0));2380 maxRadii = max <LayoutUnit>(newRadii.bottomLeft().height(), newRadii.bottomRight().height());2379 newRadii.setTopLeft(IntSize(0, 0)); 2380 newRadii.setTopRight(IntSize(0, 0)); 2381 maxRadii = max(newRadii.bottomLeft().height(), newRadii.bottomRight().height()); 2381 2382 if (maxRadii > newRect.height()) { 2382 2383 newRect.move(0, newRect.height() - maxRadii); … … 2393 2394 newRect.move(0, -overshoot); 2394 2395 } 2395 newRadii.setTopRight( LayoutSize(0, 0));2396 newRadii.setBottomRight( LayoutSize(0, 0));2397 maxRadii = max <LayoutUnit>(newRadii.topLeft().width(), newRadii.bottomLeft().width());2396 newRadii.setTopRight(IntSize(0, 0)); 2397 newRadii.setBottomRight(IntSize(0, 0)); 2398 maxRadii = max(newRadii.topLeft().width(), newRadii.bottomLeft().width()); 2398 2399 if (maxRadii > newRect.width()) 2399 2400 newRect.setWidth(maxRadii); … … 2408 2409 newRect.move(0, -overshoot); 2409 2410 } 2410 newRadii.setTopLeft( LayoutSize(0, 0));2411 newRadii.setBottomLeft( LayoutSize(0, 0));2412 maxRadii = max <LayoutUnit>(newRadii.topRight().width(), newRadii.bottomRight().width());2411 newRadii.setTopLeft(IntSize(0, 0)); 2412 newRadii.setBottomLeft(IntSize(0, 0)); 2413 maxRadii = max(newRadii.topRight().width(), newRadii.bottomRight().width()); 2413 2414 if (maxRadii > newRect.width()) { 2414 2415 newRect.move(newRect.width() - maxRadii, 0); -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r98852 r99019 138 138 class BackgroundImageGeometry { 139 139 public: 140 LayoutPoint destOrigin() const { return m_destOrigin; }141 void setDestOrigin(const LayoutPoint& destOrigin)140 IntPoint destOrigin() const { return m_destOrigin; } 141 void setDestOrigin(const IntPoint& destOrigin) 142 142 { 143 143 m_destOrigin = destOrigin; 144 144 } 145 145 146 LayoutRect destRect() const { return m_destRect; }147 void setDestRect(const LayoutRect& destRect)146 IntRect destRect() const { return m_destRect; } 147 void setDestRect(const IntRect& destRect) 148 148 { 149 149 m_destRect = destRect; … … 151 151 152 152 // Returns the phase relative to the destination rectangle. 153 LayoutPoint relativePhase() const;154 155 LayoutPoint phase() const { return m_phase; }156 void setPhase(const LayoutPoint& phase)153 IntPoint relativePhase() const; 154 155 IntPoint phase() const { return m_phase; } 156 void setPhase(const IntPoint& phase) 157 157 { 158 158 m_phase = phase; 159 159 } 160 160 161 LayoutSize tileSize() const { return m_tileSize; }162 void setTileSize(const LayoutSize& tileSize)161 IntSize tileSize() const { return m_tileSize; } 162 void setTileSize(const IntSize& tileSize) 163 163 { 164 164 m_tileSize = tileSize; … … 171 171 void setNoRepeatY(int yOffset); 172 172 173 void useFixedAttachment(const LayoutPoint& attachmentPoint);174 175 void clip(const LayoutRect&);173 void useFixedAttachment(const IntPoint& attachmentPoint); 174 175 void clip(const IntRect&); 176 176 private: 177 LayoutRect m_destRect;178 LayoutPoint m_destOrigin;179 LayoutPoint m_phase;180 LayoutSize m_tileSize;177 IntRect m_destRect; 178 IntPoint m_destOrigin; 179 IntPoint m_phase; 180 IntSize m_tileSize; 181 181 }; 182 182 … … 196 196 virtual bool isBoxModelObject() const { return true; } 197 197 198 LayoutSize calculateFillTileSize(const FillLayer*, const LayoutSize& scaledPositioningAreaSize) const;199 LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize) const;198 IntSize calculateFillTileSize(const FillLayer*, const IntSize& scaledPositioningAreaSize) const; 199 IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize) const; 200 200 201 201 RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
Note: See TracChangeset
for help on using the changeset viewer.