Diff
Modified: trunk/LayoutTests/ChangeLog (131765 => 131766)
--- trunk/LayoutTests/ChangeLog 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/LayoutTests/ChangeLog 2012-10-18 17:08:41 UTC (rev 131766)
@@ -1,3 +1,15 @@
+2012-10-18 Hans Muller <[email protected]>
+
+ [CSS Exclusions] Handle special case "empty" shapes
+ https://bugs.webkit.org/show_bug.cgi?id=99342
+
+ Reviewed by Dirk Schulze.
+
+ 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.
+
2012-10-18 Takashi Sakamoto <[email protected]>
REGRESSION(r131464): Null-pointer crash in StyleResolver::styleForElement
Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty-expected.html (0 => 131766)
--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty-expected.html (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty-expected.html 2012-10-18 17:08:41 UTC (rev 131766)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+ .shape-inside {
+ width: 800px;
+ height: 2em;
+ border: solid green;
+ }
+</style>
+</head>
+<body>
+ <p class="shape-inside">
+ This text should be unconstrained by the rectangle(0px, 0px, 0px, 100px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the rectangle(0px, 0px, 100px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the circle(0px, 0px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the ellipseX0(0px, 0px, 0px, 100px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the ellipse(0px, 0px, 100px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the polygon() shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the polygon(0px 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside">
+ This text should be unconstrained by the polygon(0px 0px, 10px 0px) shape-inside CSS property.
+ </p>
+</body>
+</html>
Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty.html (0 => 131766)
--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty.html (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty.html 2012-10-18 17:08:41 UTC (rev 131766)
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+ .shape-inside {
+ width: 800px;
+ height: 2em;
+ border: solid green;
+ }
+
+ #shape-inside-rectangle-width0 {
+ -webkit-shape-inside: rectangle(0px, 0px, 0px, 100px);
+ }
+
+ #shape-inside-rectangle-height0 {
+ -webkit-shape-inside: rectangle(0px, 0px, 100px, 0px);
+ }
+
+ #shape-inside-circle-radius0 {
+ -webkit-shape-inside: circle(0px, 0px, 0px);
+ }
+
+ #shape-inside-ellipse-radiusX0 {
+ -webkit-shape-inside: ellipse(0px, 0px, 0px, 100px);
+ }
+
+ #shape-inside-ellipse-radiusY0 {
+ -webkit-shape-inside: ellipse(0px, 0px, 100px, 0px);
+ }
+
+ #shape-inside-polygon-0vertices {
+ -webkit-shape-inside: polygon();
+ }
+
+ #shape-inside-polygon-1vertex {
+ -webkit-shape-inside: polygon(0px 0px);
+ }
+
+ #shape-inside-polygon-2vertices {
+ -webkit-shape-inside: polygon(0px 0px, 10px 0px);
+ }
+</style>
+</head>
+<body>
+ <p class="shape-inside" id="shape-inside-rectangle-width0">
+ This text should be unconstrained by the rectangle(0px, 0px, 0px, 100px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-rectangle-height0">
+ This text should be unconstrained by the rectangle(0px, 0px, 100px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-circle-radius0">
+ This text should be unconstrained by the circle(0px, 0px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-ellipse-radiusX0">
+ This text should be unconstrained by the ellipseX0(0px, 0px, 0px, 100px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-ellipse-radiusY0">
+ This text should be unconstrained by the ellipse(0px, 0px, 100px, 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-polygon-0vertices">
+ This text should be unconstrained by the polygon() shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-polygon-1vertex">
+ This text should be unconstrained by the polygon(0px 0px) shape-inside CSS property.
+ </p>
+ <p class="shape-inside" id="shape-inside-polygon-2vertices">
+ This text should be unconstrained by the polygon(0px 0px, 10px 0px) shape-inside CSS property.
+ </p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (131765 => 131766)
--- trunk/Source/WebCore/ChangeLog 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/ChangeLog 2012-10-18 17:08:41 UTC (rev 131766)
@@ -1,3 +1,30 @@
+2012-10-18 Hans Muller <[email protected]>
+
+ [CSS Exclusions] Handle special case "empty" shapes
+ https://bugs.webkit.org/show_bug.cgi?id=99342
+
+ Reviewed by Dirk Schulze.
+
+ 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):
+
2012-10-18 Takashi Sakamoto <[email protected]>
REGRESSION(r131464): Null-pointer crash in StyleResolver::styleForElement
Modified: trunk/Source/WebCore/rendering/ExclusionPolygon.cpp (131765 => 131766)
--- trunk/Source/WebCore/rendering/ExclusionPolygon.cpp 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/rendering/ExclusionPolygon.cpp 2012-10-18 17:08:41 UTC (rev 131766)
@@ -57,10 +57,9 @@
, m_vertices(vertices)
, m_fillRule(fillRule)
{
- // FIXME: Handle polygons defined with less than 3 non-colinear vertices.
-
unsigned nVertices = numberOfVertices();
m_edges.resize(nVertices);
+ m_empty = nVertices < 3;
Vector<ExclusionPolygonEdge*> sortedEdgesMinY(nVertices);
const FloatPoint& vertex0 = vertexAt(0);
@@ -257,6 +256,9 @@
void ExclusionPolygon::getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const
{
+ if (isEmpty())
+ return;
+
float y1 = minYForLogicalLine(logicalTop, logicalBottom);
float y2 = maxYForLogicalLine(logicalTop, logicalBottom);
@@ -281,6 +283,9 @@
void ExclusionPolygon::getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const
{
+ if (isEmpty())
+ return;
+
float y1 = minYForLogicalLine(logicalTop, logicalBottom);
float y2 = maxYForLogicalLine(logicalTop, logicalBottom);
Modified: trunk/Source/WebCore/rendering/ExclusionPolygon.h (131765 => 131766)
--- trunk/Source/WebCore/rendering/ExclusionPolygon.h 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/rendering/ExclusionPolygon.h 2012-10-18 17:08:41 UTC (rev 131766)
@@ -62,6 +62,7 @@
virtual FloatRect shapeLogicalBoundingBox() const OVERRIDE { return internalToLogicalBoundingBox(m_boundingBox); }
virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE;
virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE;
+ virtual bool isEmpty() const OVERRIDE { return m_empty; }
private:
float rightVertexY(unsigned) const;
@@ -76,6 +77,7 @@
FloatRect m_boundingBox;
Vector<ExclusionPolygonEdge> m_edges;
EdgeIntervalTree m_edgeTree;
+ bool m_empty;
};
// EdgeIntervalTree nodes store minY, maxY, and a ("UserData") pointer to an ExclusionPolygonEdge. Edge vertex
Modified: trunk/Source/WebCore/rendering/ExclusionRectangle.cpp (131765 => 131766)
--- trunk/Source/WebCore/rendering/ExclusionRectangle.cpp 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/rendering/ExclusionRectangle.cpp 2012-10-18 17:08:41 UTC (rev 131766)
@@ -42,6 +42,9 @@
void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const
{
+ if (isEmpty())
+ return;
+
float y1 = minYForLogicalLine(logicalTop, logicalBottom);
float y2 = maxYForLogicalLine(logicalTop, logicalBottom);
@@ -70,6 +73,9 @@
void ExclusionRectangle::getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const
{
+ if (isEmpty())
+ return;
+
float y1 = minYForLogicalLine(logicalTop, logicalBottom);
float y2 = maxYForLogicalLine(logicalTop, logicalBottom);
Modified: trunk/Source/WebCore/rendering/ExclusionRectangle.h (131765 => 131766)
--- trunk/Source/WebCore/rendering/ExclusionRectangle.h 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/rendering/ExclusionRectangle.h 2012-10-18 17:08:41 UTC (rev 131766)
@@ -53,6 +53,7 @@
virtual FloatRect shapeLogicalBoundingBox() const OVERRIDE { return internalToLogicalBoundingBox(FloatRect(m_x, m_y, m_width, m_height)); }
virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE;
virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE;
+ virtual bool isEmpty() const OVERRIDE { return m_width <= 0 || m_height <= 0; }
private:
float m_x;
Modified: trunk/Source/WebCore/rendering/ExclusionShape.h (131765 => 131766)
--- trunk/Source/WebCore/rendering/ExclusionShape.h 2012-10-18 17:02:40 UTC (rev 131765)
+++ trunk/Source/WebCore/rendering/ExclusionShape.h 2012-10-18 17:08:41 UTC (rev 131766)
@@ -66,6 +66,7 @@
virtual FloatRect shapeLogicalBoundingBox() const = 0;
virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const = 0;
virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const = 0;
+ virtual bool isEmpty() const = 0;
protected:
float minYForLogicalLine(float logicalTop, float logicalBottom) const { return (m_writingMode == RightToLeftWritingMode) ? m_logicalBoxHeight - logicalBottom : logicalTop; }