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

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

Issue 1316603002: Make DragController to use VisibleSelection::toNormalizedEphemeralRange() instead of toNormalizedRan (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-25T14:37:36 Created 5 years, 4 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return DragOperationNone; 423 return DragOperationNone;
424 return dragOperation(dragData); 424 return dragOperation(dragData);
425 } 425 }
426 426
427 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point) 427 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point)
428 { 428 {
429 frame->selection().setSelection(dragCaret); 429 frame->selection().setSelection(dragCaret);
430 if (frame->selection().isNone()) { 430 if (frame->selection().isNone()) {
431 dragCaret = VisibleSelection(frame->visiblePositionForPoint(point)); 431 dragCaret = VisibleSelection(frame->visiblePositionForPoint(point));
432 frame->selection().setSelection(dragCaret); 432 frame->selection().setSelection(dragCaret);
433 range = dragCaret.toNormalizedRange(); 433 range = createRange(dragCaret.toNormalizedEphemeralRange());
434 } 434 }
435 return !frame->selection().isNone() && frame->selection().isContentEditable( ); 435 return !frame->selection().isNone() && frame->selection().isContentEditable( );
436 } 436 }
437 437
438 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData* dragData) 438 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData* dragData)
439 { 439 {
440 ASSERT(m_page->dragCaretController().hasCaret()); 440 ASSERT(m_page->dragCaretController().hasCaret());
441 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(); 441 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText();
442 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition())); 442 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition()));
443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text)); 443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return fileInput->receiveDroppedFiles(dragData); 476 return fileInput->receiveDroppedFiles(dragData);
477 } 477 }
478 478
479 if (!m_page->dragController().canProcessDrag(dragData)) { 479 if (!m_page->dragController().canProcessDrag(dragData)) {
480 m_page->dragCaretController().clear(); 480 m_page->dragCaretController().clear();
481 return false; 481 return false;
482 } 482 }
483 483
484 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition()); 484 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition());
485 m_page->dragCaretController().clear(); 485 m_page->dragCaretController().clear();
486 RefPtrWillBeRawPtr<Range> range = dragCaret.toNormalizedRange(); 486 RefPtrWillBeRawPtr<Range> range = createRange(dragCaret.toNormalizedEphemera lRange());
487 RefPtrWillBeRawPtr<Element> rootEditableElement = innerFrame->selection().ro otEditableElement(); 487 RefPtrWillBeRawPtr<Element> rootEditableElement = innerFrame->selection().ro otEditableElement();
488 488
489 // For range to be null a WebKit client must have done something bad while 489 // For range to be null a WebKit client must have done something bad while
490 // manually controlling drag behaviour 490 // manually controlling drag behaviour
491 if (!range) 491 if (!range)
492 return false; 492 return false;
493 ResourceFetcher* fetcher = range->ownerDocument().fetcher(); 493 ResourceFetcher* fetcher = range->ownerDocument().fetcher();
494 ResourceCacheValidationSuppressor validationSuppressor(fetcher); 494 ResourceCacheValidationSuppressor validationSuppressor(fetcher);
495 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) { 495 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) {
496 bool chosePlainText = false; 496 bool chosePlainText = false;
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 958
959 DEFINE_TRACE(DragController) 959 DEFINE_TRACE(DragController)
960 { 960 {
961 visitor->trace(m_page); 961 visitor->trace(m_page);
962 visitor->trace(m_documentUnderMouse); 962 visitor->trace(m_documentUnderMouse);
963 visitor->trace(m_dragInitiator); 963 visitor->trace(m_dragInitiator);
964 visitor->trace(m_fileInputElementUnderMouse); 964 visitor->trace(m_fileInputElementUnderMouse);
965 } 965 }
966 966
967 } // namespace blink 967 } // 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