Title: [158860] trunk
Revision
158860
Author
[email protected]
Date
2013-11-07 11:45:13 -0800 (Thu, 07 Nov 2013)

Log Message

Simple line layout crashes with SVG fonts
https://bugs.webkit.org/show_bug.cgi?id=124002

Source/WebCore: 

Reviewed by Simon Fraser.
        
Don't use simple line layout for flows using SVG fonts. They crash if kerning is enabled.

Test: fast/text/svg-font-simple-line-crash.html

* platform/graphics/Font.h:
(WebCore::Font::isSVGFont):
        
    Add isSVGFont() so callers don't need to go via primaryFont().

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::constructTextRun):
* rendering/RenderBlock.cpp:
(WebCore::constructTextRunInternal):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor):
        
    Disallow SVG fonts.

* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::constructTextRun):
* rendering/svg/SVGTextMetrics.cpp:
(WebCore::SVGTextMetrics::constructTextRun):
(WebCore::SVGTextMetrics::SVGTextMetrics):
* rendering/svg/SVGTextRunRenderingContext.h:
        
    Get rid of the abstract textRunNeedsRenderingContext in favor of just testing isSVGFont().

LayoutTests: 

Reviewed by Simon Fraser.

* fast/text/svg-font-simple-line-crash-expected.txt: Added.
* fast/text/svg-font-simple-line-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (158859 => 158860)


--- trunk/LayoutTests/ChangeLog	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/LayoutTests/ChangeLog	2013-11-07 19:45:13 UTC (rev 158860)
@@ -1,3 +1,13 @@
+2013-11-07  Antti Koivisto  <[email protected]>
+
+        Simple line layout crashes with SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=124002
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/svg-font-simple-line-crash-expected.txt: Added.
+        * fast/text/svg-font-simple-line-crash.html: Added.
+
 2013-11-07  Alexandru Chiculita  <[email protected]>
 
         Web Inspector: CSS Regions: Removing a content node of a ContentFlow from the DOM will send a 0 nodeId

Added: trunk/LayoutTests/fast/text/svg-font-simple-line-crash-expected.txt (0 => 158860)


--- trunk/LayoutTests/fast/text/svg-font-simple-line-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/svg-font-simple-line-crash-expected.txt	2013-11-07 19:45:13 UTC (rev 158860)
@@ -0,0 +1 @@
+This test passes if it does not crash.

Added: trunk/LayoutTests/fast/text/svg-font-simple-line-crash.html (0 => 158860)


--- trunk/LayoutTests/fast/text/svg-font-simple-line-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/svg-font-simple-line-crash.html	2013-11-07 19:45:13 UTC (rev 158860)
@@ -0,0 +1,21 @@
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+        setTimeout(function () { testRunner.notifyDone(); }, 50);
+    }
+</script>
+<style>
+    @font-face {
+        font-family: freesans;
+        src: url(../../svg/custom/resources/SVGFreeSans.svg) format("svg");
+    }
+
+    div {
+        font-family: freesans;
+        -webkit-font-kerning: normal;
+    }
+</style>
+<div id=test>
+    This test passes if it does not crash.
+</div>

Modified: trunk/Source/WebCore/ChangeLog (158859 => 158860)


--- trunk/Source/WebCore/ChangeLog	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/ChangeLog	2013-11-07 19:45:13 UTC (rev 158860)
@@ -1,3 +1,37 @@
+2013-11-07  Antti Koivisto  <[email protected]>
+
+        Simple line layout crashes with SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=124002
+
+        Reviewed by Simon Fraser.
+        
+        Don't use simple line layout for flows using SVG fonts. They crash if kerning is enabled.
+
+        Test: fast/text/svg-font-simple-line-crash.html
+
+        * platform/graphics/Font.h:
+        (WebCore::Font::isSVGFont):
+        
+            Add isSVGFont() so callers don't need to go via primaryFont().
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::constructTextRun):
+        * rendering/RenderBlock.cpp:
+        (WebCore::constructTextRunInternal):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseFor):
+        
+            Disallow SVG fonts.
+
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::constructTextRun):
+        * rendering/svg/SVGTextMetrics.cpp:
+        (WebCore::SVGTextMetrics::constructTextRun):
+        (WebCore::SVGTextMetrics::SVGTextMetrics):
+        * rendering/svg/SVGTextRunRenderingContext.h:
+        
+            Get rid of the abstract textRunNeedsRenderingContext in favor of just testing isSVGFont().
+
 2013-11-07  Simon Fraser  <[email protected]>
 
         Allow customization of the contentsScale of TileController tiles

Modified: trunk/Source/WebCore/platform/graphics/Font.h (158859 => 158860)


--- trunk/Source/WebCore/platform/graphics/Font.h	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/platform/graphics/Font.h	2013-11-07 19:45:13 UTC (rev 158860)
@@ -118,6 +118,7 @@
     void setLetterSpacing(short s) { m_letterSpacing = s; }
     bool isFixedPitch() const;
     bool isPrinterFont() const { return m_fontDescription.usePrinterFont(); }
+    bool isSVGFont() const { return primaryFont()->isSVGFont(); }
     
     FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
 

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (158859 => 158860)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-11-07 19:45:13 UTC (rev 158860)
@@ -1475,7 +1475,7 @@
 
     TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
     run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
-    if (textRunNeedsRenderingContext(font))
+    if (font.isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(renderer()));
 
     // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (158859 => 158860)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-07 19:45:13 UTC (rev 158860)
@@ -5291,7 +5291,7 @@
     bool directionalOverride = style.rtlOrdering() == VisualOrder;
 
     TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride);
-    if (textRunNeedsRenderingContext(font)) {
+    if (font.isSVGFont()) {
         ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything.
         run.setRenderingContext(SVGTextRunRenderingContext::create(*context));
     }
@@ -5311,7 +5311,7 @@
             directionalOverride |= isOverride(style.unicodeBidi());
     }
     TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride);
-    if (textRunNeedsRenderingContext(font)) {
+    if (font.isSVGFont()) {
         ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything.
         run.setRenderingContext(SVGTextRunRenderingContext::create(*context));
     }

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (158859 => 158860)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-11-07 19:45:13 UTC (rev 158860)
@@ -155,6 +155,8 @@
         return false;
     if (style.font().codePath(TextRun(textRenderer.text())) != Font::Simple)
         return false;
+    if (style.font().isSVGFont())
+        return false;
 
     // We assume that all lines have metrics based purely on the primary font.
     auto& primaryFontData = *style.font().primaryFont();

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (158859 => 158860)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2013-11-07 19:45:13 UTC (rev 158860)
@@ -407,7 +407,7 @@
                 , direction()
                 , dirOverride() || style->rtlOrdering() == VisualOrder /* directionalOverride */);
 
-    if (textRunNeedsRenderingContext(style->font()))
+    if (style->font().isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(renderer()));
 
     run.disableRoundingHacks();

Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp (158859 => 158860)


--- trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp	2013-11-07 19:45:13 UTC (rev 158860)
@@ -75,7 +75,7 @@
                 , style.direction()
                 , isOverride(style.unicodeBidi()) /* directionalOverride */);
 
-    if (textRunNeedsRenderingContext(style.font()))
+    if (style.font().isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(*text));
 
     run.disableRoundingHacks();
@@ -99,7 +99,7 @@
 {
     ASSERT(text);
 
-    bool needsContext = textRunNeedsRenderingContext(text->style().font());
+    bool needsContext = text->style().font().isSVGFont();
     float scalingFactor = text->scalingFactor();
     ASSERT(scalingFactor);
 

Modified: trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h (158859 => 158860)


--- trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h	2013-11-07 19:34:01 UTC (rev 158859)
+++ trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h	2013-11-07 19:45:13 UTC (rev 158860)
@@ -66,14 +66,6 @@
 #endif
 };
 
-inline bool textRunNeedsRenderingContext(const Font& font)
-{
-    // Only save the extra data if SVG Fonts are used, which depend on them.
-    // FIXME: SVG Fonts won't work as segmented fonts at the moment, if that's fixed, we need to check for them as well below.
-    ASSERT(font.primaryFont());
-    return font.primaryFont()->isSVGFont();
-}
-
 } // namespace WebCore
 
 #endif // SVGTextRunRenderingContext_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to