[CSS Exclusions] Add support for computing first included interval position for polygons
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 23:11:31 +0000 (23:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 23:11:31 +0000 (23:11 +0000)
commit4d4731d9583b808396db33fe9c0ff3fe96ff8150
treebcf8718332fe77aa3d27f3254f2f403fa385393d
parent7647a4ad7627650875fdfb28985bfe03abae0ef0
[CSS Exclusions] Add support for computing first included interval position for polygons
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: https://svn.webkit.org/repository/webkit/trunk@140606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-001-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-001.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-002-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-002.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-003-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-first-fit-003.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FloatSize.h
Source/WebCore/rendering/ExclusionPolygon.cpp
Source/WebCore/rendering/ExclusionPolygon.h