Title: [202348] trunk
Revision
202348
Author
[email protected]
Date
2016-06-22 13:44:26 -0700 (Wed, 22 Jun 2016)

Log Message

REGRESSION (r201629): Weird button glitching on github.com
https://bugs.webkit.org/show_bug.cgi?id=159031
rdar://problem/26880332

Reviewed by Tim Horton.

Source/WebCore:

r201629 changed the logic slightly when creating an image buffer for a scaled context;
it set the buffer context's scale to the scale in the source context, but this failed
to take into account the rounding up of the buffer size, which the old code did.

Fix by reverting to the old behavior.

Since buffer sizes can only be integral, changed compatibleBufferSize() to return
an IntSize.

Test: fast/backgrounds/scaled-gradient-background.html

* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
(WebCore::ImageBuffer::compatibleBufferSize):
* platform/graphics/ImageBuffer.h:
* platform/graphics/IntRect.h:
(WebCore::IntRect::area):
* platform/graphics/IntSize.h:
(WebCore::IntSize::area): Make this return an unsigned.

LayoutTests:

* fast/backgrounds/scaled-gradient-background-expected.html: Added.
* fast/backgrounds/scaled-gradient-background.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202347 => 202348)


--- trunk/LayoutTests/ChangeLog	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/LayoutTests/ChangeLog	2016-06-22 20:44:26 UTC (rev 202348)
@@ -1,3 +1,14 @@
+2016-06-22  Simon Fraser  <[email protected]>
+
+        REGRESSION (r201629): Weird button glitching on github.com
+        https://bugs.webkit.org/show_bug.cgi?id=159031
+        rdar://problem/26880332
+
+        Reviewed by Tim Horton.
+
+        * fast/backgrounds/scaled-gradient-background-expected.html: Added.
+        * fast/backgrounds/scaled-gradient-background.html: Added.
+
 2016-06-22  Alexey Proskuryakov  <[email protected]>
 
         Test expectation gardening for rdar://problem/26950065

Added: trunk/LayoutTests/fast/backgrounds/scaled-gradient-background-expected.html (0 => 202348)


--- trunk/LayoutTests/fast/backgrounds/scaled-gradient-background-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/scaled-gradient-background-expected.html	2016-06-22 20:44:26 UTC (rev 202348)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+    .box {
+        position: absolute;
+        top: 50px;
+        left: 50px;
+        height: 100px;
+        width: 100px;
+        margin: 100px;
+        background-color: green;
+        border: 1px solid black;
+    }
+
+    .clipper {
+        position: absolute;
+        top: 78px;
+        left: 78px;
+        height: 205px;
+        width: 205px;
+        border: 20px solid gray;
+    }
+    </style>
+</head>
+<body>
+
+<p>Green background should not appear stripey</p>
+<div class="box" style="transform: scale(2.19)"></div>
+
+<div class="clipper"></div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/backgrounds/scaled-gradient-background.html (0 => 202348)


--- trunk/LayoutTests/fast/backgrounds/scaled-gradient-background.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/scaled-gradient-background.html	2016-06-22 20:44:26 UTC (rev 202348)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+    .box {
+        position: absolute;
+        top: 50px;
+        left: 50px;
+        height: 100px;
+        width: 100px;
+        margin: 100px;
+        background-image: linear-gradient(green, green);
+        border: 1px solid black;
+    }
+    
+    .clipper {
+        position: absolute;
+        top: 78px;
+        left: 78px;
+        height: 205px;
+        width: 205px;
+        border: 20px solid gray;
+    }
+    </style>
+</head>
+<body>
+
+<p>Green background should not appear stripey</p>
+<div class="box" style="transform: scale(2.19)"></div>
+
+<div class="clipper"></div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (202347 => 202348)


--- trunk/Source/WebCore/ChangeLog	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/Source/WebCore/ChangeLog	2016-06-22 20:44:26 UTC (rev 202348)
@@ -1,3 +1,31 @@
+2016-06-22  Simon Fraser  <[email protected]>
+
+        REGRESSION (r201629): Weird button glitching on github.com
+        https://bugs.webkit.org/show_bug.cgi?id=159031
+        rdar://problem/26880332
+
+        Reviewed by Tim Horton.
+
+        r201629 changed the logic slightly when creating an image buffer for a scaled context;
+        it set the buffer context's scale to the scale in the source context, but this failed
+        to take into account the rounding up of the buffer size, which the old code did.
+
+        Fix by reverting to the old behavior.
+
+        Since buffer sizes can only be integral, changed compatibleBufferSize() to return
+        an IntSize.
+
+        Test: fast/backgrounds/scaled-gradient-background.html
+
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        (WebCore::ImageBuffer::compatibleBufferSize):
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/IntRect.h:
+        (WebCore::IntRect::area):
+        * platform/graphics/IntSize.h:
+        (WebCore::IntSize::area): Make this return an unsigned.
+
 2016-06-22  Anders Carlsson  <[email protected]>
 
         Inline the last of the Apple Pay WebCore code

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (202347 => 202348)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2016-06-22 20:44:26 UTC (rev 202348)
@@ -169,14 +169,14 @@
     if (size.isEmpty())
         return nullptr;
 
-    FloatSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
+    IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
 
-    auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(scaledSize), 1, ColorSpaceSRGB, context, hasAlpha);
+    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceSRGB, context, hasAlpha);
     if (!buffer)
         return nullptr;
 
     // Set up a corresponding scale factor on the graphics context.
-    buffer->context().scale(context.scaleFactor());
+    buffer->context().scale(FloatSize(scaledSize.width() / size.width(), scaledSize.height() / size.height()));
     return buffer;
 }
 
@@ -185,11 +185,11 @@
     return create(size, context.renderingMode(), resolutionScale, colorSpace);
 }
 
-FloatSize ImageBuffer::compatibleBufferSize(const FloatSize& size, const GraphicsContext& context)
+IntSize ImageBuffer::compatibleBufferSize(const FloatSize& size, const GraphicsContext& context)
 {
     // Enlarge the buffer size if the context's transform is scaling it so we need a higher
     // resolution than one pixel per unit.
-    return size * context.scaleFactor();
+    return expandedIntSize(size * context.scaleFactor());
 }
 
 bool ImageBuffer::isCompatibleWithContext(const GraphicsContext& context) const

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (202347 => 202348)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2016-06-22 20:44:26 UTC (rev 202348)
@@ -83,7 +83,7 @@
     static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, const GraphicsContext&, bool hasAlpha = true);
     static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&, bool hasAlpha);
 
-    static FloatSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
+    static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
     bool isCompatibleWithContext(const GraphicsContext&) const;
 
     WEBCORE_EXPORT ~ImageBuffer();

Modified: trunk/Source/WebCore/platform/graphics/IntRect.h (202347 => 202348)


--- trunk/Source/WebCore/platform/graphics/IntRect.h	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/Source/WebCore/platform/graphics/IntRect.h	2016-06-22 20:44:26 UTC (rev 202348)
@@ -85,6 +85,8 @@
     int maxY() const { return y() + height(); }
     int width() const { return m_size.width(); }
     int height() const { return m_size.height(); }
+    
+    unsigned area() const { return m_size.area(); }
 
     void setX(int x) { m_location.setX(x); }
     void setY(int y) { m_location.setY(y); }

Modified: trunk/Source/WebCore/platform/graphics/IntSize.h (202347 => 202348)


--- trunk/Source/WebCore/platform/graphics/IntSize.h	2016-06-22 20:39:49 UTC (rev 202347)
+++ trunk/Source/WebCore/platform/graphics/IntSize.h	2016-06-22 20:44:26 UTC (rev 202348)
@@ -125,9 +125,9 @@
 
     IntSize constrainedBetween(const IntSize& min, const IntSize& max) const;
 
-    int area() const
+    unsigned area() const
     {
-        return m_width * m_height;
+        return abs(m_width) * abs(m_height);
     }
 
     int diagonalLengthSquared() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to