WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2008 22:59:30 +0000 (22:59 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2008 22:59:30 +0000 (22:59 +0000)
        Reviewed by Darin Adler.

        - make :first-letter apply to the first letter in normal flow, skipping
          floats and positioned objects

        Test: fast/css/first-letter-skip-out-of-flow.html

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::updateFirstLetter):

LayoutTests:

        Reviewed by Darin Adler.

        - test that :first-letter applies to the first letter in normal flow,
          skipping floats and positioned objects

        * fast/css/first-letter-skip-out-of-flow.html: Added.
        * platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.checksum: Added.
        * platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png: Added.
        * platform/mac/fast/css/first-letter-skip-out-of-flow-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30724 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css/first-letter-skip-out-of-flow.html [new file with mode: 0644]
LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/first-letter-skip-out-of-flow-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBlock.cpp

index cf2e0e8d0e4037de140804839845b41ffabce6ca..0e738d4c859bf1fcb615e149383d0cea6372a8a9 100644 (file)
@@ -1,3 +1,15 @@
+2008-03-03  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - test that :first-letter applies to the first letter in normal flow,
+          skipping floats and positioned objects
+
+        * fast/css/first-letter-skip-out-of-flow.html: Added.
+        * platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.checksum: Added.
+        * platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png: Added.
+        * platform/mac/fast/css/first-letter-skip-out-of-flow-expected.txt: Added.
+
 2008-03-03  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/fast/css/first-letter-skip-out-of-flow.html b/LayoutTests/fast/css/first-letter-skip-out-of-flow.html
new file mode 100644 (file)
index 0000000..3946e24
--- /dev/null
@@ -0,0 +1,30 @@
+<style>
+.greenFirstLetter:first-letter { color: green; }
+</style>
+<p>
+    All the X&rsquo;s below should be green. All other letters should be black.
+</p>
+<div class="greenFirstLetter">
+    XY
+</div>
+<div class="greenFirstLetter">
+    <img>YZ
+</div>
+<div class="greenFirstLetter">
+    <img align="left">XY
+</div>
+<div class="greenFirstLetter">
+    <div style="position: absolute; left: 100px;">VW</div>XY
+</div>
+<div class="greenFirstLetter">
+    <div>
+        <div style="position: absolute; left: 100px;">VW</div>XY
+    </div>
+</div>
+
+<div class="greenFirstLetter">
+    <div>
+        <img>
+        <div style="position: absolute; left: 100px;">VW</div>YZ
+    </div>
+</div>
diff --git a/LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.checksum b/LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.checksum
new file mode 100644 (file)
index 0000000..ffcabab
--- /dev/null
@@ -0,0 +1 @@
+af1642ce11a6e894d15914dbcb6397ff
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png b/LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png
new file mode 100644 (file)
index 0000000..7d9cc40
Binary files /dev/null and b/LayoutTests/platform/mac-leopard/fast/css/first-letter-skip-out-of-flow-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/first-letter-skip-out-of-flow-expected.txt b/LayoutTests/platform/mac/fast/css/first-letter-skip-out-of-flow-expected.txt
new file mode 100644 (file)
index 0000000..0325b30
--- /dev/null
@@ -0,0 +1,57 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 429x18
+          text run at (0,0) width 429: "All the X\x{2019}s below should be green. All other letters should be black."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderInline (generated) at (0,0) size 12x18 [color=#008000]
+          RenderText {#text} at (0,0) size 12x18
+            text run at (0,0) width 12: "X"
+        RenderText {#text} at (12,0) size 12x18
+          text run at (12,0) width 12: "Y"
+      RenderBlock {DIV} at (0,52) size 784x18
+        RenderImage {IMG} at (0,14) size 0x0
+        RenderText {#text} at (0,0) size 22x18
+          text run at (0,0) width 22: "YZ"
+      RenderBlock {DIV} at (0,70) size 784x18
+        RenderInline (generated) at (0,0) size 12x18 [color=#008000]
+          RenderText {#text} at (0,0) size 12x18
+            text run at (0,0) width 12: "X"
+        RenderImage {IMG} at (0,0) size 0x0
+        RenderText {#text} at (12,0) size 12x18
+          text run at (12,0) width 12: "Y"
+      RenderBlock {DIV} at (0,88) size 784x18
+        RenderInline (generated) at (0,0) size 12x18 [color=#008000]
+          RenderText {#text} at (0,0) size 12x18
+            text run at (0,0) width 12: "X"
+        RenderText {#text} at (12,0) size 12x18
+          text run at (12,0) width 12: "Y"
+      RenderBlock {DIV} at (0,106) size 784x18
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderInline (generated) at (0,0) size 12x18 [color=#008000]
+            RenderText {#text} at (0,0) size 12x18
+              text run at (0,0) width 12: "X"
+          RenderText {#text} at (12,0) size 12x18
+            text run at (12,0) width 12: "Y"
+      RenderBlock {DIV} at (0,124) size 784x18
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderImage {IMG} at (0,14) size 0x0
+          RenderText {#text} at (0,0) size 4x18
+            text run at (0,0) width 4: " "
+          RenderText {#text} at (4,0) size 22x18
+            text run at (4,0) width 22: "YZ"
+layer at (100,114) size 27x18
+  RenderBlock (positioned) {DIV} at (100,114) size 27x18
+    RenderText {#text} at (0,0) size 27x18
+      text run at (0,0) width 27: "VW"
+layer at (100,132) size 27x18
+  RenderBlock (positioned) {DIV} at (100,132) size 27x18
+    RenderText {#text} at (0,0) size 27x18
+      text run at (0,0) width 27: "VW"
+layer at (100,150) size 27x18
+  RenderBlock (positioned) {DIV} at (100,150) size 27x18
+    RenderText {#text} at (0,0) size 27x18
+      text run at (0,0) width 27: "VW"
index 898cf83292d8073cad98a8f38e18555ececf06b9..46ca15c215b1a767ffa72956bb6c14be3268b8f1 100644 (file)
@@ -1,3 +1,15 @@
+2008-03-03  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - make :first-letter apply to the first letter in normal flow, skipping
+          floats and positioned objects
+
+        Test: fast/css/first-letter-skip-out-of-flow.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateFirstLetter):
+
 2008-03-03  Ada Chan  <adachan@apple.com>
 
         Fix build.
index 0fa0b6f51550be7ce971758d380e743972054122..aaffb8eddbd25538023be0a833ab97afcf21e7d2 100644 (file)
@@ -4081,19 +4081,23 @@ void RenderBlock::updateFirstLetter()
 
     if (!hasPseudoStyle) 
         return;
-    
+
     // Drill into inlines looking for our first text child.
     RenderObject* currChild = firstLetterBlock->firstChild();
-    while (currChild && currChild->needsLayout() && !currChild->isReplaced() && !currChild->isText()) 
-        currChild = currChild->firstChild();
+    while (currChild && currChild->needsLayout() && (!currChild->isReplaced() || currChild->isFloatingOrPositioned()) && !currChild->isText()) {
+        if (currChild->isFloatingOrPositioned())
+            currChild = currChild->nextSibling();
+        else
+            currChild = currChild->firstChild();
+    }
 
     // Get list markers out of the way.
     while (currChild && currChild->isListMarker())
         currChild = currChild->nextSibling();
-    
+
     if (!currChild)
         return;
-    
+
     RenderObject* firstLetterContainer = currChild->parent();
 
     // If the child already has style, then it has already been created, so we just want