2007-07-08 Mitz Pettel <mitz@webkit.org>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Jul 2007 09:54:42 +0000 (09:54 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Jul 2007 09:54:42 +0000 (09:54 +0000)
        Reviewed by Darin.

        - fix http://bugs.webkit.org/show_bug.cgi?id=14221
          Repro crash (ASSERTION FAILED: oldText in RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)

        Test: fast/css-generated-content/before-with-first-letter.html

        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::updateBeforeAfterContentForContainer): If a child
        of the existing 'before' container is not text, do not assume that it is an
        image, since it can also be an inline wrapping a first-letter. In that case,
        do not update its style (so in particular, keep it a FIRST_LETTER type style)
        and leave it to updateFirstLetter() to take care of.

2007-07-08  Mitz Pettel  <mitz@webkit.org>

        Reviewed by Darin.

        - test for http://bugs.webkit.org/show_bug.cgi?id=14221
          Repro crash (ASSERTION FAILED: oldText in RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)

        * fast/css-generated-content/before-with-first-letter-expected.checksum: Added.
        * fast/css-generated-content/before-with-first-letter-expected.png: Added.
        * fast/css-generated-content/before-with-first-letter-expected.txt: Added.
        * fast/css-generated-content/before-with-first-letter.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css-generated-content/before-with-first-letter-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css-generated-content/before-with-first-letter-expected.png [new file with mode: 0644]
LayoutTests/fast/css-generated-content/before-with-first-letter-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-generated-content/before-with-first-letter.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderContainer.cpp

index fcbd687..5d3596b 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-08  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Darin.
+
+        - test for http://bugs.webkit.org/show_bug.cgi?id=14221
+          Repro crash (ASSERTION FAILED: oldText in RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)
+
+        * fast/css-generated-content/before-with-first-letter-expected.checksum: Added.
+        * fast/css-generated-content/before-with-first-letter-expected.png: Added.
+        * fast/css-generated-content/before-with-first-letter-expected.txt: Added.
+        * fast/css-generated-content/before-with-first-letter.html: Added.
+
 2007-07-07  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.checksum b/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.checksum
new file mode 100644 (file)
index 0000000..70678a9
--- /dev/null
@@ -0,0 +1 @@
+1a12c9fa5fa4c88e987cbaa3c16e4d16
\ No newline at end of file
diff --git a/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.png b/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.png
new file mode 100644 (file)
index 0000000..e74bdac
Binary files /dev/null and b/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.png differ
diff --git a/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.txt b/LayoutTests/fast/css-generated-content/before-with-first-letter-expected.txt
new file mode 100644 (file)
index 0000000..fa3f1e9
--- /dev/null
@@ -0,0 +1,27 @@
+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 784x36
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {I} at (0,0) size 660x36
+          RenderInline {A} at (0,0) size 301x18 [color=#0000EE]
+            RenderText {#text} at (53,0) size 301x18
+              text run at (53,0) width 301: "http://bugs.webkit.org/show_bug.cgi?id=14221"
+          RenderText {#text} at (354,0) size 660x36
+            text run at (354,0) width 4: " "
+            text run at (358,0) width 302: "Repro crash (ASSERTION FAILED: oldText in"
+            text run at (0,18) width 562: "RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)"
+        RenderText {#text} at (562,18) size 4x18
+          text run at (562,18) width 4: "."
+      RenderBlock {DIV} at (0,52) size 784x33
+        RenderInline (generated) at (0,0) size 47x28
+          RenderInline (generated) at (0,0) size 18x33 [color=#008000]
+            RenderText at (0,0) size 18x33
+              text run at (0,0) width 18: "T"
+          RenderText at (18,4) size 29x28
+            text run at (18,4) width 29: "he "
+        RenderText {#text} at (47,4) size 413x28
+          text run at (47,4) width 413: "first letter is green and larger than the rest."
diff --git a/LayoutTests/fast/css-generated-content/before-with-first-letter.html b/LayoutTests/fast/css-generated-content/before-with-first-letter.html
new file mode 100644 (file)
index 0000000..94070ad
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+    <style>
+        div:first-letter { font-size: larger; color: green; }
+        div:before { content: "The "; }
+    </style>
+    <script>
+        function test()
+        {
+            document.body.offsetTop;
+            document.getElementById('target').style.fontSize = '24px';
+        }
+    </script>
+</head>
+<body onload="test()">
+    <p>
+        Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=14221">http://bugs.webkit.org/show_bug.cgi?id=14221</a>
+        Repro crash (ASSERTION FAILED: oldText in RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)</i>.
+    </p>
+    <div id="target">
+        first letter is green and larger than the rest.
+    </div>
+</body>
+</html>
index 2b1dd9b..93ffb9c 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-08  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Darin.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=14221
+          Repro crash (ASSERTION FAILED: oldText in RenderBlock::updateFirstLetter() during relayout of :before content with first-letter style)
+
+        Test: fast/css-generated-content/before-with-first-letter.html
+
+        * rendering/RenderContainer.cpp:
+        (WebCore::RenderContainer::updateBeforeAfterContentForContainer): If a child
+        of the existing 'before' container is not text, do not assume that it is an
+        image, since it can also be an inline wrapping a first-letter. In that case,
+        do not update its style (so in particular, keep it a FIRST_LETTER type style)
+        and leave it to updateFirstLetter() to take care of.
+
 2007-07-07  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver Hunt.
index 093183a..f800f1f 100644 (file)
@@ -307,12 +307,14 @@ void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId
                 if (genChild->isText())
                     // Generated text content is a child whose style also needs to be set to the pseudo-element style.
                     genChild->setStyle(pseudoElementStyle);
-                else {
+                else if (genChild->isImage()) {
                     // Images get an empty style that inherits from the pseudo.
                     RenderStyle* style = new (renderArena()) RenderStyle;
                     style->inheritFrom(pseudoElementStyle);
                     genChild->setStyle(style);
-                }
+                } else
+                    // Must be a first-letter container. updateFirstLetter() will take care of it.
+                    ASSERT(genChild->style()->styleType() == RenderStyle::FIRST_LETTER);
             }
         }
         return; // We've updated the generated content. That's all we needed to do.