Changeset 73279 in webkit
- Timestamp:
- Dec 3, 2010 11:26:22 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r73278 r73279 1 2010-12-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 REGRESSION: Crash when deleting text after textarea's value is modified on input event 6 https://bugs.webkit.org/show_bug.cgi?id=49962 7 8 Added tests to ensure inserting and deleting a character inside input or textarea 9 succeeds even if the value of those elements have been rewritten by its input event handler. 10 11 * editing/input/set-value-on-input-and-delete-expected.txt: Added. 12 * editing/input/set-value-on-input-and-delete.html: Added. 13 * editing/input/set-value-on-input-and-forward-delete-expected.txt: Added. 14 * editing/input/set-value-on-input-and-forward-delete.html: Added. 15 * editing/input/set-value-on-input-and-type-input-expected.txt: Added. 16 * editing/input/set-value-on-input-and-type-input.html: Added. 17 * editing/input/set-value-on-input-and-type-textarea-expected.txt: Added. 18 * editing/input/set-value-on-input-and-type-textarea.html: Added. 19 1 20 2010-12-03 Sam Weinig <sam@webkit.org> 2 21 -
trunk/WebCore/ChangeLog
r73276 r73279 1 2010-12-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 REGRESSION: Crash when deleting text after textarea's value is modified on input event 6 https://bugs.webkit.org/show_bug.cgi?id=49962 7 8 The crash was caused by TypingCommand::deleteKeyPressed's reusing a typing command for 9 textarea's shadow DOM after its input event handler rewrote the value set by the typing command. 10 Because the reused typing command's ending selection was pointing at a shadow node 11 that has been detached from the document when the event handler set the new value, 12 rootEditableElement of the ending selection was null and caused the crash. 13 14 Fixed the bug by updating the ending selection of the last typing command when it differsfrom 15 that of the current selection held by the SelectionController in TypingCommand::deleteKeyPressed. 16 Also fixed similar bugs in forwardDeleteKeyPressed and insertText, and insertTextRunWithoutNewlines. 17 18 Tests: editing/input/set-value-on-input-and-delete.html 19 editing/input/set-value-on-input-and-forward-delete.html 20 editing/input/set-value-on-input-and-type-input.html 21 editing/input/set-value-on-input-and-type-textarea.html 22 23 * editing/InsertTextCommand.h: Added TypingCommand as a friend because it needs to update selection. 24 * editing/TypingCommand.cpp: 25 (WebCore::TypingCommand::deleteKeyPressed): Updates the last typing command's selection as needed. 26 (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto. 27 (WebCore::TypingCommand::insertText): Ditto. 28 (WebCore::TypingCommand::updateSelectionIfDifferentFromCurrentSelection): Added. 29 (WebCore::TypingCommand::insertTextRunWithoutNewlines): Updates InsertTextCommand's selection as needed. 30 * editing/TypingCommand.h: 31 1 32 2010-12-03 Daniel Cheng <dcheng@chromium.org> 2 33 -
trunk/WebCore/editing/InsertTextCommand.h
r55271 r73279 55 55 56 56 unsigned m_charactersAdded; 57 58 friend class TypingCommand; 57 59 }; 58 60 -
trunk/WebCore/editing/TypingCommand.cpp
r72469 r73279 92 92 EditCommand* lastEditCommand = frame->editor()->lastEditCommand(); 93 93 if (granularity == CharacterGranularity && isOpenForMoreTypingCommand(lastEditCommand)) { 94 updateSelectionIfDifferentFromCurrentSelection(static_cast<TypingCommand*>(lastEditCommand), frame); 94 95 static_cast<TypingCommand*>(lastEditCommand)->deleteKeyPressed(granularity, killRing); 95 96 return; … … 111 112 EditCommand* lastEditCommand = frame->editor()->lastEditCommand(); 112 113 if (granularity == CharacterGranularity && isOpenForMoreTypingCommand(lastEditCommand)) { 114 updateSelectionIfDifferentFromCurrentSelection(static_cast<TypingCommand*>(lastEditCommand), frame); 113 115 static_cast<TypingCommand*>(lastEditCommand)->forwardDeleteKeyPressed(granularity, killRing); 114 116 return; … … 120 122 } 121 123 124 void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Frame* frame) 125 { 126 ASSERT(frame); 127 VisibleSelection currentSelection = frame->selection()->selection(); 128 if (currentSelection == typingCommand->endingSelection()) 129 return; 130 131 typingCommand->setStartingSelection(currentSelection); 132 typingCommand->setEndingSelection(currentSelection); 133 } 134 135 122 136 void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, bool insertedTextIsComposition) 123 137 { … … 130 144 } 131 145 146 // FIXME: We shouldn't need to take selectionForInsertion. It should be identical to SelectionController's current selection. 132 147 void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, bool insertedTextIsComposition) 133 148 { … … 164 179 if (isOpenForMoreTypingCommand(lastEditCommand.get())) { 165 180 TypingCommand* lastTypingCommand = static_cast<TypingCommand*>(lastEditCommand.get()); 166 if ( changeSelection) {181 if (lastTypingCommand->endingSelection() != selectionForInsertion) { 167 182 lastTypingCommand->setStartingSelection(selectionForInsertion); 168 183 lastTypingCommand->setEndingSelection(selectionForInsertion); 169 184 } 170 185 lastTypingCommand->insertText(newText, selectInsertedText); 171 if (changeSelection) {172 lastTypingCommand->setEndingSelection(currentSelection);173 frame->selection()->setSelection(currentSelection);174 }175 186 return; 176 187 } … … 371 382 command = InsertTextCommand::create(document()); 372 383 applyCommandToComposite(command); 384 } 385 if (endingSelection() != command->endingSelection()) { 386 command->setStartingSelection(endingSelection()); 387 command->setEndingSelection(endingSelection()); 373 388 } 374 389 command->input(text, selectInsertedText); -
trunk/WebCore/editing/TypingCommand.h
r68613 r73279 82 82 virtual bool preservesTypingStyle() const { return m_preservesTypingStyle; } 83 83 84 static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*); 85 84 86 void updatePreservesTypingStyle(ETypingCommand); 85 87 void markMisspellingsAfterTyping(ETypingCommand);
Note: See TracChangeset
for help on using the changeset viewer.