Changeset 125575 in webkit


Ignore:
Timestamp:
Aug 14, 2012 10:16:19 AM (12 years ago)
Author:
commit-queue@webkit.org
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 <Christophe Dumez> 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:

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:
Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125572 r125575  
     12012-08-14  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        Fix  LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
     4        https://bugs.webkit.org/show_bug.cgi?id=92974
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Unskip canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html for
     9        all the ports now that space characters are correctly replaced in
     10        the text passed to fillText() and strokeText().
     11
     12        * platform/chromium/TestExpectations:
     13        * platform/efl/Skipped:
     14        * platform/gtk/TestExpectations:
     15        * platform/mac/canvas/philip/tests/2d.text.draw.space.collapse.nonspace-expected.txt: Removed.
     16        * platform/qt/Skipped:
     17
    1182012-08-14  Zan Dobersek  <zandobersek@gmail.com>
    219
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r125566 r125575  
    18891889
    18901890BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
    1891 BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
    18921891BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
    18931892BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
    18941893BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.start.html = TEXT
    18951894BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
    1896 BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
    18971895BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
    18981896BUGWK45991 : platform/chromium/virtual/gpu/canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
  • trunk/LayoutTests/platform/efl/Skipped

    r125450 r125575  
    322322canvas/philip/tests/2d.text.draw.baseline.top.html
    323323canvas/philip/tests/2d.text.draw.space.collapse.end.html
    324 canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
    325324canvas/philip/tests/2d.text.draw.space.collapse.other.html
    326325canvas/philip/tests/2d.text.draw.space.collapse.space.html
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r125572 r125575  
    903903BUGWKGTK : canvas/philip/tests/2d.text.draw.baseline.top.html = TEXT
    904904BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
    905 BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
    906905BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.other.html = TEXT
    907906BUGWKGTK : canvas/philip/tests/2d.text.draw.space.collapse.space.html = TEXT
  • trunk/LayoutTests/platform/qt/Skipped

    r125517 r125575  
    21082108canvas/philip/tests/2d.text.draw.fontface.notinpage.html
    21092109canvas/philip/tests/2d.text.draw.space.collapse.end.html
    2110 canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
    21112110canvas/philip/tests/2d.text.draw.space.collapse.other.html
    21122111canvas/philip/tests/2d.text.draw.space.collapse.space.html
  • trunk/Source/WebCore/ChangeLog

    r125570 r125575  
     12012-08-14  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        Fix  LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
     4        https://bugs.webkit.org/show_bug.cgi?id=92974
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Replace space characters by U+0020 SPACE characters in
     9        CanvasRenderingContext2D::drawTextInternal() in order to
     10        comply with the HTML Canvas 2D Context specification:
     11        - http://www.w3.org/TR/2dcontext/#drawing-text-to-the-canvas
     12
     13        No new tests, already tested by canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html.
     14
     15        * html/canvas/CanvasRenderingContext2D.cpp:
     16        (WebCore::replaceCharacterInString):
     17        (WebCore):
     18        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     19
    1202012-08-14  George Staikos  <staikos@webkit.org>
    221
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r125450 r125575  
    21332133}
    21342134
     2135static void replaceCharacterInString(String& text, WTF::CharacterMatchFunctionPtr matchFunction, const String& replacement)
     2136{
     2137    const size_t replacementLength = replacement.length();
     2138    size_t index = 0;
     2139    while ((index = text.find(matchFunction, index)) != notFound) {
     2140        text.replace(index, 1, replacement);
     2141        index += replacementLength;
     2142    }
     2143}
     2144
    21352145void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth, bool useMaxWidth)
    21362146{
     
    21492159    const Font& font = accessFont();
    21502160    const FontMetrics& fontMetrics = font.fontMetrics();
     2161    // According to spec, all the space characters must be replaced with U+0020 SPACE characters.
     2162    String normalizedText = text;
     2163    replaceCharacterInString(normalizedText, isSpaceOrNewline, " ");
    21512164
    21522165    // FIXME: Need to turn off font smoothing.
     
    21572170    bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
    21582171
    2159     TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
     2172    TextRun textRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
    21602173    // Draw the item text at the correct point.
    21612174    FloatPoint location(x, y);
     
    21782191    }
    21792192
    2180     float fontWidth = font.width(TextRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
     2193    float fontWidth = font.width(TextRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
    21812194
    21822195    useMaxWidth = (useMaxWidth && maxWidth < fontWidth);
Note: See TracChangeset for help on using the changeset viewer.