https://bugs.webkit.org/show_bug.cgi?id=87774
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2012 20:20:33 +0000 (20:20 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2012 20:20:33 +0000 (20:20 +0000)
REGRESSION (r105515): reflection masks are truncated at zoom levels < 1
-and corresponding-
<rdar://problem/11387506>

Reviewed by Simon Fraser.

Source/WebCore:

paintNinePieceImage() expects un-zoomed results from
calculateImageIntrinsicDimensions(). This was previously addressed by having
paintNinePieceImage() divide the effective zoom out of the result from
calculateImageIntrinsicDimensions(). However, that results in buggy behavior for
generated images and images with percentage sizes. In the end it seems best to
just send a parameter to calculateImageIntrinsicDimensions() indicating whether
the caller wants the result to be scaled by the effective zoom when appropriate.

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
* rendering/RenderBoxModelObject.h:
(RenderBoxModelObject):

LayoutTests:

* fast/reflections/reflection-with-zoom.html: Added.
* platform/mac/fast/reflections/reflection-with-zoom-expected.png: Added.
* platform/mac/fast/reflections/reflection-with-zoom-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119274 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/reflections/reflection-with-zoom.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h

index fd0d1c9..032f34f 100644 (file)
@@ -1,3 +1,16 @@
+2012-06-01  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=87774
+        REGRESSION (r105515): reflection masks are truncated at zoom levels < 1
+        -and corresponding-
+        <rdar://problem/11387506>
+
+        Reviewed by Simon Fraser.
+
+        * fast/reflections/reflection-with-zoom.html: Added.
+        * platform/mac/fast/reflections/reflection-with-zoom-expected.png: Added.
+        * platform/mac/fast/reflections/reflection-with-zoom-expected.txt: Added.
+
 2012-06-01  Stephen Chenney  <schenney@chromium.org>
 
         Another Chromium test expectation update per the bug 88124.
diff --git a/LayoutTests/fast/reflections/reflection-with-zoom.html b/LayoutTests/fast/reflections/reflection-with-zoom.html
new file mode 100644 (file)
index 0000000..f4fd1cf
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<style type="text/css">
+    body {
+        zoom: 0.75;
+    }
+    img {
+        border: 1px solid black;
+        -webkit-box-reflect: below 1px -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(white));
+    }
+</style>
+</head>
+
+<body>
+    <img src="resources/kate.png">
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.png b/LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.png
new file mode 100644 (file)
index 0000000..27487a0
Binary files /dev/null and b/LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.txt b/LayoutTests/platform/mac/fast/reflections/reflection-with-zoom-expected.txt
new file mode 100644 (file)
index 0000000..baad127
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (6,6) size 788x588
+      RenderText {#text} at (0,0) size 0x0
+layer at (6,6) size 253x224
+  RenderImage {IMG} at (0,0) size 253x224 [border: (1px solid #000000)]
index 3bde3cb..62f1ee2 100644 (file)
@@ -1,3 +1,27 @@
+2012-06-01  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=87774
+        REGRESSION (r105515): reflection masks are truncated at zoom levels < 1
+        -and corresponding-
+        <rdar://problem/11387506>
+
+        Reviewed by Simon Fraser.
+
+        paintNinePieceImage() expects un-zoomed results from 
+        calculateImageIntrinsicDimensions(). This was previously addressed by having 
+        paintNinePieceImage() divide the effective zoom out of the result from 
+        calculateImageIntrinsicDimensions(). However, that results in buggy behavior for 
+        generated images and images with percentage sizes. In the end it seems best to 
+        just send a parameter to calculateImageIntrinsicDimensions() indicating whether 
+        the caller wants the result to be scaled by the effective zoom when appropriate.
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
+        (WebCore::RenderBoxModelObject::calculateFillTileSize):
+        (WebCore::RenderBoxModelObject::paintNinePieceImage):
+        * rendering/RenderBoxModelObject.h:
+        (RenderBoxModelObject):
+
 2012-06-01  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Prepare table collapsed border computation to support mixed directionality on row group
index 0cbf991..646ffe2 100644 (file)
@@ -977,7 +977,7 @@ static inline IntSize resolveAgainstIntrinsicRatio(const IntSize& size, const Fl
     return IntSize(size.width(), solutionHeight);
 }
 
-IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize) const
+IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
 {
     // A generated image without a fixed size, will always return the container size as intrinsic size.
     if (image->isGeneratedImage() && image->usesImageContainerSize())
@@ -1001,7 +1001,8 @@ IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
 
     IntSize resolvedSize(intrinsicWidth.isFixed() ? intrinsicWidth.value() : 0, intrinsicHeight.isFixed() ? intrinsicHeight.value() : 0);
     IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
-    resolvedSize.scale(style()->effectiveZoom());
+    if (shouldScaleOrNot == ScaleByEffectiveZoom)
+        resolvedSize.scale(style()->effectiveZoom());
     resolvedSize.clampToMinimumSize(minimumSize);
 
     if (!resolvedSize.isEmpty())
@@ -1030,7 +1031,7 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
     StyleImage* image = fillLayer->image();
     EFillSizeType type = fillLayer->size().type;
 
-    IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
+    IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
     imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScaleFactor());
     RenderView* renderView = view();
     switch (type) {
@@ -1241,13 +1242,13 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
     LayoutUnit rightWithOutset = rect.maxX() + rightOutset;
     IntRect borderImageRect = pixelSnappedIntRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
 
-    IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
+    IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size(), DoNotScaleByEffectiveZoom);
 
     // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
     styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoom());
 
-    int imageWidth = imageSize.width() / style->effectiveZoom();
-    int imageHeight = imageSize.height() / style->effectiveZoom();
+    int imageWidth = imageSize.width();
+    int imageHeight = imageSize.height();
     RenderView* renderView = view();
 
     float imageScaleFactor = styleImage->imageScaleFactor();
index 28a50eb..9a0eea2 100644 (file)
@@ -272,7 +272,9 @@ private:
     virtual bool isBoxModelObject() const { return true; }
 
     IntSize calculateFillTileSize(const FillLayer*, const IntSize& scaledPositioningAreaSize) const;
-    IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize) const;
+
+    enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffectiveZoom };
+    IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
 
     RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
         bool includeLogicalLeftEdge, bool includeLogicalRightEdge);