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 c7938b4518e0a78294801d7a639abfd978e3bb52..bae2b719a67955c3d0b95823ef63d1fdb87d33bb 100644 |
--- a/third_party/WebKit/Source/core/page/DragController.cpp |
+++ b/third_party/WebKit/Source/core/page/DragController.cpp |
@@ -460,8 +460,11 @@ static bool setSelectionToDragCaret(LocalFrame* frame, |
const IntPoint& point) { |
frame->selection().setSelection(dragCaret); |
if (frame->selection().isNone()) { |
- dragCaret = |
- createVisibleSelectionDeprecated(frame->positionForPoint(point)); |
+ // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
+ // needs to be audited. See http://crbug.com/590369 for more details. |
+ frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ dragCaret = createVisibleSelection(frame->positionForPoint(point)); |
frame->selection().setSelection(dragCaret); |
range = createRange(dragCaret.toNormalizedEphemeralRange()); |
} |
@@ -471,13 +474,14 @@ static bool setSelectionToDragCaret(LocalFrame* frame, |
DispatchEventResult DragController::dispatchTextInputEventFor( |
LocalFrame* innerFrame, |
DragData* dragData) { |
+ // Layout should be clean due to a hit test performed in |elementUnderMouse|. |
+ DCHECK(!innerFrame->document()->needsLayoutTreeUpdate()); |
ASSERT(m_page->dragCaretController().hasCaret()); |
String text = m_page->dragCaretController().isContentRichlyEditable() |
? "" |
: dragData->asPlainText(); |
- Element* target = |
- innerFrame->editor().findEventTargetFrom(createVisibleSelectionDeprecated( |
- m_page->dragCaretController().caretPosition())); |
+ Element* target = innerFrame->editor().findEventTargetFrom( |
+ createVisibleSelection(m_page->dragCaretController().caretPosition())); |
return target->dispatchEvent( |
TextEvent::createForDrop(innerFrame->domWindow(), text)); |
} |
@@ -522,8 +526,18 @@ bool DragController::concludeEditDrag(DragData* dragData) { |
return false; |
} |
- VisibleSelection dragCaret = createVisibleSelectionDeprecated( |
- m_page->dragCaretController().caretPosition()); |
+ if (m_page->dragCaretController().hasCaret()) { |
+ // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
+ // needs to be audited. See http://crbug.com/590369 for more details. |
+ m_page->dragCaretController() |
+ .caretPosition() |
+ .position() |
+ .document() |
+ ->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ } |
+ |
+ VisibleSelection dragCaret = |
+ createVisibleSelection(m_page->dragCaretController().caretPosition()); |
m_page->dragCaretController().clear(); |
// |innerFrame| can be removed by event handler called by |
// |dispatchTextInputEventFor()|. |
@@ -787,7 +801,7 @@ static void prepareDataTransferForImageDrag(LocalFrame* source, |
Range* range = source->document()->createRange(); |
range->selectNode(node, ASSERT_NO_EXCEPTION); |
source->selection().setSelection( |
- createVisibleSelectionDeprecated(EphemeralRange(range))); |
+ createVisibleSelection(EphemeralRange(range))); |
} |
dataTransfer->declareAndWriteDragImage( |
node, !linkURL.isEmpty() ? linkURL : imageURL, label); |