Changeset 95121 in webkit
- Timestamp:
- Sep 14, 2011 2:15:56 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 91 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95111 r95121 1 2011-09-14 David Hyatt <hyatt@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=68103 4 5 Centered portions of border images don't render correctly. Make the tile scale factor have to be 6 explicitly passed in and modify paintNinePieceImage to compute it for all sides. The attempts to 7 implicitly compute the scale for the pattern based off the source and destination rects just don't 8 work, since the center image rects don't provide the right information to be able to infer the 9 scale factor. 10 11 Reviewed by Sam Weinig. 12 13 Reset all the existing fast/borders pixel results to Lion for these changes. 14 15 * platform/mac/fast/borders/bidi-002-expected.png: 16 * platform/mac/fast/borders/bidi-009a-expected.png: 17 * platform/mac/fast/borders/bidi-012-expected.png: 18 * platform/mac/fast/borders/block-mask-overlay-image-expected.png: 19 * platform/mac/fast/borders/border-antialiasing-expected.png: 20 * platform/mac/fast/borders/border-color-inherit-expected.png: 21 * platform/mac/fast/borders/border-fit-expected.png: 22 * platform/mac/fast/borders/border-image-01-expected.png: 23 * platform/mac/fast/borders/border-image-border-radius-expected.png: 24 * platform/mac/fast/borders/border-image-longhand-expected.png: 25 * platform/mac/fast/borders/border-image-omit-right-slice-expected.png: 26 * platform/mac/fast/borders/border-image-outset-expected.png: 27 * platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png: 28 * platform/mac/fast/borders/border-image-repeat-expected.png: 29 * platform/mac/fast/borders/border-image-rotate-transform-expected.png: 30 * platform/mac/fast/borders/border-image-scale-transform-expected.png: 31 * platform/mac/fast/borders/border-image-scaled-expected.png: 32 * platform/mac/fast/borders/border-image-scrambled-expected.png: 33 * platform/mac/fast/borders/border-image-slices-expected.png: 34 * platform/mac/fast/borders/border-image-source-expected.png: 35 * platform/mac/fast/borders/border-radius-circle-expected.png: 36 * platform/mac/fast/borders/border-radius-constraints-expected.png: 37 * platform/mac/fast/borders/border-radius-different-width-001-expected.png: 38 * platform/mac/fast/borders/border-radius-groove-01-expected.png: 39 * platform/mac/fast/borders/border-radius-groove-02-expected.png: 40 * platform/mac/fast/borders/border-radius-groove-03-expected.png: 41 * platform/mac/fast/borders/border-radius-huge-assert-expected.png: 42 * platform/mac/fast/borders/border-radius-inline-flow-expected.png: 43 * platform/mac/fast/borders/border-radius-inset-outset-expected.png: 44 * platform/mac/fast/borders/border-radius-split-inline-expected.png: 45 * platform/mac/fast/borders/border-radius-wide-border-01-expected.png: 46 * platform/mac/fast/borders/border-radius-wide-border-02-expected.png: 47 * platform/mac/fast/borders/border-radius-wide-border-03-expected.png: 48 * platform/mac/fast/borders/border-radius-wide-border-04-expected.png: 49 * platform/mac/fast/borders/border-styles-split-expected.png: 50 * platform/mac/fast/borders/borderRadiusAllStylesAllCorners-expected.png: 51 * platform/mac/fast/borders/borderRadiusArcs01-expected.png: 52 * platform/mac/fast/borders/borderRadiusDashed01-expected.png: 53 * platform/mac/fast/borders/borderRadiusDashed02-expected.png: 54 * platform/mac/fast/borders/borderRadiusDashed03-expected.png: 55 * platform/mac/fast/borders/borderRadiusDashed04-expected.png: 56 * platform/mac/fast/borders/borderRadiusDashed05-expected.png: 57 * platform/mac/fast/borders/borderRadiusDashed06-expected.png: 58 * platform/mac/fast/borders/borderRadiusDotted01-expected.png: 59 * platform/mac/fast/borders/borderRadiusDotted02-expected.png: 60 * platform/mac/fast/borders/borderRadiusDotted03-expected.png: 61 * platform/mac/fast/borders/borderRadiusDotted04-expected.png: 62 * platform/mac/fast/borders/borderRadiusDotted05-expected.png: 63 * platform/mac/fast/borders/borderRadiusDotted06-expected.png: 64 * platform/mac/fast/borders/borderRadiusDouble01-expected.png: 65 * platform/mac/fast/borders/borderRadiusDouble02-expected.png: 66 * platform/mac/fast/borders/borderRadiusDouble03-expected.png: 67 * platform/mac/fast/borders/borderRadiusDouble04-expected.png: 68 * platform/mac/fast/borders/borderRadiusDouble05-expected.png: 69 * platform/mac/fast/borders/borderRadiusDouble06-expected.png: 70 * platform/mac/fast/borders/borderRadiusDouble07-expected.png: 71 * platform/mac/fast/borders/borderRadiusDouble08-expected.png: 72 * platform/mac/fast/borders/borderRadiusDouble09-expected.png: 73 * platform/mac/fast/borders/borderRadiusGroove01-expected.png: 74 * platform/mac/fast/borders/borderRadiusGroove02-expected.png: 75 * platform/mac/fast/borders/borderRadiusInset01-expected.png: 76 * platform/mac/fast/borders/borderRadiusInvalidColor-expected.png: 77 * platform/mac/fast/borders/borderRadiusOutset01-expected.png: 78 * platform/mac/fast/borders/borderRadiusRidge01-expected.png: 79 * platform/mac/fast/borders/borderRadiusSolid01-expected.png: 80 * platform/mac/fast/borders/borderRadiusSolid02-expected.png: 81 * platform/mac/fast/borders/borderRadiusSolid03-expected.png: 82 * platform/mac/fast/borders/borderRadiusSolid04-expected.png: 83 * platform/mac/fast/borders/different-color-borders-expected.png: 84 * platform/mac/fast/borders/fieldsetBorderRadius-expected.png: 85 * platform/mac/fast/borders/inline-mask-overlay-image-expected.png: 86 * platform/mac/fast/borders/mixed-border-styles-expected.png: 87 * platform/mac/fast/borders/mixed-border-styles-radius-expected.png: 88 * platform/mac/fast/borders/mixed-border-styles-radius2-expected.png: 89 * platform/mac/fast/borders/outline-alpha-block-expected.png: 90 * platform/mac/fast/borders/outline-alpha-inline-expected.png: 91 * platform/mac/fast/borders/outline-offset-min-assert-expected.png: 92 * platform/mac/fast/borders/rtl-border-01-expected.png: 93 * platform/mac/fast/borders/rtl-border-02-expected.png: 94 * platform/mac/fast/borders/rtl-border-03-expected.png: 95 * platform/mac/fast/borders/rtl-border-04-expected.png: 96 * platform/mac/fast/borders/rtl-border-05-expected.png: 97 * platform/mac/fast/borders/table-borders-expected.png: 98 * platform/mac/fast/borders/webkit-border-radius-expected.png: 99 1 100 2011-09-14 Eric Carlson <eric.carlson@apple.com> 2 101 -
trunk/Source/WebCore/ChangeLog
r95120 r95121 1 2011-09-14 David Hyatt <hyatt@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=68103 4 5 Centered portions of border images don't render correctly. Make the tile scale factor have to be 6 explicitly passed in and modify paintNinePieceImage to compute it for all sides. The attempts to 7 implicitly compute the scale for the pattern based off the source and destination rects just don't 8 work, since the center image rects don't provide the right information to be able to infer the 9 scale factor. 10 11 Reviewed by Sam Weinig. 12 13 Reset all the existing fast/borders pixel results to Lion for these changes. 14 15 * platform/graphics/GraphicsContext.cpp: 16 (WebCore::GraphicsContext::drawTiledImage): 17 * platform/graphics/GraphicsContext.h: 18 * platform/graphics/Image.cpp: 19 (WebCore::Image::drawTiled): 20 * platform/graphics/Image.h: 21 * rendering/RenderBoxModelObject.cpp: 22 (WebCore::RenderBoxModelObject::paintNinePieceImage): 23 1 24 2011-09-14 Anders Carlsson <andersca@apple.com> 2 25 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r94897 r95121 502 502 } 503 503 504 void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale) 504 void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, 505 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale) 505 506 { 506 507 if (paintingDisabled() || !image) … … 516 517 InterpolationQuality previousInterpolationQuality = imageInterpolationQuality(); 517 518 setImageInterpolationQuality(InterpolationLow); 518 image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);519 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op); 519 520 setImageInterpolationQuality(previousInterpolationQuality); 520 521 } else 521 image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);522 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op); 522 523 } 523 524 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r94897 r95121 316 316 CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false); 317 317 void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, 318 Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,318 const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile, 319 319 CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false); 320 320 -
trunk/Source/WebCore/platform/graphics/Image.cpp
r94420 r95121 89 89 } 90 90 91 static inline FloatSize calculatePatternScale(const FloatRect& dstRect, const FloatRect& srcRect, Image::TileRule hRule, Image::TileRule vRule)92 {93 float scaleX = 1.0f, scaleY = 1.0f;94 95 if (hRule == Image::StretchTile)96 scaleX = dstRect.width() / srcRect.width();97 if (vRule == Image::StretchTile)98 scaleY = dstRect.height() / srcRect.height();99 100 if (hRule == Image::RepeatTile)101 scaleX = scaleY;102 if (vRule == Image::RepeatTile)103 scaleY = scaleX;104 105 return FloatSize(scaleX, scaleY);106 }107 108 109 91 void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, ColorSpace styleColorSpace, CompositeOperator op) 110 92 { … … 152 134 153 135 // FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things. 154 void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator op) 136 void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, 137 const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator op) 155 138 { 156 139 if (mayFillWithSolidColor()) { … … 165 148 vRule = RepeatTile; 166 149 167 FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule); 168 AffineTransform patternTransform = AffineTransform().scaleNonUniform(scale.width(), scale.height()); 150 AffineTransform patternTransform = AffineTransform().scaleNonUniform(tileScaleFactor.width(), tileScaleFactor.height()); 169 151 170 152 // We want to construct the phase such that the pattern is centered (when stretch is not 171 153 // set for a particular rule). 172 float hPhase = scale.width() * srcRect.x();173 float vPhase = scale.height() * srcRect.y();154 float hPhase = tileScaleFactor.width() * srcRect.x(); 155 float vPhase = tileScaleFactor.height() * srcRect.y(); 174 156 if (hRule == Image::RepeatTile) 175 hPhase -= fmodf(dstRect.width(), scale.width() * srcRect.width()) / 2.0f;157 hPhase -= fmodf(dstRect.width(), tileScaleFactor.width() * srcRect.width()) / 2.0f; 176 158 if (vRule == Image::RepeatTile) 177 vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2.0f;159 vPhase -= fmodf(dstRect.height(), tileScaleFactor.height() * srcRect.height()) / 2.0f; 178 160 FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase); 179 161 -
trunk/Source/WebCore/platform/graphics/Image.h
r94420 r95121 174 174 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0; 175 175 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace, CompositeOperator); 176 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator);176 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator); 177 177 178 178 // Supporting tiled drawing -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r94912 r95121 977 977 // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function 978 978 // doesn't have any understanding of the zoom that is in effect on the tile. 979 styleImage->setImageContainerSize(rect.size());980 LayoutSize imageSize = styleImage->imageSize(this, 1.0f);981 LayoutUnit imageWidth = imageSize.width();982 LayoutUnit imageHeight = imageSize.height();983 984 LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));985 LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));986 LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));987 LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));988 989 ENinePieceImageRule hRule = ninePieceImage.horizontalRule();990 ENinePieceImageRule vRule = ninePieceImage.verticalRule();991 992 979 LayoutUnit topOutset; 993 980 LayoutUnit rightOutset; … … 1001 988 LayoutUnit rightWithOutset = rect.maxX() + rightOutset; 1002 989 LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset); 1003 990 991 styleImage->setImageContainerSize(borderImageRect.size()); 992 LayoutSize imageSize = styleImage->imageSize(this, 1.0f); 993 LayoutUnit imageWidth = imageSize.width(); 994 LayoutUnit imageHeight = imageSize.height(); 995 996 LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight)); 997 LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth)); 998 LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight)); 999 LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth)); 1000 1001 ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); 1002 ENinePieceImageRule vRule = ninePieceImage.verticalRule(); 1003 1004 1004 LayoutUnit topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height()); 1005 1005 LayoutUnit rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width()); … … 1030 1030 RefPtr<Image> image = styleImage->image(this, imageSize); 1031 1031 ColorSpace colorSpace = style->colorSpace(); 1032 1032 1033 float destinationWidth = borderImageRect.width() - leftWidth - rightWidth; 1034 float destinationHeight = borderImageRect.height() - topWidth - bottomWidth; 1035 1036 float sourceWidth = imageWidth - leftSlice - rightSlice; 1037 float sourceHeight = imageHeight - topSlice - bottomSlice; 1038 1039 float leftSideScale = drawLeft ? (float)leftWidth / leftSlice : 1; 1040 float rightSideScale = drawRight ? (float)rightWidth / rightSlice : 1; 1041 float topSideScale = drawTop ? (float)topWidth / topSlice : 1; 1042 float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1; 1043 1033 1044 if (drawLeft) { 1034 1045 // Paint the top and bottom left corners. … … 1049 1060 // Have to scale and tile into the border rect. 1050 1061 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth, 1051 borderImageRect.height() - topWidth - bottomWidth),1052 LayoutRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),1053 Image::StretchTile, (Image::TileRule)vRule, op);1062 destinationHeight), 1063 LayoutRect(0, topSlice, leftSlice, sourceHeight), 1064 FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op); 1054 1065 } 1055 1066 … … 1070 1081 // Paint the right edge. 1071 1082 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth, 1072 borderImageRect.height() - topWidth - bottomWidth), 1073 LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice), 1083 destinationHeight), 1084 LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight), 1085 FloatSize(rightSideScale, rightSideScale), 1074 1086 Image::StretchTile, (Image::TileRule)vRule, op); 1075 1087 } … … 1077 1089 // Paint the top edge. 1078 1090 if (drawTop) 1079 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), borderImageRect.width() - leftWidth - rightWidth, topWidth),1080 LayoutRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),1081 (Image::TileRule)hRule, Image::StretchTile, op);1091 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth), 1092 LayoutRect(leftSlice, 0, sourceWidth, topSlice), 1093 FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op); 1082 1094 1083 1095 // Paint the bottom edge. 1084 1096 if (drawBottom) 1085 1097 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth, 1086 borderImageRect.width() - leftWidth - rightWidth, bottomWidth), 1087 LayoutRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice), 1098 destinationWidth, bottomWidth), 1099 LayoutRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice), 1100 FloatSize(bottomSideScale, bottomSideScale), 1088 1101 (Image::TileRule)hRule, Image::StretchTile, op); 1089 1102 1090 1103 // Paint the middle. 1091 if (drawMiddle) 1092 graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, borderImageRect.width() - leftWidth - rightWidth, 1093 borderImageRect.height() - topWidth - bottomWidth), 1094 LayoutRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice), 1095 (Image::TileRule)hRule, (Image::TileRule)vRule, op); 1104 if (drawMiddle) { 1105 FloatSize middleScaleFactor(1, 1); 1106 if (drawTop) 1107 middleScaleFactor.setWidth(topSideScale); 1108 else if (drawBottom) 1109 middleScaleFactor.setWidth(bottomSideScale); 1110 if (drawLeft) 1111 middleScaleFactor.setHeight(leftSideScale); 1112 else if (drawRight) 1113 middleScaleFactor.setHeight(rightSideScale); 1114 1115 // For "stretch" rules, just override the scale factor and replace. We only had to do this for the 1116 // center tile, since sides don't even use the scale factor unless they have a rule other than "stretch". 1117 // The middle however can have "stretch" specified in one axis but not the other, so we have to 1118 // correct the scale here. 1119 if (hRule == StretchImageRule) 1120 middleScaleFactor.setWidth(destinationWidth / sourceWidth); 1121 1122 if (vRule == StretchImageRule) 1123 middleScaleFactor.setHeight(destinationHeight / sourceHeight); 1124 1125 graphicsContext->drawTiledImage(image.get(), colorSpace, 1126 LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight), 1127 LayoutRect(leftSlice, topSlice, sourceWidth, sourceHeight), 1128 middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op); 1129 } 1096 1130 1097 1131 return true;
Note: See TracChangeset
for help on using the changeset viewer.