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

Side by Side Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2386083002: Prune createVisibleSelectionDeprecated from DragController (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return DragOperationNone; 453 return DragOperationNone;
454 return dragOperation(dragData); 454 return dragOperation(dragData);
455 } 455 }
456 456
457 static bool setSelectionToDragCaret(LocalFrame* frame, 457 static bool setSelectionToDragCaret(LocalFrame* frame,
458 VisibleSelection& dragCaret, 458 VisibleSelection& dragCaret,
459 Range*& range, 459 Range*& range,
460 const IntPoint& point) { 460 const IntPoint& point) {
461 frame->selection().setSelection(dragCaret); 461 frame->selection().setSelection(dragCaret);
462 if (frame->selection().isNone()) { 462 if (frame->selection().isNone()) {
463 dragCaret = 463 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
464 createVisibleSelectionDeprecated(frame->positionForPoint(point)); 464 // needs to be audited. See http://crbug.com/590369 for more details.
465 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
466
467 dragCaret = createVisibleSelection(frame->positionForPoint(point));
465 frame->selection().setSelection(dragCaret); 468 frame->selection().setSelection(dragCaret);
466 range = createRange(dragCaret.toNormalizedEphemeralRange()); 469 range = createRange(dragCaret.toNormalizedEphemeralRange());
467 } 470 }
468 return !frame->selection().isNone() && frame->selection().isContentEditable(); 471 return !frame->selection().isNone() && frame->selection().isContentEditable();
469 } 472 }
470 473
471 DispatchEventResult DragController::dispatchTextInputEventFor( 474 DispatchEventResult DragController::dispatchTextInputEventFor(
472 LocalFrame* innerFrame, 475 LocalFrame* innerFrame,
473 DragData* dragData) { 476 DragData* dragData) {
474 ASSERT(m_page->dragCaretController().hasCaret()); 477 ASSERT(m_page->dragCaretController().hasCaret());
475 String text = m_page->dragCaretController().isContentRichlyEditable() 478 String text = m_page->dragCaretController().isContentRichlyEditable()
476 ? "" 479 ? ""
477 : dragData->asPlainText(); 480 : dragData->asPlainText();
478 Element* target = 481 Element* target = innerFrame->editor().findEventTargetFrom(
479 innerFrame->editor().findEventTargetFrom(createVisibleSelectionDeprecated( 482 createVisibleSelection(m_page->dragCaretController().caretPosition()));
tkent 2016/10/03 23:37:09 Please explain why we can use non-deprecated versi
480 m_page->dragCaretController().caretPosition()));
481 return target->dispatchEvent( 483 return target->dispatchEvent(
482 TextEvent::createForDrop(innerFrame->domWindow(), text)); 484 TextEvent::createForDrop(innerFrame->domWindow(), text));
483 } 485 }
484 486
485 bool DragController::concludeEditDrag(DragData* dragData) { 487 bool DragController::concludeEditDrag(DragData* dragData) {
486 ASSERT(dragData); 488 ASSERT(dragData);
487 489
488 HTMLInputElement* fileInput = m_fileInputElementUnderMouse; 490 HTMLInputElement* fileInput = m_fileInputElementUnderMouse;
489 if (m_fileInputElementUnderMouse) { 491 if (m_fileInputElementUnderMouse) {
490 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 492 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
(...skipping 24 matching lines...) Expand all
515 return false; 517 return false;
516 518
517 return fileInput->receiveDroppedFiles(dragData); 519 return fileInput->receiveDroppedFiles(dragData);
518 } 520 }
519 521
520 if (!m_page->dragController().canProcessDrag(dragData)) { 522 if (!m_page->dragController().canProcessDrag(dragData)) {
521 m_page->dragCaretController().clear(); 523 m_page->dragCaretController().clear();
522 return false; 524 return false;
523 } 525 }
524 526
525 VisibleSelection dragCaret = createVisibleSelectionDeprecated( 527 if (m_page->dragCaretController().hasCaret()) {
526 m_page->dragCaretController().caretPosition()); 528 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
529 // needs to be audited. See http://crbug.com/590369 for more details.
530 m_page->dragCaretController()
531 .caretPosition()
532 .position()
533 .document()
534 ->updateStyleAndLayoutIgnorePendingStylesheets();
535 }
536
537 VisibleSelection dragCaret =
538 createVisibleSelection(m_page->dragCaretController().caretPosition());
527 m_page->dragCaretController().clear(); 539 m_page->dragCaretController().clear();
528 // |innerFrame| can be removed by event handler called by 540 // |innerFrame| can be removed by event handler called by
529 // |dispatchTextInputEventFor()|. 541 // |dispatchTextInputEventFor()|.
530 if (!innerFrame->selection().isAvailable()) { 542 if (!innerFrame->selection().isAvailable()) {
531 // "editing/pasteboard/drop-text-events-sideeffect-crash.html" reaches 543 // "editing/pasteboard/drop-text-events-sideeffect-crash.html" reaches
532 // here. 544 // here.
533 return false; 545 return false;
534 } 546 }
535 Range* range = createRange(dragCaret.toNormalizedEphemeralRange()); 547 Range* range = createRange(dragCaret.toNormalizedEphemeralRange());
536 Element* rootEditableElement = innerFrame->selection().rootEditableElement(); 548 Element* rootEditableElement = innerFrame->selection().rootEditableElement();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 DataTransfer* dataTransfer, 792 DataTransfer* dataTransfer,
781 Element* node, 793 Element* node,
782 const KURL& linkURL, 794 const KURL& linkURL,
783 const KURL& imageURL, 795 const KURL& imageURL,
784 const String& label) { 796 const String& label) {
785 node->document().updateStyleAndLayoutTree(); 797 node->document().updateStyleAndLayoutTree();
786 if (hasRichlyEditableStyle(*node)) { 798 if (hasRichlyEditableStyle(*node)) {
787 Range* range = source->document()->createRange(); 799 Range* range = source->document()->createRange();
788 range->selectNode(node, ASSERT_NO_EXCEPTION); 800 range->selectNode(node, ASSERT_NO_EXCEPTION);
789 source->selection().setSelection( 801 source->selection().setSelection(
790 createVisibleSelectionDeprecated(EphemeralRange(range))); 802 createVisibleSelection(EphemeralRange(range)));
791 } 803 }
792 dataTransfer->declareAndWriteDragImage( 804 dataTransfer->declareAndWriteDragImage(
793 node, !linkURL.isEmpty() ? linkURL : imageURL, label); 805 node, !linkURL.isEmpty() ? linkURL : imageURL, label);
794 } 806 }
795 807
796 bool DragController::populateDragDataTransfer(LocalFrame* src, 808 bool DragController::populateDragDataTransfer(LocalFrame* src,
797 const DragState& state, 809 const DragState& state,
798 const IntPoint& dragOrigin) { 810 const IntPoint& dragOrigin) {
799 ASSERT(dragTypeIsValid(state.m_dragType)); 811 ASSERT(dragTypeIsValid(state.m_dragType));
800 ASSERT(src); 812 ASSERT(src);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 } 1129 }
1118 1130
1119 DEFINE_TRACE(DragController) { 1131 DEFINE_TRACE(DragController) {
1120 visitor->trace(m_page); 1132 visitor->trace(m_page);
1121 visitor->trace(m_documentUnderMouse); 1133 visitor->trace(m_documentUnderMouse);
1122 visitor->trace(m_dragInitiator); 1134 visitor->trace(m_dragInitiator);
1123 visitor->trace(m_fileInputElementUnderMouse); 1135 visitor->trace(m_fileInputElementUnderMouse);
1124 } 1136 }
1125 1137
1126 } // namespace blink 1138 } // namespace blink
OLDNEW
« 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