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

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

Issue 2587623002: Make LayoutSVGViewportContainer's viewport updates an internal detail (Closed)
Patch Set: Fix mistake in setting m_isLayoutSizeChanged Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp
index 3b5b2fef87910c939e18b3d55e4e35c695400b76..eeb53b13625b2112d8e1689689b3750aa1c92868 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp
@@ -32,10 +32,28 @@ LayoutSVGViewportContainer::LayoutSVGViewportContainer(SVGSVGElement* node)
m_isLayoutSizeChanged(false),
m_needsTransformUpdate(true) {}
-void LayoutSVGViewportContainer::determineIfLayoutSizeChanged() {
+void LayoutSVGViewportContainer::layout() {
+ DCHECK(needsLayout());
DCHECK(isSVGSVGElement(element()));
- m_isLayoutSizeChanged =
- toSVGSVGElement(element())->hasRelativeLengths() && selfNeedsLayout();
+
+ const SVGSVGElement* svg = toSVGSVGElement(element());
+ m_isLayoutSizeChanged = selfNeedsLayout() && svg->hasRelativeLengths();
+
+ if (selfNeedsLayout()) {
+ SVGLengthContext lengthContext(svg);
+ FloatRect oldViewport = m_viewport;
+ m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext),
+ svg->y()->currentValue()->value(lengthContext),
+ svg->width()->currentValue()->value(lengthContext),
+ svg->height()->currentValue()->value(lengthContext));
+ if (oldViewport != m_viewport) {
+ setNeedsBoundariesUpdate();
+ // The transform depends on viewport values.
+ setNeedsTransformUpdate();
+ }
+ }
+
+ LayoutSVGContainer::layout();
}
void LayoutSVGViewportContainer::setNeedsTransformUpdate() {
@@ -49,26 +67,11 @@ void LayoutSVGViewportContainer::setNeedsTransformUpdate() {
}
SVGTransformChange LayoutSVGViewportContainer::calculateLocalTransform() {
- DCHECK(isSVGSVGElement(element()));
- const SVGSVGElement* svg = toSVGSVGElement(element());
-
- FloatRect oldViewport = m_viewport;
- SVGLengthContext lengthContext(svg);
- m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext),
- svg->y()->currentValue()->value(lengthContext),
- svg->width()->currentValue()->value(lengthContext),
- svg->height()->currentValue()->value(lengthContext));
-
- // TODO(pdr): Mark this object as needing updates when the viewport values
- // change instead of waiting for layout.
- if (m_viewport != oldViewport) {
- setNeedsBoundariesUpdate();
- setNeedsTransformUpdate();
- }
-
if (!m_needsTransformUpdate)
return SVGTransformChange::None;
+ DCHECK(isSVGSVGElement(element()));
+ const SVGSVGElement* svg = toSVGSVGElement(element());
SVGTransformChangeDetector changeDetector(m_localToParentTransform);
m_localToParentTransform =
AffineTransform::translation(m_viewport.x(), m_viewport.y()) *
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698