Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp

Issue 1996543002: Avoid using forced layout to trigger paint invalidation for SVG containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TE updates Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp
index e27c088da31d36a9f684c06e4d686ed8ec29f84d..3c7b70ca1ad1194c04ae01d532c56181c2212d12 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTransformableContainer.cpp
@@ -66,7 +66,18 @@ bool LayoutSVGTransformableContainer::isChildAllowed(LayoutObject* child, const
return LayoutSVGContainer::isChildAllowed(child, style);
}
-bool LayoutSVGTransformableContainer::calculateLocalTransform()
+void LayoutSVGTransformableContainer::setNeedsTransformUpdate()
+{
+ setMayNeedPaintInvalidationSubtree();
+ m_needsTransformUpdate = true;
+}
+
+static std::pair<double, double> scaleReference(const AffineTransform& transform)
+{
+ return std::make_pair(transform.xScaleSquared(), transform.yScaleSquared());
+}
+
+LayoutSVGContainer::TransformChange LayoutSVGTransformableContainer::calculateLocalTransform()
{
SVGGraphicsElement* element = toSVGGraphicsElement(this->element());
ASSERT(element);
@@ -88,18 +99,23 @@ bool LayoutSVGTransformableContainer::calculateLocalTransform()
FloatSize translation(
useElement->x()->currentValue()->value(lengthContext),
useElement->y()->currentValue()->value(lengthContext));
+ // TODO(fs): Signal this on style update instead. (Since these are
+ // suppose to be presentation attributes now, this does feel a bit
+ // broken...)
if (translation != m_additionalTranslation)
- m_needsTransformUpdate = true;
+ setNeedsTransformUpdate();
m_additionalTranslation = translation;
}
if (!m_needsTransformUpdate)
- return false;
+ return TransformChange::None;
+ std::pair<double, double> oldScale = scaleReference(m_localTransform);
m_localTransform = element->calculateAnimatedLocalTransform();
m_localTransform.translate(m_additionalTranslation.width(), m_additionalTranslation.height());
m_needsTransformUpdate = false;
- return true;
+ return scaleReference(m_localTransform) != oldScale
+ ? TransformChange::Full : TransformChange::ScaleInvariant;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698