Seaming on border corners with mixed colour alpha borders
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 00:57:30 +0000 (00:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 00:57:30 +0000 (00:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70471

Patch by Ben Wells <benwells@chromium.org> on 2011-11-16
Reviewed by Simon Fraser.

Source/WebCore:

Seaming is fixed by antialiasing mitred corners for edges that have alpha and are joining
a side that is of a different color.

Test: fast/borders/border-mixed-alpha.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::colorNeedsAntiAliasAtCorner):
(WebCore::RenderBoxModelObject::paintOneBorderSide):

LayoutTests:

* fast/borders/border-mixed-alpha.html: Added.
* platform/chromium/test_expectations.txt:
* platform/mac/fast/borders/border-mixed-alpha-expected.png: Added.
* platform/mac/fast/borders/border-mixed-alpha-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/borders/border-mixed-alpha.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBoxModelObject.cpp

index a5a0ebe3f4b32ef722df1e29b16915f242677aee..e317ccc314ec112600356ba35d453c82960047be 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-16  Ben Wells  <benwells@chromium.org>
+
+        Seaming on border corners with mixed colour alpha borders
+        https://bugs.webkit.org/show_bug.cgi?id=70471
+
+        Reviewed by Simon Fraser.
+
+        * fast/borders/border-mixed-alpha.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/fast/borders/border-mixed-alpha-expected.png: Added.
+        * platform/mac/fast/borders/border-mixed-alpha-expected.txt: Added.
+
 2011-11-16  Peter Kasting  <pkasting@google.com>
 
         [chromium] Clean up some animations/ expectations.
diff --git a/LayoutTests/fast/borders/border-mixed-alpha.html b/LayoutTests/fast/borders/border-mixed-alpha.html
new file mode 100644 (file)
index 0000000..486e97a
--- /dev/null
@@ -0,0 +1,32 @@
+<!doctype html>
+<style>
+    div {
+        width: 10px;
+        height: 100px;
+        display: inline-block;
+        border-width: 85px;
+        border-color: rgba(0, 255, 0, 0.5);
+        border-right-color: rgba(0, 0, 255, 0.5);
+    }
+    .dashed { border-style: dashed; }
+    .dotted { border-style: dotted; }
+    .solid { border-style: solid; }
+    .double { border-style: double; }
+    .groove { border-style: groove; }
+    .ridge { border-style: ridge; }
+    .inset { border-style: inset; }
+    .outset { border-style: outset; }
+</style>
+<div class="dashed"></div>
+<div class="dotted"></div>
+<div class="solid"></div>
+<div class="double"></div>
+<br>
+<div class="groove"></div>
+<div class="ridge"></div>
+<div class="inset"></div>
+<div class="outset"></div>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText(true);
+</script>
index 7b53c0a238bcbf791bd68798bc810c70005b8a4c..3356fc6e6bf5ef62d4308a1e313e4f7c0c65d92e 100644 (file)
@@ -3535,6 +3535,11 @@ BUGWK68436 SNOWLEOPARD CPU DEBUG : fast/repaint/background-clip-text.html = TIME
 BUGWK68436 SNOWLEOPARD CPU : fast/repaint/text-emphasis-h.html = TIMEOUT IMAGE
 BUGWK68436 SNOWLEOPARD CPU : svg/W3C-SVG-1.1/paths-data-12-t.svg = IMAGE+TEXT
 
+// New test that needs rebaselining for chromium ports
+BUGWK70471 : fast/borders/border-mixed-alpha.html = IMAGE
+// WK70471 introduces slight changes in seams for this test
+BUGWK70471 : fast/borders/mixed-border-styles.html = IMAGE
+
 // Tests that are known to exhibit TEXT failures on Mac10.5 with Skia (CPU and/or GPU) graphics.
 BUGWK68437 LEOPARD CPU : canvas/philip/tests/2d.text.draw.fontface.notinpage.html = TEXT
 
diff --git a/LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.png b/LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.png
new file mode 100644 (file)
index 0000000..23c8c8e
Binary files /dev/null and b/LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.txt b/LayoutTests/platform/mac/fast/borders/border-mixed-alpha-expected.txt
new file mode 100644 (file)
index 0000000..9322120
--- /dev/null
@@ -0,0 +1,2 @@
+    
+   
index 840f6f5c1ecda8a4690c3e5e9bae8c54f691d351..4128ca638d011cecac4e984d5f2e81472c291042 100644 (file)
@@ -1,3 +1,19 @@
+2011-11-16  Ben Wells  <benwells@chromium.org>
+
+        Seaming on border corners with mixed colour alpha borders
+        https://bugs.webkit.org/show_bug.cgi?id=70471
+
+        Reviewed by Simon Fraser.
+
+        Seaming is fixed by antialiasing mitred corners for edges that have alpha and are joining
+        a side that is of a different color.
+
+        Test: fast/borders/border-mixed-alpha.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::colorNeedsAntiAliasAtCorner):
+        (WebCore::RenderBoxModelObject::paintOneBorderSide):
+
 2011-11-16  Sam Weinig  <sam@webkit.org>
 
         JS wrappers of DOM objects should have no-op constructors
index 1960b04ce89614bbe94f8cdffceb88a0e404b5bd..5a9137a7280136ee7df88066337c99773ee5f2f8 100644 (file)
@@ -1424,6 +1424,21 @@ static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const
     return !borderStyleHasUnmatchedColorsAtCorner(edges[side].style, side, adjacentSide);
 }
 
+
+static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
+{
+    if (!edges[side].color.hasAlpha())
+        return false;
+
+    if (edges[side].shouldRender() != edges[adjacentSide].shouldRender())
+        return false;
+
+    if (!edgesShareColor(edges[side], edges[adjacentSide]))
+        return true;
+
+    return borderStyleHasUnmatchedColorsAtCorner(edges[side].style, side, adjacentSide);
+}
+
 // This assumes that we draw in order: top, bottom, left, right.
 static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
 {
@@ -1506,11 +1521,16 @@ void RenderBoxModelObject::paintOneBorderSide(GraphicsContext* graphicsContext,
         drawBoxSideFromPath(graphicsContext, outerBorder.rect(), *path, edges, edgeToRender.width, thickness, side, style,
             colorToPaint, edgeToRender.style, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
     } else {
-        bool shouldClip = styleRequiresClipPolygon(edgeToRender.style) && (mitreAdjacentSide1 || mitreAdjacentSide2);
+        bool clipForStyle = styleRequiresClipPolygon(edgeToRender.style) && (mitreAdjacentSide1 || mitreAdjacentSide2);
+        bool clipAdjacentSide1 = colorNeedsAntiAliasAtCorner(side, adjacentSide1, edges) && mitreAdjacentSide1;
+        bool clipAdjacentSide2 = colorNeedsAntiAliasAtCorner(side, adjacentSide2, edges) && mitreAdjacentSide2;
+        bool shouldClip = clipForStyle || clipAdjacentSide1 || clipAdjacentSide2;
         
         GraphicsContextStateSaver clipStateSaver(*graphicsContext, shouldClip);
         if (shouldClip) {
-            clipBorderSidePolygon(graphicsContext, outerBorder, innerBorder, side, !mitreAdjacentSide1, !mitreAdjacentSide2);
+            bool aliasAdjacentSide1 = clipAdjacentSide1 || (clipForStyle && mitreAdjacentSide1);
+            bool aliasAdjacentSide2 = clipAdjacentSide2 || (clipForStyle && mitreAdjacentSide2);
+            clipBorderSidePolygon(graphicsContext, outerBorder, innerBorder, side, !aliasAdjacentSide1, !aliasAdjacentSide2);
             // Since we clipped, no need to draw with a mitre.
             mitreAdjacentSide1 = false;
             mitreAdjacentSide2 = false;