| Index: Source/core/layout/svg/LayoutSVGShape.cpp
|
| diff --git a/Source/core/layout/svg/LayoutSVGShape.cpp b/Source/core/layout/svg/LayoutSVGShape.cpp
|
| index f5f47a848267768566bd24f9858ad452e8490d10..64423083c10202ca9322ddfa1e15978f9a79f5b3 100644
|
| --- a/Source/core/layout/svg/LayoutSVGShape.cpp
|
| +++ b/Source/core/layout/svg/LayoutSVGShape.cpp
|
| @@ -56,19 +56,33 @@ LayoutSVGShape::~LayoutSVGShape()
|
| {
|
| }
|
|
|
| -void LayoutSVGShape::createPath()
|
| +void LayoutSVGShape::updateShapeFromElement()
|
| {
|
| if (!m_path)
|
| m_path = adoptPtr(new Path());
|
| *m_path = toSVGGeometryElement(element())->asPath();
|
| }
|
|
|
| -void LayoutSVGShape::updateShapeFromElement()
|
| +void LayoutSVGShape::updateStrokeAndFillBoundingBoxes()
|
| {
|
| - createPath();
|
| + m_fillBoundingBox = path().boundingRect();
|
|
|
| - m_fillBoundingBox = calculateObjectBoundingBox();
|
| - m_strokeBoundingBox = calculateStrokeBoundingBox();
|
| + m_strokeBoundingBox = m_fillBoundingBox;
|
| + if (style()->svgStyle().hasStroke()) {
|
| + StrokeData strokeData;
|
| + SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, styleRef(), *this);
|
| + if (hasNonScalingStroke()) {
|
| + AffineTransform nonScalingTransform = nonScalingStrokeTransform();
|
| + if (nonScalingTransform.isInvertible()) {
|
| + Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
|
| + FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strokeData);
|
| + strokeBoundingRect = nonScalingTransform.inverse().mapRect(strokeBoundingRect);
|
| + m_strokeBoundingBox.unite(strokeBoundingRect);
|
| + }
|
| + } else {
|
| + m_strokeBoundingBox.unite(path().strokeBoundingRect(strokeData));
|
| + }
|
| + }
|
| }
|
|
|
| FloatRect LayoutSVGShape::hitTestStrokeBoundingBox() const
|
| @@ -152,11 +166,14 @@ void LayoutSVGShape::layout()
|
| bool updateCachedBoundariesInParents = false;
|
| LayoutAnalyzer::Scope analyzer(*this);
|
|
|
| - if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
|
| + if (m_needsShapeUpdate)
|
| updateShapeFromElement();
|
| - m_needsShapeUpdate = false;
|
| +
|
| + if (m_needsBoundariesUpdate || m_needsShapeUpdate) {
|
| + updateStrokeAndFillBoundingBoxes();
|
| updatePaintInvalidationBoundingBox();
|
| m_needsBoundariesUpdate = false;
|
| + m_needsShapeUpdate = false;
|
| updateCachedBoundariesInParents = true;
|
| }
|
|
|
| @@ -241,35 +258,6 @@ bool LayoutSVGShape::nodeAtFloatPointInternal(const HitTestRequest& request, con
|
| return false;
|
| }
|
|
|
| -FloatRect LayoutSVGShape::calculateObjectBoundingBox() const
|
| -{
|
| - return path().boundingRect();
|
| -}
|
| -
|
| -FloatRect LayoutSVGShape::calculateStrokeBoundingBox() const
|
| -{
|
| - ASSERT(m_path);
|
| - FloatRect strokeBoundingBox = m_fillBoundingBox;
|
| -
|
| - if (style()->svgStyle().hasStroke()) {
|
| - StrokeData strokeData;
|
| - SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, styleRef(), *this);
|
| - if (hasNonScalingStroke()) {
|
| - AffineTransform nonScalingTransform = nonScalingStrokeTransform();
|
| - if (nonScalingTransform.isInvertible()) {
|
| - Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
|
| - FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strokeData);
|
| - strokeBoundingRect = nonScalingTransform.inverse().mapRect(strokeBoundingRect);
|
| - strokeBoundingBox.unite(strokeBoundingRect);
|
| - }
|
| - } else {
|
| - strokeBoundingBox.unite(path().strokeBoundingRect(strokeData));
|
| - }
|
| - }
|
| -
|
| - return strokeBoundingBox;
|
| -}
|
| -
|
| void LayoutSVGShape::updatePaintInvalidationBoundingBox()
|
| {
|
| m_paintInvalidationBoundingBox = strokeBoundingBox();
|
|
|