| Differences between
and this patch
- Source/WebCore/ChangeLog +14 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2011-06-01  Philip Rogers  <pdr@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add simplifyHTMLWhiteSpace method to collapse whitespace per the HTML spec, and call it in CanvasRenderingContext2D::measureText(). This makes us pass 2d.text.measure.width.space.html, see: https://bugs.webkit.org/show_bug.cgi?id=61799.
6
7
        No new tests. (OOPS!)
8
9
        * html/canvas/CanvasRenderingContext2D.cpp:
10
        (WebCore::CanvasRenderingContext2D::measureText):
11
        * html/parser/HTMLParserIdioms.cpp:
12
        (WebCore::simplifyHTMLWhiteSpace):
13
        * html/parser/HTMLParserIdioms.h:
14
1
2011-06-01  Sheriff Bot  <webkit.review.bot@gmail.com>
15
2011-06-01  Sheriff Bot  <webkit.review.bot@gmail.com>
2
16
3
        Unreviewed, rolling out r87788.
17
        Unreviewed, rolling out r87788.
- Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp -1 / +5 lines
Lines 48-53 Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp_sec1
48
#include "HTMLImageElement.h"
48
#include "HTMLImageElement.h"
49
#include "HTMLMediaElement.h"
49
#include "HTMLMediaElement.h"
50
#include "HTMLNames.h"
50
#include "HTMLNames.h"
51
#include "HTMLParserIdioms.h"
51
#include "HTMLVideoElement.h"
52
#include "HTMLVideoElement.h"
52
#include "ImageBuffer.h"
53
#include "ImageBuffer.h"
53
#include "ImageData.h"
54
#include "ImageData.h"
Lines 1874-1879 void CanvasRenderingContext2D::strokeTex Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp_sec2
1874
1875
1875
PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
1876
PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
1876
{
1877
{
1878
    // Need to trim and collapse whitespace.
1879
    const String& str = simplifyHTMLWhiteSpace(text);
1880
1877
    RefPtr<TextMetrics> metrics = TextMetrics::create();
1881
    RefPtr<TextMetrics> metrics = TextMetrics::create();
1878
1882
1879
#if PLATFORM(QT)
1883
#if PLATFORM(QT)
Lines 1882-1888 PassRefPtr<TextMetrics> CanvasRenderingC Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp_sec3
1882
    Font::setCodePath(Font::Complex);
1886
    Font::setCodePath(Font::Complex);
1883
#endif
1887
#endif
1884
1888
1885
    metrics->setWidth(accessFont().width(TextRun(text.characters(), text.length())));
1889
    metrics->setWidth(accessFont().width(TextRun(str.characters(), str.length())));
1886
1890
1887
#if PLATFORM(QT)
1891
#if PLATFORM(QT)
1888
    Font::setCodePath(oldCodePath);
1892
    Font::setCodePath(oldCodePath);
- Source/WebCore/html/parser/HTMLParserIdioms.cpp +37 lines
Lines 29-34 Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec1
29
#include <wtf/MathExtras.h>
29
#include <wtf/MathExtras.h>
30
#include <wtf/dtoa.h>
30
#include <wtf/dtoa.h>
31
#include <wtf/text/AtomicString.h>
31
#include <wtf/text/AtomicString.h>
32
#include <wtf/text/StringBuffer.h>
32
33
33
namespace WebCore {
34
namespace WebCore {
34
35
Lines 57-62 String stripLeadingAndTrailingHTMLSpaces Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec2
57
    return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTrailingSpaces));
58
    return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTrailingSpaces));
58
}
59
}
59
60
61
String simplifyHTMLWhiteSpace(const String& string)
62
{
63
    unsigned length = string.length();
64
    const UChar* from = string.characters();
65
    const UChar* fromend = from + length;
66
    int outc = 0;
67
    bool changedToSpace = false;
68
69
    StringBuffer data(length);
70
    UChar* to = data.characters();
71
72
    while (true) {
73
        while (from != fromend && isHTMLSpace(*from)) {
74
            if (*from != ' ')
75
                changedToSpace = true;
76
            from++;
77
        }
78
        while (from != fromend && !isHTMLSpace(*from))
79
            to[outc++] = *from++;
80
        if (from != fromend)
81
            to[outc++] = ' ';
82
        else
83
            break;
84
    }
85
86
    if (outc > 0 && to[outc - 1] == ' ')
87
        outc--;
88
89
    if (static_cast<unsigned>(outc) == length && !changedToSpace)
90
        return string;
91
92
    data.shrink(outc);
93
94
    return String::adopt(data);
95
}
96
60
String serializeForNumberType(double number)
97
String serializeForNumberType(double number)
61
{
98
{
62
    // According to HTML5, "the best representation of the number n as a floating
99
    // According to HTML5, "the best representation of the number n as a floating
- Source/WebCore/html/parser/HTMLParserIdioms.h +3 lines
Lines 37-42 bool isNotHTMLSpace(UChar); Source/WebCore/html/parser/HTMLParserIdioms.h_sec1
37
// Strip leading and trailing whitespace as defined by the HTML specification. 
37
// Strip leading and trailing whitespace as defined by the HTML specification. 
38
String stripLeadingAndTrailingHTMLSpaces(const String&);
38
String stripLeadingAndTrailingHTMLSpaces(const String&);
39
39
40
// Trim leading and trailing HTMLSpace and collapse internal HTML spaces.
41
String simplifyHTMLWhiteSpace(const String&);
42
40
// An implementation of the HTML specification's algorithm to convert a number to a string for number and range types.
43
// An implementation of the HTML specification's algorithm to convert a number to a string for number and range types.
41
String serializeForNumberType(double);
44
String serializeForNumberType(double);
42
45
- LayoutTests/ChangeLog +12 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2011-06-01  Philip Rogers  <pdr@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Update tests and skip lists to reflect passing test for https://bugs.webkit.org/show_bug.cgi?id=61799
6
7
        * platform/chromium/test_expectations.txt:
8
        * platform/gtk/Skipped:
9
        * platform/mac-leopard/Skipped:
10
        * platform/mac/canvas/philip/tests/2d.text.measure.width.space-expected.txt:
11
        * platform/qt/Skipped:
12
1
2011-06-01  Gabor Loki  <loki@webkit.org>
13
2011-06-01  Gabor Loki  <loki@webkit.org>
2
14
3
        Rubber-stamped by Csaba Osztrogonác.
15
        Rubber-stamped by Csaba Osztrogonác.
- LayoutTests/platform/chromium/test_expectations.txt -1 lines
Lines 2030-2036 BUGWK50859 : canvas/philip/tests/2d.text LayoutTests/platform/chromium/test_expectations.txt_sec1
2030
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
2030
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.default.html = TEXT
2031
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
2031
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.size.percentage.html = TEXT
2032
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.system.html = TEXT
2032
BUGWK50859 : canvas/philip/tests/2d.text.font.parse.system.html = TEXT
2033
BUGWK45991 : canvas/philip/tests/2d.text.measure.width.space.html = TEXT
2034
2033
2035
// These tests fail everywhere we use skia and are most likely skia bugs
2034
// These tests fail everywhere we use skia and are most likely skia bugs
2036
BUGWK45991 LINUX WIN : canvas/philip/tests/2d.gradient.object.update.html = TEXT
2035
BUGWK45991 LINUX WIN : canvas/philip/tests/2d.gradient.object.update.html = TEXT
- LayoutTests/platform/gtk/Skipped -1 lines
Lines 1064-1070 canvas/philip/tests/2d.text.font.parse.s LayoutTests/platform/gtk/Skipped_sec1
1064
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
1064
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
1065
svg/filters/sourceAlpha.svg
1065
svg/filters/sourceAlpha.svg
1066
canvas/philip/tests/2d.text.font.parse.system.html
1066
canvas/philip/tests/2d.text.font.parse.system.html
1067
canvas/philip/tests/2d.text.measure.width.space.html
1068
canvas/philip/tests/toDataURL.jpeg.alpha.html
1067
canvas/philip/tests/toDataURL.jpeg.alpha.html
1069
canvas/philip/tests/type.prototype.html
1068
canvas/philip/tests/type.prototype.html
1070
1069
- LayoutTests/platform/mac-leopard/Skipped -1 lines
Lines 176-182 canvas/philip/tests/2d.text.font.parse.i LayoutTests/platform/mac-leopard/Skipped_sec1
176
canvas/philip/tests/2d.text.font.parse.size.percentage.html
176
canvas/philip/tests/2d.text.font.parse.size.percentage.html
177
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
177
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
178
canvas/philip/tests/2d.text.font.parse.system.html
178
canvas/philip/tests/2d.text.font.parse.system.html
179
canvas/philip/tests/2d.text.measure.width.space.html
180
canvas/philip/tests/toDataURL.jpeg.alpha.html
179
canvas/philip/tests/toDataURL.jpeg.alpha.html
181
canvas/philip/tests/type.prototype.html
180
canvas/philip/tests/type.prototype.html
182
181
- LayoutTests/platform/mac/canvas/philip/tests/2d.text.measure.width.space-expected.txt -4 / +1 lines
Lines 1-4 LayoutTests/platform/mac/canvas/philip/tests/2d.text.measure.width.space-expected.txt_sec1
1
Failed assertion ctx.measureText('A B').width === 150 (got 200[number], expected 150[number])
1
Passed
2
Failed assertion ctx.measureText('A \x09\x0a\x0c\x0d \x09\x0a\x0c\x0dB').width === 150 (got 450[number], expected 150[number])
3
Failed assertion ctx.measureText(' AB').width === 100 (got 150[number], expected 100[number])
4
Failed assertion ctx.measureText('AB ').width === 100 (got 150[number], expected 100[number])
- LayoutTests/platform/qt/Skipped -1 lines
Lines 1867-1873 canvas/philip/tests/2d.text.font.parse.i LayoutTests/platform/qt/Skipped_sec1
1867
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
1867
canvas/philip/tests/2d.text.font.parse.size.percentage.default.html
1868
canvas/philip/tests/2d.text.font.parse.size.percentage.html
1868
canvas/philip/tests/2d.text.font.parse.size.percentage.html
1869
canvas/philip/tests/2d.text.font.parse.system.html
1869
canvas/philip/tests/2d.text.font.parse.system.html
1870
canvas/philip/tests/2d.text.measure.width.space.html
1871
canvas/philip/tests/2d.transformation.setTransform.skewed.html
1870
canvas/philip/tests/2d.transformation.setTransform.skewed.html
1872
canvas/philip/tests/2d.transformation.transform.skewed.html
1871
canvas/philip/tests/2d.transformation.transform.skewed.html
1873
canvas/philip/tests/type.prototype.html
1872
canvas/philip/tests/type.prototype.html

Return to Bug 61799