Title: [125663] trunk
Revision
125663
Author
[email protected]
Date
2012-08-15 03:27:18 -0700 (Wed, 15 Aug 2012)

Log Message

Relative units are not set when the canvas has not parent
https://bugs.webkit.org/show_bug.cgi?id=93840

Patch by Thiago Marcos P. Santos <[email protected]> on 2012-08-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Set the default font when no parent style is set. It will make
possible to apply relative units when a parent is not set.

No new tests, unskipped the existing ones.

* css/StyleBuilder.cpp:
(WebCore::ApplyPropertyFontSize::applyValue):
Make it possible to apply relative units if a parent style exist but
not a parent node. It works like this for em and ex, but not for
percent units.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore):
(WebCore::CanvasRenderingContext2D::setFont):

LayoutTests:

Unskipped tests that will now pass, removed wrong expectations
and updated test case which was fixed by the W3C.

* canvas/philip/tests/2d.text.font.parse.size.percentage.default.html:
This test case was fixed on W3C upstream:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=18522
* fast/canvas/canvas-font-ex-units-crash-expected.txt:
* fast/canvas/script-tests/canvas-font-ex-units-crash.js:
* platform/chromium/TestExpectations:
* platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt: Removed.
* platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt: Removed.
* platform/efl/Skipped:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt: Removed.
* platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt: Removed.
* platform/qt/Skipped:

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125662 => 125663)


--- trunk/LayoutTests/ChangeLog	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/ChangeLog	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1,3 +1,28 @@
+2012-08-15  Thiago Marcos P. Santos  <[email protected]>
+
+        Relative units are not set when the canvas has not parent
+        https://bugs.webkit.org/show_bug.cgi?id=93840
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskipped tests that will now pass, removed wrong expectations
+        and updated test case which was fixed by the W3C.
+
+        * canvas/philip/tests/2d.text.font.parse.size.percentage.default.html:
+        This test case was fixed on W3C upstream:
+        https://www.w3.org/Bugs/Public/show_bug.cgi?id=18522
+        * fast/canvas/canvas-font-ex-units-crash-expected.txt:
+        * fast/canvas/script-tests/canvas-font-ex-units-crash.js:
+        * platform/chromium/TestExpectations:
+        * platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt: Removed.
+        * platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt: Removed.
+        * platform/efl/Skipped:
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt: Removed.
+        * platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt: Removed.
+        * platform/qt/Skipped:
+
 2012-08-15  Zoltan Arvai  <[email protected]>
 
         [Qt] Unreviewd gardening. Readd removed expectations in r125658 with some modification.

Modified: trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.size.percentage.default.html (125662 => 125663)


--- trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.size.percentage.default.html	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/canvas/philip/tests/2d.text.font.parse.size.percentage.default.html	2012-08-15 10:27:18 UTC (rev 125663)
@@ -14,8 +14,8 @@
 
 var canvas2 = document.createElement('canvas');
 var ctx2 = canvas2.getContext('2d');
-ctx.font = '1000% serif';
-_assertSame(ctx.font, '100px serif', "ctx.font", "'100px serif'");
+ctx2.font = '1000% serif';
+_assertSame(ctx2.font, '100px serif', "ctx2.font", "'100px serif'");
 
 
 });

Modified: trunk/LayoutTests/fast/canvas/canvas-font-ex-units-crash-expected.txt (125662 => 125663)


--- trunk/LayoutTests/fast/canvas/canvas-font-ex-units-crash-expected.txt	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/fast/canvas/canvas-font-ex-units-crash-expected.txt	2012-08-15 10:27:18 UTC (rev 125663)
@@ -3,7 +3,8 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS ctx.font = '0px sans-serif'; ctx.font is '0px sans-serif'
+PASS size is within 10 of 25
+PASS family is 'sans-serif'
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/canvas/script-tests/canvas-font-ex-units-crash.js (125662 => 125663)


--- trunk/LayoutTests/fast/canvas/script-tests/canvas-font-ex-units-crash.js	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-font-ex-units-crash.js	2012-08-15 10:27:18 UTC (rev 125663)
@@ -2,6 +2,10 @@
 
 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 = '0px sans-serif'; ctx.font", "'0px sans-serif'");
+
+size = parseInt(ctx.font.substr(0, 2));
+family = ctx.font.substr(5);
+
+shouldBeCloseTo("size", 25, 10);
+shouldBe("family", "'sans-serif'");

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (125662 => 125663)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1904,11 +1904,6 @@
 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.size.percentage.default.html = TEXT
-BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.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
-
 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
 

Deleted: trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt (125662 => 125663)


--- trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1 +0,0 @@
-Passed

Deleted: trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt (125662 => 125663)


--- trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/chromium/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1 +0,0 @@
-Passed

Modified: trunk/LayoutTests/platform/efl/Skipped (125662 => 125663)


--- trunk/LayoutTests/platform/efl/Skipped	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-08-15 10:27:18 UTC (rev 125663)
@@ -320,8 +320,6 @@
 canvas/philip/tests/2d.text.draw.baseline.ideographic.html
 canvas/philip/tests/2d.text.draw.baseline.middle.html
 canvas/philip/tests/2d.text.draw.baseline.top.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/type.prototype.html
 
 # Test takes too long in a debug build

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (125662 => 125663)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2012-08-15 10:27:18 UTC (rev 125663)
@@ -910,8 +910,6 @@
 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.size.percentage.html = TEXT
-BUGWKGTK : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.measure.width.space.html = TEXT
 BUGWKGTK : canvas/philip/tests/type.prototype.html = TEXT
 

Modified: trunk/LayoutTests/platform/mac/TestExpectations (125662 => 125663)


--- trunk/LayoutTests/platform/mac/TestExpectations	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2012-08-15 10:27:18 UTC (rev 125663)
@@ -379,10 +379,6 @@
 // (r125185) http/tests/images/jpg-img-partial-load.html timeout on Lion
 BUGWK93636 : http/tests/images/jpg-img-partial-load.html = TEXT
 
-// Relative units are not set when the canvas has no parent
-BUGWK93840 : canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
-BUGWK93840 : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
-
 // Require rebaselining after  https://bugs.webkit.org/show_bug.cgi?id=89826
 BUGWK89826 : fast/css/word-space-extra.html = TEXT
 

Deleted: trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt (125662 => 125663)


--- trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage-expected.txt	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1,2 +0,0 @@
-Failed assertion ctx.font === '72px serif' (got 50% serif[string], expected 72px serif[string])
-Failed assertion ctx.font === '72px serif' (got 50% serif[string], expected 72px serif[string])

Deleted: trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt (125662 => 125663)


--- trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.font.parse.size.percentage.default-expected.txt	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1 +0,0 @@
-Failed assertion ctx.font === '100px serif' (got 1000% serif[string], expected 100px serif[string])

Modified: trunk/LayoutTests/platform/qt/Skipped (125662 => 125663)


--- trunk/LayoutTests/platform/qt/Skipped	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-08-15 10:27:18 UTC (rev 125663)
@@ -2110,8 +2110,6 @@
 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.size.percentage.default.html
-canvas/philip/tests/2d.text.font.parse.size.percentage.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

Modified: trunk/Source/WebCore/ChangeLog (125662 => 125663)


--- trunk/Source/WebCore/ChangeLog	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/Source/WebCore/ChangeLog	2012-08-15 10:27:18 UTC (rev 125663)
@@ -1,3 +1,24 @@
+2012-08-15  Thiago Marcos P. Santos  <[email protected]>
+
+        Relative units are not set when the canvas has not parent
+        https://bugs.webkit.org/show_bug.cgi?id=93840
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Set the default font when no parent style is set. It will make
+        possible to apply relative units when a parent is not set.
+
+        No new tests, unskipped the existing ones.
+
+        * css/StyleBuilder.cpp:
+        (WebCore::ApplyPropertyFontSize::applyValue):
+        Make it possible to apply relative units if a parent style exist but
+        not a parent node. It works like this for em and ex, but not for
+        percent units.
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore):
+        (WebCore::CanvasRenderingContext2D::setFont):
+
 2012-08-14  Pavel Feldman  <[email protected]>
 
         Web Inspector: split standalone test runner, test scanner and test stub.

Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (125662 => 125663)


--- trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-15 10:27:18 UTC (rev 125663)
@@ -719,7 +719,7 @@
         bool parentIsAbsoluteSize = false;
         float size = 0;
 
-        if (styleResolver->hasParentNode()) {
+        if (styleResolver->parentStyle()) {
             parentSize = styleResolver->parentStyle()->fontDescription().specifiedSize();
             parentIsAbsoluteSize = styleResolver->parentStyle()->fontDescription().isAbsoluteSize();
         }

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (125662 => 125663)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-08-15 10:15:57 UTC (rev 125662)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-08-15 10:27:18 UTC (rev 125663)
@@ -83,6 +83,8 @@
 
 using namespace HTMLNames;
 
+static const int defaultFontSize = 10;
+static const char* const defaultFontFamily = "sans-serif";
 static const char* const defaultFont = "10px sans-serif";
 
 static bool isOriginClean(CachedImage* cachedImage, SecurityOrigin* securityOrigin)
@@ -2037,6 +2039,18 @@
     RefPtr<RenderStyle> newStyle = RenderStyle::create();
     if (RenderStyle* computedStyle = canvas()->computedStyle())
         newStyle->setFontDescription(computedStyle->fontDescription());
+    else {
+        FontFamily fontFamily;
+        fontFamily.setFamily(defaultFontFamily);
+
+        FontDescription defaultFontDescription;
+        defaultFontDescription.setFamily(fontFamily);
+        defaultFontDescription.setSpecifiedSize(defaultFontSize);
+        defaultFontDescription.setComputedSize(defaultFontSize);
+
+        newStyle->setFontDescription(defaultFontDescription);
+    }
+
     newStyle->font().update(newStyle->font().fontSelector());
 
     // Now map the font property longhands into the style.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to