Commit 31cc5e8f authored by rob.buis@samsung.com's avatar rob.buis@samsung.com

[CSS Shapes] clamp RasterShape shapeMargin to reference box size

Verify that a very large shape-margin value combined with a very small
shape-outside image defines a shape that matches the shape-outside
element's margin-box.

This is a merge of http://trac.webkit.org/changeset/166019 by
Hans Muller <hmuller@adobe.com>.

BUG=354917

Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=169768

Review URL: https://codereview.chromium.org/208423003

git-svn-id: svn://svn.chromium.org/blink/trunk@169877 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 54f2fae4
<!DOCTYPE html>
<html>
<head>
<style>
#content {
font: 50px/1 Ahem, sans-serif;
-webkit-font-smoothing: antialiased;
color: green;
}
#sandbag {
float: left;
width: 150px;
height: 100px;
}
</style>
</head>
<body>
<p>The shape-outside in this test is a 2x2 image with only the upper left pixel set. The shape
element's margin-box is and the the shape-margin is big enough (is greater than 150 * sqrt(2))
so that the shape-margin boundary extends beyond the margin-box's bounds. The shape-outside boundary
is clipped to the margin-box, so it's as if the shape-outside was equal to the margin-box.</p>
<div id="content">
<div id="sandbag"></div>X<br>X
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
#content {
font: 50px/1 Ahem, sans-serif;
-webkit-font-smoothing: antialiased;
color: green;
}
#image-shape {
float: left;
shape-outside: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='2px' height='2px'><rect width='1' height='1' fill='blue'/></svg>");
shape-margin: 500px;
margin-right: 50px;
margin-bottom: 50px;
width: 100px;
height: 50px;
}
</style>
</head>
<body>
<p>The shape-outside in this test is a 2x2 image with only the upper left pixel set. The shape
element's margin-box is and the the shape-margin is big enough (is greater than 150 * sqrt(2))
so that the shape-margin boundary extends beyond the margin-box's bounds. The shape-outside boundary
is clipped to the margin-box, so it's as if the shape-outside was equal to the margin-box.</p>
<div id="content">
<div id="image-shape"></div>
X<br>X
</div>
</body>
</html>
...@@ -255,11 +255,10 @@ const RasterShapeIntervals& RasterShape::marginIntervals() const ...@@ -255,11 +255,10 @@ const RasterShapeIntervals& RasterShape::marginIntervals() const
if (!shapeMargin()) if (!shapeMargin())
return *m_intervals; return *m_intervals;
int marginBoundaryRadius = std::min(clampToInteger(ceil(shapeMargin())), std::max(m_imageSize.width(), m_imageSize.height())); int shapeMarginInt = clampToPositiveInteger(ceil(shapeMargin()));
if (!m_marginIntervals) { int maxShapeMarginInt = std::max(m_marginRectSize.width(), m_marginRectSize.height()) * sqrtf(2);
ASSERT(marginBoundaryRadius >= 0); if (!m_marginIntervals)
m_marginIntervals = m_intervals->computeShapeMarginIntervals(marginBoundaryRadius); m_marginIntervals = m_intervals->computeShapeMarginIntervals(std::min(shapeMarginInt, maxShapeMarginInt));
}
return *m_marginIntervals; return *m_marginIntervals;
} }
......
...@@ -92,9 +92,9 @@ private: ...@@ -92,9 +92,9 @@ private:
class RasterShape FINAL : public Shape { class RasterShape FINAL : public Shape {
WTF_MAKE_NONCOPYABLE(RasterShape); WTF_MAKE_NONCOPYABLE(RasterShape);
public: public:
RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& imageSize) RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& marginRectSize)
: m_intervals(intervals) : m_intervals(intervals)
, m_imageSize(imageSize) , m_marginRectSize(marginRectSize)
{ {
} }
...@@ -111,7 +111,7 @@ private: ...@@ -111,7 +111,7 @@ private:
OwnPtr<RasterShapeIntervals> m_intervals; OwnPtr<RasterShapeIntervals> m_intervals;
mutable OwnPtr<RasterShapeIntervals> m_marginIntervals; mutable OwnPtr<RasterShapeIntervals> m_marginIntervals;
IntSize m_imageSize; IntSize m_marginRectSize;
}; };
} // namespace WebCore } // namespace WebCore
......
...@@ -62,7 +62,7 @@ typedef Vector<LineSegment> SegmentList; ...@@ -62,7 +62,7 @@ typedef Vector<LineSegment> SegmentList;
class Shape { class Shape {
public: public:
static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& logicalBoxSize, WritingMode, Length margin, Length padding); static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& logicalBoxSize, WritingMode, Length margin, Length padding);
static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& drawRect, const LayoutRect& clipRect, WritingMode, Length margin, Length padding); static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& imageRect, const LayoutRect& marginRect, WritingMode, Length margin, Length padding);
static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMode, const Length& margin, const Length& padding); static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMode, const Length& margin, const Length& padding);
virtual ~Shape() { } virtual ~Shape() { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment