1. 05 Apr, 2013 1 commit
    • hmuller@adobe.com's avatar
      [CSS Exclusions] Add support for the simple case of shape-margin polygonal shape-outside · 2a8e9f3b
      hmuller@adobe.com authored
      https://bugs.webkit.org/show_bug.cgi?id=113726
      
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Add support for computing the shape-outside shape-margin boundary for a polygon.
      This change is similar to the one added for padding polygons, see bug 112592.
      The algorithm used for computing the margin boundary is is provisional. It works
      correctly for convex polygons and will work correctly for non self-intersecting
      polygons whose margin boundary is the same shape as the original polygon.
      
      Tests: fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html
             fast/exclusions/shape-outside-floats/shape-outside-floats-left-margin-polygon.html
             fast/exclusions/shape-outside-floats/shape-outside-floats-right-margin-polygon.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::appendArc): Generalized this method a little, to deal with margin and padding connecting arcs.
      (WebCore::computeShapePaddingBounds): Pass the new appendArc() parameter.
      (WebCore::computeShapeMarginBounds): Compute the margin boundary for a polygon, per the constraints summarized above.
      (WebCore::ExclusionPolygon::getExcludedIntervals): Use the margin polygon for this computation.
      
      LayoutTests:
      
      Verify that shape-outside layout works correctly on floats, when shape-margin is specifed.
      
      * fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon-expected.txt: Added.
      * fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html: Added.
      * fast/exclusions/shape-outside-floats/shape-outside-floats-left-margin-polygon-expected.html: Added.
      * fast/exclusions/shape-outside-floats/shape-outside-floats-left-margin-polygon.html: Added.
      * fast/exclusions/shape-outside-floats/shape-outside-floats-right-margin-polygon-expected.html: Added.
      * fast/exclusions/shape-outside-floats/shape-outside-floats-right-margin-polygon.html: Added.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147831 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      2a8e9f3b
  2. 28 Mar, 2013 1 commit
    • hmuller@adobe.com's avatar
      [CSS Exclusions] Add support for the simple case of padding a polygonal shape-inside · 6592248d
      hmuller@adobe.com authored
      https://bugs.webkit.org/show_bug.cgi?id=112592
      
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      First pass at computing the padded or inset boundary of a polygon.  This version does not handle
      self-intersecting polygons, or values of shape-padding large enough to change the shape of the
      original polygon. The implementation computes an offset edge for each polgon edge, where the offset
      edge is parallel to the original edge and separated by shape-padding. The padded polygon's vertices
      are the intersections of each pair of adjacent offset edges. When adjacent offset edges do not intersect,
      because they share a reflex vertex in the original polygon, an approximation to a circular arc
      connects the offset edges.
      
      Tests: fast/exclusions/shape-inside/shape-inside-polygon-padding-001.html
             fast/exclusions/shape-inside/shape-inside-polygon-padding-002.html
             fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::isReflexVertex): Just moved this function earlier in the file.
      (WebCore::inwardEdgeNormal): Unit vector that's perpindicular to the edge and that points inwards.
      (WebCore::outwardEdgeNormal): Unit vector that's perpindicular to the edge and that points outwards.
      (WebCore::appendArc): Append a linear approximation to a circular arc to a vector of vertices.
      (WebCore::computeShapePaddingBounds): Return a polygon whose edges are all inset by shape-padding from m_polygon.
      (WebCore::computeShapeMarginBounds): Just a stub, see bug 112917.
      (WebCore::ExclusionPolygon::shapePaddingBounds): Lazily use computeShapePaddingBounds() to initialize m_paddingBounds.
      (WebCore::ExclusionPolygon::shapeMarginBounds): Lazily use computeShapeMarginBounds() to initialize m_marginBounds.
      (WebCore::ExclusionPolygon::getIncludedIntervals): Now based on the value of shapePaddingBounds().
      (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Now based on the value of shapePaddingBounds().
      * rendering/ExclusionPolygon.h:
      (WebCore::ExclusionPolygon::ExclusionPolygon):
      
      LayoutTests:
      
      Verify that the CSS shape-padding property works correctly for some simple polygonal shapes:
      a rectangle, a rectangle rotated 45 degress, and rectangular shape with a single reflex vertex.
      
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-001-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-001.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-002-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-002.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-003-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html: Added.
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147111 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6592248d
  3. 11 Mar, 2013 1 commit
    • hmuller@adobe.com's avatar
      [CSS Exclusions] Refactor the ExclusionPolygon class to enable storing multiple boundaries · b44dbb00
      hmuller@adobe.com authored
      https://bugs.webkit.org/show_bug.cgi?id=111766
      
      Reviewed by Dirk Schulze.
      
      Refactored the ExclusionPolygon class to enable adding support for shape-margin and shape-padding.
      Extracted a new FloatPolygon class which is now used by ExclusionPolygon to represent the shape's
      boundary. It will be used to add m_paddedPolygon and m_marginPolygon members to ExclusionPolygon
      in a subsequent patch.
      
      No new tests. This is strictly a refactoring of the existing code.
      
      * CMakeLists.txt:
      * GNUmakefile.list.am:
      * WebCore.gypi:
      * WebCore.vcproj/WebCore.vcproj:
      * WebCore.xcodeproj/project.pbxproj:
      * platform/graphics/FloatPolygon.cpp: Factored out of Source/WebCore/rendering/ExclusionPolygon.cpp.
      (WebCore::determinant):
      (WebCore::areCollinearPoints):
      (WebCore::areCoincidentPoints):
      (WebCore::isPointOnLineSegment):
      (WebCore::nextVertexIndex):
      (WebCore::FloatPolygon::FloatPolygon):
      (WebCore::FloatPolygon::findNextEdgeVertexIndex):
      (WebCore::FloatPolygon::overlappingEdges):
      (WebCore::leftSide):
      (WebCore::FloatPolygon::contains):
      (WebCore::VertexPair::overlapsRect):
      (WebCore::VertexPair::intersection):
      * platform/graphics/FloatPolygon.h: Factored out of Source/WebCore/rendering/ExclusionPolygon.h.
      (FloatPolygon):
      (WebCore::FloatPolygon::vertexAt):
      (WebCore::FloatPolygon::numberOfVertices):
      (WebCore::FloatPolygon::fillRule):
      (WebCore::FloatPolygon::edgeAt):
      (WebCore::FloatPolygon::numberOfEdges):
      (WebCore::FloatPolygon::boundingBox):
      (WebCore::FloatPolygon::isEmpty):
      (VertexPair):
      (WebCore::VertexPair::~VertexPair):
      (WebCore::VertexPair::minX):
      (WebCore::VertexPair::minY):
      (WebCore::VertexPair::maxX):
      (WebCore::VertexPair::maxY):
      (FloatPolygonEdge):
      (WebCore::FloatPolygonEdge::previousEdge):
      (WebCore::FloatPolygonEdge::nextEdge):
      (WebCore::FloatPolygonEdge::polygon):
      (WebCore::FloatPolygonEdge::vertexIndex1):
      (WebCore::FloatPolygonEdge::vertexIndex2):
      (WebCore::FloatPolygonEdge::edgeIndex):
      * rendering/ExclusionPolygon.cpp: Now depends on FloatPolygon.
      (EdgeIntersection):
      (WebCore::leftSide):
      (WebCore::computeXIntersection):
      (WebCore::getVertexIntersectionVertices):
      (WebCore::computeXIntersections):
      (WebCore::computeOverlappingEdgeXProjections):
      (WebCore::ExclusionPolygon::getExcludedIntervals):
      (WebCore::ExclusionPolygon::getIncludedIntervals):
      (WebCore::firstFitRectInPolygon):
      (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop):
      * rendering/ExclusionPolygon.h: Now depends on FloatPolygon.
      (WebCore::OffsetPolygonEdge::OffsetPolygonEdge):
      (ExclusionPolygon):
      (WebCore::ExclusionPolygon::ExclusionPolygon):
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      b44dbb00
  4. 13 Feb, 2013 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] ExclusionPolygon reflex vertices should constrain the first fit location. · a465a237
      commit-queue@webkit.org authored
      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.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      a465a237
  5. 07 Feb, 2013 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Ignore ExclusionPolygon edges above minLogicalIntervalTop · 41c85590
      commit-queue@webkit.org authored
      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: http://svn.webkit.org/repository/webkit/trunk@142187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      41c85590
  6. 23 Jan, 2013 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Add support for computing first included interval position for polygons · 48236e0a
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=103429
      
      Patch by Hans Muller <hmuller@adobe.com> on 2013-01-23
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Added support for computing the "first fit" location, i.e. the logical shape-inside
      location where a line's layout begins. The algorithm for doing so is described here:
      http://hansmuller-webkit.blogspot.com/2012/08/revised-algorithm-for-finding-first.html.
      
      Tests: fast/exclusions/shape-inside/shape-inside-first-fit-001.html
             fast/exclusions/shape-inside/shape-inside-first-fit-002.html
             fast/exclusions/shape-inside/shape-inside-first-fit-003.html
      
      * platform/graphics/FloatSize.h:
      (WebCore::operator*): Scale a FloatSize. This simplified the final expression in VertexPair::intersection().
      * rendering/ExclusionPolygon.cpp:
      (WebCore::isPointOnLineSegment): Returns true if the specified point is collinear and within the line segement's bounds.
      (WebCore::leftSide): Return a value > 0 if point is on the left side of the line segment, < 0 if it's on the right, 0 if it's collinear.
      (WebCore::ExclusionPolygon::contains): Return true if the point is within the polygon or on an edge.
      (WebCore::VertexPair::overlapsRect): Returns true if the line segment from vertex1 to vertex2 overlaps the specified FloatRect.
      (WebCore::VertexPair::intersection): Finds the intersection of a pair of line segments defined by VertexPairs.
      (WebCore::ExclusionPolygon::firstFitRectInPolygon): Returns true if none of the polygon's edges, except the two used
          to define by the offset edges, overlap the FloatRect.
      (WebCore::aboveOrToTheLeft): Defines the top/left preference for "first fit" locations.
      (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Replaced the stub implementation of this method.
      * rendering/ExclusionPolygon.h:
      (ExclusionPolygon): Added declarations noted above.
      (VertexPair): Abstract class that defines a pair of FloatPoints.
      (OffsetPolygonEdge): Represents an edge that's horizontally offset from a polygon edge.
      (WebCore::OffsetPolygonEdge::edgeIndex): The ExclusionPolygon edge index used to define this OffsetEdge.
      
      LayoutTests:
      
      All of the existing shape-inside tests exercise the new code.  Added new tests which
      verify that layout works correctly when layout can not begin at the shape's logical top.
      Test 001 additionally checks all writing-modes, test 002 verifies that the topmost/leftmost
      rule is followed, and test3 checks a self-intersecting polygon.
      
      * fast/exclusions/shape-inside/shape-inside-first-fit-001-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-first-fit-001.html: Added.
      * fast/exclusions/shape-inside/shape-inside-first-fit-002-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-first-fit-002.html: Added.
      * fast/exclusions/shape-inside/shape-inside-first-fit-003-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-first-fit-003.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      48236e0a
  7. 04 Jan, 2013 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] The ExclusionPolygon classes should allow more than one type of "Edge" class · 45ecd977
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=106026
      
      Patch by Hans Muller <hmuller@adobe.com> on 2013-01-04
      Reviewed by Dirk Schulze.
      
      Refactored the ExclusionPolygonEdge class to pave the way for a similar
      OffsetEdge class. The new VertexPair abstract base class provides the common
      state and operations. ExclusionPolygonEdge now extends VertexPair and defines
      ExclusionPolygon as a friend, since the ExclusionPolygon constructor initializes
      its private state.
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::ExclusionPolygon): Use ExclusionPolygonEdge accessors instead of direct field access.
      (WebCore::getVertexIntersectionVertices): Ditto.
      * rendering/ExclusionPolygon.h:
      (VertexPair): New abstract base class.
      (WebCore::VertexPair::~VertexPair):
      (WebCore::VertexPair::minX): This method was defined in ExclusionPolygonEdge.
      (WebCore::VertexPair::minY): Ditto.
      (WebCore::VertexPair::maxX): Ditto.
      (WebCore::VertexPair::maxY): Ditto.
      (ExclusionPolygonEdge): Now extends VertexPair.
      (WebCore::ExclusionPolygonEdge::previousEdge): Refer to m_ private class fields, instead of public struct fields.
      (WebCore::ExclusionPolygonEdge::nextEdge): Ditto.
      (WebCore::ExclusionPolygonEdge::polygon): Ditto.
      (WebCore::ExclusionPolygonEdge::vertexIndex1): Ditto.
      (WebCore::ExclusionPolygonEdge::vertexIndex2): Ditto.
      (WebCore::ExclusionPolygonEdge::edgeIndex): Ditto.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      45ecd977
  8. 18 Dec, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] shape-inside layout fails to adjust first line correctly for... · cdf0e482
      commit-queue@webkit.org authored
      [CSS Exclusions] shape-inside layout fails to adjust first line correctly for writing-mode: vertical-rl
      https://bugs.webkit.org/show_bug.cgi?id=104419
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-12-18
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      ExclusionShapes no longer maintain a private "internal" coordinate system,
      they're now defined in logical coordinates. The createExclusionShape() method
      now handles the one-time conversion from physical to logical coordinates.
      
      Test: fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-003.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::getExcludedIntervals): Removed logical to internal coordinate conversions.
      (WebCore::ExclusionPolygon::getIncludedIntervals): Ditto.
      (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Ditto.
      * rendering/ExclusionPolygon.h:
      * rendering/ExclusionRectangle.cpp:
      (WebCore::ExclusionRectangle::getExcludedIntervals): Removed logical to internal coordinate conversions.
      (WebCore::ExclusionRectangle::getIncludedIntervals): Ditto.
      (WebCore::ExclusionRectangle::firstIncludedIntervalLogicalTop): Ditto.
      * rendering/ExclusionRectangle.h:
      * rendering/ExclusionShape.cpp:
      (WebCore::physicalRectToLogical): Convert a FloatRect defined with coordinates to logical coordinates.
      (WebCore::physicalPointToLogical): Similar.
      (WebCore::physicalSizeToLogical): Simlar.
      (WebCore::ExclusionShape::createExclusionShape): Convert shapes from physical to logical coordinates.
      * rendering/ExclusionShape.h:
      (ExclusionShape): Removed internal to logical coordinate conversion utility methods.
      
      LayoutTests:
      
      For the vertical writing modes, verify that rounded rectangle shape-inside content is
      adjusted in the logical down direction when it will not fit betwen the rounded corners.
      
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-003-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-003.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138043 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      cdf0e482
  9. 06 Dec, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Add support for computing the first included interval position. · 4055b2e0
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=103327
      
      Source/WebCore:
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-12-06
      Reviewed by Levi Weintraub.
      
      If the first "word" in a line doesn't fit within the shape-inside when lineTop
      is the top of the shape's logical bounding box, adjust lineTop downwards to where
      the word fits.  Currently only rounded rectangle shapes are supported.
      
      Added ExclusionShape::firstIncludedIntervalLogicalTop(). The new virtual method
      computes the topmost/leftmost location where a line segment with the specified
      minLogicalIntervalSize will fit within the exclusion shape and returns the
      corresponding logical Y coordinate.  The result is additionally constrained to
      be at or below minLogicalIntervalTop. If the segment will not fit anywhere within
      the shape, then false is returned.
      
      During layout, minLogicalIntervalTop is the nominal top of the line being laid
      out within the exclusion shape.
      
      RenderBlock::layoutRunsAndFloatsInRange() now calls a new ExclusionShapeInsideInfo
      method, adjustLogicalLineTop(), which uses firstIncludedIntervalLogicalTop() to
      decide if the logical top of the line has to be moved downwards, for the first
      word to fit within the exclusion shape.
      
      Tests: fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-001.html
             fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): This is a stub implementation.
      * rendering/ExclusionPolygon.h:
      * rendering/ExclusionRectangle.cpp:
      (WebCore::ellipseXIntercept): Added spaces to conform to webkit style and to be consistent with ellipseYIntercept()
      (WebCore::ellipseYIntercept): Compute an ellipse's Y intercept for an X coordinate.
      (WebCore::ExclusionRectangle::firstIncludedIntervalLogicalTop): See the description above.
      * rendering/ExclusionRectangle.h:
      * rendering/ExclusionShape.h:
      (ExclusionShape):
      (WebCore::ExclusionShape::logicalTopForMinY): Internal to logical coordinate conversion.
      * rendering/ExclusionShapeInsideInfo.cpp:
      (WebCore::ExclusionShapeInsideInfo::adjustLogicalLineTop): A new method that updates m_lineTop with firstIncludedIntervalPosition().
      * rendering/ExclusionShapeInsideInfo.h:
      (ExclusionShapeInsideInfo):
      (WebCore::ExclusionShapeInsideInfo::logicalLineTop): This is just a cover for the private m_lineTop field.
      * rendering/RenderBlockLineLayout.cpp:
      (WebCore::RenderBlock::layoutRunsAndFloatsInRange): Added code that restarts the layout loop if it's necessary to adjust the line's logicalTop.
      (WebCore::RenderBlock::restartLayoutRunsAndFloatsInRange): Factored newly common code into this helper function.
      
      LayoutTests:
      
      Test the rounded rectangle support for adjusting the top of a line downwards
      when the first word doesn't fit within the shape.
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-12-06
      Reviewed by Levi Weintraub.
      
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-001-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-001.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      4055b2e0
  10. 08 Nov, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Polygon with horizontal bottom edges returns incorrect segments · 556283fc
      commit-queue@webkit.org authored
      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.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      556283fc
  11. 06 Nov, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Store ExclusionPolygonEdge vertices in clockwise order · 6a17d333
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=100763
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-11-06
      Reviewed by Darin Adler.
      
      Source/WebCore:
      
      The ExclusionPolygon's internal logic, notably getVertexIntersectionVertices(),
      assumes that ExclusionPolygonEdge vertices are stored in clockwise order.
      If this is not true, then we construct the polygon's edges in reverse.
      
      To determine if the vertices are in clockwise order, we compare the slope
      of the line between the top,left vertex and its previous vertex, with the
      the slope of the line of vertices before and after the top,left vertex.
      If the slope of the latter is greater, then top,left vertex is located
      to its left, and the vertices are clockwise.
      
      Test: fast/exclusions/shape-inside/shape-inside-counterclockwise-polygon.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::determinant): Used to decide if the min vertex is on the left side of the line that passes through its adjacent vertices.
      (WebCore::ExclusionPolygon::ExclusionPolygon): If the polygon's vertices are specified in counterclockwise order, construct the edges in reverse.
      (WebCore::appendIntervalX): Made this an inline since it was only defined as a function for the sake of clarity.
      
      LayoutTests:
      
      Verify that a shape-inside polygon whose vertices are specified in counterclockwise
      order is handled correctly.
      
      * fast/exclusions/shape-inside/shape-inside-counterclockwise-polygon-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-counterclockwise-polygon.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6a17d333
  12. 05 Nov, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Polygon edges should span colinear vertices · 0bac6043
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=99343
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-11-05
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      ExclusionPolygonEdges now span coincident and collinear vertices. Currently
      pairs of vertices are only considered coincident if their coordinates are exactly
      equal. Similarly, a vertex is only considered collinear with an edge if the area
      of the triangle defined by the three vertices is exactly zero.  In the future it
      may be useful to relax the comparison with zero.
      
      Tests: fast/exclusions/shape-inside/shape-inside-coincident-vertices.html
             fast/exclusions/shape-inside/shape-inside-collinear-vertices.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::determinant): Used to measure collinearity.
      (WebCore):
      (WebCore::areCollinearPoints): True if three FloatPoint arguments are collinear per the test outlined above.
      (WebCore::areCoincidentPoints): True if the two FloatPoint arguments are equal.
      (WebCore::nextVertexIndex): The next vertex index in clockwise or counterclockwise order.
      (WebCore::ExclusionPolygon::findNextEdgeVertexIndex): Return the index of the next non-coincident, non-collinear vertex.
      (WebCore::ExclusionPolygon::ExclusionPolygon): Skip coincident and collinear vertices when building the list of edges.
      * rendering/ExclusionPolygon.h: Added private findNextEdgeVertexIndex() declaration.
      
      LayoutTests:
      
      Verify that exclusion polygonal shape-inside layout is unaffected by coincident
      or collinear vertices.
      
      * fast/exclusions/shape-inside/shape-inside-coincident-vertices-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-coincident-vertices.html: Added.
      * fast/exclusions/shape-inside/shape-inside-collinear-vertices-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-collinear-vertices.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      0bac6043
  13. 30 Oct, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Multiple segment polygon layout does not get all segments · 635973c7
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=100039
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-10-30
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Corrected the algorithm for computing included polygon intervals for rectilinear polygons,
      and polygons with horizontal edges in general.
      
      Tests: fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-001.html
             fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-002.html
      
      * rendering/ExclusionPolygon.cpp: Removed some internal dead code related to the no-longer-used sortedEdgesMinY Vector.
      (WebCore::ExclusionPolygon::ExclusionPolygon): Initialize new ExclusionPolygonEdge edgeIndex field.
      (WebCore::getVertexIntersectionVertices): Return the previous, next, and target vertex indices for a vertex intersection.
      (WebCore::ExclusionPolygon::computeXIntersections): Refactored the core of this method to improve handling of horizontal edges.
      (WebCore::ExclusionPolygon::computeEdgeIntersections): Ignore zero-width edges.
      * rendering/ExclusionPolygon.h: Removed the rightVertexY() method, since it's no longer used.
      (WebCore::ExclusionPolygon::edgeAt): New method.
      (WebCore::ExclusionPolygon::numberOfEdges): New method.
      (ExclusionPolygon): Added support for retrieving edges.
      (WebCore::ExclusionPolygonEdge::vertex1): Use vertex1Index.
      (WebCore::ExclusionPolygonEdge::vertex2): Use vertex2Index.
      (ExclusionPolygonEdge): Renamed index1, index2 fields to vertex1Index, vertex2Index.
      (WebCore::ExclusionPolygonEdge::previousEdge): New method.
      (WebCore::ExclusionPolygonEdge::nextEdge): New method.
      
      LayoutTests:
      
      Added tests for CSS Exclusion shape-inside polygons with horizontal edges.
      Corrected the simple-polygon.js code for computing a polygon's included intervals.
      
      * fast/exclusions/resources/simple-polygon.js:
      * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-001-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-001.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-002-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-002.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-004-expected.html:
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-004.html:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      635973c7
  14. 22 Oct, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Points on the bottom and right edges of an exclusion shape... · 849e71b8
      commit-queue@webkit.org authored
      [CSS Exclusions] Points on the bottom and right edges of an exclusion shape should be classified as "outside"
      https://bugs.webkit.org/show_bug.cgi?id=98967
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-10-22
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Changed the way lines are represented in the ExclusionShapeInsideInfo and ExclusionShape classes
      so that they're consistent with the rendering code that depends on them.  Lines are now defined
      by logicalTop, logicalHeight, instead of logicalTop,logicalBottom.  This a clean-up, not a change
      in functionality. It's already covered by the existing fast/exclusions LayoutTests.
      
      Test: fast/exclusions/shape-inside/shape-inside-bottom-edge.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::getExcludedIntervals):
      (WebCore::ExclusionPolygon::getIncludedIntervals):
      * rendering/ExclusionPolygon.h:
      * rendering/ExclusionRectangle.cpp:
      (WebCore::ExclusionRectangle::getExcludedIntervals):
      (WebCore::ExclusionRectangle::getIncludedIntervals):
      * rendering/ExclusionRectangle.h:
      * rendering/ExclusionShape.h:
      (LineSegment): Moved the struct fields below the constructor per webkit style.
      (ExclusionShape):
      (WebCore::ExclusionShape::minYForLogicalLine):
      (WebCore::ExclusionShape::maxYForLogicalLine):
      * rendering/ExclusionShapeInsideInfo.cpp:
      (WebCore::ExclusionShapeInsideInfo::computeSegmentsForLine):
      * rendering/ExclusionShapeInsideInfo.h:
      (ExclusionShapeInsideInfo):
      (WebCore::ExclusionShapeInsideInfo::lineOverlapsShapeBounds): Changed the test to not include
          lines whose logicalTop is equal to the shape's top+height.
      * rendering/RenderBlockLineLayout.cpp:
      (WebCore::RenderBlock::layoutRunsAndFloatsInRange):
      
      LayoutTests:
      
      Verify that a exclusion shape-inside overlaps lines whose top is less than the
      shape bounds' top+height but not equal to the shape bounds' top+height.
      
      * fast/exclusions/shape-inside/shape-inside-bottom-edge-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-bottom-edge.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      849e71b8
  15. 18 Oct, 2012 2 commits
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Add ExclusionShape::shapeBoundingBox() method · ceb5df53
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=99216
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-10-18
      Reviewed by Dirk Schulze.
      
      Added a FloatRect::extend() method which simplifies writing loops that
      accumulate the bounding box for a sequence of FloatPoints. The new method
      is used by ExclusionPolygon to initialize the shape's logical and physical
      bounding boxes. This a clean-up, not a change in functionality. It's already
      covered by the existing fast/exclusions LayoutTests.
      
      * platform/graphics/FloatRect.cpp:
      (WebCore::FloatRect::extend): Extend the FloatRect's bounds to include a FloatPoint.
      (WebCore):
      * platform/graphics/FloatRect.h:
      (FloatRect): Added extend() method.
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::ExclusionPolygon): Use FloatRect::extend() to compute the polygon's internal bounding box.
      * rendering/ExclusionShape.cpp:
      (WebCore::ExclusionShape::createExclusionShape): Use FloatRect::extend() to compute the polygon's physical bounding box.
      * rendering/ExclusionShape.h:
      (WebCore::ExclusionShape::shapeBoundingBox): Return the shape's bounding box in physical coordinates.
      (ExclusionShape):
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131768 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      ceb5df53
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Handle special case "empty" shapes · e109feff
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=99342
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-10-18
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Provide expclit coverage of the simple "empty" shape-inside shapes.
      Shapes will be considered "empty" in the sense that ExclusionShape::getIncludedIntervals()
      and ExclusionShape::getExcludedIntervals() will always return empty lists of intervals.
      This patch covers rectangles of zero width or height, circles with 0 radius, ellipses
      with 0 radiusX or radiusY, polygons with less than 3 vertices.
      
      Test: fast/exclusions/shape-inside/shape-inside-empty.html
      
      * rendering/ExclusionPolygon.cpp:
      (WebCore::ExclusionPolygon::ExclusionPolygon): Initialize the m_empty flag.
      (WebCore::ExclusionPolygon::getExcludedIntervals): Added short-circuit return when the polygon is empty.
      (WebCore::ExclusionPolygon::getIncludedIntervals): Added short-circuit return when the polygon is empty.
      * rendering/ExclusionPolygon.h: Added the isEmpty() method.
      * rendering/ExclusionRectangle.cpp:
      (WebCore::ExclusionRectangle::getExcludedIntervals): Added short-circuit return when the rectangle is empty.
      (WebCore::ExclusionRectangle::getIncludedIntervals): Added short-circuit return when the rectangle is empty.
      * rendering/ExclusionRectangle.h: Added the isEmpty() method.
      * rendering/ExclusionShape.h: Added a virtual isEmpty() ExclusionShape method.
      (ExclusionShape):
      
      LayoutTests:
      
      Verify that "empty" shape-inside shapes do not constrain the text their element contains.
      
      * fast/exclusions/shape-inside/shape-inside-empty-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-empty.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e109feff
  16. 08 Oct, 2012 1 commit
    • commit-queue@webkit.org's avatar
      [CSS Exclusions] Add support for polygonal shapes · bbdd50f0
      commit-queue@webkit.org authored
      https://bugs.webkit.org/show_bug.cgi?id=96811
      
      Patch by Hans Muller <hmuller@adobe.com> on 2012-10-08
      Reviewed by Dirk Schulze.
      
      Source/WebCore:
      
      Initial version of the layout support for polygonal exclusion shapes: the ExclusionPolygon class.
      Supports the public ExclusionShape operations using the algorithm described here:
      http://hansmuller-webkit.blogspot.com/2012/06/horizontal-box-polygon-intersection-for.html.
      Although both the "included" and "excluded" operations are supported, only the former is
      used, since only shape-inside is supported at the moment.
      
      The ExclusionPolygon class stores the polygon's edges in an interval tree.
      
      Polygon edges are represented by the ExclusionPolygonEdge struct, which records the indices of
      the pair of vertices joined by the edge.  Edge vertex index1 is usually less than index2, except
      the last edge where index2 is 0.  We plan to improve the algorithm that creates the edges
      by spanning vertices contained in sequences of more than two colinear vertices. For example,
      a triangular polygon might be specified with 5 vertices like this: 3,0 5,0, 5,5, 4,4 2,2, 0,0.
      By spanning the extra colinear points: 0,0 5,0, 5,5, which implies index1-index2 edges: 5-1 1-2 2-5.
      
      Although the implementation supports complex polygons, the layout code is limited to
      essentially rectangular shapes until a patch for https://bugs.webkit.org/show_bug.cgi?id=96813
      lands.
      
      Tests: fast/exclusions/shape-inside/shape-inside-polygon-rectangle.html
             fast/exclusions/shape-inside/shape-inside-simple-polygon-001.html
             fast/exclusions/shape-inside/shape-inside-simple-polygon-002.html
             fast/exclusions/shape-inside/shape-inside-simple-polygon-003.html
             fast/exclusions/shape-inside/shape-inside-simple-polygon-004.html
      
      * CMakeLists.txt:
      * GNUmakefile.list.am:
      * Target.pri:
      * WebCore.gypi:
      * WebCore.vcproj/WebCore.vcproj:
      * WebCore.xcodeproj/project.pbxproj:
      * rendering/ExclusionPolygon.cpp: Added.
      (WebCore):
      (EdgeIntersection): Internal description of the intersection of a polygon edge and a horizontal line.
      (WebCore::ExclusionPolygon::ExclusionPolygon): See the introductory text above for a description of this type.
      (WebCore::computeXIntersection): Find and classify the X intercept of a polygon edge with horizontal line, if any.
      (WebCore::ExclusionPolygon::rightVertexY): This method is used to decide if a horizontal line "crosses" a vertex.
      (WebCore::appendIntervalX): Append an x coordinate to a vector of ExclusionIntervals.
      (WebCore::ExclusionPolygon::computeXIntersections): Return a vector of the intersections of a horizontal line with the polygon's edges.
      (WebCore::ExclusionPolygon::computeEdgeIntersections): Return a vector of the X projections of the edges that overlap a horizonal rectangle.
      (WebCore::ExclusionPolygon::getExcludedIntervals): Return a SegmentList of the X intervals within a horizontal rectangle that overlap the polygon.
      (WebCore::ExclusionPolygon::getIncludedIntervals): Return the X intervals within a horizontal rectangle that fit inside the polygon.
      * rendering/ExclusionPolygon.h: Added.
      (WebCore):
      (ExclusionPolygon):
      (WebCore::ExclusionPolygon::getXAt): X coordinate of a polygon vertex
      (WebCore::ExclusionPolygon::getYAt): Y coordinate of a polygon vertex
      (WebCore::ExclusionPolygon::numberOfVertices):
      (WebCore::ExclusionPolygon::fillRule): A WindRule value that defines "inside" for self-intersecting polygons.
      (ExclusionPolygonEdge):
      (WebCore::ExclusionPolygonEdge::ExclusionPolygonEdge):
      (WebCore::ExclusionPolygonEdge::vertex1):
      (WebCore::ExclusionPolygonEdge::vertex2):
      (WebCore::ExclusionPolygonEdge::minX):
      (WebCore::ExclusionPolygonEdge::minY):
      (WebCore::ExclusionPolygonEdge::maxX):
      (WebCore::ExclusionPolygonEdge::maxY):
      * rendering/ExclusionShape.cpp:
      (WebCore::createExclusionPolygon): Return a new ExclusionPolygon.
      (WebCore):
      (WebCore::ExclusionShape::createExclusionShape): Added support for BasicShape::BASIC_SHAPE_POLYGON.
      * rendering/ExclusionShapeInsideInfo.cpp:
      (WebCore::ExclusionShapeInsideInfo::isExclusionShapeInsideInfoEnabledForRenderBlock): Enable BASIC_SHAPE_POLYGON shapes for RenderBlocks.
      
      LayoutTests:
      
      Verify that a rectangular shape-inside specified as a polygon works as expected for all
      writing-modes.
      
      Added exclusions tests for non-complex concave shape-inside polygons as well.
      The shapes in this set of tests are "rectangular" in the sense that
      horizontal lines that overlap the polygon only cross the polygon twice.
      The expected part of each test uses float "sandbags" to simulate the
      shape-inside area in the test expectations. The  tests use SVG to
      display the polygon itself, to simplify visual inspection.
      (See http://www.alistapart.com/articles/sandbags/).
      
      * fast/exclusions/shape-inside/shape-inside-polygon-rectangle-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-polygon-rectangle.html: Added.
      * fast/exclusions/resources/simple-polygon.js: Added.
      (createPolygon):
      (polygonXIntercepts):
      (generatePolygonContentString):
      (simulatePolygonShape):
      (generateSimulatedPolygonShapeInsideElement):
      (positionInformativeText):
      (createPolygonShapeInsideTestCase):
      (createPolygonShapeInsideTestCaseExpected):
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-001-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-001.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-002-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-002.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-003-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-003.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-004-expected.html: Added.
      * fast/exclusions/shape-inside/shape-inside-simple-polygon-004.html: Added.
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      bbdd50f0