summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Rogers <pdr@chromium.org>2016-03-17 18:30:47 -0700
committerPhilip Rogers <pdr@chromium.org>2016-03-18 01:33:21 +0000
commita69719e121cc0c8e5fecfaa65a8366cb65216f3c (patch)
tree86fb3a1379c85edb3677700cd68d2a1217be08c3
parent07848822badbaf506f571c039a3eb2896e2ac107 (diff)
downloadchromium_src-a69719e121cc0c8e5fecfaa65a8366cb65216f3c.zip
chromium_src-a69719e121cc0c8e5fecfaa65a8366cb65216f3c.tar.gz
chromium_src-a69719e121cc0c8e5fecfaa65a8366cb65216f3c.tar.bz2
Defer SVG text metrics rebuilding from style changes until layout
This patch removes LayoutSVGText::subtreeStyleDidChange which was added in [1] to fix a font face crash. We no longer support SVG fonts and subtreeStyleDidChange should never have been called on every layout in the first place. With this patch we mark LayoutSVGText as needing a text metrics update when a child inline's style changes, and recalculate the text metrics during layout. This patch results in a 45% improvement on the SVGCubics benchmark which is the heaviest SVG text benchmark we have. [1] https://src.chromium.org/viewvc/blink?revision=167993&view=revision BUG=589525 Review URL: https://codereview.chromium.org/1770663002 Cr-Commit-Position: refs/heads/master@{#379566} (cherry picked from commit d0ffb54118db1b76565dd6d3ffe7623227663038) Review URL: https://codereview.chromium.org/1809203004 . Cr-Commit-Position: refs/branch-heads/2623@{#632} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
-rw-r--r--third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp4
-rw-r--r--third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp18
-rw-r--r--third_party/WebKit/Source/core/layout/svg/LayoutSVGText.h1
3 files changed, 3 insertions, 20 deletions
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
index 5243c2c..b78cebe 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -96,8 +96,10 @@ void LayoutSVGInlineText::styleDidChange(StyleDifference diff, const ComputedSty
return;
// The text metrics may be influenced by style changes.
- if (LayoutSVGText* textLayoutObject = LayoutSVGText::locateLayoutSVGTextAncestor(this))
+ if (LayoutSVGText* textLayoutObject = LayoutSVGText::locateLayoutSVGTextAncestor(this)) {
+ textLayoutObject->setNeedsTextMetricsUpdate();
textLayoutObject->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::StyleChange);
+ }
}
InlineTextBox* LayoutSVGInlineText::createTextBox(int start, unsigned short length)
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
index cc7ad13..1ef39af 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
@@ -263,22 +263,6 @@ void LayoutSVGText::subtreeChildWasRemoved(const Vector<SVGTextLayoutAttributes*
m_layoutAttributesBuilder.buildLayoutAttributesForText(affectedAttributes[i]->context());
}
-void LayoutSVGText::subtreeStyleDidChange()
-{
- if (!shouldHandleSubtreeMutations() || documentBeingDestroyed())
- return;
-
- checkLayoutAttributesConsistency(this, m_layoutAttributes);
-
- // Only update the metrics cache, but not the text positioning element cache
- // nor the layout attributes cached in the leaf #text layoutObjects.
- FontCachePurgePreventer fontCachePurgePreventer;
- for (LayoutObject* descendant = firstChild(); descendant; descendant = descendant->nextInPreOrder(this)) {
- if (descendant->isSVGInlineText())
- m_layoutAttributesBuilder.rebuildMetricsForTextLayoutObject(toLayoutSVGInlineText(descendant));
- }
-}
-
void LayoutSVGText::subtreeTextDidChange(LayoutSVGInlineText* text)
{
ASSERT(text);
@@ -319,8 +303,6 @@ void LayoutSVGText::layout()
ASSERT(needsLayout());
LayoutAnalyzer::Scope analyzer(*this);
- subtreeStyleDidChange();
-
bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
m_localTransform = toSVGTextElement(node())->calculateAnimatedLocalTransform();
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.h
index fde5c84..566aba3 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.h
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.h
@@ -54,7 +54,6 @@ public:
void subtreeChildWasAdded(LayoutObject*);
void subtreeChildWillBeRemoved(LayoutObject*, Vector<SVGTextLayoutAttributes*, 2>& affectedAttributes);
void subtreeChildWasRemoved(const Vector<SVGTextLayoutAttributes*, 2>& affectedAttributes);
- void subtreeStyleDidChange();
void subtreeTextDidChange(LayoutSVGInlineText*);
const AffineTransform& localToParentTransform() const override { return m_localTransform; }