Chromium Code Reviews| 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..26a168391532fb3c186db13a3b5ef6b9f2f733bf 100644 |
| --- a/Source/core/layout/svg/LayoutSVGShape.cpp |
| +++ b/Source/core/layout/svg/LayoutSVGShape.cpp |
| @@ -56,19 +56,44 @@ LayoutSVGShape::~LayoutSVGShape() |
| { |
| } |
| -void LayoutSVGShape::createPath() |
| +void LayoutSVGShape::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle) |
| +{ |
| + if (diff.needsFullLayout()) { |
| + if (oldStyle && (oldStyle->svgStyle().vectorEffect() != style()->svgStyle().vectorEffect())) |
| + setNeedsShapeUpdate(); |
| + } |
| + |
| + // LayoutSVGModelObject will take care of calling clientStyleChanged. |
| + LayoutSVGModelObject::styleDidChange(diff, oldStyle); |
| +} |
| + |
| +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 +177,17 @@ void LayoutSVGShape::layout() |
| bool updateCachedBoundariesInParents = false; |
| LayoutAnalyzer::Scope analyzer(*this); |
| - if (m_needsShapeUpdate || m_needsBoundariesUpdate) { |
| + if (m_needsBoundariesUpdate && toSVGGeometryElement(element())->selfHasRelativeLengths()) |
|
fs
2015/06/16 10:54:02
I think this needs to consider the "new" geometric
pdr.
2015/06/17 03:50:49
I think we can just check for the exact property c
|
| + m_needsShapeUpdate = true; |
| + |
| + if (m_needsShapeUpdate) |
| updateShapeFromElement(); |
| - m_needsShapeUpdate = false; |
| + |
| + if (m_needsBoundariesUpdate || m_needsShapeUpdate) { |
| + updateStrokeAndFillBoundingBoxes(); |
| updatePaintInvalidationBoundingBox(); |
| m_needsBoundariesUpdate = false; |
| + m_needsShapeUpdate = false; |
| updateCachedBoundariesInParents = true; |
| } |
| @@ -241,35 +272,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(); |