Title: [125575] trunk
Revision
125575
Author
[email protected]
Date
2012-08-14 10:16:19 -0700 (Tue, 14 Aug 2012)

Log Message

Fix  LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
https://bugs.webkit.org/show_bug.cgi?id=92974

Patch by Christophe Dumez <[email protected]> on 2012-08-14
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Replace space characters by U+0020 SPACE characters in
CanvasRenderingContext2D::drawTextInternal() in order to
comply with the HTML Canvas 2D Context specification:
- http://www.w3.org/TR/2dcontext/#drawing-text-to-the-canvas

No new tests, already tested by canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html.

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

LayoutTests:

Unskip canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html for
all the ports now that space characters are correctly replaced in
the text passed to fillText() and strokeText().

* platform/chromium/TestExpectations:
* platform/efl/Skipped:
* platform/gtk/TestExpectations:
* platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt: Removed.
* platform/qt/Skipped:

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125574 => 125575)


--- trunk/LayoutTests/ChangeLog	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/ChangeLog	2012-08-14 17:16:19 UTC (rev 125575)
@@ -1,3 +1,20 @@
+2012-08-14  Christophe Dumez  <[email protected]>
+
+        Fix  LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
+        https://bugs.webkit.org/show_bug.cgi?id=92974
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskip canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html for
+        all the ports now that space characters are correctly replaced in
+        the text passed to fillText() and strokeText().
+
+        * platform/chromium/TestExpectations:
+        * platform/efl/Skipped:
+        * platform/gtk/TestExpectations:
+        * platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt: Removed.
+        * platform/qt/Skipped:
+
 2012-08-14  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (125574 => 125575)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-08-14 17:16:19 UTC (rev 125575)
@@ -1888,12 +1888,10 @@
 BUGWK38463 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.baseline.top.html = TEXT
 
 BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
-BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
 BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
 BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
 BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.start.html = TEXT
 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
-BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
 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

Modified: trunk/LayoutTests/platform/efl/Skipped (125574 => 125575)


--- trunk/LayoutTests/platform/efl/Skipped	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-08-14 17:16:19 UTC (rev 125575)
@@ -321,7 +321,6 @@
 canvas/philip/tests/2d.text.draw.baseline.middle.html
 canvas/philip/tests/2d.text.draw.baseline.top.html
 canvas/philip/tests/2d.text.draw.space.collapse.end.html
-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

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (125574 => 125575)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2012-08-14 17:16:19 UTC (rev 125575)
@@ -902,7 +902,6 @@
 BUGWKGTK : canvas/philip/tests/2d.text.draw.baseline.middle.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.draw.baseline.top.html = TEXT
 BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
-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

Deleted: trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt (125574 => 125575)


--- trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt	2012-08-14 17:16:19 UTC (rev 125575)
@@ -1 +0,0 @@
-Failed assertion: got pixel [255,0,0,255] at (75,25), expected [0,255,0,255] +/- 2

Modified: trunk/LayoutTests/platform/qt/Skipped (125574 => 125575)


--- trunk/LayoutTests/platform/qt/Skipped	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-08-14 17:16:19 UTC (rev 125575)
@@ -2107,7 +2107,6 @@
 canvas/philip/tests/2d.text.draw.baseline.top.html
 canvas/philip/tests/2d.text.draw.fontface.notinpage.html
 canvas/philip/tests/2d.text.draw.space.collapse.end.html
-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

Modified: trunk/Source/WebCore/ChangeLog (125574 => 125575)


--- trunk/Source/WebCore/ChangeLog	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/Source/WebCore/ChangeLog	2012-08-14 17:16:19 UTC (rev 125575)
@@ -1,3 +1,22 @@
+2012-08-14  Christophe Dumez  <[email protected]>
+
+        Fix  LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
+        https://bugs.webkit.org/show_bug.cgi?id=92974
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Replace space characters by U+0020 SPACE characters in
+        CanvasRenderingContext2D::drawTextInternal() in order to
+        comply with the HTML Canvas 2D Context specification:
+        - http://www.w3.org/TR/2dcontext/#drawing-text-to-the-canvas
+
+        No new tests, already tested by canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::replaceCharacterInString):
+        (WebCore):
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+
 2012-08-14  George Staikos  <[email protected]>
 
         [BlackBerry] Avoid assertion failure in App Cache.

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (125574 => 125575)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-08-14 17:09:55 UTC (rev 125574)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-08-14 17:16:19 UTC (rev 125575)
@@ -2132,6 +2132,16 @@
     return metrics.release();
 }
 
+static void replaceCharacterInString(String& text, WTF::CharacterMatchFunctionPtr matchFunction, const String& replacement)
+{
+    const size_t replacementLength = replacement.length();
+    size_t index = 0;
+    while ((index = text.find(matchFunction, index)) != notFound) {
+        text.replace(index, 1, replacement);
+        index += replacementLength;
+    }
+}
+
 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth, bool useMaxWidth)
 {
     GraphicsContext* c = drawingContext();
@@ -2148,6 +2158,9 @@
 
     const Font& font = accessFont();
     const FontMetrics& fontMetrics = font.fontMetrics();
+    // According to spec, all the space characters must be replaced with U+0020 SPACE characters.
+    String normalizedText = text;
+    replaceCharacterInString(normalizedText, isSpaceOrNewline, " ");
 
     // FIXME: Need to turn off font smoothing.
 
@@ -2156,7 +2169,7 @@
     bool isRTL = direction == RTL;
     bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
 
-    TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
+    TextRun textRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
     // Draw the item text at the correct point.
     FloatPoint location(x, y);
     switch (state().m_textBaseline) {
@@ -2177,7 +2190,7 @@
         break;
     }
 
-    float fontWidth = font.width(TextRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
+    float fontWidth = font.width(TextRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
 
     useMaxWidth = (useMaxWidth && maxWidth < fontWidth);
     float width = useMaxWidth ? maxWidth : fontWidth;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to