LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 02:46:54 +0000 (02:46 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 02:46:54 +0000 (02:46 +0000)
        Reviewed by darin

        <rdar://problem/4818134>
        Crash in WebCore::selectRange when invoking WebView:insertNewLine in any empty content editable DIV.

        * editing/selection/select-line-expected.txt: Added.
        * editing/selection/select-line.html: Added.

WebCore:

        Reviewed by darin

        <rdar://problem/4818134>
        Crash in WebCore::selectRange when invoking WebView:insertNewLine in any empty content editable DIV.

        * WebCore.vcproj/WebCore/WebCore.vcproj: Removed RebalanceWhitespaceCommand.*.
        * editing/visible_units.cpp:
        (WebCore::startOfLine): There are VisiblePositions at offset 0 in blocks without
        RootInlineBoxes, like empty editable blocks and bordered blocks.
        (WebCore::endOfLine): Ditto.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/select-line-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-line.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore/WebCore.vcproj
WebCore/editing/visible_units.cpp

index b1da667..96657e9 100644 (file)
@@ -1,5 +1,15 @@
 2006-12-06  Justin Garcia  <justin.garcia@apple.com>
 
+        Reviewed by darin
+        
+        <rdar://problem/4818134>
+        Crash in WebCore::selectRange when invoking WebView:insertNewLine in any empty content editable DIV.
+
+        * editing/selection/select-line-expected.txt: Added.
+        * editing/selection/select-line.html: Added.
+
+2006-12-06  Justin Garcia  <justin.garcia@apple.com>
+
         Reviewed by john
         
         <rdar://problem/4854869>
diff --git a/LayoutTests/editing/selection/select-line-expected.txt b/LayoutTests/editing/selection/select-line-expected.txt
new file mode 100644 (file)
index 0000000..38cc39f
--- /dev/null
@@ -0,0 +1,3 @@
+This tests for a crash when performing selectLine: inside an empty editable div. It cannot be run manually.
+
+
diff --git a/LayoutTests/editing/selection/select-line.html b/LayoutTests/editing/selection/select-line.html
new file mode 100644 (file)
index 0000000..2d10391
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests for a crash when performing selectLine: inside an empty editable div.  It cannot be run manually.</p>
+<div id="div" contenteditable="true"></div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+if (window.layoutTestController)
+    textInputController.doCommand("selectLine:");
+</script>
index e2e8d76..8225dcf 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-06  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by darin
+        
+        <rdar://problem/4818134>
+        Crash in WebCore::selectRange when invoking WebView:insertNewLine in any empty content editable DIV.
+
+        * WebCore.vcproj/WebCore/WebCore.vcproj: Removed RebalanceWhitespaceCommand.*.
+        * editing/visible_units.cpp:
+        (WebCore::startOfLine): There are VisiblePositions at offset 0 in blocks without
+        RootInlineBoxes, like empty editable blocks and bordered blocks.
+        (WebCore::endOfLine): Ditto.
+        
 2006-12-06  Kevin McCullough  <KMcCullough@apple.com>
 
         Reviewed by.
index 847333f..ddcb597 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath="..\..\editing\RebalanceWhitespaceCommand.cpp"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\editing\RebalanceWhitespaceCommand.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\..\editing\RemoveCSSPropertyCommand.cpp"
                                >
                        </File>
index a37c9f9..f3509c8 100644 (file)
@@ -283,11 +283,20 @@ static RootInlineBox *rootBoxForLine(const VisiblePosition &c)
     return box->root();
 }
 
-VisiblePosition startOfLine(const VisiblePosition &c)
+VisiblePosition startOfLine(const VisiblePositionc)
 {
+    if (c.isNull())
+        return VisiblePosition();
+        
     RootInlineBox *rootBox = rootBoxForLine(c);
-    if (!rootBox)
+    if (!rootBox) {
+        // There are VisiblePositions at offset 0 in blocks without
+        // RootInlineBoxes, like empty editable blocks and bordered blocks.
+        Position p = c.deepEquivalent();
+        if (p.node()->renderer() && p.node()->renderer()->isRenderBlock() && p.offset() == 0)
+            return c;
         return VisiblePosition();
+    }
     
     // Generated content (e.g. list markers and CSS :before and :after
     // pseudoelements) have no corresponding DOM element, and so cannot be
@@ -320,9 +329,18 @@ VisiblePosition startOfLine(const VisiblePosition &c)
 
 VisiblePosition endOfLine(const VisiblePosition& c)
 {
+    if (c.isNull())
+        return VisiblePosition();
+        
     RootInlineBox *rootBox = rootBoxForLine(c);
-    if (!rootBox)
+    if (!rootBox) {
+        // There are VisiblePositions at offset 0 in blocks without
+        // RootInlineBoxes, like empty editable blocks and bordered blocks.
+        Position p = c.deepEquivalent();
+        if (p.node()->renderer() && p.node()->renderer()->isRenderBlock() && p.offset() == 0)
+            return c;
         return VisiblePosition();
+    }
     
     // Generated content (e.g. list markers and CSS :before and :after
     // pseudoelements) have no corresponding DOM element, and so cannot be