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

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

Issue 1861013003: Separate metrics update and layout attribute resolving (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-layoutattr-invalidation
Patch Set: Rebase Created 4 years, 8 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/LayoutSVGText.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
index 9d0d385cb0e269e935a80a827aca59d1012112f9..2b8499e5cbb77b476cd2077bb2ce117d70b12086 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
@@ -145,6 +145,7 @@ void LayoutSVGText::subtreeChildWillBeRemoved()
// The positioning elements cache depends on the size of each text layoutObject in the
// subtree. If this changes, clear the cache. It will be rebuilt on the next layout.
invalidatePositioningValues(LayoutInvalidationReason::ChildChanged);
+ setNeedsTextMetricsUpdate();
}
void LayoutSVGText::subtreeTextDidChange()
@@ -163,15 +164,15 @@ void LayoutSVGText::subtreeTextDidChange()
setNeedsTextMetricsUpdate();
}
-static inline void updateFontInAllDescendants(LayoutSVGText& textRoot, SVGTextLayoutAttributesBuilder* builder = nullptr)
+static inline void updateFontAndMetrics(LayoutSVGText& textRoot)
{
- for (LayoutObject* descendant = &textRoot; descendant; descendant = descendant->nextInPreOrder(&textRoot)) {
+ bool lastCharacterWasWhiteSpace = true;
+ for (LayoutObject* descendant = textRoot.firstChild(); descendant; descendant = descendant->nextInPreOrder(&textRoot)) {
if (!descendant->isSVGInlineText())
continue;
- LayoutSVGInlineText* text = toLayoutSVGInlineText(descendant);
- text->updateScaledFont();
- if (builder)
- builder->rebuildMetricsForTextLayoutObject(textRoot, *text);
+ LayoutSVGInlineText& text = toLayoutSVGInlineText(*descendant);
+ text.updateScaledFont();
+ text.updateMetricsList(lastCharacterWasWhiteSpace);
}
}
@@ -201,8 +202,8 @@ void LayoutSVGText::layout()
// and propogate resulting SVGLayoutAttributes to all LayoutSVGInlineText children in the subtree.
ASSERT(m_layoutAttributes.isEmpty());
collectLayoutAttributes(this, m_layoutAttributes);
- updateFontInAllDescendants(*this);
- m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
+ updateFontAndMetrics(*this);
+ m_layoutAttributesBuilder.buildLayoutAttributesForTextRoot(*this);
m_needsReordering = true;
m_needsTextMetricsUpdate = false;
@@ -212,20 +213,20 @@ void LayoutSVGText::layout()
// When the x/y/dx/dy/rotate lists change, recompute the layout attributes, and eventually
// update the on-screen font objects as well in all descendants.
if (m_needsTextMetricsUpdate) {
- updateFontInAllDescendants(*this);
+ updateFontAndMetrics(*this);
m_needsTextMetricsUpdate = false;
}
m_layoutAttributes.clear();
collectLayoutAttributes(this, m_layoutAttributes);
- m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
+ m_layoutAttributesBuilder.buildLayoutAttributesForTextRoot(*this);
m_needsReordering = true;
m_needsPositioningValuesUpdate = false;
updateCachedBoundariesInParents = true;
} else if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject(this)->isLayoutSizeChanged()) {
// If the root layout size changed (eg. window size changes) or the transform to the root
// context has changed then recompute the on-screen font size.
- updateFontInAllDescendants(*this, &m_layoutAttributesBuilder);
+ updateFontAndMetrics(*this);
ASSERT(!m_needsReordering);
ASSERT(!m_needsPositioningValuesUpdate);

Powered by Google App Engine
This is Rietveld 408576698