[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 13:25:27 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5f66b7a0135719cae12c90df469e17dbfee96e06
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 14 23:32:26 2010 +0000

    2010-09-14  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Handle <font size=0> as <font size=1> like any other browser
            https://bugs.webkit.org/show_bug.cgi?id=39148
    
            Update font size parser to match HTML5 spec.  The main difference here
            is the handling of 0, which now maps to 1 instead of 3.
    
            * html/HTMLFontElement.cpp:
            (WebCore::parseFontSize):
            (WebCore::HTMLFontElement::cssValueFromFontSizeNumber):
    2010-09-14  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Handle <font size=0> as <font size=1> like any other browser
            https://bugs.webkit.org/show_bug.cgi?id=39148
    
            Update tests and results to match new behavior.
    
            * editing/execCommand/query-font-size-expected.txt:
            * fast/dom/HTMLFontElement/script-tests/size-attribute.js:
            * fast/dom/HTMLFontElement/size-attribute-expected.txt:
            * platform/mac/tables/mozilla/bugs/bug16012-expected.txt:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67514 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 864348c..6fa01fd 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -2,6 +2,20 @@
 
         Reviewed by Darin Adler.
 
+        Handle <font size=0> as <font size=1> like any other browser
+        https://bugs.webkit.org/show_bug.cgi?id=39148
+
+        Update tests and results to match new behavior.
+
+        * editing/execCommand/query-font-size-expected.txt:
+        * fast/dom/HTMLFontElement/script-tests/size-attribute.js:
+        * fast/dom/HTMLFontElement/size-attribute-expected.txt:
+        * platform/mac/tables/mozilla/bugs/bug16012-expected.txt:
+
+2010-09-14  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
         document.lastModified gives no output if the response doesn't have a Last-Modified header
         https://bugs.webkit.org/show_bug.cgi?id=8475
 
diff --git a/LayoutTests/editing/execCommand/query-font-size-expected.txt b/LayoutTests/editing/execCommand/query-font-size-expected.txt
index 98adf80..b26894e 100644
--- a/LayoutTests/editing/execCommand/query-font-size-expected.txt
+++ b/LayoutTests/editing/execCommand/query-font-size-expected.txt
@@ -1,7 +1,7 @@
 test	html	queryCommandValue result
 execCommand('FontSize', -2)	<font class="Apple-style-span" size="1">test</font>	1
 execCommand('FontSize', -1)	<font class="Apple-style-span" size="2">test</font>	2
-execCommand('FontSize', 0)	test	3
+execCommand('FontSize', 0)	<font class="Apple-style-span" size="1">test</font>	1
 execCommand('FontSize', 1)	<font class="Apple-style-span" size="1">test</font>	1
 execCommand('FontSize', 2)	<font class="Apple-style-span" size="2">test</font>	2
 execCommand('FontSize', 3)	test	3
@@ -21,7 +21,7 @@ manual CSS font-size: 10px	<span style="font-size: 10px">test</span>	1
 monospace tests to ensure the bug 19161 does not affect queryCommandValue's values
 execCommand('FontSize', -2)	<font class="Apple-style-span" size="1"><font class="Apple-style-span" face="monospace">test</font></font>	1
 execCommand('FontSize', -1)	<font class="Apple-style-span" size="2"><font class="Apple-style-span" face="monospace">test</font></font>	2
-execCommand('FontSize', 0)	<font class="Apple-style-span" face="monospace">test</font>	3
+execCommand('FontSize', 0)	<font class="Apple-style-span" size="1"><font class="Apple-style-span" face="monospace">test</font></font>	1
 execCommand('FontSize', 1)	<font class="Apple-style-span" size="1"><font class="Apple-style-span" face="monospace">test</font></font>	1
 execCommand('FontSize', 2)	<font class="Apple-style-span" size="2"><font class="Apple-style-span" face="monospace">test</font></font>	2
 execCommand('FontSize', 3)	<font class="Apple-style-span" face="monospace">test</font>	3
diff --git a/LayoutTests/fast/dom/HTMLFontElement/script-tests/size-attribute.js b/LayoutTests/fast/dom/HTMLFontElement/script-tests/size-attribute.js
index 3e090b1..2e32331 100644
--- a/LayoutTests/fast/dom/HTMLFontElement/script-tests/size-attribute.js
+++ b/LayoutTests/fast/dom/HTMLFontElement/script-tests/size-attribute.js
@@ -24,7 +24,7 @@ shouldBe('fontSizeAttributeEffect("5")', '"24px"');
 shouldBe('fontSizeAttributeEffect("6")', '"32px"');
 shouldBe('fontSizeAttributeEffect("7")', '"48px"');
 
-shouldBe('fontSizeAttributeEffect("0")', '"16px"'); // Gecko and WebKit do not agree on this result. Which matches IE?
+shouldBe('fontSizeAttributeEffect("0")', '"10px"');
 
 shouldBe('fontSizeAttributeEffect("-1")', '"13px"');
 shouldBe('fontSizeAttributeEffect("-2")', '"10px"');
@@ -37,6 +37,41 @@ shouldBe('fontSizeAttributeEffect("-8")', '"10px"');
 shouldBe('fontSizeAttributeEffect("-9")', '"10px"');
 shouldBe('fontSizeAttributeEffect("-10")', '"10px"');
 
+shouldBe('fontSizeAttributeEffect("x6")', 'null');
+shouldBe('fontSizeAttributeEffect(" 6")', '"32px"');
+shouldBe('fontSizeAttributeEffect("\\t6")', '"32px"');
+shouldBe('fontSizeAttributeEffect("\\r6")', '"32px"');
+shouldBe('fontSizeAttributeEffect("\\n6")', '"32px"');
+shouldBe('fontSizeAttributeEffect("\\u20086")', 'null');
+
+shouldBe('fontSizeAttributeEffect("x-6")', 'null');
+shouldBe('fontSizeAttributeEffect(" -6")', '"10px"');
+shouldBe('fontSizeAttributeEffect("\\t-6")', '"10px"');
+shouldBe('fontSizeAttributeEffect("\\r-6")', '"10px"');
+shouldBe('fontSizeAttributeEffect("\\n-6")', '"10px"');
+shouldBe('fontSizeAttributeEffect("\\u2008-6")', 'null');
+
+shouldBe('fontSizeAttributeEffect("x+6")', 'null');
+shouldBe('fontSizeAttributeEffect(" +6")', '"48px"');
+shouldBe('fontSizeAttributeEffect("\\t+6")', '"48px"');
+shouldBe('fontSizeAttributeEffect("\\r+6")', '"48px"');
+shouldBe('fontSizeAttributeEffect("\\n+6")', '"48px"');
+shouldBe('fontSizeAttributeEffect("\\u2008+6")', 'null');
+
+shouldBe('fontSizeAttributeEffect("x+x6")', 'null');
+shouldBe('fontSizeAttributeEffect(" + 6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\t+\\t6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\r+\\r6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\n+\\n6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\u2008+\\u20086")', 'null');
+
+shouldBe('fontSizeAttributeEffect("x-x6")', 'null');
+shouldBe('fontSizeAttributeEffect(" - 6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\t-\\t6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\r-\\r6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\n-\\n6")', 'null');
+shouldBe('fontSizeAttributeEffect("\\u2008-\\u20086")', 'null');
+
 shouldBe('fontSizeAttributeEffect("8")', '"48px"');
 shouldBe('fontSizeAttributeEffect("9")', '"48px"');
 shouldBe('fontSizeAttributeEffect("10")', '"48px"');
diff --git a/LayoutTests/fast/dom/HTMLFontElement/size-attribute-expected.txt b/LayoutTests/fast/dom/HTMLFontElement/size-attribute-expected.txt
index 28d44af..53d19e4 100644
--- a/LayoutTests/fast/dom/HTMLFontElement/size-attribute-expected.txt
+++ b/LayoutTests/fast/dom/HTMLFontElement/size-attribute-expected.txt
@@ -11,7 +11,7 @@ PASS fontSizeAttributeEffect("4") is "18px"
 PASS fontSizeAttributeEffect("5") is "24px"
 PASS fontSizeAttributeEffect("6") is "32px"
 PASS fontSizeAttributeEffect("7") is "48px"
-PASS fontSizeAttributeEffect("0") is "16px"
+PASS fontSizeAttributeEffect("0") is "10px"
 PASS fontSizeAttributeEffect("-1") is "13px"
 PASS fontSizeAttributeEffect("-2") is "10px"
 PASS fontSizeAttributeEffect("-3") is "10px"
@@ -22,6 +22,36 @@ PASS fontSizeAttributeEffect("-7") is "10px"
 PASS fontSizeAttributeEffect("-8") is "10px"
 PASS fontSizeAttributeEffect("-9") is "10px"
 PASS fontSizeAttributeEffect("-10") is "10px"
+PASS fontSizeAttributeEffect("x6") is null
+PASS fontSizeAttributeEffect(" 6") is "32px"
+PASS fontSizeAttributeEffect("\t6") is "32px"
+PASS fontSizeAttributeEffect("\r6") is "32px"
+PASS fontSizeAttributeEffect("\n6") is "32px"
+PASS fontSizeAttributeEffect("\u20086") is null
+PASS fontSizeAttributeEffect("x-6") is null
+PASS fontSizeAttributeEffect(" -6") is "10px"
+PASS fontSizeAttributeEffect("\t-6") is "10px"
+PASS fontSizeAttributeEffect("\r-6") is "10px"
+PASS fontSizeAttributeEffect("\n-6") is "10px"
+PASS fontSizeAttributeEffect("\u2008-6") is null
+PASS fontSizeAttributeEffect("x+6") is null
+PASS fontSizeAttributeEffect(" +6") is "48px"
+PASS fontSizeAttributeEffect("\t+6") is "48px"
+PASS fontSizeAttributeEffect("\r+6") is "48px"
+PASS fontSizeAttributeEffect("\n+6") is "48px"
+PASS fontSizeAttributeEffect("\u2008+6") is null
+PASS fontSizeAttributeEffect("x+x6") is null
+PASS fontSizeAttributeEffect(" + 6") is null
+PASS fontSizeAttributeEffect("\t+\t6") is null
+PASS fontSizeAttributeEffect("\r+\r6") is null
+PASS fontSizeAttributeEffect("\n+\n6") is null
+PASS fontSizeAttributeEffect("\u2008+\u20086") is null
+PASS fontSizeAttributeEffect("x-x6") is null
+PASS fontSizeAttributeEffect(" - 6") is null
+PASS fontSizeAttributeEffect("\t-\t6") is null
+PASS fontSizeAttributeEffect("\r-\r6") is null
+PASS fontSizeAttributeEffect("\n-\n6") is null
+PASS fontSizeAttributeEffect("\u2008-\u20086") is null
 PASS fontSizeAttributeEffect("8") is "48px"
 PASS fontSizeAttributeEffect("9") is "48px"
 PASS fontSizeAttributeEffect("10") is "48px"
diff --git a/LayoutTests/platform/mac/tables/mozilla/bugs/bug16012-expected.txt b/LayoutTests/platform/mac/tables/mozilla/bugs/bug16012-expected.txt
index c718a98..525f527 100644
--- a/LayoutTests/platform/mac/tables/mozilla/bugs/bug16012-expected.txt
+++ b/LayoutTests/platform/mac/tables/mozilla/bugs/bug16012-expected.txt
@@ -21,7 +21,7 @@ layer at (0,0) size 800x600
           RenderTableRow {TR} at (0,2) size 34x1
             RenderTableCell {TD} at (2,2) size 30x1 [bgcolor=#FF0000] [r=0 c=0 rs=1 cs=1]
               RenderImage {IMG} at (0,0) size 30x1
-      RenderBlock (anonymous) at (0,64) size 784x184
+      RenderBlock (anonymous) at (0,64) size 784x170
         RenderBR {BR} at (0,0) size 0x18
         RenderBR {BR} at (0,18) size 0x18
         RenderBR {BR} at (0,36) size 0x18
@@ -30,19 +30,19 @@ layer at (0,0) size 800x600
           text run at (222,54) width 175: "1st at size=0, 2nd at size=-4"
         RenderBR {BR} at (397,68) size 0x0
         RenderBR {BR} at (0,72) size 0x18
-        RenderInline {FONT} at (0,0) size 160x35
-          RenderText {#text} at (0,90) size 160x17
-            text run at (0,90) width 160: "Detonator 3.53 Drivers"
-          RenderBR {BR} at (160,104) size 0x0
-          RenderText {#text} at (0,108) size 118x17
-            text run at (0,108) width 118: "Available NOW! "
-        RenderBR {BR} at (118,122) size 0x0
-        RenderBR {BR} at (0,126) size 0x18
         RenderInline {FONT} at (0,0) size 104x22
-          RenderText {#text} at (0,144) size 104x11
-            text run at (0,144) width 104: "Detonator 3.53 Drivers"
-          RenderBR {BR} at (104,153) size 0x0
-          RenderText {#text} at (0,155) size 75x11
-            text run at (0,155) width 75: "Available NOW! "
-        RenderBR {BR} at (75,164) size 0x0
-        RenderBR {BR} at (0,166) size 0x18
+          RenderText {#text} at (0,90) size 104x11
+            text run at (0,90) width 104: "Detonator 3.53 Drivers"
+          RenderBR {BR} at (104,99) size 0x0
+          RenderText {#text} at (0,101) size 75x11
+            text run at (0,101) width 75: "Available NOW! "
+        RenderBR {BR} at (75,110) size 0x0
+        RenderBR {BR} at (0,112) size 0x18
+        RenderInline {FONT} at (0,0) size 104x22
+          RenderText {#text} at (0,130) size 104x11
+            text run at (0,130) width 104: "Detonator 3.53 Drivers"
+          RenderBR {BR} at (104,139) size 0x0
+          RenderText {#text} at (0,141) size 75x11
+            text run at (0,141) width 75: "Available NOW! "
+        RenderBR {BR} at (75,150) size 0x0
+        RenderBR {BR} at (0,152) size 0x18
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f0dc58d..4237d81 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,20 @@
 
         Reviewed by Darin Adler.
 
+        Handle <font size=0> as <font size=1> like any other browser
+        https://bugs.webkit.org/show_bug.cgi?id=39148
+
+        Update font size parser to match HTML5 spec.  The main difference here
+        is the handling of 0, which now maps to 1 instead of 3.
+
+        * html/HTMLFontElement.cpp:
+        (WebCore::parseFontSize):
+        (WebCore::HTMLFontElement::cssValueFromFontSizeNumber):
+
+2010-09-14  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
         document.lastModified gives no output if the response doesn't have a Last-Modified header
         https://bugs.webkit.org/show_bug.cgi?id=8475
 
diff --git a/WebCore/html/HTMLFontElement.cpp b/WebCore/html/HTMLFontElement.cpp
index 81ae415..f0993dd 100644
--- a/WebCore/html/HTMLFontElement.cpp
+++ b/WebCore/html/HTMLFontElement.cpp
@@ -27,6 +27,7 @@
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
 #include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 
 using namespace WTF;
 
@@ -45,49 +46,78 @@ PassRefPtr<HTMLFontElement> HTMLFontElement::create(const QualifiedName& tagName
     return adoptRef(new HTMLFontElement(tagName, document));
 }
 
-// Allows leading spaces.
-// Allows trailing nonnumeric characters.
-// Returns 10 for any size greater than 9.
-static bool parseFontSizeNumber(const String& s, int& size)
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#fonts-and-colors
+static bool parseFontSize(const String& input, int& size)
 {
-    unsigned pos = 0;
-    
-    // Skip leading spaces.
-    while (isSpaceOrNewline(s[pos]))
-        ++pos;
-    
-    // Skip a plus or minus.
-    bool sawPlus = false;
-    bool sawMinus = false;
-    if (s[pos] == '+') {
-        ++pos;
-        sawPlus = true;
-    } else if (s[pos] == '-') {
-        ++pos;
-        sawMinus = true;
+
+    // Step 1
+    // Step 2
+    const UChar* position = input.characters();
+    const UChar* end = position + input.length();
+
+    // Step 3
+    while (position < end) {
+        if (!isHTMLSpace(*position))
+            break;
+        ++position;
     }
-    
-    // Parse a single digit.
-    if (!isASCIIDigit(s[pos]))
+
+    // Step 4
+    if (position == end)
         return false;
-    int num = s[pos++] - '0';
-    
-    // Check for an additional digit.
-    if (isASCIIDigit(s[pos]))
-        num = 10;
-    
-    if (sawPlus) {
-        size = num + 3;
-        return true;
+    ASSERT(position < end);
+
+    // Step 5
+    enum {
+        RelativePlus,
+        RelativeMinus,
+        Absolute
+    } mode;
+
+    switch (*position) {
+    case '+':
+        mode = RelativePlus;
+        ++position;
+        break;
+    case '-':
+        mode = RelativeMinus;
+        ++position;
+        break;
+    default:
+        mode = Absolute;
+        break;
     }
-    
-    // Don't return 0 (which means 3) or a negative number (which means the same as 1).
-    if (sawMinus) {
-        size = num == 1 ? 2 : 1;
-        return true;
+
+    // Step 6
+    Vector<UChar, 16> digits;
+    while (position < end) {
+        if (!isASCIIDigit(*position))
+            break;
+        digits.append(*position++);
     }
-    
-    size = num;
+
+    // Step 7
+    if (digits.isEmpty())
+        return false;
+
+    // Step 8
+    int value = charactersToIntStrict(digits.data(), digits.size());
+
+    // Step 9
+    if (mode == RelativePlus)
+        value += 3;
+    else if (mode == RelativeMinus)
+        value = 3 - value;
+
+    // Step 10
+    if (value > 7)
+        value = 7;
+
+    // Step 11
+    if (value < 1)
+        value = 1;
+
+    size = value;
     return true;
 }
 
@@ -105,32 +135,35 @@ bool HTMLFontElement::mapToEntry(const QualifiedName& attrName, MappedAttributeE
 
 bool HTMLFontElement::cssValueFromFontSizeNumber(const String& s, int& size)
 {
-    int num;
-    if (!parseFontSizeNumber(s, num))
+    int num = 0;
+    if (!parseFontSize(s, num))
         return false;
-        
+
     switch (num) {
-        case 2: 
-            size = CSSValueSmall; 
-            break;
-        case 0: // treat 0 the same as 3, because people expect it to be between -1 and +1
-        case 3: 
-            size = CSSValueMedium; 
-            break;
-        case 4: 
-            size = CSSValueLarge; 
-            break;
-        case 5: 
-            size = CSSValueXLarge; 
-            break;
-        case 6: 
-            size = CSSValueXxLarge; 
-            break;
-        default:
-            if (num > 6)
-                size = CSSValueWebkitXxxLarge;
-            else
-                size = CSSValueXSmall;
+    case 1:
+        // FIXME: The spec says that we're supposed to use CSSValueXxSmall here.
+        size = CSSValueXSmall;
+        break;
+    case 2: 
+        size = CSSValueSmall;
+        break;
+    case 3: 
+        size = CSSValueMedium;
+        break;
+    case 4: 
+        size = CSSValueLarge;
+        break;
+    case 5: 
+        size = CSSValueXLarge;
+        break;
+    case 6: 
+        size = CSSValueXxLarge;
+        break;
+    case 7:
+        size = CSSValueWebkitXxxLarge;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
     }
     return true;
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list