Changeset 142805 in webkit


Ignore:
Timestamp:
Feb 13, 2013 2:43:38 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Exclusions] ExclusionPolygon reflex vertices should constrain the first fit location.
https://bugs.webkit.org/show_bug.cgi?id=107568

Patch by Hans Muller <hmuller@adobe.com> on 2013-02-13
Reviewed by Dirk Schulze.

Source/WebCore:

The ExclusionPolygon::firstIncludedIntervalLogicalTop() method now includes offset edges
for each of the polygon's reflex vertices. The motivation for this change is explained
here: http://hansmuller-webkit.blogspot.com/2013/01/getting-to-point-reflex-vertices.html.

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

  • rendering/ExclusionPolygon.cpp:

(WebCore::isReflexVertex): Given three vertices that represent a pair of connected polygon edges, return true if the second vertex is a reflex vertex.
(WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): This method now includes offset edges for reflex vertices.

  • rendering/ExclusionPolygon.h:

(WebCore::OffsetPolygonEdge::OffsetPolygonEdge): Added a constructor for creating an OffsetPolygonEdge given a reflex vertex.
(WebCore::OffsetPolygonEdge::edgeIndex): Changed this property from unsigned to int. Now using -1 to indicate that the offset edge doesn't correspond to a single polygon edge.

LayoutTests:

In this carefully contrived test case, the Y coordinate of the origin of the line
of text is only computed correctly if the constraints implied by the polygon's
reflex vertices are considered.

  • fast/exclusions/shape-inside/shape-inside-first-fit-reflex-expected.html: Added.
  • fast/exclusions/shape-inside/shape-inside-first-fit-reflex.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142799 r142805  
     12013-02-13  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Exclusions] ExclusionPolygon reflex vertices should constrain the first fit location.
     4        https://bugs.webkit.org/show_bug.cgi?id=107568
     5
     6        Reviewed by Dirk Schulze.
     7
     8        In this carefully contrived test case, the Y coordinate of the origin of the line
     9        of text is only computed correctly if the constraints implied by the polygon's
     10        reflex vertices are considered.
     11
     12        * fast/exclusions/shape-inside/shape-inside-first-fit-reflex-expected.html: Added.
     13        * fast/exclusions/shape-inside/shape-inside-first-fit-reflex.html: Added.
     14
    1152013-02-13  Zan Dobersek  <zdobersek@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r142803 r142805  
     12013-02-13  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Exclusions] ExclusionPolygon reflex vertices should constrain the first fit location.
     4        https://bugs.webkit.org/show_bug.cgi?id=107568
     5
     6        Reviewed by Dirk Schulze.
     7
     8        The ExclusionPolygon::firstIncludedIntervalLogicalTop() method now includes offset edges
     9        for each of the polygon's reflex vertices. The motivation for this change is explained
     10        here: http://hansmuller-webkit.blogspot.com/2013/01/getting-to-point-reflex-vertices.html.
     11
     12        Test: fast/exclusions/shape-inside/shape-inside-first-fit-reflex.html
     13
     14        * rendering/ExclusionPolygon.cpp:
     15        (WebCore::isReflexVertex): Given three vertices that represent a pair of connected polygon edges, return true if the second vertex is a reflex vertex.
     16        (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): This method now includes offset edges for reflex vertices.
     17        * rendering/ExclusionPolygon.h:
     18        (WebCore::OffsetPolygonEdge::OffsetPolygonEdge): Added a constructor for creating an OffsetPolygonEdge given a reflex vertex.
     19        (WebCore::OffsetPolygonEdge::edgeIndex): Changed this property from unsigned to int. Now using -1 to indicate that the offset edge doesn't correspond to a single polygon edge.
     20
    1212013-02-13  Adam Barth  <abarth@webkit.org>
    222
  • trunk/Source/WebCore/rendering/ExclusionPolygon.cpp

    r142187 r142805  
    439439}
    440440
     441static inline bool isReflexVertex(const FloatPoint& prevVertex, const FloatPoint& vertex, const FloatPoint& nextVertex)
     442{
     443    return leftSide(prevVertex, nextVertex, vertex) < 0;
     444}
     445
    441446bool VertexPair::intersection(const VertexPair& other, FloatPoint& point) const
    442447{
     
    507512    for (unsigned i = 0; i < overlappingEdges.size(); ++i) {
    508513        const ExclusionPolygonEdge& edge = *static_cast<ExclusionPolygonEdge*>(overlappingEdges[i].data());
     514        const FloatPoint& vertex0 = edge.previousEdge().vertex1();
    509515        const FloatPoint& vertex1 = edge.vertex1();
    510516        const FloatPoint& vertex2 = edge.vertex2();
    511         Vector<OffsetPolygonEdge> offsetEdgePair;
     517        Vector<OffsetPolygonEdge> offsetEdgeBuffer;
    512518
    513519        if (vertex2.y() > vertex1.y() ? vertex2.x() >= vertex1.x() : vertex1.x() >= vertex2.x()) {
    514             offsetEdgePair.append(OffsetPolygonEdge(edge, FloatSize(dx, -dy)));
    515             offsetEdgePair.append(OffsetPolygonEdge(edge, FloatSize(-dx, dy)));
     520            offsetEdgeBuffer.append(OffsetPolygonEdge(edge, FloatSize(dx, -dy)));
     521            offsetEdgeBuffer.append(OffsetPolygonEdge(edge, FloatSize(-dx, dy)));
    516522        } else {
    517             offsetEdgePair.append(OffsetPolygonEdge(edge, FloatSize(dx, dy)));
    518             offsetEdgePair.append(OffsetPolygonEdge(edge, FloatSize(-dx, -dy)));
    519         }
    520 
    521         for (unsigned j = 0; j < offsetEdgePair.size(); ++j)
    522             if (offsetEdgePair[j].maxY() >= minY)
    523                 offsetEdges.append(offsetEdgePair[j]);
     523            offsetEdgeBuffer.append(OffsetPolygonEdge(edge, FloatSize(dx, dy)));
     524            offsetEdgeBuffer.append(OffsetPolygonEdge(edge, FloatSize(-dx, -dy)));
     525        }
     526
     527        if (isReflexVertex(vertex0, vertex1, vertex2)) {
     528            if (vertex2.x() <= vertex1.x() && vertex0.x() <= vertex1.x())
     529                offsetEdgeBuffer.append(OffsetPolygonEdge(vertex1, FloatSize(dx, -dy), FloatSize(dx, dy)));
     530            else if (vertex2.x() >= vertex1.x() && vertex0.x() >= vertex1.x())
     531                offsetEdgeBuffer.append(OffsetPolygonEdge(vertex1, FloatSize(-dx, -dy), FloatSize(-dx, dy)));
     532            if (vertex2.y() <= vertex1.y() && vertex0.y() <= vertex1.y())
     533                offsetEdgeBuffer.append(OffsetPolygonEdge(vertex1, FloatSize(-dx, dy), FloatSize(dx, dy)));
     534            else if (vertex2.y() >= vertex1.y() && vertex0.y() >= vertex1.y())
     535                offsetEdgeBuffer.append(OffsetPolygonEdge(vertex1, FloatSize(-dx, -dy), FloatSize(dx, -dy)));
     536        }
     537
     538        for (unsigned j = 0; j < offsetEdgeBuffer.size(); ++j)
     539            if (offsetEdgeBuffer[j].maxY() >= minY)
     540                offsetEdges.append(offsetEdgeBuffer[j]);
    524541    }
    525542
  • trunk/Source/WebCore/rendering/ExclusionPolygon.h

    r140606 r142805  
    166166    }
    167167
     168    OffsetPolygonEdge(const FloatPoint& reflexVertex, const FloatSize& offset1, const FloatSize& offset2)
     169        : m_vertex1(reflexVertex + offset1)
     170        , m_vertex2(reflexVertex + offset2)
     171        , m_edgeIndex(-1)
     172    {
     173    }
     174
    168175    OffsetPolygonEdge(const ExclusionPolygon& polygon, float minLogicalIntervalTop, const FloatSize& offset)
    169176        : m_vertex1(FloatPoint(polygon.shapeLogicalBoundingBox().x(), minLogicalIntervalTop) + offset)
    170177        , m_vertex2(FloatPoint(polygon.shapeLogicalBoundingBox().maxX(), minLogicalIntervalTop) + offset)
    171         , m_edgeIndex(polygon.numberOfEdges())
     178        , m_edgeIndex(-1)
    172179    {
    173180    }
     
    175182    virtual const FloatPoint& vertex1() const OVERRIDE { return m_vertex1; }
    176183    virtual const FloatPoint& vertex2() const OVERRIDE { return m_vertex2; }
    177     unsigned edgeIndex() const { return m_edgeIndex; }
     184    int edgeIndex() const { return m_edgeIndex; }
    178185
    179186private:
    180187    FloatPoint m_vertex1;
    181188    FloatPoint m_vertex2;
    182     unsigned m_edgeIndex;
     189    int m_edgeIndex;
    183190};
    184191
Note: See TracChangeset for help on using the changeset viewer.