CanvasRenderContext2D::font() does not re-serialize the font
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2012 21:15:06 +0000 (21:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2012 21:15:06 +0000 (21:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=50859

Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-08-13
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Added proper serialization for the font property.

No new tests, unskipped the existing ones.

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

LayoutTests:

Unskip tests that will now pass and remove wrong/duplicated
expectations. canvas-font-ex-units-crash has now the wrong
expectations until we fix the issue on 93840.

* fast/canvas/canvas-font-ex-units-crash-expected.txt:
* fast/canvas/script-tests/canvas-font-ex-units-crash.js:
Even though we are setting a value on this test case (and verifying),
the font is not being effectiviely set as the serialization reveled. This
is going to be fixed in another bug.
* platform/chromium/TestExpectations:
* platform/chromium/canvas/philip/tests/2d.text.font.parse.system-expected.txt: Removed.
* platform/efl/Skipped:
* platform/gtk/TestExpectations:
* platform/mac/canvas/philip/tests/2d.text.font.parse.system-expected.txt: Removed.
* platform/qt/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/fast/canvas/canvas-font-ex-units-crash-expected.txt
LayoutTests/fast/canvas/script-tests/canvas-font-ex-units-crash.js
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.system-expected.txt [deleted file]
LayoutTests/platform/efl/Skipped
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.system-expected.txt [deleted file]
LayoutTests/platform/qt/Skipped
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

index 7b60034..016a541 100644 (file)
@@ -1,3 +1,26 @@
+2012-08-13  Thiago Marcos P. Santos  <thiago.santos@intel.com>
+
+        CanvasRenderContext2D::font() does not re-serialize the font
+        https://bugs.webkit.org/show_bug.cgi?id=50859
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskip tests that will now pass and remove wrong/duplicated
+        expectations. canvas-font-ex-units-crash has now the wrong
+        expectations until we fix the issue on 93840.
+
+        * fast/canvas/canvas-font-ex-units-crash-expected.txt:
+        * fast/canvas/script-tests/canvas-font-ex-units-crash.js:
+        Even though we are setting a value on this test case (and verifying),
+        the font is not being effectiviely set as the serialization reveled. This
+        is going to be fixed in another bug.
+        * platform/chromium/TestExpectations:
+        * platform/chromium/canvas/philip/tests/2d.text.font.parse.system-expected.txt: Removed.
+        * platform/efl/Skipped:
+        * platform/gtk/TestExpectations:
+        * platform/mac/canvas/philip/tests/2d.text.font.parse.system-expected.txt: Removed.
+        * platform/qt/Skipped:
+
 2012-08-13  Elliott Sprehn  <esprehn@chromium.org>
 
         CSS quotes output quotes when depth is negative
index 48309f4..83cce83 100644 (file)
@@ -3,7 +3,7 @@ Test that setting a font with size in 'ex' units doesn't crash.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS ctx.font = '5ex sans-serif'; ctx.font is '5ex sans-serif'
+PASS ctx.font = '0px sans-serif'; ctx.font is '0px sans-serif'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 1a3bf8b..110ce8d 100644 (file)
@@ -2,5 +2,6 @@ description("Test that setting a font with size in 'ex' units doesn't crash.");
 
 ctx = document.createElement('canvas').getContext('2d');
 
+// Relative units doesn't work when the canvas has no parent. See bug 93840.
 ctx.font = "5ex sans-serif";
-shouldBe("ctx.font = '5ex sans-serif'; ctx.font", "'5ex sans-serif'");
+shouldBe("ctx.font = '0px sans-serif'; ctx.font", "'0px sans-serif'");
index 007332c..62c6bf3 100644 (file)
@@ -1896,16 +1896,10 @@ BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.spac
 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.start.html = TEXT
 
-BUGWK50859 : canvas/philip/tests/2d.text.font.parse.basic.html = TEXT
-BUGWK50859 : canvas/philip/tests/2d.text.font.parse.complex.html = TEXT
 BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
 BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
-BUGWK50859 : canvas/philip/tests/2d.text.font.parse.system.html = TEXT
-BUGWK50859 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.font.parse.basic.html = TEXT
-BUGWK50859 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.font.parse.complex.html = TEXT
 BUGWK50859 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
 BUGWK50859 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
-BUGWK50859 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.font.parse.system.html = TEXT
 
 BUGWK45991 : canvas/philip/tests/2d.text.measure.width.space.html = TEXT
 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.measure.width.space.html = TEXT
diff --git a/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.system-expected.txt b/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.system-expected.txt
deleted file mode 100644 (file)
index 863339f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Passed
index 3d1b5f8..1cc0c38 100644 (file)
@@ -325,11 +325,8 @@ canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
 canvas/philip/tests/2d.text.draw.space.collapse.other.html
 canvas/philip/tests/2d.text.draw.space.collapse.space.html
 canvas/philip/tests/2d.text.draw.space.collapse.start.html
-canvas/philip/tests/2d.text.font.parse.basic.html
-canvas/philip/tests/2d.text.font.parse.complex.html
 canvas/philip/tests/2d.text.font.parse.size.percentage.html
 canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
-canvas/philip/tests/2d.text.font.parse.system.html
 canvas/philip/tests/2d.text.measure.width.space.html
 canvas/philip/tests/type.prototype.html
 
index 25b7eae..5e1b5d0 100644 (file)
@@ -907,11 +907,8 @@ BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.start.html = TEXT
-BUGWKGTK : canvas/philip/tests/2d.text.font.parse.basic.html = TEXT
-BUGWKGTK : canvas/philip/tests/2d.text.font.parse.complex.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
-BUGWKGTK : canvas/philip/tests/2d.text.font.parse.system.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.measure.width.space.html = TEXT
 BUGWKGTK : canvas/philip/tests/type.prototype.html = TEXT
 
diff --git a/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.system-expected.txt b/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.system-expected.txt
deleted file mode 100644 (file)
index 3ea652b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Failed assertion ctx.font !== 'message-box' (got message-box[string], expected not message-box[string])
index 640a5af..0ce1451 100644 (file)
@@ -2111,11 +2111,8 @@ canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
 canvas/philip/tests/2d.text.draw.space.collapse.other.html
 canvas/philip/tests/2d.text.draw.space.collapse.space.html
 canvas/philip/tests/2d.text.draw.space.collapse.start.html
-canvas/philip/tests/2d.text.font.parse.basic.html
-canvas/philip/tests/2d.text.font.parse.complex.html
 canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
 canvas/philip/tests/2d.text.font.parse.size.percentage.html
-canvas/philip/tests/2d.text.font.parse.system.html
 canvas/philip/tests/2d.text.measure.width.space.html
 canvas/philip/tests/2d.transformation.setTransform.skewed.html
 canvas/philip/tests/2d.transformation.transform.skewed.html
index e97ea26..e64057a 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-13  Thiago Marcos P. Santos  <thiago.santos@intel.com>
+
+        CanvasRenderContext2D::font() does not re-serialize the font
+        https://bugs.webkit.org/show_bug.cgi?id=50859
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added proper serialization for the font property.
+
+        No new tests, unskipped the existing ones.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::font):
+
 2012-08-13  Elliott Sprehn  <esprehn@chromium.org>
 
         CSS quotes output quotes when depth is negative
index 722c9c5..a073802 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
  * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
  * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1986,7 +1987,34 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, ImageBuffer::Coordi
 
 String CanvasRenderingContext2D::font() const
 {
-    return state().m_unparsedFont;
+    if (!state().m_realizedFont)
+        return defaultFont;
+
+    String serializedFont;
+    const FontDescription& fontDescription = state().m_font.fontDescription();
+
+    if (fontDescription.italic())
+        serializedFont += "italic ";
+    if (fontDescription.smallCaps() == FontSmallCapsOn)
+        serializedFont += "small-caps ";
+
+    serializedFont += String::number(fontDescription.computedPixelSize()) + "px";
+
+    const FontFamily& firstFontFamily = fontDescription.family();
+    for (const FontFamily* fontFamily = &firstFontFamily; fontFamily; fontFamily = fontFamily->next()) {
+        if (fontFamily != &firstFontFamily)
+            serializedFont += ",";
+
+        String family = fontFamily->family();
+        if (family.startsWith("-webkit-"))
+            family = family.substring(8);
+        if (family.contains(' '))
+            family = makeString('"', family, '"');
+
+        serializedFont += " " + family;
+    }
+
+    return serializedFont;
 }
 
 void CanvasRenderingContext2D::setFont(const String& newFont)