cachedFont not getting updated for inline SVG text.
authorinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 17:23:52 +0000 (17:23 +0000)
committerinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 17:23:52 +0000 (17:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68060

Reviewed by Nikolas Zimmermann.

Source/WebCore:

The cached scaledFont needs to be updated on every style set call. It
is not similar to m_style which can get derived from parent's style and
hence will get automatically updated on ancestor's style change. This is
required, otherwise we will maintain stale font list in cached scaledFont
when custom fonts are retired on Document::recalcStyle.

Test: svg/text/text-style-recalc-crash.html

* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::styleDidChange):
(WebCore::RenderSVGInlineText::setStyle):
* rendering/svg/RenderSVGInlineText.h:

LayoutTests:

* svg/text/text-style-recalc-crash-expected.txt: Added.
* svg/text/text-style-recalc-crash.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95301 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/text/text-style-recalc-crash-expected.txt [new file with mode: 0644]
LayoutTests/svg/text/text-style-recalc-crash.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
Source/WebCore/rendering/svg/RenderSVGInlineText.h

index 52a01af..05b40ec 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-16  Abhishek Arya  <inferno@chromium.org>
+
+        cachedFont not getting updated for inline SVG text.
+        https://bugs.webkit.org/show_bug.cgi?id=68060
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/text/text-style-recalc-crash-expected.txt: Added.
+        * svg/text/text-style-recalc-crash.html: Added.
+
 2011-09-16  Csaba Osztrogonác  <ossy@webkit.org>
 
         Unreviewed rolling out r95277.
diff --git a/LayoutTests/svg/text/text-style-recalc-crash-expected.txt b/LayoutTests/svg/text/text-style-recalc-crash-expected.txt
new file mode 100644 (file)
index 0000000..202c556
--- /dev/null
@@ -0,0 +1,3 @@
+Test passes if it does not crash. 
+PASS
+
diff --git a/LayoutTests/svg/text/text-style-recalc-crash.html b/LayoutTests/svg/text/text-style-recalc-crash.html
new file mode 100644 (file)
index 0000000..a5bceb8
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+Test passes if it does not crash.
+<svg viewBox="0 0 1 1">
+<font-face font-family="A">
+<font-face-src>
+<font-face-uri xlink:href="A"/>
+</font-face-src>
+</font-face>
+<g font-family="A">
+<text>PASS</text>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    document.execCommand("SelectAll");
+</script>
+<g>
+<text></text>
+</g>
+</g>
+</svg>
+</html>
index 9ecdcf9..65d946b 100644 (file)
@@ -1,3 +1,23 @@
+2011-09-16  Abhishek Arya  <inferno@chromium.org>
+
+        cachedFont not getting updated for inline SVG text.
+        https://bugs.webkit.org/show_bug.cgi?id=68060
+
+        Reviewed by Nikolas Zimmermann.
+
+        The cached scaledFont needs to be updated on every style set call. It
+        is not similar to m_style which can get derived from parent's style and
+        hence will get automatically updated on ancestor's style change. This is
+        required, otherwise we will maintain stale font list in cached scaledFont
+        when custom fonts are retired on Document::recalcStyle.
+
+        Test: svg/text/text-style-recalc-crash.html
+
+        * rendering/svg/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::styleDidChange):
+        (WebCore::RenderSVGInlineText::setStyle):
+        * rendering/svg/RenderSVGInlineText.h:
+
 2011-09-16  Antti Koivisto  <antti@apple.com>
 
         REGRESSION (r95052): SelectorChecker identifier filter not working
index 0d435cf..a09a895 100644 (file)
@@ -87,8 +87,6 @@ void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle
         // The text metrics may be influenced by style changes.
         if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
             textRenderer->setNeedsPositioningValuesUpdate();
-
-        updateScaledFont();
     }
 
     const RenderStyle* newStyle = style();
@@ -223,6 +221,19 @@ VisiblePosition RenderSVGInlineText::positionForPoint(const LayoutPoint& point)
     return createVisiblePosition(offset + closestDistanceBox->start(), offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
 }
 
+void RenderSVGInlineText::setStyle(PassRefPtr<RenderStyle> style)
+{
+    RenderText::setStyle(style);
+
+    // The cached scaledFont needs to be updated on every style set call. It
+    // is not similar to m_style which can get derived from parent's style and
+    // hence will get automatically updated on ancestor's style change. This is
+    // required, otherwise we will maintain stale font list in cached scaledFont
+    // when custom fonts are retired on Document::recalcStyle. See webkit bug
+    // https://bugs.webkit.org/show_bug.cgi?id=68060.
+    updateScaledFont();
+}
+
 void RenderSVGInlineText::updateScaledFont()
 {
     computeNewScaledFontForStyle(this, style(), m_scalingFactor, m_scaledFont);
index 8caa127..0d6568c 100644 (file)
@@ -49,6 +49,8 @@ private:
     virtual const char* renderName() const { return "RenderSVGInlineText"; }
 
     virtual void willBeDestroyed();
+    
+    virtual void setStyle(PassRefPtr<RenderStyle>);
     virtual void styleDidChange(StyleDifference, const RenderStyle*);
 
     // FIXME: We need objectBoundingBox for DRT results and filters at the moment.