WebCore:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 01:27:54 +0000 (01:27 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 01:27:54 +0000 (01:27 +0000)
        Reviewed by Darin Adler.

        <rdar://problem/5549929> CrashTracer: [USER] 35 crashes at WebCore::CharacterData::insertData

        We were trying to insert a tab into a br, after the br incorrectly ended up inside
        a tab span.

        * editing/DeleteButtonController.cpp:
        (WebCore::isDeletableElement): Changed to take in a const Node* instead of a Node*.
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::isTableRow): Ditto.
        * editing/IndentOutdentCommand.cpp:
        (WebCore::isIndentBlockquote): Ditto.
        (WebCore::isListOrIndentBlockquote): Ditto.
        * editing/InsertLineBreakCommand.cpp:
        (WebCore::InsertLineBreakCommand::shouldUseBreakElement): Added, moved code from
        doApply here.
        (WebCore::InsertLineBreakCommand::doApply):
        Don't upstream() the insertion position.  upstream()ing it will only have an effect
        when the insertion position is the first in its paragraph (since we canonicalize
        VisiblePositions to the upstream() candidate).  In this start of paragraph case,
        upstream() can move outside inline elements like tab spans or elements that might
        have a different whitespace mode (added two test cases to cover these).
        Moved code to decide whether to insert a br or a '\n' to its own method.
        Removed special case code for inserting at a position inside a tab span.  We instead
        adjust the insertion position before insertion if it is inside a tab span and
        handle insertion in the appropriate if-block.  This fixes a bug where we would
        only insert one line break when two were needed (added a testcase).
        Removed special case code for inserting before and after tables and horizontal
        rules.  We handle these insertions in the appropriate if-block.
        * editing/InsertLineBreakCommand.h:
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::isMailPasteAsQuotationNode): Change to take in a const Node*.
        * editing/htmlediting.cpp:
        (WebCore::isContentEditable): Ditto.
        (WebCore::isBlock): Ditto.
        (WebCore::enclosingNodeOfType): Changed to take a function pointer to a function
        that takes in a const Node*.
        (WebCore::isTabSpanTextNode): Check to see that the node actually a text node,
        and not, say, a br.
        * editing/htmlediting.h:
        * editing/markup.cpp:
        (WebCore::styleFromMatchedRulesAndInlineDecl): Changed to take in a const Node*.
        (WebCore::elementHasTextDecorationProperty): Ditto.

LayoutTests:

        Reviewed by Darin Adler.

        <rdar://problem/5549929> CrashTracer: [USER] 35 crashes at WebCore::CharacterData::insertData

        * editing/inserting/5549929-1-expected.txt: Added.
        * editing/inserting/5549929-1.html: Added.
        * editing/inserting/5549929-2.html: Added.
        * editing/inserting/5549929-3.html: Added.
        * platform/mac/editing/inserting/5549929-2-expected.checksum: Added.
        * platform/mac/editing/inserting/5549929-2-expected.png: Added.
        * platform/mac/editing/inserting/5549929-2-expected.txt: Added.
        * platform/mac/editing/inserting/5549929-3-expected.checksum: Added.
        * platform/mac/editing/inserting/5549929-3-expected.png: Added.
        * platform/mac/editing/inserting/5549929-3-expected.txt: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/inserting/5549929-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/5549929-1.html [new file with mode: 0755]
LayoutTests/editing/inserting/5549929-2.html [new file with mode: 0755]
LayoutTests/editing/inserting/5549929-3.html [new file with mode: 0755]
LayoutTests/platform/mac/editing/inserting/5549929-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/5549929-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/5549929-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/5549929-3-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/5549929-3-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/5549929-3-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/DeleteButtonController.cpp
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/IndentOutdentCommand.cpp
WebCore/editing/InsertLineBreakCommand.cpp
WebCore/editing/InsertLineBreakCommand.h
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/htmlediting.cpp
WebCore/editing/htmlediting.h
WebCore/editing/markup.cpp

index ba9ae3402037e81709dc678968905ae52024ce2d..49e0891f12a0476ded5597188942583010982a22 100644 (file)
@@ -1,3 +1,20 @@
+2007-10-30  Justin Garcia  <set EMAIL_ADDRESS environment variable>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/5549929> CrashTracer: [USER] 35 crashes at WebCore::CharacterData::insertData
+
+        * editing/inserting/5549929-1-expected.txt: Added.
+        * editing/inserting/5549929-1.html: Added.
+        * editing/inserting/5549929-2.html: Added.
+        * editing/inserting/5549929-3.html: Added.
+        * platform/mac/editing/inserting/5549929-2-expected.checksum: Added.
+        * platform/mac/editing/inserting/5549929-2-expected.png: Added.
+        * platform/mac/editing/inserting/5549929-2-expected.txt: Added.
+        * platform/mac/editing/inserting/5549929-3-expected.checksum: Added.
+        * platform/mac/editing/inserting/5549929-3-expected.png: Added.
+        * platform/mac/editing/inserting/5549929-3-expected.txt: Added.
+
 2007-10-30  Adam Roben  <aroben@apple.com>
 
         Add another failing test to the Windows Skipped file
diff --git a/LayoutTests/editing/inserting/5549929-1-expected.txt b/LayoutTests/editing/inserting/5549929-1-expected.txt
new file mode 100644 (file)
index 0000000..46a839f
--- /dev/null
@@ -0,0 +1,5 @@
+This tests for a crash when inserting into a tab into a tab span that contains a br. You should no longer be able to get a br inside a tab span while editing but we should still avoid the crash.
+
+foo
+       
+bar
diff --git a/LayoutTests/editing/inserting/5549929-1.html b/LayoutTests/editing/inserting/5549929-1.html
new file mode 100755 (executable)
index 0000000..420c5f6
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests for a crash when inserting into a tab into a tab span that contains a br.  You should no longer be able to get a br inside a tab span while editing but we should still avoid the crash.</p>
+<div id="div" contenteditable="true">
+<div>foo</div>
+<div><span id="span" class="Apple-tab-span"><br></span></div>
+<div>bar</div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+document.getElementById("div").focus();
+span = document.getElementById("span");
+window.getSelection().setPosition(span, 0);
+document.execCommand("InsertText", false, "\t");
+</script>
diff --git a/LayoutTests/editing/inserting/5549929-2.html b/LayoutTests/editing/inserting/5549929-2.html
new file mode 100755 (executable)
index 0000000..2723201
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests to make sure that a br isn't inserted into a tab span during an InsertLineBreak operation.  You can test for its existence with the DOM inspector or you can look at the render tree.</p>
+<div id="div" contenteditable="true">
+<div><span class="Apple-tab-span" style="white-space:pre">     </span>foo</div>
+<div><span class="Apple-tab-span" style="white-space:pre">     </span>bar</div>
+</div>
+
+<script>
+div = document.getElementById("div");
+div.focus();
+sel = window.getSelection();
+sel.setPosition(div, 0);
+sel.modify("extend", "forward", "paragraph");
+document.execCommand("InsertLineBreak");
+</script>
diff --git a/LayoutTests/editing/inserting/5549929-3.html b/LayoutTests/editing/inserting/5549929-3.html
new file mode 100755 (executable)
index 0000000..f81e4fb
--- /dev/null
@@ -0,0 +1,9 @@
+<p>This tests inserting a line break at the end of a tab span.  Below you should see 'foo' followed by an empty paragraph, with the caret in it.</p>
+<div id="div" contenteditable="true">foo<span class="Apple-tab-span" style="white-space:pre">  </span></div>
+    
+<script>
+div = document.getElementById("div");
+sel = window.getSelection();
+sel.setPosition(div, div.childNodes.length);
+document.execCommand("InsertLineBreak");
+</script>
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.checksum b/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.checksum
new file mode 100644 (file)
index 0000000..1440b09
--- /dev/null
@@ -0,0 +1 @@
+bc90ab348ab49c2cc7edaea67eae9f46
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.png b/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.png
new file mode 100644 (file)
index 0000000..c897b1b
Binary files /dev/null and b/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.txt b/LayoutTests/platform/mac/editing/inserting/5549929-2-expected.txt
new file mode 100644 (file)
index 0000000..792f8ff
--- /dev/null
@@ -0,0 +1,19 @@
+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 735x36
+          text run at (0,0) width 616: "This tests to make sure that a br isn't inserted into a tab span during an InsertLineBreak operation. "
+          text run at (616,0) width 119: "You can test for its"
+          text run at (0,18) width 432: "existence with the DOM inspector or you can look at the render tree."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderBlock {DIV} at (0,0) size 784x36
+          RenderBR {BR} at (0,0) size 0x18
+          RenderInline {SPAN} at (0,0) size 32x18
+            RenderText {#text} at (0,18) size 32x18
+              text run at (0,18) width 32: "\x{9}"
+          RenderText {#text} at (32,18) size 20x18
+            text run at (32,18) width 20: "bar"
+caret: position 0 of child 0 {#text} of child 1 {SPAN} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.checksum b/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.checksum
new file mode 100644 (file)
index 0000000..0746036
--- /dev/null
@@ -0,0 +1 @@
+ee0d37eefc69b4205655bd3818ab7277
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.png b/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.png
new file mode 100644 (file)
index 0000000..6755707
Binary files /dev/null and b/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.txt b/LayoutTests/platform/mac/editing/inserting/5549929-3-expected.txt
new file mode 100644 (file)
index 0000000..1f3ad22
--- /dev/null
@@ -0,0 +1,19 @@
+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 767x36
+          text run at (0,0) width 351: "This tests inserting a line break at the end of a tab span. "
+          text run at (351,0) width 416: "Below you should see 'foo' followed by an empty paragraph, with"
+          text run at (0,18) width 85: "the caret in it."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderText {#text} at (0,0) size 21x18
+          text run at (0,0) width 21: "foo"
+        RenderInline {SPAN} at (0,0) size 11x18
+          RenderText {#text} at (21,0) size 11x18
+            text run at (21,0) width 11: "\x{9}"
+        RenderBR {BR} at (32,14) size 0x0
+        RenderBR {BR} at (0,18) size 0x18
+caret: position 0 of child 3 {BR} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
index 0cc37c43d8e14d3c64fabd18bd806128abb4b1a8..d531e55bc4fc7c9050ab840b458d53b3a71036b2 100644 (file)
@@ -1,3 +1,50 @@
+2007-10-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/5549929> CrashTracer: [USER] 35 crashes at WebCore::CharacterData::insertData
+        
+        We were trying to insert a tab into a br, after the br incorrectly ended up inside
+        a tab span.
+        
+        * editing/DeleteButtonController.cpp: 
+        (WebCore::isDeletableElement): Changed to take in a const Node* instead of a Node*.
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::isTableRow): Ditto.
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::isIndentBlockquote): Ditto.
+        (WebCore::isListOrIndentBlockquote): Ditto.
+        * editing/InsertLineBreakCommand.cpp:
+        (WebCore::InsertLineBreakCommand::shouldUseBreakElement): Added, moved code from
+        doApply here.
+        (WebCore::InsertLineBreakCommand::doApply): 
+        Don't upstream() the insertion position.  upstream()ing it will only have an effect
+        when the insertion position is the first in its paragraph (since we canonicalize
+        VisiblePositions to the upstream() candidate).  In this start of paragraph case, 
+        upstream() can move outside inline elements like tab spans or elements that might
+        have a different whitespace mode (added two test cases to cover these).
+        Moved code to decide whether to insert a br or a '\n' to its own method.
+        Removed special case code for inserting at a position inside a tab span.  We instead
+        adjust the insertion position before insertion if it is inside a tab span and
+        handle insertion in the appropriate if-block.  This fixes a bug where we would 
+        only insert one line break when two were needed (added a testcase).
+        Removed special case code for inserting before and after tables and horizontal
+        rules.  We handle these insertions in the appropriate if-block.
+        * editing/InsertLineBreakCommand.h:
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::isMailPasteAsQuotationNode): Change to take in a const Node*.
+        * editing/htmlediting.cpp:
+        (WebCore::isContentEditable): Ditto.
+        (WebCore::isBlock): Ditto.
+        (WebCore::enclosingNodeOfType): Changed to take a function pointer to a function
+        that takes in a const Node*.
+        (WebCore::isTabSpanTextNode): Check to see that the node actually a text node,
+        and not, say, a br.
+        * editing/htmlediting.h:
+        * editing/markup.cpp:
+        (WebCore::styleFromMatchedRulesAndInlineDecl): Changed to take in a const Node*.
+        (WebCore::elementHasTextDecorationProperty): Ditto.
+
 2007-10-30  Antti Koivisto  <antti@apple.com>
 
         Reviewed by NOBODY.
index ea4eb94d104215de9c28a4850b01f53760d78e29..e41d4c564feb27e98f123beee64b69e5ba76c68d 100644 (file)
@@ -61,7 +61,7 @@ DeleteButtonController::DeleteButtonController(Frame* frame)
 {
 }
 
-static bool isDeletableElement(Node* node)
+static bool isDeletableElement(const Node* node)
 {
     if (!node || !node->isHTMLElement() || !node->inDocument() || !node->isContentEditable())
         return false;
index 188f6bf8cbf9f3a7e954546ebfd2e2d5d8b7c6b6..1a6771a241f0675baaa463639d241dcd2977bedc 100644 (file)
@@ -52,7 +52,7 @@ static bool isTableCell(Node* node)
     return node && (node->hasTagName(tdTag) || node->hasTagName(thTag));
 }
 
-static bool isTableRow(Node* node)
+static bool isTableRow(const Node* node)
 {
     return node && node->hasTagName(trTag);
 }
index 9a6e4ae51866d9888af18ab0b765dce1d561cc6d..77efdbffe2552d1f0f7233febba1a2737f3a7c1f 100644 (file)
@@ -55,16 +55,16 @@ static PassRefPtr<Element> createIndentBlockquoteElement(Document* document)
     return indentBlockquoteElement.release();
 }
 
-static bool isIndentBlockquote(Node* node)
+static bool isIndentBlockquote(const Node* node)
 {
     if (!node || !node->hasTagName(blockquoteTag) || !node->isElementNode())
         return false;
 
-    Element* elem = static_cast<Element*>(node);
+    Element* elem = static_cast<const Element*>(node);
     return elem->getAttribute(classAttr) == indentBlockquoteString();
 }
 
-static bool isListOrIndentBlockquote(Node* node)
+static bool isListOrIndentBlockquote(const Node* node)
 {
     return node && (node->hasTagName(ulTag) || node->hasTagName(olTag) || isIndentBlockquote(node));
 }
index 7891f9a4ad1c7c56cc39b09b8bd78dc34846c707..9d40dc13dd9c75eb52da3aedf45acbe4e16716dc 100644 (file)
@@ -77,6 +77,12 @@ void InsertLineBreakCommand::insertNodeBeforePosition(Node *node, const Position
         insertNodeBefore(node, pos.node());
 }
 
+// Whether we should insert a break element or a '\n'.
+bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos)
+{
+    return insertionPos.node()->renderer() && !insertionPos.node()->renderer()->style()->preserveNewline();
+}
+
 void InsertLineBreakCommand::doApply()
 {
     deleteSelection();
@@ -85,59 +91,41 @@ void InsertLineBreakCommand::doApply()
         return;
     
     VisiblePosition caret(selection.visibleStart());
-
-    Position pos(caret.deepEquivalent().upstream());
-    Position canonicalPos(caret.deepEquivalent());
+    Position pos(caret.deepEquivalent());
 
     pos = positionAvoidingSpecialElementBoundary(pos);
-
-    Node* styleNode = pos.node();
-    bool isTabSpan = isTabSpanTextNode(styleNode);
-    if (isTabSpan)
-        styleNode = styleNode->parentNode()->parentNode();
-    RenderObject* styleRenderer = styleNode->renderer();
-    bool useBreakElement = !styleRenderer || !styleRenderer->style()->preserveNewline();
+    
+    pos = positionOutsideTabSpan(pos);
 
     RefPtr<Node> nodeToInsert;
-    if (useBreakElement)
+    if (shouldUseBreakElement(pos))
         nodeToInsert = createBreakElement(document());
     else
         nodeToInsert = document()->createTextNode("\n");
-        // FIXME: Need to merge text nodes when inserting just after or before text.
     
-    if (isTabSpan) {
-        insertNodeAtTabSpanPosition(nodeToInsert.get(), pos);
-        setEndingSelection(Selection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM));
-    } else if (canonicalPos.node()->renderer() && canonicalPos.node()->renderer()->isTable() ||
-               canonicalPos.node()->hasTagName(hrTag)) {
-        if (canonicalPos.offset() == 0) {
-            insertNodeBefore(nodeToInsert.get(), canonicalPos.node());
-            // Insert an extra br or '\n' if the just inserted one collapsed.
-            if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))))
-                insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
-            // Leave the selection where it was, just before the table/horizontal rule.
-        } else if (canonicalPos.offset() == maxDeepOffset(canonicalPos.node())) {
-            insertNodeAfter(nodeToInsert.get(), canonicalPos.node());
-            setEndingSelection(Selection(VisiblePosition(Position(nodeToInsert.get(), 0))));
-        } else
-            // There aren't any VisiblePositions like this yet.
-            ASSERT_NOT_REACHED();
-    } else if (isEndOfParagraph(caret) && !lineBreakExistsAtPosition(caret)) {
+    // FIXME: Need to merge text nodes when inserting just after or before text.
+    
+    if (isEndOfParagraph(caret) && !lineBreakExistsAtPosition(caret)) {
+        bool needExtraLineBreak = !pos.node()->hasTagName(hrTag) && !pos.node()->hasTagName(tableTag);
+        
         insertNodeAt(nodeToInsert.get(), pos);
-        insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
+        
+        if (needExtraLineBreak)
+            insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
+        
         VisiblePosition endingPosition(Position(nodeToInsert.get(), 0));
         setEndingSelection(Selection(endingPosition));
     } else if (pos.offset() <= pos.node()->caretMinOffset()) {
-        // Insert node before downstream position, and place caret there as well. 
-        Position endingPosition = pos.downstream();
-        insertNodeBeforePosition(nodeToInsert.get(), endingPosition);
-        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
+        insertNodeAt(nodeToInsert.get(), pos);
+        
+        // Insert an extra br or '\n' if the just inserted one collapsed.
+        if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))))
+            insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
+        
+        setEndingSelection(Selection(positionAfterNode(nodeToInsert.get()), DOWNSTREAM));
     } else if (pos.offset() >= pos.node()->caretMaxOffset()) {
-        // Insert BR after this node. Place caret in the position that is downstream
-        // of the current position, reckoned before inserting the BR in between.
-        Position endingPosition = pos.downstream();
-        insertNodeAfterPosition(nodeToInsert.get(), pos);
-        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
+        insertNodeAt(nodeToInsert.get(), pos);
+        setEndingSelection(Selection(positionAfterNode(nodeToInsert.get()), DOWNSTREAM));
     } else {
         // Split a text node
         ASSERT(pos.node()->isTextNode());
index 84003e3dac26f099aa40ba245ad835a90ae4d930..1f5cdc81f9e2ea3c9391cd0f44578ba746639a5d 100644 (file)
@@ -40,6 +40,7 @@ private:
     virtual bool preservesTypingStyle() const;
     void insertNodeAfterPosition(Node*, const Position&);
     void insertNodeBeforePosition(Node*, const Position&);
+    bool shouldUseBreakElement(const Position&);
 };
 
 } // namespace WebCore
index a49feef0087ba096b1449901e2de4039addc13e9..348bc0174d806db01a0f0ba847fdbd3aae79b44e 100644 (file)
@@ -318,9 +318,9 @@ bool ReplaceSelectionCommand::shouldMergeEnd(bool selectionEndWasEndOfParagraph)
            shouldMerge(endOfInsertedContent, next);
 }
 
-static bool isMailPasteAsQuotationNode(Node* node)
+static bool isMailPasteAsQuotationNode(const Node* node)
 {
-    return node && node->hasTagName(blockquoteTag) && node->isElementNode() && static_cast<Element*>(node)->getAttribute(classAttr) == ApplePasteAsQuotation;
+    return node && node->hasTagName(blockquoteTag) && node->isElementNode() && static_cast<const Element*>(node)->getAttribute(classAttr) == ApplePasteAsQuotation;
 }
 
 // Wrap CompositeEditCommand::removeNodePreservingChildren() so we can update the nodes we track
index a11fbffcbbeb51be8073a49034a7b581c1a04796..66ac3563be6a635417c059615f5feb6e251c42fd 100644 (file)
@@ -190,7 +190,7 @@ Element* editableRootForPosition(const Position& p)
     return node->rootEditableElement();
 }
 
-bool isContentEditable(Node* node)
+bool isContentEditable(const Node* node)
 {
     return node->isContentEditable();
 }
@@ -286,7 +286,7 @@ VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio
 }
 
 // Whether or not content before and after this node will collapse onto the same line as it.
-bool isBlock(Node* node)
+bool isBlock(const Node* node)
 {
     return node && node->renderer() && !node->renderer()->isInline();
 }
@@ -577,7 +577,7 @@ Node* enclosingNodeWithTag(Node* node, const QualifiedName& tagName)
     return 0;
 }
 
-Node* enclosingNodeOfType(Node* node, bool (*nodeIsOfType)(Node*))
+Node* enclosingNodeOfType(Node* node, bool (*nodeIsOfType)(const Node*))
 {
     if (!node)
         return 0;
@@ -786,7 +786,7 @@ bool isTabSpanNode(const Node *node)
 
 bool isTabSpanTextNode(const Node *node)
 {
-    return (node && node->parentNode() && isTabSpanNode(node->parentNode()));
+    return node && node->isTextNode() && node->parentNode() && isTabSpanNode(node->parentNode());
 }
 
 Node *tabSpanNode(const Node *node)
index f1d442c256586c87f116de8b8d4b06c153b2eb25..351730d358fea1121751812a066cd295c65cb657 100644 (file)
@@ -51,7 +51,7 @@ VisiblePosition firstEditablePositionAfterPositionInRoot(const Position&, Node*)
 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position&, Node*);
 int comparePositions(const Position&, const Position&);
 Node* lowestEditableAncestor(Node*);
-bool isContentEditable(Node*);
+bool isContentEditable(const Node*);
 Position nextCandidate(const Position&);
 Position nextVisuallyDistinctCandidate(const Position&);
 Position previousCandidate(const Position&);
@@ -59,7 +59,7 @@ Position previousVisuallyDistinctCandidate(const Position&);
 bool isEditablePosition(const Position&);
 bool isRichlyEditablePosition(const Position&);
 Element* editableRootForPosition(const Position&);
-bool isBlock(Node*);
+bool isBlock(const Node*);
 Node* enclosingBlock(Node*);
 
 String stringWithRebalancedWhitespace(const String&, bool, bool);
@@ -109,7 +109,7 @@ Node* isLastPositionBeforeTable(const VisiblePosition&);
 Node* isFirstPositionAfterTable(const VisiblePosition&);
 
 Node* enclosingNodeWithTag(Node*, const QualifiedName&);
-Node* enclosingNodeOfType(Node*, bool (*nodeIsOfType)(Node*));
+Node* enclosingNodeOfType(Node*, bool (*nodeIsOfType)(const Node*));
 Node* enclosingTableCell(const Position&);
 Node* enclosingEmptyListItem(const VisiblePosition&);
 Node* enclosingAnchorElement(const Position&);
index 10a81644141eaf6b9940bdf4ba3b212e7bf4e5e4..5aa5a8ba80cab39aa3af4293d5231daded2e9541 100644 (file)
@@ -572,12 +572,12 @@ static bool needInterchangeNewlineAfter(const VisiblePosition& v)
     return isEndOfParagraph(v) && isStartOfParagraph(next) && !(upstreamNode->hasTagName(brTag) && upstreamNode == downstreamNode);
 }
 
-static PassRefPtr<CSSMutableStyleDeclaration> styleFromMatchedRulesAndInlineDecl(Node* node)
+static PassRefPtr<CSSMutableStyleDeclaration> styleFromMatchedRulesAndInlineDecl(const Node* node)
 {
     if (!node->isHTMLElement())
         return 0;
     
-    HTMLElement* element = static_cast<HTMLElement*>(node);
+    HTMLElement* element = static_cast<const HTMLElement*>(node);
     RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesForElement(element);
     RefPtr<CSSMutableStyleDeclaration> inlineStyleDecl = element->getInlineStyleDecl();
     style->merge(inlineStyleDecl.get());
@@ -596,7 +596,7 @@ static bool propertyMissingOrEqualToNone(CSSMutableStyleDeclaration* style, int
     return static_cast<CSSPrimitiveValue*>(value.get())->getIdent() == CSS_VAL_NONE;
 }
 
-static bool elementHasTextDecorationProperty(Node* node)
+static bool elementHasTextDecorationProperty(const Node* node)
 {
     RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesAndInlineDecl(node);
     if (!style)