Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2120223002: Make redo command not to set invalid selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-04T15:06:28 Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/undo/redo-selection-modify-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 } 803 }
804 804
805 void Editor::reappliedEditing(EditCommandComposition* cmd) 805 void Editor::reappliedEditing(EditCommandComposition* cmd)
806 { 806 {
807 EventQueueScope scope; 807 EventQueueScope scope;
808 frame().document()->updateStyleAndLayout(); 808 frame().document()->updateStyleAndLayout();
809 809
810 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement()); 810 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement());
811 dispatchInputEventEditableContentChanged(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), InputEvent::InputType::Redo, emptyString(), I nputEvent::EventIsComposing::NotComposing); 811 dispatchInputEventEditableContentChanged(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), InputEvent::InputType::Redo, emptyString(), I nputEvent::EventIsComposing::NotComposing);
812 812
813 // TODO(yosin): Since |dispatchEditableContentChangedEvents()| and
814 // |dispatchInputEventEditableContentChanged()|, we would like to know
815 // such case. Once we have a case, this |DCHECK()| should be replaced
816 // with if-statement.
817 DCHECK(frame().document());
813 VisibleSelection newSelection(cmd->endingSelection()); 818 VisibleSelection newSelection(cmd->endingSelection());
814 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram eSelection::ClearTypingStyle); 819 if (newSelection.isValidFor(*frame().document()))
Xiaocheng 2016/07/04 08:01:37 The fix looks fine to me, but for curiosity: It s
yosin_UTC9 2016/07/04 09:57:07 I may not understand you question fully... Anythi
820 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
815 821
816 m_lastEditCommand = nullptr; 822 m_lastEditCommand = nullptr;
817 if (UndoStack* undoStack = this->undoStack()) 823 if (UndoStack* undoStack = this->undoStack())
818 undoStack->registerUndoStep(cmd); 824 undoStack->registerUndoStep(cmd);
819 respondToChangedContents(newSelection); 825 respondToChangedContents(newSelection);
820 } 826 }
821 827
822 Editor* Editor::create(LocalFrame& frame) 828 Editor* Editor::create(LocalFrame& frame)
823 { 829 {
824 return new Editor(frame); 830 return new Editor(frame);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 } 1437 }
1432 1438
1433 DEFINE_TRACE(Editor) 1439 DEFINE_TRACE(Editor)
1434 { 1440 {
1435 visitor->trace(m_frame); 1441 visitor->trace(m_frame);
1436 visitor->trace(m_lastEditCommand); 1442 visitor->trace(m_lastEditCommand);
1437 visitor->trace(m_mark); 1443 visitor->trace(m_mark);
1438 } 1444 }
1439 1445
1440 } // namespace blink 1446 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/undo/redo-selection-modify-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698