Changeset 27796 in webkit


Ignore:
Timestamp:
Nov 14, 2007 2:33:07 PM (16 years ago)
Author:
justin.garcia@apple.com
Message:

WebCore:

Reviewed by Alexey Proskuryakov.

<rdar://problem/5546763> CrashTracer: [USER] 362 crashes at WebCore::DeleteSelectionCommand::mergeParagraphs

  • editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::handleGeneralDelete): Removed an irrelevant FIXME. (WebCore::DeleteSelectionCommand::mergeParagraphs): If the block that contained the end of the selection hasn't been removed but has been emptied by deletion, we would to try and fail to create a VisiblePosition inside that block, which could lead to a crash. If that happens, there's no content in the block to move, so just remove the block and return. Preserve m_needPlaceholder during the call to moveParagraphs, since it may change it and since it does its own placeholder insertion when necessary. (WebCore::DeleteSelectionCommand::doApply): No need to check m_needPlaceholder before calling mergeParagraphs, because it handles preserving m_needPlaceholder when it calls moveParagraphs.

LayoutTests:

Reviewed by Alexey Proskuryakov.


<rdar://problem/5546763> CrashTracer: [USER] 362 crashes at WebCore::DeleteSelectionCommand::mergeParagraphs

  • editing/deleting/5546763-expected.txt: Added.
  • editing/deleting/5546763.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r27795 r27796  
     12007-11-14  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4       
     5        <rdar://problem/5546763> CrashTracer: [USER] 362 crashes at WebCore::DeleteSelectionCommand::mergeParagraphs
     6
     7        * editing/deleting/5546763-expected.txt: Added.
     8        * editing/deleting/5546763.html: Added.
     9
    1102007-11-14  Anders Carlsson  <andersca@apple.com>
    211
  • trunk/WebCore/ChangeLog

    r27789 r27796  
     12007-11-14  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        <rdar://problem/5546763> CrashTracer: [USER] 362 crashes at WebCore::DeleteSelectionCommand::mergeParagraphs
     6
     7        * editing/DeleteSelectionCommand.cpp:
     8        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
     9        Removed an irrelevant FIXME.
     10        (WebCore::DeleteSelectionCommand::mergeParagraphs): If the block that contained the end of the selection
     11        hasn't been removed but has been emptied by deletion, we would to try and fail to create a VisiblePosition
     12        inside that block, which could lead to a crash.  If that happens, there's no content in the block to move,
     13        so just remove the block and return.
     14        Preserve m_needPlaceholder during the call to moveParagraphs, since it may change it and since it does
     15        its own placeholder insertion when necessary.
     16        (WebCore::DeleteSelectionCommand::doApply): No need to check m_needPlaceholder before calling mergeParagraphs,
     17        because it handles preserving m_needPlaceholder when it calls moveParagraphs.
     18       
    1192007-11-14  Timothy Hatcher  <timothy@apple.com>
    220
  • trunk/WebCore/editing/DeleteSelectionCommand.cpp

    r27690 r27796  
    447447        if (m_downstreamEnd.node() != startNode && !m_upstreamStart.node()->isDescendantOf(m_downstreamEnd.node()) && m_downstreamEnd.node()->inDocument() && m_downstreamEnd.offset() >= caretMinOffset(m_downstreamEnd.node())) {
    448448            if (m_downstreamEnd.offset() >= maxDeepOffset(m_downstreamEnd.node()) && !canHaveChildrenForEditing(m_downstreamEnd.node())) {
    449                 // FIXME: Shouldn't remove m_downstreamEnd.node() if its offsets refer to children.
    450449                // The node itself is fully selected, not just its contents.  Delete it.
    451450                removeNode(m_downstreamEnd.node());
     
    520519    VisiblePosition mergeDestination(m_upstreamStart);
    521520   
     521    // m_downstreamEnd's block has been emptied out by deletion.  There is no content inside of it to
     522    // move, so just remove it.
     523    Element* endBlock = static_cast<Element*>(enclosingBlock(m_downstreamEnd.node()));
     524    if (!startOfParagraphToMove.deepEquivalent().node() || !endBlock->contains(startOfParagraphToMove.deepEquivalent().node())) {
     525        removeNode(enclosingBlock(m_downstreamEnd.node()));
     526        return;
     527    }
     528   
    522529    // We need to merge into m_upstreamStart's block, but it's been emptied out and collapsed by deletion.
    523530    if (!mergeDestination.deepEquivalent().node() || !mergeDestination.deepEquivalent().node()->isDescendantOf(m_upstreamStart.node()->enclosingBlockFlowElement())) {
     
    551558        return;
    552559   
     560    // moveParagraphs will insert placeholders if it removes blocks that would require their use, don't let block
     561    // removals that it does cause the insertion of *another* placeholder.
     562    bool needPlaceholder = m_needPlaceholder;
    553563    moveParagraph(startOfParagraphToMove, endOfParagraphToMove, mergeDestination);
     564    m_needPlaceholder = needPlaceholder;
    554565    // The endingPosition was likely clobbered by the move, so recompute it (moveParagraph selects the moved paragraph).
    555566    m_endingPosition = endingSelection().start();
     
    719730   
    720731    fixupWhitespace();
    721 
    722     RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()) : 0;
    723732   
    724733    mergeParagraphs();
    725734   
    726735    removePreviouslySelectedEmptyTableRows();
     736   
     737    RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).get() : 0;
    727738   
    728739    if (placeholder)
Note: See TracChangeset for help on using the changeset viewer.