Diff
Modified: trunk/Source/WebCore/ChangeLog (172356 => 172357)
--- trunk/Source/WebCore/ChangeLog 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/ChangeLog 2014-08-08 21:12:06 UTC (rev 172357)
@@ -1,3 +1,41 @@
+2014-08-08 Bem Jones-Bey <[email protected]>
+
+ [CSS Shapes] Refactor getExcludedIntervals since only one LineSegment is ever returned
+ https://bugs.webkit.org/show_bug.cgi?id=135757
+
+ Reviewed by Zoltan Horvath.
+
+ The interface for getExcludedIntervals was designed when shape-inside
+ was still a thing, and it was possible for a line in a shape to have
+ multiple segments. shape-outside can only have one segment per line,
+ so this refactors the code to simplify and reflect that reality.
+
+ No new test, no behavior change.
+
+ * rendering/shapes/BoxShape.cpp:
+ (WebCore::BoxShape::getExcludedInterval):
+ (WebCore::BoxShape::getExcludedIntervals): Deleted.
+ * rendering/shapes/BoxShape.h:
+ * rendering/shapes/PolygonShape.cpp:
+ (WebCore::PolygonShape::getExcludedInterval):
+ (WebCore::PolygonShape::getExcludedIntervals): Deleted.
+ * rendering/shapes/PolygonShape.h:
+ * rendering/shapes/RasterShape.cpp:
+ (WebCore::RasterShape::getExcludedInterval):
+ (WebCore::RasterShape::getExcludedIntervals): Deleted.
+ * rendering/shapes/RasterShape.h:
+ * rendering/shapes/RectangleShape.cpp:
+ (WebCore::RectangleShape::getExcludedInterval):
+ (WebCore::RectangleShape::getExcludedIntervals): Deleted.
+ * rendering/shapes/RectangleShape.h:
+ * rendering/shapes/Shape.h:
+ (WebCore::LineSegment::LineSegment):
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::logicalLeftOffset):
+ (WebCore::ShapeOutsideInfo::updateDeltasForContainingBlockLine):
+ (WebCore::ShapeOutsideInfo::computeSegmentsForLine): Deleted.
+ * rendering/shapes/ShapeOutsideInfo.h:
+
2014-08-08 Brian J. Burg <[email protected]>
Web Inspector: add debugging flag to InspectorTest for unbuffered logging to stderr
Modified: trunk/Source/WebCore/rendering/shapes/BoxShape.cpp (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/BoxShape.cpp 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/BoxShape.cpp 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -112,28 +112,24 @@
return marginBounds;
}
-void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
+LineSegment BoxShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const
{
const FloatRoundedRect& marginBounds = shapeMarginBounds();
if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, logicalHeight))
- return;
+ return LineSegment();
float y1 = logicalTop;
float y2 = logicalTop + logicalHeight;
const FloatRect& rect = marginBounds.rect();
- if (!marginBounds.isRounded()) {
- result.append(LineSegment(rect.x(), rect.maxX()));
- return;
- }
+ if (!marginBounds.isRounded())
+ return LineSegment(rect.x(), rect.maxX());
float topCornerMaxY = std::max<float>(marginBounds.topLeftCorner().maxY(), marginBounds.topRightCorner().maxY());
float bottomCornerMinY = std::min<float>(marginBounds.bottomLeftCorner().y(), marginBounds.bottomRightCorner().y());
- if (topCornerMaxY <= bottomCornerMinY && y1 <= topCornerMaxY && y2 >= bottomCornerMinY) {
- result.append(LineSegment(rect.x(), rect.maxX()));
- return;
- }
+ if (topCornerMaxY <= bottomCornerMinY && y1 <= topCornerMaxY && y2 >= bottomCornerMinY)
+ return LineSegment(rect.x(), rect.maxX());
float x1 = rect.maxX();
float x2 = rect.x();
@@ -157,7 +153,7 @@
}
ASSERT(x2 >= x1);
- result.append(LineSegment(x1, x2));
+ return LineSegment(x1, x2);
}
void BoxShape::buildDisplayPaths(DisplayPaths& paths) const
Modified: trunk/Source/WebCore/rendering/shapes/BoxShape.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/BoxShape.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/BoxShape.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -49,7 +49,7 @@
virtual LayoutRect shapeMarginLogicalBoundingBox() const override;
virtual bool isEmpty() const override { return m_bounds.isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
+ virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
virtual void buildDisplayPaths(DisplayPaths&) const override;
Modified: trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -117,17 +117,17 @@
return LayoutRect(box);
}
-void PolygonShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
+LineSegment PolygonShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const
{
float y1 = logicalTop;
float y2 = logicalTop + logicalHeight;
if (m_polygon.isEmpty() || !m_polygon.boundingBox().overlapsYRange(y1 - shapeMargin(), y2 + shapeMargin()))
- return;
+ return LineSegment();
Vector<const FloatPolygonEdge*> overlappingEdges;
if (!m_polygon.overlappingEdges(y1 - shapeMargin(), y2 + shapeMargin(), overlappingEdges))
- return;
+ return LineSegment();
FloatShapeInterval excludedInterval;
for (unsigned i = 0; i < overlappingEdges.size(); i++) {
@@ -143,8 +143,10 @@
}
}
- if (!excludedInterval.isEmpty())
- result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2()));
+ if (excludedInterval.isEmpty())
+ return LineSegment();
+
+ return LineSegment(excludedInterval.x1(), excludedInterval.x2());
}
void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const
Modified: trunk/Source/WebCore/rendering/shapes/PolygonShape.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/PolygonShape.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/PolygonShape.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -67,7 +67,7 @@
virtual LayoutRect shapeMarginLogicalBoundingBox() const override;
virtual bool isEmpty() const override { return m_polygon.isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
+ virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
virtual void buildDisplayPaths(DisplayPaths&) const override;
Modified: trunk/Source/WebCore/rendering/shapes/RasterShape.cpp (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/RasterShape.cpp 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/RasterShape.cpp 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -149,17 +149,17 @@
return *m_marginIntervals;
}
-void RasterShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
+LineSegment RasterShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const
{
const RasterShapeIntervals& intervals = marginIntervals();
if (intervals.isEmpty())
- return;
+ return LineSegment();
int y1 = logicalTop;
int y2 = logicalTop + logicalHeight;
ASSERT(y2 >= y1);
if (y2 < intervals.bounds().y() || y1 >= intervals.bounds().maxY())
- return;
+ return LineSegment();
y1 = std::max(y1, intervals.bounds().y());
y2 = std::min(y2, intervals.bounds().maxY());
@@ -172,7 +172,7 @@
excludedInterval.unite(intervals.intervalAt(y));
}
- result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2()));
+ return LineSegment(excludedInterval.x1(), excludedInterval.x2());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/shapes/RasterShape.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/RasterShape.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/RasterShape.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -61,7 +61,7 @@
ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_intervals.size());
return m_intervals[y + m_offset];
}
-
+
std::unique_ptr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin) const;
void buildBoundsPath(Path&) const;
@@ -88,7 +88,7 @@
virtual LayoutRect shapeMarginLogicalBoundingBox() const override { return static_cast<LayoutRect>(marginIntervals().bounds()); }
virtual bool isEmpty() const override { return m_intervals->isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
+ virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
virtual void buildDisplayPaths(DisplayPaths& paths) const override
{
Modified: trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -53,17 +53,17 @@
return FloatRect(boundsX, boundsY, boundsWidth, boundsHeight);
}
-void RectangleShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
+LineSegment RectangleShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const
{
const FloatRect& bounds = shapeMarginBounds();
if (bounds.isEmpty())
- return;
+ return LineSegment();
float y1 = logicalTop;
float y2 = logicalTop + logicalHeight;
if (y2 < bounds.y() || y1 >= bounds.maxY())
- return;
+ return LineSegment();
float x1 = bounds.x();
float x2 = bounds.maxX();
@@ -85,7 +85,7 @@
}
}
- result.append(LineSegment(x1, x2));
+ return LineSegment(x1, x2);
}
void RectangleShape::buildDisplayPaths(DisplayPaths& paths) const
Modified: trunk/Source/WebCore/rendering/shapes/RectangleShape.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/RectangleShape.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/RectangleShape.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -49,7 +49,7 @@
virtual LayoutRect shapeMarginLogicalBoundingBox() const override { return static_cast<LayoutRect>(shapeMarginBounds()); }
virtual bool isEmpty() const override { return m_bounds.isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
+ virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
virtual void buildDisplayPaths(DisplayPaths&) const override;
Modified: trunk/Source/WebCore/rendering/shapes/Shape.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/Shape.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/Shape.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -37,23 +37,29 @@
namespace WebCore {
struct LineSegment {
+ LineSegment()
+ : logicalLeft(0)
+ , logicalRight(0)
+ , isValid(false)
+ {
+ }
+
LineSegment(float logicalLeft, float logicalRight)
: logicalLeft(logicalLeft)
, logicalRight(logicalRight)
+ , isValid(true)
{
}
float logicalLeft;
float logicalRight;
+ bool isValid;
};
class BasicShape;
class Image;
class RoundedRect;
-typedef Vector<LineSegment> SegmentList;
-
-
// A representation of a BasicShape that enables layout code to determine how to break a line up into segments
// that will fit within or around a shape. The line is defined by a pair of logical Y coordinates and the
// computed segments are returned as pairs of logical X coordinates. The BasicShape itself is defined in
@@ -74,7 +80,7 @@
virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0;
virtual bool isEmpty() const = 0;
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const = 0;
+ virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const = 0;
bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogicalBoundingBox()); }
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2014-08-08 21:12:06 UTC (rev 172357)
@@ -282,7 +282,7 @@
case ViewBox: break;
case BoxMissing: break;
}
-
+
ASSERT_NOT_REACHED();
return LayoutUnit();
}
@@ -303,23 +303,10 @@
return false;
}
-SegmentList ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
+void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
ASSERT(lineHeight >= 0);
- SegmentList segments;
- computedShape().getExcludedIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);
-
- for (size_t i = 0; i < segments.size(); i++) {
- segments[i].logicalLeft += logicalLeftOffset();
- segments[i].logicalRight += logicalLeftOffset();
- }
-
- return segments;
-}
-
-void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
-{
LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject) + containingBlock.marginBeforeForChild(m_renderer);
LayoutUnit borderBoxLineTop = lineTop - borderBoxTop;
@@ -331,14 +318,14 @@
LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&floatingObject);
if (computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineTop, m_lineHeight)) {
- SegmentList segments = computeSegmentsForLine(borderBoxLineTop, lineHeight);
- if (segments.size()) {
+ LineSegment segment = computedShape().getExcludedInterval((borderBoxLineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - borderBoxLineTop));
+ if (segment.isValid) {
LayoutUnit logicalLeftMargin = containingBlock.style().isLeftToRightDirection() ? containingBlock.marginStartForChild(m_renderer) : containingBlock.marginEndForChild(m_renderer);
- LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft + logicalLeftMargin;
+ LayoutUnit rawLeftMarginBoxDelta = segment.logicalLeft + logicalLeftOffset() + logicalLeftMargin;
m_leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMarginBoxDelta, LayoutUnit(), floatMarginBoxWidth);
LayoutUnit logicalRightMargin = containingBlock.style().isLeftToRightDirection() ? containingBlock.marginEndForChild(m_renderer) : containingBlock.marginStartForChild(m_renderer);
- LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight - containingBlock.logicalWidthForChild(m_renderer) - logicalRightMargin;
+ LayoutUnit rawRightMarginBoxDelta = segment.logicalRight + logicalLeftOffset() - containingBlock.logicalWidthForChild(m_renderer) - logicalRightMargin;
m_rightMarginBoxDelta = clampTo<LayoutUnit>(rawRightMarginBoxDelta, -floatMarginBoxWidth, LayoutUnit());
m_lineOverlapsShape = true;
return;
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h (172356 => 172357)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h 2014-08-08 20:59:30 UTC (rev 172356)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h 2014-08-08 21:12:06 UTC (rev 172357)
@@ -96,8 +96,6 @@
private:
std::unique_ptr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold, WritingMode, float margin) const;
- SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const;
-
LayoutUnit logicalTopOffset() const;
LayoutUnit logicalLeftOffset() const;