Changeset 100285 in webkit


Ignore:
Timestamp:
Nov 15, 2011 8:32:02 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Implement maxWidth for fillText and strokeText, fixing the canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html test.
https://bugs.webkit.org/show_bug.cgi?id=61528

Patch by Philip Rogers <pdr@google.com> on 2011-11-15
Reviewed by Stephen White.

Source/WebCore:

Tests: fast/canvas/2d.text.draw.fill.maxWidth.gradient.html

fast/canvas/2d.text.draw.fill.maxWidth.negative.html
fast/canvas/2d.text.draw.fill.maxWidth.veryLarge.html
fast/canvas/2d.text.draw.fill.maxWidth.verySmall.html

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawTextInternal):

LayoutTests:

  • fast/canvas/2d.text.draw.fill.maxWidth.gradient-expected.txt: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.gradient.html: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.negative-expected.txt: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.negative.html: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.veryLarge-expected.txt: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.veryLarge.html: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.verySmall-expected.txt: Added.
  • fast/canvas/2d.text.draw.fill.maxWidth.verySmall.html: Added.
  • platform/chromium/canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface-expected.txt: Removed.
  • platform/chromium/test_expectations.txt:
  • platform/gtk/Skipped:
  • platform/mac-leopard/Skipped:
  • platform/mac/canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface-expected.txt:
  • platform/qt/Skipped:
  • resources/Ahem.ttf: Added.
Location:
trunk
Files:
9 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r100283 r100285  
     12011-11-15  Philip Rogers  <pdr@google.com>
     2
     3        Implement maxWidth for fillText and strokeText, fixing the canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html test.
     4        https://bugs.webkit.org/show_bug.cgi?id=61528
     5
     6        Reviewed by Stephen White.
     7
     8        * fast/canvas/2d.text.draw.fill.maxWidth.gradient-expected.txt: Added.
     9        * fast/canvas/2d.text.draw.fill.maxWidth.gradient.html: Added.
     10        * fast/canvas/2d.text.draw.fill.maxWidth.negative-expected.txt: Added.
     11        * fast/canvas/2d.text.draw.fill.maxWidth.negative.html: Added.
     12        * fast/canvas/2d.text.draw.fill.maxWidth.veryLarge-expected.txt: Added.
     13        * fast/canvas/2d.text.draw.fill.maxWidth.veryLarge.html: Added.
     14        * fast/canvas/2d.text.draw.fill.maxWidth.verySmall-expected.txt: Added.
     15        * fast/canvas/2d.text.draw.fill.maxWidth.verySmall.html: Added.
     16        * platform/chromium/canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface-expected.txt: Removed.
     17        * platform/chromium/test_expectations.txt:
     18        * platform/gtk/Skipped:
     19        * platform/mac-leopard/Skipped:
     20        * platform/mac/canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface-expected.txt:
     21        * platform/qt/Skipped:
     22        * resources/Ahem.ttf: Added.
     23
    1242011-11-15  Cary Clark  <caryclark@google.com>
    225
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r100283 r100285  
    20132013BUGWK45991 : canvas/philip/tests/2d.text.draw.baseline.middle.html = TEXT
    20142014BUGWK38463 : canvas/philip/tests/2d.text.draw.baseline.top.html = TEXT
    2015 BUGWK20867 : canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html = TEXT
    20162015BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.end.html = TEXT
    20172016BUGWK45991 : canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html = TEXT
  • trunk/LayoutTests/platform/gtk/Skipped

    r100272 r100285  
    10371037canvas/philip/tests/2d.text.draw.baseline.middle.html
    10381038canvas/philip/tests/2d.text.draw.baseline.top.html
    1039 canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html
    10401039canvas/philip/tests/2d.text.draw.space.collapse.end.html
    10411040canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
  • trunk/LayoutTests/platform/mac-leopard/Skipped

    r97407 r100285  
    167167canvas/philip/tests/2d.text.draw.baseline.middle.html
    168168canvas/philip/tests/2d.text.draw.baseline.top.html
    169 canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html
    170169canvas/philip/tests/2d.text.draw.space.collapse.end.html
    171170canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
  • trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface-expected.txt

    r77719 r100285  
    1 Failed assertion: got pixel [255,0,0,255] at (5,5), expected [0,255,0,255] +/- 2
    2 Failed assertion: got pixel [255,0,0,255] at (95,5), expected [0,255,0,255] +/- 2
    3 Failed assertion: got pixel [255,0,0,255] at (25,25), expected [0,255,0,255] +/- 2
    4 Failed assertion: got pixel [255,0,0,255] at (75,25), expected [0,255,0,255] +/- 2
     1Passed
  • trunk/LayoutTests/platform/qt/Skipped

    r100281 r100285  
    15531553canvas/philip/tests/2d.text.draw.baseline.middle.html
    15541554canvas/philip/tests/2d.text.draw.baseline.top.html
    1555 canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html
    15561555canvas/philip/tests/2d.text.draw.fontface.notinpage.html
    15571556canvas/philip/tests/2d.text.draw.space.collapse.end.html
  • trunk/Source/WebCore/ChangeLog

    r100284 r100285  
     12011-11-15  Philip Rogers  <pdr@google.com>
     2
     3        Implement maxWidth for fillText and strokeText, fixing the canvas/philip/tests/2d.text.draw.fill.maxWidth.fontface.html test.
     4        https://bugs.webkit.org/show_bug.cgi?id=61528
     5
     6        Reviewed by Stephen White.
     7
     8        Tests: fast/canvas/2d.text.draw.fill.maxWidth.gradient.html
     9               fast/canvas/2d.text.draw.fill.maxWidth.negative.html
     10               fast/canvas/2d.text.draw.fill.maxWidth.veryLarge.html
     11               fast/canvas/2d.text.draw.fill.maxWidth.verySmall.html
     12
     13        * html/canvas/CanvasRenderingContext2D.cpp:
     14        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     15
    1162011-11-15  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r100273 r100285  
    20752075}
    20762076
    2077 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float /*maxWidth*/, bool /*useMaxWidth*/)
     2077void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth, bool useMaxWidth)
    20782078{
    20792079    GraphicsContext* c = drawingContext();
     
    20832083        return;
    20842084    if (!isfinite(x) | !isfinite(y))
     2085        return;
     2086    if (useMaxWidth && !isfinite(maxWidth))
    20852087        return;
    20862088
     
    20902092    const FontMetrics& fontMetrics = font.fontMetrics();
    20912093
    2092     // FIXME: Handle maxWidth.
    20932094    // FIXME: Need to turn off font smoothing.
    20942095
     
    21222123    }
    21232124
    2124     float width = font.width(TextRun(text, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
     2125    float fontWidth = font.width(TextRun(text, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
     2126
     2127    useMaxWidth = (useMaxWidth && maxWidth < fontWidth);
     2128    float width = useMaxWidth ? maxWidth : fontWidth;
    21252129
    21262130    TextAlign align = state().m_textAlign;
     
    21692173
    21702174        maskImageContext->setTextDrawingMode(fill ? TextModeFill : TextModeStroke);
    2171         maskImageContext->translate(-maskRect.x(), -maskRect.y());
    2172 
    2173         maskImageContext->drawBidiText(font, textRun, location);
     2175
     2176        if (useMaxWidth) {
     2177            maskImageContext->translate(location.x() - maskRect.x(), location.y() - maskRect.y());
     2178            // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) still work.
     2179            maskImageContext->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1));
     2180            maskImageContext->drawBidiText(font, textRun, FloatPoint(0, 0));
     2181        } else {
     2182            maskImageContext->translate(-maskRect.x(), -maskRect.y());
     2183            maskImageContext->drawBidiText(font, textRun, location);
     2184        }
    21742185
    21752186        GraphicsContextStateSaver stateSaver(*c);
     
    21892200#endif
    21902201
    2191     c->drawBidiText(font, textRun, location);
     2202    if (useMaxWidth) {
     2203        GraphicsContextStateSaver stateSaver(*c);
     2204        c->translate(location.x(), location.y());
     2205        // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) still work.
     2206        c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1));
     2207        c->drawBidiText(font, textRun, FloatPoint(0, 0));
     2208        stateSaver.restore();
     2209    } else
     2210        c->drawBidiText(font, textRun, location);
    21922211
    21932212    if (fill)
Note: See TracChangeset for help on using the changeset viewer.