Changeset 133968 in webkit


Ignore:
Timestamp:
Nov 8, 2012 4:09:57 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Exclusions] Polygon with horizontal bottom edges returns incorrect segments
https://bugs.webkit.org/show_bug.cgi?id=100874

Patch by Hans Muller <hmuller@adobe.com> on 2012-11-08
Reviewed by Dirk Schulze.

Source/WebCore:

Revised the way that computeXIntersections() handles intersections with horizotal polygon edges.
Deciding if a vertex intersection corresponds to a polygon "edge crossing", i.e. a change from inside
to outside or outside to inside, now depends on which side of the horizontal line the function's
y parameter corresponds to. If the y corresponds to the top of the line, then isaMinY the parameter
is true, and an intersection with a horizontal edge is only considered to be an edge crossing if
if the inside of the polygon is just below the horizontal edge. When isMinY is false then the inside
of the polygon must be just above the horizontal edge.

Tests: fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003.html

fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004.html

  • rendering/ExclusionPolygon.cpp:

(WebCore::getVertexIntersectionVertices): Corrected two cases where the next/previous vertex was determined incorrectly.
(WebCore::ExclusionPolygon::computeXIntersections): Added a bool isMinY parameter which specifies if the y parameter corresponds to the top or bottom a horizontal line.
(WebCore::ExclusionPolygon::getExcludedIntervals): Added the new computeXIntersections() parameter.
(WebCore::ExclusionPolygon::getIncludedIntervals): Ditto.

  • rendering/ExclusionPolygon.h:

(WebCore::ExclusionPolygonEdge::previousEdge): Corrected the previousEdge() function.

LayoutTests:

Added two additional tests for rectilinear polygons, where the tops and bottoms
of lines intersect the polygons' horizontal edges. More tests of this kind will
be needed when exclusion layout supports polygons that break horizontal lines up
into more than one segment.

  • fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003-expected.html: Added.
  • fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003.html: Added.
  • fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004-expected.html: Added.
  • fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133966 r133968  
     12012-11-08  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Exclusions] Polygon with horizontal bottom edges returns incorrect segments
     4        https://bugs.webkit.org/show_bug.cgi?id=100874
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Added two additional tests for rectilinear polygons, where the tops and bottoms
     9        of lines intersect the polygons' horizontal edges. More tests of this kind will
     10        be needed when exclusion layout supports polygons that break horizontal lines up
     11        into more than one segment.
     12
     13        * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003-expected.html: Added.
     14        * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003.html: Added.
     15        * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004-expected.html: Added.
     16        * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004.html: Added.
     17
    1182012-11-08  Christophe Dumez  <christophe.dumez@intel.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r133964 r133968  
     12012-11-08  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Exclusions] Polygon with horizontal bottom edges returns incorrect segments
     4        https://bugs.webkit.org/show_bug.cgi?id=100874
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Revised the way that computeXIntersections() handles intersections with horizotal polygon edges.
     9        Deciding if a vertex intersection corresponds to a polygon "edge crossing", i.e. a change from inside
     10        to outside or outside to inside, now depends on which side of the horizontal line the function's
     11        y parameter corresponds to. If the y corresponds to the top of the line, then isaMinY the parameter
     12        is true, and an intersection with a horizontal edge is only considered to be an edge crossing if
     13        if the inside of the polygon is just below the horizontal edge.  When isMinY is false then the inside
     14        of the polygon must be just above the horizontal edge.
     15
     16        Tests: fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003.html
     17               fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004.html
     18
     19        * rendering/ExclusionPolygon.cpp:
     20        (WebCore::getVertexIntersectionVertices): Corrected two cases where the next/previous vertex was determined incorrectly.
     21        (WebCore::ExclusionPolygon::computeXIntersections): Added a bool isMinY parameter which specifies if the y parameter corresponds to the top or bottom a horizontal line.
     22        (WebCore::ExclusionPolygon::getExcludedIntervals): Added the new computeXIntersections() parameter.
     23        (WebCore::ExclusionPolygon::getIncludedIntervals): Ditto.
     24        * rendering/ExclusionPolygon.h:
     25        (WebCore::ExclusionPolygonEdge::previousEdge): Corrected the previousEdge() function.
     26
    1272012-11-08  Otto Derek Cheung  <otcheung@rim.com>
    228
  • trunk/Source/WebCore/rendering/ExclusionPolygon.cpp

    r133682 r133968  
    191191    if ((intersection.type == VertexMinY && (thisEdge.vertex1().y() < thisEdge.vertex2().y()))
    192192        || (intersection.type == VertexMaxY && (thisEdge.vertex1().y() > thisEdge.vertex2().y()))) {
    193         prevVertex = polygon.vertexAt(thisEdge.previousEdge().vertexIndex2);
     193        prevVertex = polygon.vertexAt(thisEdge.previousEdge().vertexIndex1);
    194194        thisVertex = polygon.vertexAt(thisEdge.vertexIndex1);
    195195        nextVertex = polygon.vertexAt(thisEdge.vertexIndex2);
     
    197197        prevVertex = polygon.vertexAt(thisEdge.vertexIndex1);
    198198        thisVertex = polygon.vertexAt(thisEdge.vertexIndex2);
    199         nextVertex = polygon.vertexAt(thisEdge.nextEdge().vertexIndex1);
     199        nextVertex = polygon.vertexAt(thisEdge.nextEdge().vertexIndex2);
    200200    }
    201201
     
    220220}
    221221
    222 void ExclusionPolygon::computeXIntersections(float y, Vector<ExclusionInterval>& result) const
     222void ExclusionPolygon::computeXIntersections(float y, bool isMinY, Vector<ExclusionInterval>& result) const
    223223{
    224224    Vector<ExclusionPolygon::EdgeInterval> overlappingEdges;
     
    266266
    267267        if (evenOddCrossing) {
    268             bool edgeCrossing = false;
    269             if (thisIntersection.type == Normal || !inside || index == intersections.size() - 1)
    270                 edgeCrossing = true;
    271             else {
     268            bool edgeCrossing = thisIntersection.type == Normal;
     269            if (!edgeCrossing) {
    272270                FloatPoint prevVertex;
    273271                FloatPoint thisVertex;
     
    275273
    276274                if (getVertexIntersectionVertices(thisIntersection, prevVertex, thisVertex, nextVertex)) {
    277                     if (prevVertex.y() == y)
    278                         edgeCrossing =  (thisVertex.x() > prevVertex.x()) ? nextVertex.y() > y : nextVertex.y() < y;
     275                    if (nextVertex.y() == y)
     276                        edgeCrossing = (isMinY) ? prevVertex.y() > y : prevVertex.y() < y;
     277                    else if (prevVertex.y() == y)
     278                        edgeCrossing = (isMinY) ? nextVertex.y() > y : nextVertex.y() < y;
    279279                    else
    280                         edgeCrossing = (nextVertex.y() != y);
     280                        edgeCrossing = true;
    281281                }
    282282            }
     
    332332
    333333    Vector<ExclusionInterval> y1XIntervals, y2XIntervals;
    334     computeXIntersections(y1, y1XIntervals);
    335     computeXIntersections(y2, y2XIntervals);
     334    computeXIntersections(y1, true, y1XIntervals);
     335    computeXIntersections(y2, false, y2XIntervals);
    336336
    337337    Vector<ExclusionInterval> mergedIntervals;
     
    359359
    360360    Vector<ExclusionInterval> y1XIntervals, y2XIntervals;
    361     computeXIntersections(y1, y1XIntervals);
    362     computeXIntersections(y2, y2XIntervals);
     361    computeXIntersections(y1, true, y1XIntervals);
     362    computeXIntersections(y2, false, y2XIntervals);
    363363
    364364    Vector<ExclusionInterval> commonIntervals;
  • trunk/Source/WebCore/rendering/ExclusionPolygon.h

    r133490 r133968  
    6969
    7070private:
    71     void computeXIntersections(float y, Vector<ExclusionInterval>&) const;
     71    void computeXIntersections(float y, bool isMinY, Vector<ExclusionInterval>&) const;
    7272    void computeEdgeIntersections(float minY, float maxY, Vector<ExclusionInterval>&) const;
    7373    unsigned findNextEdgeVertexIndex(unsigned vertexIndex1, bool clockwise) const;
     
    103103    {
    104104        ASSERT(polygon && polygon->numberOfEdges() > 1);
    105         return polygon->edgeAt((edgeIndex + polygon->numberOfEdges() - 2) % polygon->numberOfEdges());
     105        return polygon->edgeAt((edgeIndex + polygon->numberOfEdges() - 1) % polygon->numberOfEdges());
    106106    }
    107107
Note: See TracChangeset for help on using the changeset viewer.