Reviewed by harrison
<rdar://problem/
4916235>
<rdar://problem/
4857269>
<rdar://problem/
4916583>
<rdar://problem/
4928635>
Fixed and removed FIXME:
* editing/execCommand/create-list-from-range-selection-expected.checksum:
* editing/execCommand/create-list-from-range-selection-expected.png:
* editing/execCommand/create-list-from-range-selection-expected.txt:
* editing/execCommand/create-list-from-range-selection.html:
Added:
* editing/deleting/
4916235-1-expected.txt: Added.
* editing/deleting/
4916235-1.html: Added.
* editing/execCommand/
4916235-expected.txt: Added.
* editing/execCommand/
4916235.html: Added.
* editing/execCommand/
4916583-expected.checksum: Added.
* editing/execCommand/
4916583-expected.png: Added.
* editing/execCommand/
4916583-expected.txt: Added.
* editing/execCommand/
4916583.html: Added.
* editing/execCommand/
4928635-expected.txt: Added.
* editing/execCommand/
4928635.html: Added.
Equivalent trees:
* editing/execCommand/remove-list-item-1-expected.txt:
* editing/execCommand/remove-list-items-expected.txt:
* editing/execCommand/switch-list-type-expected.txt:
Introduced an extraneous newline because of the poor substitute for
VisiblePosition creation in shouldEmitNewlineAfterNode:
* dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt:
* dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt:
* dom/xhtml/level3/core/nodeinsertbefore09-expected.txt:
WebCore:
Reviewed by harrison
<rdar://problem/
4916235>
eBay Editor: Crash occurs at WebCore::Range::startPosition() after applying ordered list styling to selected text
<rdar://problem/
4857269>
REGRESSION: editing/execCommand/create-list-from-range-selection.html no longer works as intended
<rdar://problem/
4916583>
eBay Editor: Removing a indent from a list item actually deletes the list item instead
<rdar://problem/
4928635>
designMode outdent causes crash (11750)
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs): Fixed br insertion
after the pruning of empty containers left over after the paragraph
to move is removed.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::DeleteSelectionCommand): There are
bugs that leave the wrong number of line breaks after a deletion
that expands to include special elements (lists/tables). Added
a workaround so that moveParagraphs can avoid these until they
are fixed.
(WebCore::DeleteSelectionCommand::initializeStartEnd): Ditto.
(WebCore::DeleteSelectionCommand::initializePositionData): Ditto.
* editing/DeleteSelectionCommand.h:
* editing/TextIterator.cpp:
(WebCore::TextIterator::advance): We used to not call exitNode for
ancestors of a node where the next node in a pre-order traversal is
the ranges's pastEndNode(). This is only correct for ancestors that
contain the end of the range.
(WebCore::shouldEmitNewlineAfterNode): Added, we should only emit newlines
after blocks that have VisiblePositions after them. VisiblePosition creation
though is too expensive to do here, what I added here is an OK substitute.
(WebCore::shouldEmitNewlineBeforeNode): Added. No special logic yet.
(WebCore::TextIterator::handleNonTextNode): Call shouldEmitNewlineBeforeNode.
(WebCore::TextIterator::exitNode): Call shouldEmitNewlineAfterNode.
(WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode): Call
shouldEmitNewlineAfterNode.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19088
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-01-23 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ <rdar://problem/4916235>
+ <rdar://problem/4857269>
+ <rdar://problem/4916583>
+ <rdar://problem/4928635>
+
+ Fixed and removed FIXME:
+ * editing/execCommand/create-list-from-range-selection-expected.checksum:
+ * editing/execCommand/create-list-from-range-selection-expected.png:
+ * editing/execCommand/create-list-from-range-selection-expected.txt:
+ * editing/execCommand/create-list-from-range-selection.html:
+ Added:
+ * editing/deleting/4916235-1-expected.txt: Added.
+ * editing/deleting/4916235-1.html: Added.
+ * editing/execCommand/4916235-expected.txt: Added.
+ * editing/execCommand/4916235.html: Added.
+ * editing/execCommand/4916583-expected.checksum: Added.
+ * editing/execCommand/4916583-expected.png: Added.
+ * editing/execCommand/4916583-expected.txt: Added.
+ * editing/execCommand/4916583.html: Added.
+ * editing/execCommand/4928635-expected.txt: Added.
+ * editing/execCommand/4928635.html: Added.
+ Equivalent trees:
+ * editing/execCommand/remove-list-item-1-expected.txt:
+ * editing/execCommand/remove-list-items-expected.txt:
+ * editing/execCommand/switch-list-type-expected.txt:
+ Introduced an extraneous newline because of the poor substitute for
+ VisiblePosition creation in shouldEmitNewlineAfterNode:
+ * dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt:
+ * dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt:
+ * dom/xhtml/level3/core/nodeinsertbefore09-expected.txt:
+
+
2007-01-23 Mark Rowe <mrowe@apple.com>
Reviewed by Adele.
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition12
Status error
Message TypeError: Value undefined (result of expression doc.compareDocumentPosition) is not object.
+
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition17
Status error
Message TypeError: Value undefined (result of expression pi1.compareDocumentPosition) is not object.
+
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeinsertbefore09
Status Success
+
--- /dev/null
+This tests for a bug in moveParagraphs that would cause an empty paragraph to collapse.
+
+There should be an empty paragraph below this one.
+
+There should be an empty paragraph above this one.
+
--- /dev/null
+<p>This tests for a bug in moveParagraphs that would cause an empty paragraph to collapse.</p>
+<div id="div" contenteditable="true">There should be an empty paragraph below this one.<div>There should be an empty paragraph below this one.</div><br>There should be an empty paragraph above this one.</div>
+
+<script>
+if (window.layoutTestController)
+ window.layoutTestController.dumpAsText();
+
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "character");
+sel.modify("extend", "forward", "line");
+document.execCommand("Delete");
+</script>
--- /dev/null
+This tests for a crash when performing InsertOrderedList on an unordered list item. You should see 'foo' and 'bar' each in their own ordered list items.
+
+foo
+bar
+
--- /dev/null
+<p>This tests for a crash when performing InsertOrderedList on an unordered list item. You should see 'foo' and 'bar' each in their own ordered list items.</p>
+<div id="div" contenteditable="true"><ul><li id="li1">foo</li><li id="li2">bar<br></li></ul></div>
+
+<script>
+if (window.layoutTestController)
+ window.layoutTestController.dumpAsText();
+
+var li = document.getElementById("li1");
+var sel = window.getSelection();
+
+sel.setBaseAndExtent(li, 0, li, li.childNodes.length);
+document.execCommand("InsertOrderedList");
+
+li = document.getElementById("li2");
+sel.setBaseAndExtent(li, 0, li, li.childNodes.length);
+document.execCommand("InsertOrderedList");
+</script>
--- /dev/null
+7a06fe9b1d6b1f4db98f589322292462
\ No newline at end of file
--- /dev/null
+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 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 767x18
+ text run at (0,0) width 368: "This tests for a bug when outdenting an indented list item. "
+ text run at (368,0) width 399: "You should see 'foo' and 'bar' each in their own list item below."
+ RenderBlock {DIV} at (0,34) size 784x36
+ RenderBlock {UL} at (0,0) size 784x36
+ RenderListItem {LI} at (40,0) size 744x18
+ RenderListMarker at (-17,0) size 7x18: bullet
+ RenderText {#text} at (0,0) size 21x18
+ text run at (0,0) width 21: "foo"
+ RenderListItem {LI} at (40,18) size 744x18
+ RenderListMarker at (-17,0) size 7x18: bullet
+ RenderText {#text} at (0,0) size 20x18
+ text run at (0,0) width 20: "bar"
+caret: position 0 of child 0 {#text} of child 1 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
--- /dev/null
+<p>This tests for a bug when outdenting an indented list item. You should see 'foo' and 'bar' each in their own list item below.</p>
+<div id="div" contenteditable="true"><ul><li>foo</li><ul><li id="li">bar<br></li></ul></ul></div>
+
+<script>
+var li = document.getElementById("li");
+var sel = window.getSelection();
+
+sel.setPosition(li, 0);
+document.execCommand("Outdent");
+</script>
--- /dev/null
+This tests for a crash when outdenting an indented paragraph. You should see 'foo' in a single level list item.
+
+foo
+
--- /dev/null
+<p>This tests for a crash when outdenting an indented paragraph. You should see 'foo' in a single level list item.</p>
+<div contenteditable="true"><ul><ul><li id="li">foo<br></li></ul></ul></div>
+
+<script>
+if (window.layoutTestController)
+ window.layoutTestController.dumpAsText();
+
+var li = document.getElementById("li");
+var sel = window.getSelection();
+
+sel.setPosition(li, li.childNodes.length);
+document.execCommand("Outdent");
+</script>
-faa44b9a0e599d64d8ad837d19d613b9
\ No newline at end of file
+df73fe3bb7ebfa11d32d699f1d302fba
\ No newline at end of file
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x576
- RenderBlock {P} at (0,0) size 784x72
- RenderText {#text} at (0,0) size 636x18
- text run at (0,0) width 636: "This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content. "
- RenderInline {B} at (0,0) size 781x72
- RenderText {#text} at (636,0) size 781x72
- text run at (636,0) width 138: "This test used to end"
- text run at (0,18) width 781: "with a flat list from 1 to 6, with a selection extending from just before the last \"o\" in \"1. asdfoo\" to just after the \"a\""
- text run at (0,36) width 538: "in \"6. baz\". This result changed with John's rangeCompliantEquivalent fixes in"
- text run at (0,54) width 400: "CompositeEditCommand::moveParagraphs on 11/30/2006."
- RenderBlock {DIV} at (0,88) size 784x126
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 632x18
+ text run at (0,0) width 632: "This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content."
+ RenderBlock {DIV} at (0,34) size 784x108
RenderBlock (anonymous) at (0,0) size 784x0
- RenderBlock {OL} at (0,0) size 784x126
- RenderListItem {LI} at (40,0) size 744x36
- RenderBlock (anonymous) at (0,0) size 744x18
- RenderListMarker at (-20,0) size 16x18: "1"
- RenderBlock {OL} at (0,18) size 744x18
- RenderListItem {LI} at (40,0) size 704x18
- RenderListMarker at (-20,0) size 16x18: "1"
- RenderText {#text} at (0,0) size 21x18
- text run at (0,0) width 21: "asd"
- RenderInline {SPAN} at (0,0) size 21x18
- RenderText {#text} at (21,0) size 21x18
- text run at (21,0) width 21: "foo"
- RenderListItem {LI} at (40,36) size 744x18
+ RenderBlock {OL} at (0,0) size 784x108
+ RenderListItem {LI} at (40,0) size 744x18
+ RenderListMarker at (-20,0) size 16x18: "1"
+ RenderText {#text} at (0,0) size 21x18
+ text run at (0,0) width 21: "asd"
+ RenderInline {SPAN} at (0,0) size 21x18
+ RenderText {#text} at (21,0) size 21x18
+ text run at (21,0) width 21: "foo"
+ RenderListItem {LI} at (40,18) size 744x18
RenderListMarker at (-20,0) size 16x18: "2"
RenderText {#text} at (0,0) size 20x18
text run at (0,0) width 20: "bar"
- RenderListItem {LI} at (40,54) size 744x18
+ RenderListItem {LI} at (40,36) size 744x18
RenderListMarker at (-20,0) size 16x18: "3"
RenderText {#text} at (0,0) size 22x18
text run at (0,0) width 22: "baz"
- RenderListItem {LI} at (40,72) size 744x18
+ RenderListItem {LI} at (40,54) size 744x18
RenderListMarker at (-20,0) size 16x18: "4"
RenderText {#text} at (0,0) size 21x18
text run at (0,0) width 21: "foo"
- RenderListItem {LI} at (40,90) size 744x18
+ RenderListItem {LI} at (40,72) size 744x18
RenderListMarker at (-20,0) size 16x18: "5"
RenderText {#text} at (0,0) size 20x18
text run at (0,0) width 20: "bar"
- RenderListItem {LI} at (40,108) size 744x18
+ RenderListItem {LI} at (40,90) size 744x18
RenderListMarker at (-20,0) size 16x18: "6"
RenderInline {SPAN} at (0,0) size 22x18
RenderText {#text} at (0,0) size 22x18
text run at (0,0) width 22: "baz"
- RenderBlock (anonymous) at (0,142) size 784x0
-caret: position 2 of child 0 {#text} of child 0 {SPAN} of child 5 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+ RenderBlock (anonymous) at (0,124) size 784x0
+selection start: position 2 of child 0 {#text} of child 1 {SPAN} of child 0 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end: position 2 of child 0 {#text} of child 0 {SPAN} of child 5 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
if (window.layoutTestController)
layoutTestController.dumpEditingCallbacks();
</script>
-<p>This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content.
-<b>This test used to end with a flat list from 1 to 6, with a selection extending from just before the last "o"
-in "1. asdfoo" to just after the "a" in "6. baz". This result changed with John's rangeCompliantEquivalent
-fixes in CompositeEditCommand::moveParagraphs on 11/30/2006.</b></p>
+<p>This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content.</p>
<div id="test" contenteditable="true">asd<span id="start">foo</span><br><ul><li>bar</li></ul>baz<br>foo<ol><li>bar</li></ol><span id="end">baz</span></div>
<script>
var s = window.getSelection();
text run at (0,0) width 288: "Outdenting a sublist should remove one level."
RenderBlock {DIV} at (0,34) size 784x18
RenderBlock {UL} at (0,0) size 784x18
- RenderBlock (anonymous) at (40,0) size 744x0
RenderListItem {LI} at (40,0) size 744x18
RenderListMarker at (-17,0) size 7x18: bullet
RenderText {#text} at (0,0) size 21x18
RenderInline {SPAN} at (0,0) size 170x18
RenderText {#text} at (0,18) size 170x18
text run at (0,18) width 170: "This should not be in a list."
-caret: position 0 of child 0 {#text} of child 15 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {#text} of child 16 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
RenderText {#text} at (0,0) size 170x18
text run at (0,0) width 170: "This should not be in a list."
RenderBR {BR} at (170,14) size 0x0
+ RenderText {#text} at (0,0) size 0x0
RenderInline {SPAN} at (0,0) size 0x0
RenderBlock (anonymous) at (0,316) size 784x18
RenderBlock {OL} at (0,0) size 784x18
text run at (0,0) width 206: "This should be in an ordered list."
RenderBlock (anonymous) at (0,350) size 784x0
RenderInline {SPAN} at (0,0) size 0x0
-caret: position 0 of child 0 {#text} of child 0 {SPAN} of child 0 {LI} of child 0 {OL} of child 10 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {#text} of child 0 {SPAN} of child 0 {LI} of child 0 {OL} of child 11 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+2007-01-24 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ <rdar://problem/4916235>
+ eBay Editor: Crash occurs at WebCore::Range::startPosition() after applying ordered list styling to selected text
+ <rdar://problem/4857269>
+ REGRESSION: editing/execCommand/create-list-from-range-selection.html no longer works as intended
+ <rdar://problem/4916583>
+ eBay Editor: Removing a indent from a list item actually deletes the list item instead
+ <rdar://problem/4928635>
+ designMode outdent causes crash (11750)
+
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::moveParagraphs): Fixed br insertion
+ after the pruning of empty containers left over after the paragraph
+ to move is removed.
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::DeleteSelectionCommand::DeleteSelectionCommand): There are
+ bugs that leave the wrong number of line breaks after a deletion
+ that expands to include special elements (lists/tables). Added
+ a workaround so that moveParagraphs can avoid these until they
+ are fixed.
+ (WebCore::DeleteSelectionCommand::initializeStartEnd): Ditto.
+ (WebCore::DeleteSelectionCommand::initializePositionData): Ditto.
+ * editing/DeleteSelectionCommand.h:
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::advance): We used to not call exitNode for
+ ancestors of a node where the next node in a pre-order traversal is
+ the ranges's pastEndNode(). This is only correct for ancestors that
+ contain the end of the range.
+ (WebCore::shouldEmitNewlineAfterNode): Added, we should only emit newlines
+ after blocks that have VisiblePositions after them. VisiblePosition creation
+ though is too expensive to do here, what I added here is an OK substitute.
+ (WebCore::shouldEmitNewlineBeforeNode): Added. No special logic yet.
+ (WebCore::TextIterator::handleNonTextNode): Call shouldEmitNewlineBeforeNode.
+ (WebCore::TextIterator::exitNode): Call shouldEmitNewlineAfterNode.
+ (WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode): Call
+ shouldEmitNewlineAfterNode.
+
2007-01-24 Darin Adler <darin@apple.com>
Reviewed by Mark Rowe.
}
VisiblePosition beforeParagraph = startOfParagraphToMove.previous();
+ VisiblePosition afterParagraph(endOfParagraphToMove.next());
// We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
// When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.
RefPtr<DocumentFragment> fragment = startOfParagraphToMove != endOfParagraphToMove ? createFragmentFromMarkup(document(), range->toHTML(), "") : 0;
setEndingSelection(Selection(start, end, DOWNSTREAM));
- deleteSelection(false, false);
+ applyCommandToComposite(new DeleteSelectionCommand(document(), false, false, false, false));
ASSERT(destination.deepEquivalent().node()->inDocument());
// baz
// Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would
// cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
- if (beforeParagraph.isNotNull() && !isEndOfParagraph(beforeParagraph))
+ // Must recononicalize these two VisiblePositions after the pruning above.
+ beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent());
+ afterParagraph = VisiblePosition(afterParagraph.deepEquivalent());
+ if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || beforeParagraph == afterParagraph)) {
+ // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
insertNodeAt(createBreakElement(document()).get(), beforeParagraph.deepEquivalent().node(), beforeParagraph.deepEquivalent().offset());
+ // Need an updateLayout here in case inserting the br has split a text node.
+ updateLayout();
+ }
RefPtr<Range> startToDestinationRange(new Range(document(), Position(document(), 0), rangeCompliantEquivalent(destination.deepEquivalent())));
destinationIndex = TextIterator::rangeLength(startToDestinationRange.get());
using namespace HTMLNames;
-DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
+DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
: CompositeEditCommand(document),
m_hasSelectionToDelete(false),
m_smartDelete(smartDelete),
m_mergeBlocksAfterDelete(mergeBlocksAfterDelete),
m_replace(replace),
+ m_expandForSpecialElements(expandForSpecialElements),
m_startBlock(0),
m_endBlock(0),
m_typingStyle(0),
{
}
-DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
+DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
: CompositeEditCommand(selection.start().node()->document()),
m_hasSelectionToDelete(true),
m_smartDelete(smartDelete),
m_mergeBlocksAfterDelete(mergeBlocksAfterDelete),
m_replace(replace),
+ m_expandForSpecialElements(expandForSpecialElements),
m_selectionToDelete(selection),
m_startBlock(0),
m_endBlock(0),
{
}
-void DeleteSelectionCommand::initializeStartEnd()
+void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
{
Node* startSpecialContainer = 0;
Node* endSpecialContainer = 0;
- Position start = m_selectionToDelete.start();
- Position end = m_selectionToDelete.end();
+ start = m_selectionToDelete.start();
+ end = m_selectionToDelete.end();
// For HRs, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting,
// but in these cases, we want to delete it, so manually expand the selection
else if (end.node()->hasTagName(hrTag))
end = Position(end.node(), 1);
+ // FIXME: This is only used so that moveParagraphs can avoid the bugs in special element expanion.
+ if (!m_expandForSpecialElements)
+ return;
+
while (VisiblePosition(start) == m_selectionToDelete.visibleStart() && VisiblePosition(end) == m_selectionToDelete.visibleEnd()) {
startSpecialContainer = 0;
endSpecialContainer = 0;
end = e;
}
}
-
- m_upstreamStart = start.upstream();
- m_downstreamStart = start.downstream();
- m_upstreamEnd = end.upstream();
- m_downstreamEnd = end.downstream();
}
void DeleteSelectionCommand::initializePositionData()
{
- initializeStartEnd();
+ Position start, end;
+ initializeStartEnd(start, end);
+
+ m_upstreamStart = start.upstream();
+ m_downstreamStart = start.downstream();
+ m_upstreamEnd = end.upstream();
+ m_downstreamEnd = end.downstream();
Node* startCell = enclosingTableCell(m_upstreamStart.node());
Node* endCell = enclosingTableCell(m_downstreamEnd.node());
class DeleteSelectionCommand : public CompositeEditCommand {
public:
- DeleteSelectionCommand(Document*, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
- DeleteSelectionCommand(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
+ DeleteSelectionCommand(Document*, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
+ DeleteSelectionCommand(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
virtual void doApply();
virtual EditAction editingAction() const;
private:
virtual bool preservesTypingStyle() const;
- void initializeStartEnd();
+ void initializeStartEnd(Position&, Position&);
void initializePositionData();
void saveTypingStyleState();
void saveFullySelectedAnchor();
bool m_mergeBlocksAfterDelete;
bool m_needPlaceholder;
bool m_replace;
+ bool m_expandForSpecialElements;
// This data is transient and should be cleared at the end of the doApply function.
Selection m_selectionToDelete;
if (!next) {
next = m_node->nextSibling();
if (!next) {
- if (m_node->traverseNextNode() == m_pastEndNode)
- break;
+ bool pastEnd = m_node->traverseNextNode() == m_pastEndNode;
while (!next && m_node->parentNode()) {
+ if (pastEnd && m_node->parentNode() == m_endContainer || m_endContainer->isDescendantOf(m_node->parentNode()))
+ return;
m_node = m_node->parentNode();
exitNode();
if (m_positionNode) {
return !r->isInline() && r->isRenderBlock() && !r->isBody();
}
+static bool shouldEmitNewlineAfterNode(Node* node)
+{
+ // FIXME: It should be better but slower to create a VisiblePosition here.
+ return shouldEmitNewlinesBeforeAndAfterNode(node) && node->traverseNextSibling();
+}
+
+static bool shouldEmitNewlineBeforeNode(Node* node)
+{
+ return shouldEmitNewlinesBeforeAndAfterNode(node);
+}
+
static bool shouldEmitExtraNewlineForNode(Node* node)
{
// When there is a significant collapsed bottom margin, emit an extra
// only add the tab or newline if not at the start of a line
if (shouldEmitTabBeforeNode(m_node))
emitCharacter('\t', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
- else if (shouldEmitNewlinesBeforeAndAfterNode(m_node))
+ else if (shouldEmitNewlineBeforeNode(m_node))
emitCharacter('\n', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
else if (shouldEmitSpaceBeforeAndAfterNode(m_node))
emitCharacter(' ', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
void TextIterator::exitNode()
{
- if (m_lastTextNode && shouldEmitNewlinesBeforeAndAfterNode(m_node)) {
+ if (m_lastTextNode && shouldEmitNewlineAfterNode(m_node)) {
// use extra newline to represent margin bottom, as needed
bool addNewline = shouldEmitExtraNewlineForNode(m_node);
// We can use a linefeed in place of a tab because this simple iterator is only used to
// find boundaries, not actual content. A linefeed breaks words, sentences, and paragraphs.
if (shouldEmitNewlineForNode(m_node) ||
- shouldEmitNewlinesBeforeAndAfterNode(m_node) ||
+ shouldEmitNewlineAfterNode(m_node) ||
shouldEmitTabBeforeNode(m_node))
emitNewline();