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

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

Issue 2386083002: Prune createVisibleSelectionDeprecated from DragController (Closed)
Patch Set: Add DCHECK and comments about clean layout Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698