[CSS Exclusions] Ignore ExclusionPolygon edges above minLogicalIntervalTop
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 23:20:27 +0000 (23:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 23:20:27 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107566

Patch by Hans Muller <hmuller@adobe.com> on 2013-02-07
Reviewed by David Hyatt.

Source/WebCore:

Improve ExclusionPolygon::firstIncludedIntervalLogicalTop() performance by only
creating offset edges for polygon edges that are below the horizontal minLogicalIntervalTop
line. In other words, don't bother creating offset edges that can't define the polygon's
first fit location.

Test: fast/exclusions/shape-inside/shape-inside-first-fit-004.html

* rendering/ExclusionPolygon.cpp:
(WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Don't create offset edges for polygon edges above minLogicalIntervalTop.

LayoutTests:

Added a simple polygonal shape-inside test where only a subset of the polygon edges
should contribute to each line's offset edges.

* fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-first-fit-004.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/ExclusionPolygon.cpp

index 29cd2590fbdbbd0d97357c1bcca99295e74f7025..dcf10365a40e435fa2b9455419ca5cc74a8f579e 100644 (file)
@@ -1,3 +1,16 @@
+2013-02-07  Hans Muller  <hmuller@adobe.com>
+
+        [CSS Exclusions] Ignore ExclusionPolygon edges above minLogicalIntervalTop
+        https://bugs.webkit.org/show_bug.cgi?id=107566
+
+        Reviewed by David Hyatt.
+
+        Added a simple polygonal shape-inside test where only a subset of the polygon edges
+        should contribute to each line's offset edges.
+
+        * fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html: Added.
+        * fast/exclusions/shape-inside/shape-inside-first-fit-004.html: Added.
+
 2013-02-07  James Craig  <jcraig@apple.com>
 
         Add layout test verifying role, subrole, and role description for all HTML elements and ARIA roles
diff --git a/LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html b/LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html
new file mode 100644 (file)
index 0000000..b4e0a2d
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #shape-inside {
+        position: relative;
+        width: 100px;
+        height: 150px;
+    }
+
+    #shape-outline {
+        position: absolute;
+        top: 0px;
+        left: 0px;
+        width: 100px;
+        height: 150px;
+    }
+
+    #shape-contents {
+        position: absolute;
+        top: 0px;
+        left: 0px;
+        font: 50px/1 Ahem, sans-serif;
+        color: green;
+    }
+</style>
+</head>
+<body>
+    <p>The solid green rectangle should be contained by the blue polygon outline.</p>
+    <div id="shape-inside">
+        <pre id="shape-contents">
+XX
+XX</pre>
+        <svg id="shape-outline" xmlns="http://www.w3.org/2000/svg">
+            <polygon points="0,150 0,50 12,12 50,0 88,12 100,50 100,150" stroke="blue" fill="none"/>
+        </svg>
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004.html b/LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-004.html
new file mode 100644 (file)
index 0000000..880b14f
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #shape-inside {
+        position: relative;
+        width: 100px;
+        height: 150px;
+        -webkit-shape-inside: polygon(0px 150px, 0px 50px, 12px 12px, 50px 0px, 88px 12px, 100px 50px, 100px 150px);
+        font: 50px/1 Ahem, sans-serif;
+        color: green;
+    }
+
+    #shape-outline {
+        position: absolute;
+        top: 0px;
+        left: 0px;
+        width: 100px;
+        height: 150px;
+    }
+</style>
+</head>
+<body>
+    <p>The solid green rectangle should be contained by the blue polygon outline.</p>
+    <div id="shape-inside">
+        <svg id="shape-outline" xmlns="http://www.w3.org/2000/svg">
+            <polygon points="0,150 0,50 12,12 50,0 88,12 100,50 100,150" stroke="blue" fill="none"/>
+        </svg>
+        XX XX
+    </div>
+</body>
+</html>
index 7828630ac38279b721ff9e7dfe7e13f956319c23..233a600ecf603d64cf267bffddea4c752087cdc3 100644 (file)
@@ -1,3 +1,20 @@
+2013-02-07  Hans Muller  <hmuller@adobe.com>
+
+        [CSS Exclusions] Ignore ExclusionPolygon edges above minLogicalIntervalTop
+        https://bugs.webkit.org/show_bug.cgi?id=107566
+
+        Reviewed by David Hyatt.
+
+        Improve ExclusionPolygon::firstIncludedIntervalLogicalTop() performance by only
+        creating offset edges for polygon edges that are below the horizontal minLogicalIntervalTop
+        line. In other words, don't bother creating offset edges that can't define the polygon's
+        first fit location.
+
+        Test: fast/exclusions/shape-inside/shape-inside-first-fit-004.html
+
+        * rendering/ExclusionPolygon.cpp:
+        (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Don't create offset edges for polygon edges above minLogicalIntervalTop.
+
 2013-02-07  Jer Noble  <jer.noble@apple.com>
 
         Improve logging of MediaPlayerPrivateAVFoundation Notifications.
index a9f0a45a135066c4cbdc827049ada9df4a713c4f..c9fab07dca01e29dac0addc41d0be926e0da2bc1 100644 (file)
@@ -497,12 +497,15 @@ bool ExclusionPolygon::firstIncludedIntervalLogicalTop(float minLogicalIntervalT
     if (maxY > m_boundingBox.maxY())
         return false;
 
+    Vector<ExclusionPolygon::EdgeInterval> overlappingEdges;
+    m_edgeTree.allOverlaps(ExclusionPolygon::EdgeInterval(minLogicalIntervalTop, m_boundingBox.maxY(), 0), overlappingEdges);
+
     float dx = minLogicalIntervalSize.width() / 2;
     float dy = minLogicalIntervalSize.height() / 2;
     Vector<OffsetPolygonEdge> offsetEdges;
 
-    for (unsigned i = 0; i < numberOfEdges(); ++i) {
-        const ExclusionPolygonEdge& edge = edgeAt(i);
+    for (unsigned i = 0; i < overlappingEdges.size(); ++i) {
+        const ExclusionPolygonEdge& edge = *static_cast<ExclusionPolygonEdge*>(overlappingEdges[i].data());
         const FloatPoint& vertex1 = edge.vertex1();
         const FloatPoint& vertex2 = edge.vertex2();
         Vector<OffsetPolygonEdge> offsetEdgePair;