Reviewed by John
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2005 17:55:08 +0000 (17:55 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2005 17:55:08 +0000 (17:55 +0000)
        Fix for this bug:

        <rdar://problem/3926142> REGRESSION (Mail): Deleting text decreases quote level

        * khtml/editing/htmlediting.cpp:
        (khtml::DeleteSelectionCommand::initializePositionData): Change test that will prevent block
        merging. End-of-line test was just wrong. Call new start-of and end-of paragraph functions
        added to visible_position files.
        (khtml::DeleteSelectionCommand::moveNodesAfterNode): Add tests for BR elements, which makes
        tests to determine when to stop moving nodes more complete and correct. Also improved comments.
        * khtml/editing/visible_position.cpp:
        (khtml::isFirstVisiblePositionInParagraph): New function.
        (khtml::isLastVisiblePositionInParagraph): New function.
        * khtml/editing/visible_position.h: Update header accordingly.
        * layout-tests/editing/deleting/delete-block-merge-contents-002-expected.txt: New results, slightly different from former
        results but still correct.
        * layout-tests/editing/deleting/delete-block-merge-contents-007-expected.txt: Ditto.
        * layout-tests/editing/deleting/delete-block-merge-contents-018-expected.txt: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-018.html: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-019-expected.txt: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-019.html: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-020-expected.txt: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-020.html: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-021-expected.txt: Added.
        * layout-tests/editing/deleting/delete-block-merge-contents-021.html: Added.
        * layout-tests/editing/deleting/delete-line-014-expected.txt: These new results are actually better, and fix a bug.

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

15 files changed:
LayoutTests/editing/deleting/delete-block-merge-contents-002-expected.txt
LayoutTests/editing/deleting/delete-block-merge-contents-007-expected.txt
LayoutTests/editing/deleting/delete-block-merge-contents-018-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-018.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-019-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-019.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-020-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-020.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-021-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-021.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-line-014-expected.txt
WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting.cpp
WebCore/khtml/editing/visible_position.cpp
WebCore/khtml/editing/visible_position.h

index c84eb0edaa2381dbe1f547ff83fae100b7a197fd..83e52017ca0e7391e3bbd6be22ac9922ce58744b 100644 (file)
@@ -3,14 +3,15 @@ layer 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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
-        RenderBlock {DIV} at (14,14) size 756x28
+      RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
+        RenderBlock {DIV} at (14,14) size 756x56
           RenderText {TEXT} at (0,0) size 40x28
             text run at (0,0) width 40: "One"
           RenderText {TEXT} at (40,0) size 44x28
             text run at (40,0) width 44: "Two"
-          RenderText {TEXT} at (84,0) size 63x28
-            text run at (84,0) width 63: " Three"
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {TEXT} at (0,28) size 57x28
+            text run at (0,28) width 57: "Three"
 selection is CARET:
 start:      position 3 of child 1 {TEXT} of child 2 {DIV} of root {DIV}
 upstream:   position 3 of child 1 {TEXT} of child 2 {DIV} of root {DIV}
index fbe8b153c4ea2aded44a4f6b4229c62bb5899d6c..69990a92533703b29287b82fbd5fda0612fbc2bf 100644 (file)
@@ -10,11 +10,12 @@ layer at (0,0) size 800x600
               text run at (0,0) width 40: "One"
             RenderText {TEXT} at (40,0) size 44x28
               text run at (40,0) width 44: "Two"
-            RenderBR {BR} at (0,0) size 0x0
           RenderBlock {DIV} at (0,28) size 756x28
-            RenderText {TEXT} at (0,0) size 57x28
-              text run at (0,0) width 57: "Three"
-            RenderBR {BR} at (0,0) size 0x0
+            RenderBlock (anonymous) at (0,0) size 756x0
+            RenderBlock {DIV} at (0,0) size 756x28
+              RenderText {TEXT} at (0,0) size 57x28
+                text run at (0,0) width 57: "Three"
+              RenderBR {BR} at (0,0) size 0x0
           RenderBlock (anonymous) at (0,56) size 756x28
             RenderText {TEXT} at (0,0) size 45x28
               text run at (0,0) width 45: "Four"
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-018-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-018-expected.txt
new file mode 100644 (file)
index 0000000..b5c9319
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 {DIV} at (0,0) size 784x84 [border: (2px solid #0000FF)]
+        RenderText {TEXT} at (14,14) size 726x56
+          text run at (14,14) width 726: "Should see \"Test OK\" in top red box, followed by \"...more text\", in its own"
+          text run at (14,42) width 79: "red box."
+      RenderBlock {DIV} at (0,108) size 784x112
+        RenderBlock {DIV} at (0,0) size 784x112 [border: (2px solid #FF0000)]
+          RenderBlock (anonymous) at (14,14) size 756x28
+            RenderText {TEXT} at (0,0) size 15x28
+              text run at (0,0) width 15: "T"
+            RenderText {TEXT} at (15,0) size 67x28
+              text run at (15,0) width 67: "est OK"
+          RenderBlock {DIV} at (14,42) size 756x56 [border: (2px solid #FF0000)]
+            RenderText {TEXT} at (14,14) size 111x28
+              text run at (14,14) width 111: "...more text"
+selection is CARET:
+start:      position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream:   position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-018.html b/LayoutTests/editing/deleting/delete-block-merge-contents-018.html
new file mode 100644 (file)
index 0000000..3f0b11a
--- /dev/null
@@ -0,0 +1,51 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    moveSelectionForwardByCharacterCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByCharacterCommand();
+    deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body contenteditable="true">
+<div class="explanation">
+Should see "Test OK" in top red box, followed by "...more text", in its own red box.
+</div>
+
+<div id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+T
+<div id="test" class="editing">
+xest OK<br>...more text
+</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-019-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-019-expected.txt
new file mode 100644 (file)
index 0000000..843bc3c
--- /dev/null
@@ -0,0 +1,20 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 {DIV} at (0,0) size 784x56 [border: (2px solid #0000FF)]
+        RenderText {TEXT} at (14,14) size 652x28
+          text run at (14,14) width 652: "Should see \"X\" in top red box, followed by \"X\", in its own red box."
+      RenderBlock {DIV} at (0,80) size 784x112
+        RenderBlock {DIV} at (0,0) size 784x112 [border: (2px solid #FF0000)]
+          RenderBlock (anonymous) at (14,14) size 756x28
+            RenderText {TEXT} at (0,0) size 17x28
+              text run at (0,0) width 17: "X"
+          RenderBlock {DIV} at (14,42) size 756x56 [border: (2px solid #FF0000)]
+            RenderText {TEXT} at (14,14) size 17x28
+              text run at (14,14) width 17: "X"
+selection is CARET:
+start:      position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream:   position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+downstream: position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-019.html b/LayoutTests/editing/deleting/delete-block-merge-contents-019.html
new file mode 100644 (file)
index 0000000..74f8a97
--- /dev/null
@@ -0,0 +1,51 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    moveSelectionForwardByCharacterCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByLineCommand();
+    deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body contenteditable="true">
+<div class="explanation">
+Should see "X" in top red box, followed by "X", in its own red box.
+</div>
+
+<div id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+X
+<div id="test" class="editing">
+should not see this content<br>X
+</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-020-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-020-expected.txt
new file mode 100644 (file)
index 0000000..54969ff
--- /dev/null
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 {DIV} at (0,0) size 784x56 [border: (2px solid #0000FF)]
+        RenderText {TEXT} at (14,14) size 356x28
+          text run at (14,14) width 356: "Should see \"XX\" in a single red box."
+      RenderBlock {DIV} at (0,80) size 784x56
+        RenderBlock {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+          RenderText {TEXT} at (14,14) size 17x28
+            text run at (14,14) width 17: "X"
+          RenderText {TEXT} at (31,14) size 17x28
+            text run at (31,14) width 17: "X"
+selection is CARET:
+start:      position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream:   position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-020.html b/LayoutTests/editing/deleting/delete-block-merge-contents-020.html
new file mode 100644 (file)
index 0000000..f3c0f4a
--- /dev/null
@@ -0,0 +1,52 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    moveSelectionForwardByCharacterCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByCharacterCommand();
+    deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body contenteditable="true">
+<div class="explanation">
+Should see "XX" in a single red box.
+</div>
+
+<div id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+X
+<div id="test" class="editing">
+should not see this content<br>XX
+</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-021-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-021-expected.txt
new file mode 100644 (file)
index 0000000..650a18d
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 {DIV} at (0,0) size 784x84 [border: (2px solid #0000FF)]
+        RenderText {TEXT} at (14,14) size 730x56
+          text run at (14,14) width 730: "Should see \"XX\" in a top red box, and another \"XX\" in a red box inside the"
+          text run at (14,42) width 45: "first."
+      RenderBlock {DIV} at (0,108) size 784x112
+        RenderBlock {DIV} at (0,0) size 784x112 [border: (2px solid #FF0000)]
+          RenderBlock (anonymous) at (14,14) size 756x28
+            RenderText {TEXT} at (0,0) size 17x28
+              text run at (0,0) width 17: "X"
+            RenderText {TEXT} at (17,0) size 17x28
+              text run at (17,0) width 17: "X"
+          RenderBlock {DIV} at (14,42) size 756x56 [border: (2px solid #FF0000)]
+            RenderText {TEXT} at (14,14) size 34x28
+              text run at (14,14) width 34: "XX"
+selection is CARET:
+start:      position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream:   position 2 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-021.html b/LayoutTests/editing/deleting/delete-block-merge-contents-021.html
new file mode 100644 (file)
index 0000000..861fd44
--- /dev/null
@@ -0,0 +1,52 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    moveSelectionForwardByCharacterCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByLineCommand();
+    extendSelectionForwardByCharacterCommand();
+    deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body contenteditable="true">
+<div class="explanation">
+Should see "XX" in a top red box, and another "XX" in a red box inside the first.
+</div>
+
+<div id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+X
+<div id="test" class="editing">
+should not see this content<br>XX<br>XX
+</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
index 860dd5370b4c913fdd6ed81c7545ead9d9cd37e1..75ab8412e41865dc6ff14c776f0a812454f15fc1 100644 (file)
@@ -3,15 +3,16 @@ layer 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 {DIV} at (0,0) size 784x56
+      RenderBlock {DIV} at (0,0) size 784x28
         RenderText {TEXT} at (0,0) size 15x28
           text run at (0,0) width 15: "T"
-        RenderBR {BR} at (0,0) size 0x0
-        RenderText {TEXT} at (0,28) size 197x28
-          text run at (0,28) width 197: "in the affairs of men"
+      RenderBlock (anonymous) at (0,28) size 784x28
+        RenderText {TEXT} at (0,0) size 197x28
+          text run at (0,0) width 197: "in the affairs of men"
+        RenderText {TEXT} at (0,0) size 0x0
+        RenderText {TEXT} at (0,0) size 0x0
         RenderText {TEXT} at (0,0) size 0x0
-      RenderBlock (anonymous) at (0,56) size 784x0
 selection is CARET:
 start:      position 1 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
 upstream:   position 1 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
-downstream: position 0 of child 2 {BR} of child 1 {DIV} of root {BODY}
+downstream: position 1 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
index 428fadb09a9a74581adcca1039ae1d19abc71174..acd8c8d2b18f484da786d9fb9d2ff45d163c2b49 100644 (file)
@@ -1,3 +1,34 @@
+2005-01-12  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by John
+
+        Fix for this bug:
+        
+        <rdar://problem/3926142> REGRESSION (Mail): Deleting text decreases quote level
+
+        * khtml/editing/htmlediting.cpp:
+        (khtml::DeleteSelectionCommand::initializePositionData): Change test that will prevent block
+        merging. End-of-line test was just wrong. Call new start-of and end-of paragraph functions
+        added to visible_position files.
+        (khtml::DeleteSelectionCommand::moveNodesAfterNode): Add tests for BR elements, which makes
+        tests to determine when to stop moving nodes more complete and correct. Also improved comments.
+        * khtml/editing/visible_position.cpp:
+        (khtml::isFirstVisiblePositionInParagraph): New function.
+        (khtml::isLastVisiblePositionInParagraph): New function.
+        * khtml/editing/visible_position.h: Update header accordingly.
+        * layout-tests/editing/deleting/delete-block-merge-contents-002-expected.txt: New results, slightly different from former
+        results but still correct.
+        * layout-tests/editing/deleting/delete-block-merge-contents-007-expected.txt: Ditto.
+        * layout-tests/editing/deleting/delete-block-merge-contents-018-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-018.html: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-019-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-019.html: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-020-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-020.html: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-021-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-block-merge-contents-021.html: Added.
+        * layout-tests/editing/deleting/delete-line-014-expected.txt: These new results are actually better, and fix a bug.
+
 2005-01-11  Richard Williamson   <rjw@apple.com>
 
        Fixed 3922875.  Fall back to DOM object is EMBED element
index 2b448731365d548b449294bce5130723bbf48390..d00f0bef9d83cf18096259fd77a5d7687083a456 100644 (file)
@@ -1628,7 +1628,7 @@ void DeleteSelectionCommand::initializePositionData()
     // This is one of the tests that determines if block merging of content needs to be done.
     //
     VisiblePosition visibleEnd(end);
-    if (isFirstVisiblePositionOnLine(visibleEnd)) {
+    if (isFirstVisiblePositionInParagraph(visibleEnd) || isLastVisiblePositionInParagraph(visibleEnd)) {
         Position previousLineStart = previousLinePosition(visibleEnd, DOWNSTREAM, 0).deepEquivalent();
         if (previousLineStart.isNull() || RangeImpl::compareBoundaryPoints(previousLineStart, m_downstreamStart) >= 0)
             m_mergeBlocksAfterDelete = false;
@@ -1876,9 +1876,9 @@ void DeleteSelectionCommand::fixupWhitespace()
 }
 
 // This function moves nodes in the block containing startNode to dstBlock, starting
-// from startNode and proceeding to the end of the block. Nodes in the block containing
+// from startNode and proceeding to the end of the paragraph. Nodes in the block containing
 // startNode that appear in document order before startNode are not moved.
-// This function is an important helper for deleting selections that cross block
+// This function is an important helper for deleting selections that cross paragraph
 // boundaries.
 void DeleteSelectionCommand::moveNodesAfterNode()
 {
@@ -1920,11 +1920,19 @@ void DeleteSelectionCommand::moveNodesAfterNode()
         NodeImpl *moveNode = node;
         node = node->nextSibling();
         removeNode(moveNode);
+        if (moveNode->id() == ID_BR && !moveNode->renderer()) {
+            // Just remove this node, and don't put it back.
+            // If the BR was not rendered (since it was at the end of a block, for instance), 
+            // putting it back in the document might make it appear, and that is not desirable.
+            break;
+        }
         if (refNode == rootNode)
             insertNodeAt(moveNode, refNode, 0);
         else
             insertNodeAfter(moveNode, refNode);
         refNode = moveNode;
+        if (moveNode->id() == ID_BR)
+            break;
     }
 
     // If the startBlock no longer has any kids, we may need to deal with adding a BR
@@ -1942,6 +1950,7 @@ void DeleteSelectionCommand::moveNodesAfterNode()
     document()->updateLayout();
     if (!startBlock->renderer() || !startBlock->renderer()->firstChild()) {
         removeNode(startBlock);
+        document()->updateLayout();
         if (refNode->renderer() && refNode->renderer()->inlineBox() && refNode->renderer()->inlineBox()->nextOnLineExists()) {
             insertNodeAfter(createBreakElement(document()), refNode);
         }
index 98098ec57d70684f8b60941e79141d3b85e55489..d98871cde02c0482688ef34a97a3688eddb3cdea 100644 (file)
@@ -531,6 +531,14 @@ bool isFirstVisiblePositionOnLine(const VisiblePosition &pos)
     return previous.isNull() || visiblePositionsOnDifferentLines(pos, previous);
 }
 
+bool isFirstVisiblePositionInParagraph(const VisiblePosition &pos)
+{
+    if (pos.isNull())
+        return false;
+
+    return pos.deepEquivalent().upstream(StayInBlock).node()->id() == ID_BR || isFirstVisiblePositionInBlock(pos);
+}
+
 bool isFirstVisiblePositionInBlock(const VisiblePosition &pos)
 {
     if (pos.isNull())
@@ -558,6 +566,14 @@ bool isLastVisiblePositionOnLine(const VisiblePosition &pos)
     return next.isNull() || visiblePositionsOnDifferentLines(pos, next);
 }
 
+bool isLastVisiblePositionInParagraph(const VisiblePosition &pos)
+{
+    if (pos.isNull())
+        return false;
+
+    return pos.deepEquivalent().downstream(StayInBlock).node()->id() == ID_BR || isLastVisiblePositionInBlock(pos);
+}
+
 bool isLastVisiblePositionInBlock(const VisiblePosition &pos)
 {
     if (pos.isNull())
index d9ea7c3df69ab69b6e7ad075c096292136405a7e..79571fc3bd9fc5559ea57bb1a6b42292a4863b30 100644 (file)
@@ -121,9 +121,11 @@ VisiblePosition endVisiblePosition(const DOM::RangeImpl *);
 bool visiblePositionsOnDifferentLines(const VisiblePosition &, const VisiblePosition &);
 bool visiblePositionsInDifferentBlocks(const VisiblePosition &, const VisiblePosition &);
 bool isFirstVisiblePositionOnLine(const VisiblePosition &);
+bool isFirstVisiblePositionInParagraph(const VisiblePosition &);
 bool isFirstVisiblePositionInBlock(const VisiblePosition &);
 bool isFirstVisiblePositionInNode(const VisiblePosition &, const DOM::NodeImpl *);
 bool isLastVisiblePositionOnLine(const VisiblePosition &);
+bool isLastVisiblePositionInParagraph(const VisiblePosition &);
 bool isLastVisiblePositionInBlock(const VisiblePosition &);
 bool isLastVisiblePositionInNode(const VisiblePosition &, const DOM::NodeImpl *);