Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (131767 => 131768)
--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp 2012-10-18 17:10:14 UTC (rev 131767)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp 2012-10-18 17:16:29 UTC (rev 131768)
@@ -134,6 +134,16 @@
uniteEvenIfEmpty(other);
}
+void FloatRect::extend(const FloatPoint& p)
+{
+ float minX = min(x(), p.x());
+ float minY = min(y(), p.y());
+ float maxX = max(this->maxX(), p.x());
+ float maxY = max(this->maxY(), p.y());
+
+ setLocationAndSizeFromEdges(minX, minY, maxX, maxY);
+}
+
void FloatRect::scale(float sx, float sy)
{
m_location.setX(x() * sx);
Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (131767 => 131768)
--- trunk/Source/WebCore/platform/graphics/FloatRect.h 2012-10-18 17:10:14 UTC (rev 131767)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h 2012-10-18 17:16:29 UTC (rev 131768)
@@ -164,6 +164,7 @@
void unite(const FloatRect&);
void uniteEvenIfEmpty(const FloatRect&);
void uniteIfNonZero(const FloatRect&);
+ void extend(const FloatPoint&);
// Note, this doesn't match what IntRect::contains(IntPoint&) does; the int version
// is really checking for containment of 1x1 rect, but that doesn't make sense with floats.
Modified: trunk/Source/WebCore/rendering/ExclusionPolygon.cpp (131767 => 131768)
--- trunk/Source/WebCore/rendering/ExclusionPolygon.cpp 2012-10-18 17:10:14 UTC (rev 131767)
+++ trunk/Source/WebCore/rendering/ExclusionPolygon.cpp 2012-10-18 17:16:29 UTC (rev 131768)
@@ -62,20 +62,12 @@
m_empty = nVertices < 3;
Vector<ExclusionPolygonEdge*> sortedEdgesMinY(nVertices);
- const FloatPoint& vertex0 = vertexAt(0);
- float minX = vertex0.x();
- float minY = vertex0.y();
- float maxX = minX;
- float maxY = minY;
+ if (nVertices)
+ m_boundingBox.setLocation(vertexAt(0));
for (unsigned i = 0; i < nVertices; i++) {
const FloatPoint& vertex = vertexAt(i);
-
- minX = std::min(vertex.x(), minX);
- maxX = std::max(vertex.x(), maxX);
- minY = std::min(vertex.y(), minY);
- maxY = std::max(vertex.y(), maxY);
-
+ m_boundingBox.extend(vertex);
m_edges[i].polygon = this;
m_edges[i].index1 = i;
m_edges[i].index2 = (i + 1) % nVertices;
@@ -83,11 +75,6 @@
sortedEdgesMinY[i] = &m_edges[i];
}
- m_boundingBox.setX(minX);
- m_boundingBox.setY(minY);
- m_boundingBox.setWidth(maxX - minX);
- m_boundingBox.setHeight(maxY - minY);
-
std::sort(sortedEdgesMinY.begin(), sortedEdgesMinY.end(), WebCore::compareEdgeMinY);
for (unsigned i = 0; i < m_edges.size(); i++) {
Modified: trunk/Source/WebCore/rendering/ExclusionShape.cpp (131767 => 131768)
--- trunk/Source/WebCore/rendering/ExclusionShape.cpp 2012-10-18 17:10:14 UTC (rev 131767)
+++ trunk/Source/WebCore/rendering/ExclusionShape.cpp 2012-10-18 17:16:29 UTC (rev 131768)
@@ -82,18 +82,21 @@
case BasicShape::BASIC_SHAPE_RECTANGLE: {
const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRectangle*>(basicShape);
- float x = floatValueForLength(rectangle->x(), boxWidth);
- float y = floatValueForLength(rectangle->y(), boxHeight);
- float width = floatValueForLength(rectangle->width(), boxWidth);
- float height = floatValueForLength(rectangle->height(), boxHeight);
+ FloatRect bounds(
+ floatValueForLength(rectangle->x(), boxWidth),
+ floatValueForLength(rectangle->y(), boxHeight),
+ floatValueForLength(rectangle->width(), boxWidth),
+ floatValueForLength(rectangle->height(), boxHeight));
Length radiusXLength = rectangle->cornerRadiusX();
Length radiusYLength = rectangle->cornerRadiusY();
- float radiusX = radiusXLength.isUndefined() ? 0 : floatValueForLength(radiusXLength, boxWidth);
- float radiusY = radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight);
+ FloatSize cornerRadii(
+ radiusXLength.isUndefined() ? 0 : floatValueForLength(radiusXLength, boxWidth),
+ radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight));
exclusionShape = horizontalWritingMode
- ? createExclusionRectangle(FloatRect(x, y, width, height), FloatSize(radiusX, radiusY))
- : createExclusionRectangle(FloatRect(y, x, height, width), FloatSize(radiusY, radiusX));
+ ? createExclusionRectangle(bounds, cornerRadii)
+ : createExclusionRectangle(bounds.transposedRect(), cornerRadii.transposedSize());
+ exclusionShape->m_boundingBox = bounds;
break;
}
@@ -106,6 +109,7 @@
exclusionShape = horizontalWritingMode
? createExclusionCircle(FloatPoint(centerX, centerY), radius)
: createExclusionCircle(FloatPoint(centerY, centerX), radius);
+ exclusionShape->m_boundingBox = FloatRect(centerX - radius, centerY - radius, radius * 2, radius * 2);
break;
}
@@ -119,6 +123,7 @@
exclusionShape = horizontalWritingMode
? createExclusionEllipse(FloatPoint(centerX, centerY), FloatSize(radiusX, radiusY))
: createExclusionEllipse(FloatPoint(centerY, centerX), FloatSize(radiusY, radiusX));
+ exclusionShape->m_boundingBox = FloatRect(centerX - radiusX, centerY - radiusY, radiusX * 2, radiusY * 2);
break;
}
@@ -127,14 +132,20 @@
const Vector<Length>& values = polygon->values();
size_t valuesSize = values.size();
ASSERT(!(valuesSize % 2));
+ FloatRect boundingBox;
Vector<FloatPoint>* vertices = new Vector<FloatPoint>(valuesSize / 2);
for (unsigned i = 0; i < valuesSize; i += 2) {
FloatPoint vertex(
floatValueForLength(values.at(i), boxWidth),
floatValueForLength(values.at(i + 1), boxHeight));
(*vertices)[i / 2] = horizontalWritingMode ? vertex : vertex.transposedPoint();
+ if (!i)
+ boundingBox.setLocation(vertex);
+ else
+ boundingBox.extend(vertex);
}
exclusionShape = createExclusionPolygon(adoptPtr(vertices), polygon->windRule());
+ exclusionShape->m_boundingBox = boundingBox;
break;
}
Modified: trunk/Source/WebCore/rendering/ExclusionShape.h (131767 => 131768)
--- trunk/Source/WebCore/rendering/ExclusionShape.h 2012-10-18 17:10:14 UTC (rev 131767)
+++ trunk/Source/WebCore/rendering/ExclusionShape.h 2012-10-18 17:16:29 UTC (rev 131768)
@@ -64,6 +64,7 @@
virtual ~ExclusionShape() { }
virtual FloatRect shapeLogicalBoundingBox() const = 0;
+ virtual FloatRect shapeBoundingBox() const { return m_boundingBox; }
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;
@@ -77,6 +78,7 @@
WritingMode m_writingMode;
float m_logicalBoxWidth;
float m_logicalBoxHeight;
+ FloatRect m_boundingBox;
};
} // namespace WebCore