LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Feb 2007 04:06:07 +0000 (04:06 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Feb 2007 04:06:07 +0000 (04:06 +0000)
        Reviewed by Maciej.

        - test for http://bugs.webkit.org/show_bug.cgi?id=10144
          REGRESSION: Reproducible assertion failure in DeleteSelectionCommand::fixupWhitespace()

        * fast/text/delete-hard-break-character-expected.checksum: Added.
        * fast/text/delete-hard-break-character-expected.png: Added.
        * fast/text/delete-hard-break-character-expected.txt: Added.
        * fast/text/delete-hard-break-character.html: Added.

WebCore:

        Reviewed by Maciej.

        - fix http://bugs.webkit.org/show_bug.cgi?id=10144
          REGRESSION: Reproducible assertion failure in DeleteSelectionCommand::fixupWhitespace()

        Test: fast/text/delete-hard-break-character.html

        The bug was caused by not updating a line whose line break object and offset
        has been deleted. When deleting text, all lines containing the deleted text
        are marked dirty. However, if the first character being deleted is a newline
        which serves as a hard line break for the previous line, then that line will
        not be marked, and since it will be a clean line ending with a line break,
        relayout will begin at the next line. The fix is to check for this when
        determining where to relayout from.

        * rendering/bidi.cpp:
        (WebCore::RenderBlock::determineStartPosition): Changed the condition for
        including the last clean line in relayout to include the case where the
        last clean line ends with a line break, but that line break is a newline that
        has been deleted.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/delete-hard-break-character-expected.checksum [new file with mode: 0644]
LayoutTests/fast/text/delete-hard-break-character-expected.png [new file with mode: 0644]
LayoutTests/fast/text/delete-hard-break-character-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/delete-hard-break-character.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/bidi.cpp

index e14a3b5bb9df1f6838429ece467027146dd52dd6..0fff5ce3232c48e344bd617ebde6c7190083af80 100644 (file)
@@ -1,3 +1,15 @@
+2007-02-11  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Maciej.
+
+        - test for http://bugs.webkit.org/show_bug.cgi?id=10144
+          REGRESSION: Reproducible assertion failure in DeleteSelectionCommand::fixupWhitespace()
+
+        * fast/text/delete-hard-break-character-expected.checksum: Added.
+        * fast/text/delete-hard-break-character-expected.png: Added.
+        * fast/text/delete-hard-break-character-expected.txt: Added.
+        * fast/text/delete-hard-break-character.html: Added.
+
 2007-02-12  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/fast/text/delete-hard-break-character-expected.checksum b/LayoutTests/fast/text/delete-hard-break-character-expected.checksum
new file mode 100644 (file)
index 0000000..7fa9e4b
--- /dev/null
@@ -0,0 +1 @@
+95d46172809e6b73e92699e8889501a0
\ No newline at end of file
diff --git a/LayoutTests/fast/text/delete-hard-break-character-expected.png b/LayoutTests/fast/text/delete-hard-break-character-expected.png
new file mode 100644 (file)
index 0000000..7d88f7f
Binary files /dev/null and b/LayoutTests/fast/text/delete-hard-break-character-expected.png differ
diff --git a/LayoutTests/fast/text/delete-hard-break-character-expected.txt b/LayoutTests/fast/text/delete-hard-break-character-expected.txt
new file mode 100644 (file)
index 0000000..6e72012
--- /dev/null
@@ -0,0 +1,23 @@
+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 670x36
+          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=10144"
+          RenderText {#text} at (354,0) size 670x36
+            text run at (354,0) width 4: " "
+            text run at (358,0) width 312: "REGRESSION: Reproducible assertion failure in"
+            text run at (0,18) width 288: "DeleteSelectionCommand::fixupWhitespace()"
+        RenderText {#text} at (288,18) size 4x18
+          text run at (288,18) width 4: "."
+      RenderBlock {DIV} at (0,52) size 784x100
+        RenderText {#text} at (0,0) size 0x18
+          text run at (0,0) width 0: " "
+        RenderBR {BR} at (0,18) size 0x18
+caret: position 0 of child 1 {BR} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/text/delete-hard-break-character.html b/LayoutTests/fast/text/delete-hard-break-character.html
new file mode 100644 (file)
index 0000000..68d834b
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+<head>
+    <title></title>
+</head>
+<body>
+    <p>
+        Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=10144">http://bugs.webkit.org/show_bug.cgi?id=10144</a>
+        REGRESSION: Reproducible assertion failure in DeleteSelectionCommand::fixupWhitespace()</i>.
+    </p>
+<div id="you" style="height: 100px; white-space: pre-wrap; -webkit-user-modify: read-write;">
+
+<br></div>
+    <script>
+        var div = document.getElementById("you");
+        var selection = window.getSelection();
+        selection.setPosition(div, 2);
+        document.execCommand("Delete");
+    </script>
+</body>
index 1449effa15211b0838a380eb0171d7d96fc26f65..b4c0861744e973a1dfcb42ccdbb06d081cb84469 100644 (file)
@@ -1,3 +1,26 @@
+2007-02-11  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Maciej.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=10144
+          REGRESSION: Reproducible assertion failure in DeleteSelectionCommand::fixupWhitespace()
+
+        Test: fast/text/delete-hard-break-character.html
+
+        The bug was caused by not updating a line whose line break object and offset
+        has been deleted. When deleting text, all lines containing the deleted text
+        are marked dirty. However, if the first character being deleted is a newline
+        which serves as a hard line break for the previous line, then that line will
+        not be marked, and since it will be a clean line ending with a line break,
+        relayout will begin at the next line. The fix is to check for this when
+        determining where to relayout from. 
+
+        * rendering/bidi.cpp:
+        (WebCore::RenderBlock::determineStartPosition): Changed the condition for
+        including the last clean line in relayout to include the case where the
+        last clean line ends with a line break, but that line break is a newline that
+        has been deleted.
+
 2007-02-12  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Maciej.
index 8660690579af777b5f1bebbf4610fccbe2dec4f9..529d7f066b52d4aca51e1f1818cb747c4132af99 100644 (file)
@@ -1846,10 +1846,12 @@ RootInlineBox* RenderBlock::determineStartPosition(bool fullLayout, BidiIterator
         for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextRootBox());
         if (curr) {
             // We have a dirty line.
-            if (curr->prevRootBox()) {
+            if (RootInlineBox* prevRootBox = curr->prevRootBox()) {
                 // We have a previous line.
-                if (!curr->prevRootBox()->endsWithBreak())
-                    curr = curr->prevRootBox();  // The previous line didn't break cleanly, so treat it as dirty also.
+                if (!prevRootBox->endsWithBreak() || prevRootBox->lineBreakObj()->isText() && prevRootBox->lineBreakPos() >= static_cast<RenderText*>(prevRootBox->lineBreakObj())->textLength())
+                    // The previous line didn't break cleanly or broke at a newline
+                    // that has been deleted, so treat it as dirty too.
+                    curr = prevRootBox;
             }
         } else {
             // No dirty lines were found.