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

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

Issue 2374183004: Make non-null VisibleSelections creatable only by createVisibleSelection[Deprecated] (Closed)
Patch Set: Fix mac compile error 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
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || hasEditableStyle (*doc))) 427 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || hasEditableStyle (*doc)))
428 return DragOperationNone; 428 return DragOperationNone;
429 return dragOperation(dragData); 429 return dragOperation(dragData);
430 } 430 }
431 431
432 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, Range*& range, const IntPoint& point) 432 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, Range*& range, const IntPoint& point)
433 { 433 {
434 frame->selection().setSelection(dragCaret); 434 frame->selection().setSelection(dragCaret);
435 if (frame->selection().isNone()) { 435 if (frame->selection().isNone()) {
436 dragCaret = VisibleSelection(frame->positionForPoint(point)); 436 dragCaret = createVisibleSelectionDeprecated(frame->positionForPoint(poi nt));
437 frame->selection().setSelection(dragCaret); 437 frame->selection().setSelection(dragCaret);
438 range = createRange(dragCaret.toNormalizedEphemeralRange()); 438 range = createRange(dragCaret.toNormalizedEphemeralRange());
439 } 439 }
440 return !frame->selection().isNone() && frame->selection().isContentEditable( ); 440 return !frame->selection().isNone() && frame->selection().isContentEditable( );
441 } 441 }
442 442
443 DispatchEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF rame, DragData* dragData) 443 DispatchEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF rame, DragData* dragData)
444 { 444 {
445 ASSERT(m_page->dragCaretController().hasCaret()); 445 ASSERT(m_page->dragCaretController().hasCaret());
446 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(); 446 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText();
447 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition())); 447 Element* target = innerFrame->editor().findEventTargetFrom(createVisibleSele ctionDeprecated(m_page->dragCaretController().caretPosition()));
448 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text)); 448 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text));
449 } 449 }
450 450
451 bool DragController::concludeEditDrag(DragData* dragData) 451 bool DragController::concludeEditDrag(DragData* dragData)
452 { 452 {
453 ASSERT(dragData); 453 ASSERT(dragData);
454 454
455 HTMLInputElement* fileInput = m_fileInputElementUnderMouse; 455 HTMLInputElement* fileInput = m_fileInputElementUnderMouse;
456 if (m_fileInputElementUnderMouse) { 456 if (m_fileInputElementUnderMouse) {
457 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 457 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
(...skipping 21 matching lines...) Expand all
479 return false; 479 return false;
480 480
481 return fileInput->receiveDroppedFiles(dragData); 481 return fileInput->receiveDroppedFiles(dragData);
482 } 482 }
483 483
484 if (!m_page->dragController().canProcessDrag(dragData)) { 484 if (!m_page->dragController().canProcessDrag(dragData)) {
485 m_page->dragCaretController().clear(); 485 m_page->dragCaretController().clear();
486 return false; 486 return false;
487 } 487 }
488 488
489 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition()); 489 VisibleSelection dragCaret = createVisibleSelectionDeprecated(m_page->dragCa retController().caretPosition());
490 m_page->dragCaretController().clear(); 490 m_page->dragCaretController().clear();
491 // |innerFrame| can be removed by event handler called by 491 // |innerFrame| can be removed by event handler called by
492 // |dispatchTextInputEventFor()|. 492 // |dispatchTextInputEventFor()|.
493 if (!innerFrame->selection().isAvailable()) { 493 if (!innerFrame->selection().isAvailable()) {
494 // "editing/pasteboard/drop-text-events-sideeffect-crash.html" reaches 494 // "editing/pasteboard/drop-text-events-sideeffect-crash.html" reaches
495 // here. 495 // here.
496 return false; 496 return false;
497 } 497 }
498 Range* range = createRange(dragCaret.toNormalizedEphemeralRange()); 498 Range* range = createRange(dragCaret.toNormalizedEphemeralRange());
499 Element* rootEditableElement = innerFrame->selection().rootEditableElement() ; 499 Element* rootEditableElement = innerFrame->selection().rootEditableElement() ;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 return (cachedImage && !cachedImage->errorOccurred()) ? 715 return (cachedImage && !cachedImage->errorOccurred()) ?
716 cachedImage->getImage() : nullptr; 716 cachedImage->getImage() : nullptr;
717 } 717 }
718 718
719 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri ng& label) 719 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri ng& label)
720 { 720 {
721 node->document().updateStyleAndLayoutTree(); 721 node->document().updateStyleAndLayoutTree();
722 if (hasRichlyEditableStyle(*node)) { 722 if (hasRichlyEditableStyle(*node)) {
723 Range* range = source->document()->createRange(); 723 Range* range = source->document()->createRange();
724 range->selectNode(node, ASSERT_NO_EXCEPTION); 724 range->selectNode(node, ASSERT_NO_EXCEPTION);
725 source->selection().setSelection(VisibleSelection(EphemeralRange(range)) ); 725 source->selection().setSelection(createVisibleSelectionDeprecated(Epheme ralRange(range)));
726 } 726 }
727 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label); 727 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label);
728 } 728 }
729 729
730 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState& state, const IntPoint& dragOrigin) 730 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState& state, const IntPoint& dragOrigin)
731 { 731 {
732 ASSERT(dragTypeIsValid(state.m_dragType)); 732 ASSERT(dragTypeIsValid(state.m_dragType));
733 ASSERT(src); 733 ASSERT(src);
734 if (!src->view() || src->contentLayoutItem().isNull()) 734 if (!src->view() || src->contentLayoutItem().isNull())
735 return false; 735 return false;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 997
998 DEFINE_TRACE(DragController) 998 DEFINE_TRACE(DragController)
999 { 999 {
1000 visitor->trace(m_page); 1000 visitor->trace(m_page);
1001 visitor->trace(m_documentUnderMouse); 1001 visitor->trace(m_documentUnderMouse);
1002 visitor->trace(m_dragInitiator); 1002 visitor->trace(m_dragInitiator);
1003 visitor->trace(m_fileInputElementUnderMouse); 1003 visitor->trace(m_fileInputElementUnderMouse);
1004 } 1004 }
1005 1005
1006 } // namespace blink 1006 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698