Commit 4e348b48 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Prune createVisibleSelectionDeprecated from DragController

This patch prunes createVisibleSelectionDeprecated from DragController
by either having an explicit layout update before each call site, or
confirming that the layout is already clean.

Note: Layout is clean at the call site in |dispatchTextInputEventFor()|
because it's called directly after a hit test, which is performed in
|elementUnderMouse()|.

BUG=651373

Review-Url: https://codereview.chromium.org/2386083002
Cr-Commit-Position: refs/heads/master@{#423036}
parent 1f5a5a2f
...@@ -462,8 +462,11 @@ static bool setSelectionToDragCaret(LocalFrame* frame, ...@@ -462,8 +462,11 @@ static bool setSelectionToDragCaret(LocalFrame* frame,
const IntPoint& point) { const IntPoint& point) {
frame->selection().setSelection(dragCaret); frame->selection().setSelection(dragCaret);
if (frame->selection().isNone()) { if (frame->selection().isNone()) {
dragCaret = // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
createVisibleSelectionDeprecated(frame->positionForPoint(point)); // needs to be audited. See http://crbug.com/590369 for more details.
frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
dragCaret = createVisibleSelection(frame->positionForPoint(point));
frame->selection().setSelection(dragCaret); frame->selection().setSelection(dragCaret);
range = createRange(dragCaret.toNormalizedEphemeralRange()); range = createRange(dragCaret.toNormalizedEphemeralRange());
} }
...@@ -473,13 +476,14 @@ static bool setSelectionToDragCaret(LocalFrame* frame, ...@@ -473,13 +476,14 @@ static bool setSelectionToDragCaret(LocalFrame* frame,
DispatchEventResult DragController::dispatchTextInputEventFor( DispatchEventResult DragController::dispatchTextInputEventFor(
LocalFrame* innerFrame, LocalFrame* innerFrame,
DragData* dragData) { DragData* dragData) {
// Layout should be clean due to a hit test performed in |elementUnderMouse|.
DCHECK(!innerFrame->document()->needsLayoutTreeUpdate());
ASSERT(m_page->dragCaretController().hasCaret()); ASSERT(m_page->dragCaretController().hasCaret());
String text = m_page->dragCaretController().isContentRichlyEditable() String text = m_page->dragCaretController().isContentRichlyEditable()
? "" ? ""
: dragData->asPlainText(); : dragData->asPlainText();
Element* target = Element* target = innerFrame->editor().findEventTargetFrom(
innerFrame->editor().findEventTargetFrom(createVisibleSelectionDeprecated( createVisibleSelection(m_page->dragCaretController().caretPosition()));
m_page->dragCaretController().caretPosition()));
return target->dispatchEvent( return target->dispatchEvent(
TextEvent::createForDrop(innerFrame->domWindow(), text)); TextEvent::createForDrop(innerFrame->domWindow(), text));
} }
...@@ -524,8 +528,18 @@ bool DragController::concludeEditDrag(DragData* dragData) { ...@@ -524,8 +528,18 @@ bool DragController::concludeEditDrag(DragData* dragData) {
return false; return false;
} }
VisibleSelection dragCaret = createVisibleSelectionDeprecated( if (m_page->dragCaretController().hasCaret()) {
m_page->dragCaretController().caretPosition()); // 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(); m_page->dragCaretController().clear();
// |innerFrame| can be removed by event handler called by // |innerFrame| can be removed by event handler called by
// |dispatchTextInputEventFor()|. // |dispatchTextInputEventFor()|.
...@@ -815,7 +829,7 @@ static void prepareDataTransferForImageDrag(LocalFrame* source, ...@@ -815,7 +829,7 @@ static void prepareDataTransferForImageDrag(LocalFrame* source,
Range* range = source->document()->createRange(); Range* range = source->document()->createRange();
range->selectNode(node, ASSERT_NO_EXCEPTION); range->selectNode(node, ASSERT_NO_EXCEPTION);
source->selection().setSelection( source->selection().setSelection(
createVisibleSelectionDeprecated(EphemeralRange(range))); createVisibleSelection(EphemeralRange(range)));
} }
dataTransfer->declareAndWriteDragImage( dataTransfer->declareAndWriteDragImage(
node, !linkURL.isEmpty() ? linkURL : imageURL, label); node, !linkURL.isEmpty() ? linkURL : imageURL, label);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment