Changeset 66032 in webkit
- Timestamp:
- Aug 25, 2010 12:19:26 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r66029 r66032 1 2010-08-25 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Various designmode="on"/"off" & execCommand("Undo") NULL pointer crashes 6 https://bugs.webkit.org/show_bug.cgi?id=32823 7 8 These tests ensure WebKit doesn't crash when undoing some editing commands failed 9 and either end of endingSelection() became orphaned. 10 All tests are copied from the bug to prevent regression. 11 12 * editing/undo/orphaned-selection-crash-bug32823-1-expected.txt: Added. 13 * editing/undo/orphaned-selection-crash-bug32823-1.html: Added. 14 * editing/undo/orphaned-selection-crash-bug32823-2-expected.txt: Added. 15 * editing/undo/orphaned-selection-crash-bug32823-2.html: Added. 16 * editing/undo/orphaned-selection-crash-bug32823-3-expected.txt: Added. 17 * editing/undo/orphaned-selection-crash-bug32823-3.html: Added. 18 * editing/undo/orphaned-selection-crash-bug32823-4-expected.txt: Added. 19 * editing/undo/orphaned-selection-crash-bug32823-4.html: Added. 20 * editing/undo/redo-split-text-with-removal-expected.txt: Caret is restored. 21 1 22 2010-08-25 Ojan Vafai <ojan@chromium.org> 2 23 -
trunk/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
r64303 r66032 16 16 after redo: 17 17 | <div> 18 | " hello"18 | "<#selection-caret>hello" -
trunk/WebCore/ChangeLog
r66028 r66032 1 2010-08-25 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Various designmode="on"/"off" & execCommand("Undo") NULL pointer crashes 6 https://bugs.webkit.org/show_bug.cgi?id=32823 7 8 The bug was caused by changeSelectionAfterCommand which updates the selection 9 without checking the whether new selection is valid or not. 10 11 Fixed changeSelectionAfterCommand so that it won't update the selection 12 when either end of the new selection is orphaned. Also fixed various editing commands 13 to exit early if either end of the selection is orphaned. 14 15 Tests: editing/undo/orphaned-selection-crash-bug32823-1.html 16 editing/undo/orphaned-selection-crash-bug32823-2.html 17 editing/undo/orphaned-selection-crash-bug32823-3.html 18 editing/undo/orphaned-selection-crash-bug32823-4.html 19 20 * editing/Editor.cpp: 21 (WebCore::Editor::changeSelectionAfterCommand): No longer sets orphaned selection. 22 * editing/VisibleSelection.h: 23 (WebCore::VisibleSelection::isNonOrphanedRange): Added. 24 (WebCore::VisibleSelection::isNonOrphanedCaretOrRange): Added. 25 * editing/DeleteSelectionCommand.cpp: 26 (WebCore::DeleteSelectionCommand::doApply): Added an early exist. See above. 27 * editing/FormatBlockCommand.cpp: 28 (WebCore::FormatBlockCommand::doApply): Ditto. 29 * editing/IndentOutdentCommand.cpp: 30 (WebCore::IndentOutdentCommand::doApply): Ditto. 31 * editing/InsertLineBreakCommand.cpp: 32 (WebCore::InsertLineBreakCommand::doApply): Ditto. 33 * editing/InsertListCommand.cpp: 34 (WebCore::InsertListCommand::doApply): Ditto. 35 * editing/InsertParagraphSeparatorCommand.cpp: 36 (WebCore::InsertParagraphSeparatorCommand::doApply): Ditto. 37 * editing/InsertTextCommand.cpp: 38 (WebCore::InsertTextCommand::input): Ditto. 39 * editing/MoveSelectionCommand.cpp: 40 (WebCore::MoveSelectionCommand::doApply): Ditto. 41 * editing/RemoveFormatCommand.cpp: 42 (WebCore::RemoveFormatCommand::doApply): Ditto. 43 * editing/ReplaceSelectionCommand.cpp: 44 (WebCore::ReplaceSelectionCommand::doApply): Ditto. 45 * editing/TypingCommand.cpp: 46 (WebCore::TypingCommand::doApply): Ditto. 47 * editing/UnlinkCommand.cpp: 48 (WebCore::UnlinkCommand::doApply): Ditto. 49 1 50 2010-08-25 Simon Fraser <simon.fraser@apple.com> 2 51 -
trunk/WebCore/editing/DeleteSelectionCommand.cpp
r65208 r66032 736 736 if (!m_hasSelectionToDelete) 737 737 m_selectionToDelete = endingSelection(); 738 739 if (!m_selectionToDelete.is Range())738 739 if (!m_selectionToDelete.isNonOrphanedRange()) 740 740 return; 741 741 -
trunk/WebCore/editing/Editor.cpp
r65919 r66032 2943 2943 void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, bool closeTyping, bool clearTypingStyle) 2944 2944 { 2945 // If the new selection is orphaned, then don't update the selection. 2946 if (newSelection.start().isOrphan() || newSelection.end().isOrphan()) 2947 return; 2948 2945 2949 // If there is no selection change, don't bother sending shouldChangeSelection, but still call setSelection, 2946 2950 // because there is work that it must do in this situation. -
trunk/WebCore/editing/FormatBlockCommand.cpp
r42507 r66032 71 71 void FormatBlockCommand::doApply() 72 72 { 73 if ( endingSelection().isNone())73 if (!endingSelection().isNonOrphanedCaretOrRange()) 74 74 return; 75 75 -
trunk/WebCore/editing/IndentOutdentCommand.cpp
r63039 r66032 330 330 void IndentOutdentCommand::doApply() 331 331 { 332 if ( endingSelection().isNone())332 if (!endingSelection().isNonOrphanedCaretOrRange()) 333 333 return; 334 334 -
trunk/WebCore/editing/InsertLineBreakCommand.cpp
r63773 r66032 91 91 deleteSelection(); 92 92 VisibleSelection selection = endingSelection(); 93 if ( selection.isNone())93 if (!selection.isNonOrphanedCaretOrRange()) 94 94 return; 95 95 -
trunk/WebCore/editing/InsertListCommand.cpp
r64337 r66032 98 98 void InsertListCommand::doApply() 99 99 { 100 if ( endingSelection().isNone())100 if (!endingSelection().isNonOrphanedCaretOrRange()) 101 101 return; 102 102 103 103 if (!endingSelection().rootEditableElement()) 104 104 return; -
trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r63773 r66032 149 149 { 150 150 bool splitText = false; 151 if ( endingSelection().isNone())151 if (!endingSelection().isNonOrphanedCaretOrRange()) 152 152 return; 153 153 -
trunk/WebCore/editing/InsertTextCommand.cpp
r65468 r66032 112 112 ASSERT(text.find('\n') == notFound); 113 113 114 if ( endingSelection().isNone())114 if (!endingSelection().isNonOrphanedCaretOrRange()) 115 115 return; 116 116 -
trunk/WebCore/editing/MoveSelectionCommand.cpp
r56175 r66032 41 41 { 42 42 VisibleSelection selection = endingSelection(); 43 ASSERT(selection.is Range());43 ASSERT(selection.isNonOrphanedRange()); 44 44 45 45 Position pos = m_position; -
trunk/WebCore/editing/RemoveFormatCommand.cpp
r59956 r66032 50 50 { 51 51 Frame* frame = document()->frame(); 52 52 53 if (!frame->selection()->selection().isNonOrphanedCaretOrRange()) 54 return; 55 53 56 // Make a plain text string from the selection to remove formatting like tables and lists. 54 57 String string = plainText(frame->selection()->selection().toNormalizedRange().get()); -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r59956 r66032 783 783 ASSERT(selection.isCaretOrRange()); 784 784 ASSERT(selection.start().node()); 785 if ( selection.isNone() || !selection.start().node())785 if (!selection.isNonOrphanedCaretOrRange() || !selection.start().node()) 786 786 return; 787 787 -
trunk/WebCore/editing/TypingCommand.cpp
r65468 r66032 245 245 void TypingCommand::doApply() 246 246 { 247 if ( endingSelection().isNone())247 if (!endingSelection().isNonOrphanedCaretOrRange()) 248 248 return; 249 249 -
trunk/WebCore/editing/UnlinkCommand.cpp
r47688 r66032 39 39 { 40 40 // FIXME: If a caret is inside a link, we should remove it, but currently we don't. 41 if (!endingSelection().is Range())41 if (!endingSelection().isNonOrphanedRange()) 42 42 return; 43 43 44 44 pushPartiallySelectedAnchorElementsDown(); 45 45 -
trunk/WebCore/editing/VisibleSelection.h
r56175 r66032 74 74 bool isRange() const { return selectionType() == RangeSelection; } 75 75 bool isCaretOrRange() const { return selectionType() != NoSelection; } 76 bool isNonOrphanedRange() const { return isRange() && !start().isOrphan() && !end().isOrphan(); } 77 bool isNonOrphanedCaretOrRange() const { return isCaretOrRange() && !start().isOrphan() && !end().isOrphan(); } 76 78 77 79 bool isBaseFirst() const { return m_baseIsFirst; } -
trunk/WebCore/editing/htmlediting.h
r65021 r66032 219 219 // VisibleSelection 220 220 // ------------------------------------------------------------------------- 221 221 222 222 // Functions returning VisibleSelection 223 224 223 VisibleSelection avoidIntersectionWithNode(const VisibleSelection&, Node*); 225 224 VisibleSelection selectionForParagraphIteration(const VisibleSelection&);
Note: See TracChangeset
for help on using the changeset viewer.