Changeset 63773 in webkit


Ignore:
Timestamp:
Jul 20, 2010, 2:11:52 PM (14 years ago)
Author:
inferno@chromium.org
Message:

2010-07-20 Abhishek Arya <inferno@chromium.org>

Reviewed by David Hyatt.

Check the node is a text node before doing the static cast
for editing commands.
https://bugs.webkit.org/show_bug.cgi?id=42655

Test: editing/execCommand/editing-nontext-node-crash.xhtml

  • editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::fixupWhitespace):
  • editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::doApply):
  • editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::doApply):

2010-07-20 Abhishek Arya <inferno@chromium.org>

Reviewed by David Hyatt.

Tests that applying an editing command on a non text node does not
result in crash.
https://bugs.webkit.org/show_bug.cgi?id=42655

  • editing/execCommand/editing-nontext-node-crash-expected.txt: Added.
  • editing/execCommand/editing-nontext-node-crash.xhtml: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63772 r63773  
     12010-07-20  Abhishek Arya  <inferno@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Tests that applying an editing command on a non text node does not
     6        result in crash.
     7        https://bugs.webkit.org/show_bug.cgi?id=42655
     8
     9        * editing/execCommand/editing-nontext-node-crash-expected.txt: Added.
     10        * editing/execCommand/editing-nontext-node-crash.xhtml: Added.
     11
    1122010-07-20  Leo Yang  <leo.yang@torchmobile.com.cn>
    213
  • trunk/WebCore/ChangeLog

    r63772 r63773  
     12010-07-20  Abhishek Arya  <inferno@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Check the node is a text node before doing the static cast
     6        for editing commands.
     7        https://bugs.webkit.org/show_bug.cgi?id=42655
     8
     9        Test: editing/execCommand/editing-nontext-node-crash.xhtml
     10
     11        * editing/DeleteSelectionCommand.cpp:
     12        (WebCore::DeleteSelectionCommand::fixupWhitespace):
     13        * editing/InsertLineBreakCommand.cpp:
     14        (WebCore::InsertLineBreakCommand::doApply):
     15        * editing/InsertParagraphSeparatorCommand.cpp:
     16        (WebCore::InsertParagraphSeparatorCommand::doApply):
     17
    1182010-07-20  Leo Yang  <leo.yang@torchmobile.com.cn>
    219
  • trunk/WebCore/editing/DeleteSelectionCommand.cpp

    r59956 r63773  
    538538    updateLayout();
    539539    // FIXME: isRenderedCharacter should be removed, and we should use VisiblePosition::characterAfter and VisiblePosition::characterBefore
    540     if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharacter()) {
     540    if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharacter() && m_leadingWhitespace.node()->isTextNode()) {
    541541        Text* textNode = static_cast<Text*>(m_leadingWhitespace.node());
    542542        ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseWhiteSpace());
    543543        replaceTextInNode(textNode, m_leadingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
    544544    }
    545     if (m_trailingWhitespace.isNotNull() && !m_trailingWhitespace.isRenderedCharacter()) {
     545    if (m_trailingWhitespace.isNotNull() && !m_trailingWhitespace.isRenderedCharacter() && m_trailingWhitespace.node()->isTextNode()) {
    546546        Text* textNode = static_cast<Text*>(m_trailingWhitespace.node());
    547547        ASSERT(!textNode->renderer() ||textNode->renderer()->style()->collapseWhiteSpace());
  • trunk/WebCore/editing/InsertLineBreakCommand.cpp

    r62889 r63773  
    137137        insertNodeAt(nodeToInsert.get(), pos);
    138138        setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM));
    139     } else {
     139    } else if (pos.node()->isTextNode()) {
    140140        // Split a text node
    141         ASSERT(pos.node()->isTextNode());
    142        
    143         // Do the split
    144141        Text* textNode = static_cast<Text*>(pos.node());
    145142        splitTextNode(textNode, pos.deprecatedEditingOffset());
  • trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp

    r62889 r63773  
    313313    // FIXME: leadingWhitespacePosition is returning the position before preserved newlines for positions
    314314    // after the preserved newline, causing the newline to be turned into a nbsp.
    315     if (leadingWhitespace.isNotNull()) {
     315    if (leadingWhitespace.isNotNull() && leadingWhitespace.node()->isTextNode()) {
    316316        Text* textNode = static_cast<Text*>(leadingWhitespace.node());
    317317        ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseWhiteSpace());
     
    386386        if (!insertionPosition.isRenderedCharacter()) {
    387387            // Clear out all whitespace and insert one non-breaking space
    388             ASSERT(insertionPosition.node()->isTextNode());
    389388            ASSERT(!insertionPosition.node()->renderer() || insertionPosition.node()->renderer()->style()->collapseWhiteSpace());
    390389            deleteInsignificantTextDownstream(insertionPosition);
    391             insertTextIntoNode(static_cast<Text*>(insertionPosition.node()), 0, nonBreakingSpaceString());
     390            if (insertionPosition.node()->isTextNode())
     391                insertTextIntoNode(static_cast<Text*>(insertionPosition.node()), 0, nonBreakingSpaceString());
    392392        }
    393393    }
Note: See TracChangeset for help on using the changeset viewer.