Title: [198372] trunk
Revision
198372
Author
[email protected]
Date
2016-03-17 18:26:39 -0700 (Thu, 17 Mar 2016)

Log Message

Don't initiate a style recall while drawing text 
https://bugs.webkit.org/show_bug.cgi?id=155618

Patch by Zalan Bujtas <[email protected]> on 2016-03-17
Reviewed by Simon Fraser.

This patch ensures that we don't initiate a style recalc while in the middle of text drawing.

Source/WebCore:

Test: fast/canvas/crash-while-resizing-canvas.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal):

LayoutTests:

* fast/canvas/crash-while-resizing-canvas-expected.txt: Added.
* fast/canvas/crash-while-resizing-canvas.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198371 => 198372)


--- trunk/LayoutTests/ChangeLog	2016-03-18 01:13:43 UTC (rev 198371)
+++ trunk/LayoutTests/ChangeLog	2016-03-18 01:26:39 UTC (rev 198372)
@@ -1,3 +1,15 @@
+2016-03-17  Zalan Bujtas  <[email protected]>
+
+        Don't initiate a style recall while drawing text 
+        https://bugs.webkit.org/show_bug.cgi?id=155618
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that we don't initiate a style recalc while in the middle of text drawing.
+
+        * fast/canvas/crash-while-resizing-canvas-expected.txt: Added.
+        * fast/canvas/crash-while-resizing-canvas.html: Added.
+
 2016-03-17  Myles C. Maxfield  <[email protected]>
 
         [RTL Scrollbars] Position: absolute divs are covered by vertical scrollbar

Added: trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas-expected.txt (0 => 198372)


--- trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas-expected.txt	2016-03-18 01:26:39 UTC (rev 198372)
@@ -0,0 +1 @@
+Pass if no crash or assert.   

Added: trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas.html (0 => 198372)


--- trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/crash-while-resizing-canvas.html	2016-03-18 01:26:39 UTC (rev 198372)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that changing the canvas size while executing fillText does not crash.</title>
+</head>
+<body>
+Pass if no crash or assert.
+<canvas id=ca></canvas>
+<textarea autofocus='below' _onfocusin_ = 'changeCanvasWidth()'></textarea>
+<script>
+function changeCanvasWidth() {
+    for (var i = 0; i < 1000; ++i) {
+      c3 = document.getElementById("ca");
+      c3.width = i;
+    }
+}
+
+function fillText() {
+    c2 = document.getElementById("ca").getContext("2d");
+    c2.fillText("foobar", 100, 34);
+}
+
+document.write("<iframe _onbeforeload_='fillText()'></iframe>");
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (198371 => 198372)


--- trunk/Source/WebCore/ChangeLog	2016-03-18 01:13:43 UTC (rev 198371)
+++ trunk/Source/WebCore/ChangeLog	2016-03-18 01:26:39 UTC (rev 198372)
@@ -1,3 +1,17 @@
+2016-03-17  Zalan Bujtas  <[email protected]>
+
+        Don't initiate a style recall while drawing text 
+        https://bugs.webkit.org/show_bug.cgi?id=155618
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that we don't initiate a style recalc while in the middle of text drawing.
+
+        Test: fast/canvas/crash-while-resizing-canvas.html
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+
 2016-03-17  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r198335.

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (198371 => 198372)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-03-18 01:13:43 UTC (rev 198371)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-03-18 01:26:39 UTC (rev 198372)
@@ -2421,6 +2421,9 @@
 
 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth, bool useMaxWidth)
 {
+    const auto& fontProxy = this->fontProxy();
+    const FontMetrics& fontMetrics = fontProxy.fontMetrics();
+
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
@@ -2440,16 +2443,12 @@
     if (fill && gradient && gradient->isZeroSize())
         return;
 
-    const auto& fontProxy = this->fontProxy();
-    const FontMetrics& fontMetrics = fontProxy.fontMetrics();
-
     String normalizedText = text;
     normalizeSpaces(normalizedText);
 
     // FIXME: Need to turn off font smoothing.
 
     RenderStyle* computedStyle;
-    canvas()->document().updateStyleIfNeeded();
     TextDirection direction = toTextDirection(state().direction, &computedStyle);
     bool isRTL = direction == RTL;
     bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to