RenderText {TEXT} at (0,28) size 682x56
text run at (0,28) width 682: "Should see the two lines in the red box. Each should contain \"A\" only."
text run at (0,56) width 620: "Insertion point should be blinking at the start of the second line."
- RenderBlock {DIV} at (0,264) size 784x50
- RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (0,264) size 784x60
+ RenderBlock {DIV} at (0,0) size 784x60 [border: (2px solid #FF0000)]
RenderBlock {P} at (2,2) size 780x28
RenderText {TEXT} at (0,0) size 17x28
text run at (0,0) width 17: "A"
- RenderBlock (anonymous) at (0,32) size 784x18
- RenderText {TEXT} at (0,0) size 12x18
- text run at (0,0) width 12: "A"
+ RenderBlock {P} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 17x28
+ text run at (0,0) width 17: "A"
selection is CARET:
-start: position 0 of child 2 {TEXT} of root {DIV}
-upstream: position 0 of child 2 {TEXT} of root {DIV}
-downstream: position 0 of child 2 {TEXT} of root {DIV}
+start: position 0 of child 1 {TEXT} of child 4 {P} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 4 {P} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 4 {P} of child 1 {DIV} of root {DIV}
RenderText {TEXT} at (0,28) size 682x56
text run at (0,28) width 682: "Should see the two lines in the red box. Each should contain \"A\" only."
text run at (0,56) width 620: "Insertion point should be blinking at the start of the second line."
- RenderBlock {DIV} at (0,264) size 784x50
- RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (0,264) size 784x60
+ RenderBlock {DIV} at (0,0) size 784x60 [border: (2px solid #FF0000)]
RenderBlock {P} at (2,2) size 780x28
RenderText {TEXT} at (0,0) size 17x28
text run at (0,0) width 17: "A"
RenderBlock (anonymous) at (2,30) size 780x0
- RenderBlock (anonymous) at (0,32) size 784x18
- RenderText {TEXT} at (0,0) size 12x18
- text run at (0,0) width 12: "A"
+ RenderBlock {P} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 17x28
+ text run at (0,0) width 17: "A"
selection is CARET:
-start: position 0 of child 2 {TEXT} of root {DIV}
-upstream: position 0 of child 2 {TEXT} of root {DIV}
-downstream: position 0 of child 2 {TEXT} of root {DIV}
+start: position 0 of child 1 {TEXT} of child 3 {P} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 3 {P} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 3 {P} of child 1 {DIV} of root {DIV}
--- /dev/null
+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 784x240 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x84
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 742x56
+ text run at (0,28) width 742: "Deleting when a selection starts at the beginning of a paragraph preceded by"
+ text run at (0,56) width 660: "another block and extends into the middle of a following paragraph."
+ RenderBlock {DIV} at (14,114) size 756x112
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 747x84
+ text run at (0,28) width 747: "Should see the three lines in the red box. First line should be \"one\". Next one"
+ text run at (0,56) width 167: "should be \"two\". "
+ text run at (167,56) width 573: "Next one should be \"ur\". Insertion point should be blinking"
+ text run at (0,84) width 265: "at the start of the third line."
+ RenderBlock {DIV} at (0,264) size 784x88
+ RenderBlock {DIV} at (0,0) size 784x88 [border: (2px solid #FF0000)]
+ RenderBlock (anonymous) at (2,2) size 780x28
+ RenderText {TEXT} at (0,0) size 35x28
+ text run at (0,0) width 35: "one"
+ RenderBlock {P} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 36x28
+ text run at (0,0) width 36: "two"
+ RenderBlock {P} at (2,58) size 780x28
+ RenderText {TEXT} at (0,0) size 20x28
+ text run at (0,0) width 20: "ur"
+selection is CARET:
+start: position 0 of child 1 {TEXT} of child 4 {P} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 4 {P} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 4 {P} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ moveSelectionForwardByLineCommand();
+ extendSelectionForwardByLineCommand();
+ for (i = 0; i < 2; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Deleting when a selection starts at the beginning of a
+paragraph preceded by another block and extends into the middle of a following paragraph.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Should see the three lines in the red box. First line should be "one". Next one should be "two". Next one should be "ur". Insertion point should be blinking at the start of the third line.
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+one
+<p style="margin-top: 0; margin-bottom: 0">two</p>
+<p style="margin-top: 0; margin-bottom: 0">three</p>
+<p style="margin-top: 0; margin-bottom: 0">four</p>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /dev/null
+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 784x240 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x84
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 690x56
+ text run at (0,28) width 690: "Deleting when a selection starts in the middle of the last paragraph and"
+ text run at (0,56) width 348: "extends to the end of that paragraph"
+ RenderBlock {DIV} at (14,114) size 756x112
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 738x84
+ text run at (0,28) width 738: "Should see the four lines in the red box. First line should be \"one\". Next one"
+ text run at (0,56) width 167: "should be \"two\". "
+ text run at (167,56) width 508: "Next one should be \"three\". Last one should be \"fo\"."
+ text run at (0,84) width 668: "Insertion point should be blinking at the start of the fourth (last) line."
+ RenderBlock {DIV} at (0,264) size 784x116
+ RenderBlock {DIV} at (0,0) size 784x116 [border: (2px solid #FF0000)]
+ RenderBlock (anonymous) at (2,2) size 780x28
+ RenderText {TEXT} at (0,0) size 35x28
+ text run at (0,0) width 35: "one"
+ RenderBlock {P} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 36x28
+ text run at (0,0) width 36: "two"
+ RenderBlock {P} at (2,58) size 780x28
+ RenderText {TEXT} at (0,0) size 49x28
+ text run at (0,0) width 49: "three"
+ RenderBlock {P} at (2,86) size 780x28
+ RenderText {TEXT} at (0,0) size 20x28
+ text run at (0,0) width 20: "fo"
+selection is CARET:
+start: position 2 of child 1 {TEXT} of child 6 {P} of child 1 {DIV} of root {DIV}
+upstream: position 2 of child 1 {TEXT} of child 6 {P} of child 1 {DIV} of root {DIV}
+downstream: position 2 of child 1 {TEXT} of child 6 {P} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ moveSelectionForwardByLineCommand();
+ moveSelectionForwardByLineCommand();
+ for (i = 0; i < 2; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 2; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Deleting when a selection starts in the middle of the last paragraph and extends to the end of that paragraph
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Should see the four lines in the red box. First line should be "one". Next one should be "two". Next one should be "three". Last one should be "fo". Insertion point should be blinking at the start of the fourth (last) line.
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+one
+<p style="margin-top: 0; margin-bottom: 0">two</p>
+<p style="margin-top: 0; margin-bottom: 0">three</p>
+<p style="margin-top: 0; margin-bottom: 0">four</p>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /dev/null
+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 784x240 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x84
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 742x56
+ text run at (0,28) width 742: "Deleting when a selection starts at the beginning of a paragraph preceded by"
+ text run at (0,56) width 665: "a text element and extends into the middle of a following paragraph."
+ RenderBlock {DIV} at (14,114) size 756x112
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 747x84
+ text run at (0,28) width 747: "Should see the three lines in the red box. First line should be \"one\". Next one"
+ text run at (0,56) width 153: "should be \"ee\". "
+ text run at (153,56) width 593: "Next one should be \"four\". Insertion point should be blinking"
+ text run at (0,84) width 286: "at the start of the second line."
+ RenderBlock {DIV} at (0,264) size 784x88
+ RenderBlock {DIV} at (0,0) size 784x88 [border: (2px solid #FF0000)]
+ RenderBlock (anonymous) at (2,2) size 780x28
+ RenderText {TEXT} at (0,0) size 35x28
+ text run at (0,0) width 35: "one"
+ RenderBlock {P} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 22x28
+ text run at (0,0) width 22: "ee"
+ RenderBlock {P} at (2,58) size 780x28
+ RenderText {TEXT} at (0,0) size 40x28
+ text run at (0,0) width 40: "four"
+selection is CARET:
+start: position 0 of child 1 {TEXT} of child 2 {P} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 2 {P} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 2 {P} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ extendSelectionForwardByLineCommand();
+ for (i = 0; i < 3; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Deleting when a selection starts at the beginning of a
+paragraph preceded by a text element and extends into the middle of a following paragraph.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Should see the three lines in the red box. First line should be "one". Next one should be "ee". Next one should be "four". Insertion point should be blinking at the start of the second line.
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+one
+<p style="margin-top: 0; margin-bottom: 0">two</p>
+<p style="margin-top: 0; margin-bottom: 0">three</p>
+<p style="margin-top: 0; margin-bottom: 0">four</p>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /dev/null
+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 784x324 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x112
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 743x56
+ text run at (0,28) width 743: "Deleting when a selection starts at the beginning of a text following a nested"
+ text run at (0,56) width 691: "block, and extends out of the enclosing block into the following block. "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,84) size 553x28
+ text run at (0,84) width 267: "FIXME: Currently broken! "
+ text run at (267,84) width 286: "See rdar://problem/4099839/."
+ RenderBlock {DIV} at (14,142) size 756x168
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 752x140
+ text run at (0,28) width 727: "Should see a total of five lines in the red box, with the third line inside of a"
+ text run at (0,56) width 675: "nested red box. First line should be \"one\". Next line should be \"two\". "
+ text run at (675,56) width 47: "Next"
+ text run at (0,84) width 737: "line should be \"cha cha cha\", inside of a nested red box. Next line should be"
+ text run at (0,112) width 52: "\"ur\". "
+ text run at (52,112) width 372: "The last line should be \"cha cha cha\". "
+ text run at (424,112) width 328: "Insertion point should be blinking"
+ text run at (0,140) width 340: "at the start of the fourth line (\"ur\")."
+ RenderBlock {DIV} at (0,348) size 784x148
+ RenderBlock {DIV} at (0,0) size 784x148 [border: (2px solid #FF0000)]
+ RenderBlock (anonymous) at (2,2) size 780x28
+ RenderText {TEXT} at (0,0) size 35x28
+ text run at (0,0) width 35: "one"
+ RenderBlock {DIV} at (2,30) size 780x28
+ RenderText {TEXT} at (0,0) size 36x28
+ text run at (0,0) width 36: "two"
+ RenderBlock {DIV} at (2,58) size 780x32 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (2,2) size 776x28
+ RenderText {TEXT} at (0,0) size 114x28
+ text run at (0,0) width 114: "cha cha cha"
+ RenderBlock (anonymous) at (2,30) size 776x0
+ RenderBlock {DIV} at (2,90) size 780x28
+ RenderText {TEXT} at (0,0) size 20x28
+ text run at (0,0) width 20: "ur"
+ RenderBlock {DIV} at (2,118) size 780x28
+ RenderText {TEXT} at (0,0) size 114x28
+ text run at (0,0) width 114: "cha cha cha"
+selection is CARET:
+start: position 0 of child 1 {TEXT} of child 5 {DIV} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 5 {DIV} of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 5 {DIV} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ moveSelectionForwardByLineCommand();
+ moveSelectionForwardByLineCommand();
+ extendSelectionForwardByLineCommand();
+ for (i = 0; i < 2; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Deleting when a selection starts at the beginning of a text following a nested block, and extends out of the enclosing block into the following block.
+<br>
+FIXME: Currently broken! See rdar://problem/4099839/.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Should see a total of five lines in the red box, with the third line inside of a nested red box. First line should be "one". Next line should be "two". Next line should be "cha cha cha", inside of a nested red box. Next line should be "ur". The last line should be "cha cha cha". Insertion point should be blinking at the start of the fourth line ("ur").
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+one
+<div>two</div>
+<div class="editing"><div>cha cha cha</div>three</div>
+<div>four</div><div>cha cha cha</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body></html>
\ No newline at end of file
+2005-04-26 David Harrison <harrison@apple.com>
+
+ Reviewed by Darin, Maciej.
+
+ <rdar://problem/4075576> Deleting text in new message borks content
+
+ Fixed by removing the methods that attempted to preserve the position. The idea
+ of preserving position is a very recent one, and turned out to not actually address
+ the problem it was intended to fix (see below). Further, is unclear how the position
+ could be preserved in a form that could be properly used later on. Therefore,
+ removing the code to work like before is the preferred alternative for this software
+ update. I've written <rdar://problem/4099839> to cover the bug that position
+ preservation was supposed to fix (but did not). Added layout tests for
+ both this bug and 4099839. Also, updated existing tests with correct expected results
+ (delete-at-paragraph-boundaries-003 and 004).
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::CompositeEditCommand::removeFullySelectedNode):
+ (khtml::CompositeEditCommand::removeChildrenInRange):
+ (khtml::DeleteSelectionCommand::handleGeneralDelete):
+ * khtml/editing/htmlediting.h:
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-003-expected.txt:
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-004-expected.txt:
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-007-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-007.html: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-008-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-008.html: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-009-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-009.html: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-010-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-at-paragraph-boundaries-010.html: Added.
+
2005-04-26 Darin Adler <darin@apple.com>
- fixed development builds
applyCommandToComposite(cmd);
}
-void CompositeEditCommand::removeFullySelectedNodePreservingPosition(NodeImpl *node, Position &pos)
+void CompositeEditCommand::removeFullySelectedNode(NodeImpl *node)
{
if (isTableStructureNode(node) || node == node->rootEditableElement()) {
// Do not remove an element of table structure; remove its contents.
while (child) {
NodeImpl *remove = child;
child = child->nextSibling();
- removeFullySelectedNodePreservingPosition(remove, pos);
+ removeFullySelectedNode(remove);
}
}
else {
- removeNodePreservingPosition(node, pos);
+ removeNode(node);
}
}
-void CompositeEditCommand::removeChildrenInRangePreservingPosition(NodeImpl *node, int from, int to, Position &pos)
+void CompositeEditCommand::removeChildrenInRange(NodeImpl *node, int from, int to)
{
NodeImpl *nodeToRemove = node->childNode(from);
for (int i = from; i < to; i++) {
ASSERT(nodeToRemove);
NodeImpl *next = nodeToRemove->nextSibling();
- removeNodePreservingPosition(nodeToRemove, pos);
+ removeNode(nodeToRemove);
nodeToRemove = next;
}
}
-void CompositeEditCommand::removeNodePreservingPosition(NodeImpl *removeChild, Position &pos)
-{
- if (removeChild == pos.node() || pos.node()->isAncestor(removeChild)) {
- pos = Position(removeChild->parentNode(), removeChild->nodeIndex());
- } else if (removeChild->parentNode() == pos.node() && removeChild->nodeIndex() < (unsigned)pos.offset()) {
- pos = Position(pos.node(), pos.offset() - 1);
- }
-
- EditCommandPtr cmd(new RemoveNodeCommand(document(), removeChild));
- applyCommandToComposite(cmd);
-}
-
-
void CompositeEditCommand::removeNode(NodeImpl *removeChild)
{
EditCommandPtr cmd(new RemoveNodeCommand(document(), removeChild));
if (!m_startNode->renderer() ||
(startOffset == 0 && m_downstreamEnd.offset() >= maxDeepOffset(m_startNode))) {
// just delete
- removeFullySelectedNodePreservingPosition(m_startNode, m_upstreamStart);
+ removeFullySelectedNode(m_startNode);
} else if (m_downstreamEnd.offset() - startOffset > 0) {
if (m_startNode->isTextNode()) {
// in a text node that needs to be trimmed
deleteTextFromNode(text, startOffset, m_downstreamEnd.offset() - startOffset);
m_trailingWhitespaceValid = false;
} else {
- removeChildrenInRangePreservingPosition(m_startNode, startOffset, m_downstreamEnd.offset(), m_upstreamStart);
+ removeChildrenInRange(m_startNode, startOffset, m_downstreamEnd.offset());
m_endingPosition = m_upstreamStart;
}
}
ASSERT(node->nodeIndex() < (unsigned)m_downstreamEnd.offset());
m_downstreamEnd = Position(m_downstreamEnd.node(), m_downstreamEnd.offset() - 1);
}
- removeFullySelectedNodePreservingPosition(node, m_upstreamStart);
+ removeFullySelectedNode(node);
node = nextNode;
} else {
NodeImpl *n = node->lastChild();
while (n && n->lastChild())
n = n->lastChild();
if (n == m_downstreamEnd.node() && m_downstreamEnd.offset() >= m_downstreamEnd.node()->caretMaxOffset()) {
- removeFullySelectedNodePreservingPosition(node, m_upstreamStart);
+ removeFullySelectedNode(node);
m_trailingWhitespaceValid = false;
node = 0;
}
m_upstreamStart = Position(m_downstreamEnd.node()->parentNode(), m_downstreamEnd.node()->nodeIndex());
}
- removeFullySelectedNodePreservingPosition(m_downstreamEnd.node(), m_upstreamStart);
+ removeFullySelectedNode(m_downstreamEnd.node());
m_trailingWhitespaceValid = false;
} else {
if (m_downstreamEnd.node()->isTextNode()) {
if (n)
offset = n->nodeIndex() + 1;
}
- removeChildrenInRangePreservingPosition(m_downstreamEnd.node(), offset, m_downstreamEnd.offset(), m_upstreamStart);
+ removeChildrenInRange(m_downstreamEnd.node(), offset, m_downstreamEnd.offset());
m_downstreamEnd = Position(m_downstreamEnd.node(), offset);
}
}
void joinTextNodes(DOM::TextImpl *text1, DOM::TextImpl *text2);
void rebalanceWhitespace();
void removeCSSProperty(DOM::CSSStyleDeclarationImpl *, int property);
- void removeFullySelectedNodePreservingPosition(DOM::NodeImpl *node, DOM::Position &pos);
+ void removeFullySelectedNode(DOM::NodeImpl *node);
void removeNodeAttribute(DOM::ElementImpl *, int attribute);
- void removeChildrenInRangePreservingPosition(DOM::NodeImpl *node, int from, int to, DOM::Position &pos);
+ void removeChildrenInRange(DOM::NodeImpl *node, int from, int to);
void removeNode(DOM::NodeImpl *removeChild);
- void removeNodePreservingPosition(DOM::NodeImpl *removeChild, DOM::Position &pos);
void removeNodePreservingChildren(DOM::NodeImpl *node);
void replaceTextInNode(DOM::TextImpl *node, long offset, long count, const DOM::DOMString &replacementText);
void setNodeAttribute(DOM::ElementImpl *, int attribute, const DOM::DOMString &);