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

Unified Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2558643003: [InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) (Closed)
Patch Set: xiaocheng's review 3: Rebase and remove updateStyleAndLayoutIgnorePendingStylesheets() Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/page/DragController.cpp
diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp
index 0be7eaeadf9e19192115fdf043a20fa3d9f9fab6..ffcb50ab6643b444d6de046e1bf67ce389c2c606 100644
--- a/third_party/WebKit/Source/core/page/DragController.cpp
+++ b/third_party/WebKit/Source/core/page/DragController.cpp
@@ -601,9 +601,13 @@ bool DragController::concludeEditDrag(DragData* dragData) {
? InsertMode::Smart
: InsertMode::Simple;
- if (!innerFrame->editor().deleteSelectionAfterDraggingWithEvents(
- innerFrame->editor().findEventTargetFromSelection(), deleteMode,
- dragCaret.base()))
+ innerFrame->editor().deleteSelectionWithSmartDelete(
+ EditCommandSource::kMenuOrKeyBinding, deleteMode,
+ InputEvent::InputType::DeleteByDrag, dragCaret.base());
+
+ // 'beforeinput' event handler may destroy drop frame.
+ if (innerFrame->document()->frame() != innerFrame ||
+ !element->isConnected())
return false;
innerFrame->selection().setSelection(
@@ -612,19 +616,16 @@ bool DragController::concludeEditDrag(DragData* dragData) {
.build());
if (innerFrame->selection().isAvailable()) {
DCHECK(m_documentUnderMouse);
- if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents(
- element, dragData, fragment, range, insertMode, dragSourceType))
- return false;
+ innerFrame->editor().replaceSelectionAfterDragging(fragment, insertMode,
+ dragSourceType);
}
} else {
if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
DCHECK(m_documentUnderMouse);
- if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents(
- element, dragData, fragment, range,
- dragData->canSmartReplace() ? InsertMode::Smart
- : InsertMode::Simple,
- dragSourceType))
- return false;
+ innerFrame->editor().replaceSelectionAfterDragging(
+ fragment, dragData->canSmartReplace() ? InsertMode::Smart
+ : InsertMode::Simple,
+ dragSourceType);
}
}
} else {
@@ -634,14 +635,15 @@ bool DragController::concludeEditDrag(DragData* dragData) {
if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
DCHECK(m_documentUnderMouse);
- if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents(
- element, dragData,
- createFragmentFromText(EphemeralRange(range), text), range,
- InsertMode::Simple, DragSourceType::PlainTextSource))
- return false;
+ innerFrame->editor().replaceSelectionAfterDragging(
+ createFragmentFromText(EphemeralRange(range), text),
+ InsertMode::Simple, DragSourceType::PlainTextSource);
}
}
+ // 'beforeinput' event handler may destroy drop frame.
+ if (!innerFrame->document() || innerFrame->document()->frame() != innerFrame)
+ return false;
if (rootEditableElement) {
if (LocalFrame* frame = rootEditableElement->document().frame()) {
frame->eventHandler().updateDragStateAfterEditDragIfNeeded(
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698