Title: [128076] trunk
Revision
128076
Author
[email protected]
Date
2012-09-10 10:20:54 -0700 (Mon, 10 Sep 2012)

Log Message

Font value should be parsed as a individual property
https://bugs.webkit.org/show_bug.cgi?id=96271

Patch by Thiago Marcos P. Santos <[email protected]> on 2012-09-10
Reviewed by Eric Seidel.

Source/WebCore:

Parsing the font value as an individual CSS property instead of a style
body should make it significantly more effective and will not
validate something like ctx.font = "25px serif; background: green".

Updated canvas/philip/tests/2d.text.font.parse.invalid.html to cover
this use case.

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

LayoutTests:

Updated test to the latest W3C approved version. It adds a test
that verifies this fix.

* canvas/philip/tests/2d.text.font.parse.invalid.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128075 => 128076)


--- trunk/LayoutTests/ChangeLog	2012-09-10 17:15:41 UTC (rev 128075)
+++ trunk/LayoutTests/ChangeLog	2012-09-10 17:20:54 UTC (rev 128076)
@@ -1,3 +1,15 @@
+2012-09-10  Thiago Marcos P. Santos  <[email protected]>
+
+        Font value should be parsed as a individual property
+        https://bugs.webkit.org/show_bug.cgi?id=96271
+
+        Reviewed by Eric Seidel.
+
+        Updated test to the latest W3C approved version. It adds a test
+        that verifies this fix.
+
+        * canvas/philip/tests/2d.text.font.parse.invalid.html:
+
 2012-09-10  Silvia Pfeiffer  <[email protected]>
 
         [Chromium] Handle smaller sizes of media elements in media controls.

Modified: trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.invalid.html (128075 => 128076)


--- trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.invalid.html	2012-09-10 17:15:41 UTC (rev 128075)
+++ trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.invalid.html	2012-09-10 17:20:54 UTC (rev 128076)
@@ -39,6 +39,9 @@
 ctx.font = '10px inherit';
 _assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");
 
+ctx.font = '20px serif';
+ctx.font = '1em serif; background: green; margin: 10px';
+_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");
 
 });
 </script>

Modified: trunk/Source/WebCore/ChangeLog (128075 => 128076)


--- trunk/Source/WebCore/ChangeLog	2012-09-10 17:15:41 UTC (rev 128075)
+++ trunk/Source/WebCore/ChangeLog	2012-09-10 17:20:54 UTC (rev 128076)
@@ -1,3 +1,20 @@
+2012-09-10  Thiago Marcos P. Santos  <[email protected]>
+
+        Font value should be parsed as a individual property
+        https://bugs.webkit.org/show_bug.cgi?id=96271
+
+        Reviewed by Eric Seidel.
+
+        Parsing the font value as an individual CSS property instead of a style
+        body should make it significantly more effective and will not
+        validate something like ctx.font = "25px serif; background: green".
+
+        Updated canvas/philip/tests/2d.text.font.parse.invalid.html to cover
+        this use case.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setFont):
+
 2012-09-10  Silvia Pfeiffer  <[email protected]>
 
         [Chromium] Handle smaller sizes of media elements in media controls.

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (128075 => 128076)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-09-10 17:15:41 UTC (rev 128075)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-09-10 17:20:54 UTC (rev 128076)
@@ -2026,7 +2026,7 @@
 void CanvasRenderingContext2D::setFont(const String& newFont)
 {
     RefPtr<StylePropertySet> parsedStyle = StylePropertySet::create();
-    CSSParser(strictToCSSParserMode(!m_usesCSSCompatibilityParseMode)).parseDeclaration(parsedStyle.get(), "font:" + newFont, 0, 0);
+    CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, newFont, true, strictToCSSParserMode(!m_usesCSSCompatibilityParseMode), 0);
     if (parsedStyle->isEmpty())
         return;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to