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

simon.fraser at apple.com simon.fraser at apple.com
Wed Dec 22 14:21:29 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 890494e4ae2ccca74cc8d433a6f6c458896e7319
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 7 02:37:28 2010 +0000

    2010-10-06  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Dan Bernstein, Darin Adler.
    
            :first-letter should apply to "punctuation" after the first letter
            https://bugs.webkit.org/show_bug.cgi?id=45986
    
            Follow the CSS 2.1 spec by allow certain kinds of punctuation before and after
            the :first-letter character.
    
            The spec does not describe whitespace behavior, and browsers are inconsistent.
            This patch allows whitespace (including non-breaking spaces) before and after the
            leading punctuation, and before the trailing punctuation.
    
            Test: fast/css/first-letter-punctuation.html
    
            * rendering/RenderBlock.cpp:
            (WebCore::isPunctuationForFirstLetter):
            (WebCore::shouldSkipForFirstLetter):
            (WebCore::RenderBlock::updateFirstLetter):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 05bc30d..d18b3af 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-10-06  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein, Darin Adler.
+
+        :first-letter should apply to "punctuation" after the first letter
+        https://bugs.webkit.org/show_bug.cgi?id=45986
+        
+        Testcase for :first-letter with various punctuation and whitespace combinations.
+
+        * fast/css/first-letter-punctuation.html: Added.
+        * platform/mac/fast/css/first-letter-punctuation-expected.checksum: Added.
+        * platform/mac/fast/css/first-letter-punctuation-expected.png: Added.
+        * platform/mac/fast/css/first-letter-punctuation-expected.txt: Added.
+
 2010-10-06  Jia Pu  <jpu at apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/LayoutTests/fast/css/first-letter-punctuation.html b/LayoutTests/fast/css/first-letter-punctuation.html
new file mode 100644
index 0000000..e5e1154
--- /dev/null
+++ b/LayoutTests/fast/css/first-letter-punctuation.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style type="text/css">
+            div:first-letter
+            {
+                color: green;
+                font-size: 36px;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if all the T and surrounding punctuation are green.</p>
+        <div>(T)est</div>
+        <div>&ldquo;T&rdquo;est</div>
+        <div>&laquo;&nbsp;T&nbsp;&raquo;est</div>
+        <div>&laquo;&nbsp;T&nbsp;&raquo;&nbsp;&nbsp;&nbsp;&nbsp;est</div>
+    </body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.checksum b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.checksum
new file mode 100644
index 0000000..4b0c178
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.checksum
@@ -0,0 +1 @@
+721eadf9b0aeec2b7c72fc28368f73c9
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.png b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.png
new file mode 100644
index 0000000..80c84c8
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt
new file mode 100644
index 0000000..5c15555
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt
@@ -0,0 +1,32 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x222
+  RenderBlock {HTML} at (0,0) size 800x222
+    RenderBody {BODY} at (8,16) size 784x198
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 391x18
+          text run at (0,0) width 391: "Test passes if all the T and surrounding punctuation are green."
+      RenderBlock {DIV} at (0,34) size 784x41
+        RenderInline (generated) at (0,0) size 46x41 [color=#008000]
+          RenderText {#text} at (0,0) size 46x41
+            text run at (0,0) width 46: "(T)"
+        RenderText {#text} at (46,18) size 17x18
+          text run at (46,18) width 17: "est"
+      RenderBlock {DIV} at (0,75) size 784x41
+        RenderInline (generated) at (0,0) size 54x41 [color=#008000]
+          RenderText {#text} at (0,0) size 54x41
+            text run at (0,0) width 54: "\x{201C}T\x{201D}"
+        RenderText {#text} at (54,18) size 17x18
+          text run at (54,18) width 17: "est"
+      RenderBlock {DIV} at (0,116) size 784x41
+        RenderInline (generated) at (0,0) size 76x41 [color=#008000]
+          RenderText {#text} at (0,0) size 76x41
+            text run at (0,0) width 76: "\x{AB} T \x{BB}"
+        RenderText {#text} at (76,18) size 17x18
+          text run at (76,18) width 17: "est"
+      RenderBlock {DIV} at (0,157) size 784x41
+        RenderInline (generated) at (0,0) size 76x41 [color=#008000]
+          RenderText {#text} at (0,0) size 76x41
+            text run at (0,0) width 76: "\x{AB} T \x{BB}"
+        RenderText {#text} at (76,18) size 33x18
+          text run at (76,18) width 33: "    est"
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e5f04bb..0595f79 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-06  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein, Darin Adler.
+
+        :first-letter should apply to "punctuation" after the first letter
+        https://bugs.webkit.org/show_bug.cgi?id=45986
+        
+        Follow the CSS 2.1 spec by allow certain kinds of punctuation before and after
+        the :first-letter character.
+        
+        The spec does not describe whitespace behavior, and browsers are inconsistent.
+        This patch allows whitespace (including non-breaking spaces) before and after the
+        leading punctuation, and before the trailing punctuation.
+
+        Test: fast/css/first-letter-punctuation.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::isPunctuationForFirstLetter):
+        (WebCore::shouldSkipForFirstLetter):
+        (WebCore::RenderBlock::updateFirstLetter):
+
 2010-10-06  Sanjeev Radhakrishnan  <sanjeevr at chromium.org>
 
         Reviewed by Darin Fisher.
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 479179d..23f3081 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -5256,6 +5256,24 @@ static RenderStyle* styleForFirstLetter(RenderObject* firstLetterBlock, RenderOb
     return pseudoStyle;
 }
 
+// CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter
+// "Punctuation (i.e, characters defined in Unicode [UNICODE] in the "open" (Ps), "close" (Pe),
+// "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that precedes or follows the first letter should be included"
+static inline bool isPunctuationForFirstLetter(UChar c)
+{
+    CharCategory charCategory = category(c);
+    return charCategory == Punctuation_Open
+        || charCategory == Punctuation_Close
+        || charCategory == Punctuation_InitialQuote
+        || charCategory == Punctuation_FinalQuote
+        || charCategory == Punctuation_Other;
+}
+
+static inline bool shouldSkipForFirstLetter(UChar c)
+{
+    return isSpaceOrNewline(c) || c == noBreakSpace || isPunctuationForFirstLetter(c);
+}
+
 void RenderBlock::updateFirstLetter()
 {
     if (!document()->usesFirstLetterRules())
@@ -5380,15 +5398,27 @@ void RenderBlock::updateFirstLetter()
     if (oldText && oldText->length() > 0) {
         unsigned length = 0;
 
-        // account for leading spaces and punctuation
-        while (length < oldText->length() && (isSpaceOrNewline((*oldText)[length]) || Unicode::isPunct((*oldText)[length])))
+        // Account for leading spaces and punctuation.
+        while (length < oldText->length() && shouldSkipForFirstLetter((*oldText)[length]))
             length++;
 
-        // account for first letter
+        // Account for first letter.
         length++;
+        
+        // Keep looking for whitespace and allowed punctuation, but avoid
+        // accumulating just whitespace into the :first-letter.
+        for (unsigned scanLength = length; scanLength < oldText->length(); ++scanLength) {
+            UChar c = (*oldText)[scanLength]; 
+            
+            if (!shouldSkipForFirstLetter(c))
+                break;
 
-        // construct text fragment for the text after the first letter
-        // NOTE: this might empty
+            if (isPunctuationForFirstLetter(c))
+                length = scanLength + 1;
+         }
+         
+        // Construct a text fragment for the text after the first letter.
+        // This text fragment might be empty.
         RenderTextFragment* remainingText = 
             new (renderArena()) RenderTextFragment(textObj->node() ? textObj->node() : textObj->document(), oldText.get(), length, oldText->length() - length);
         remainingText->setStyle(textObj->style());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list