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

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

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 years, 8 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 DragController::~DragController() 142 DragController::~DragController()
143 { 143 {
144 } 144 }
145 145
146 PassOwnPtr<DragController> DragController::create(Page* page, DragClient* client ) 146 PassOwnPtr<DragController> DragController::create(Page* page, DragClient* client )
147 { 147 {
148 return adoptPtr(new DragController(page, client)); 148 return adoptPtr(new DragController(page, client));
149 } 149 }
150 150
151 static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD ata, LocalFrame* frame, RefPtr<Range> context, 151 static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD ata, LocalFrame* frame, RefPtrWillBeRawPtr<Range> context,
152 bool allowPlainText, bool& chosePlainT ext) 152 bool allowPlainText, bool& chosePlainT ext)
153 { 153 {
154 ASSERT(dragData); 154 ASSERT(dragData);
155 chosePlainText = false; 155 chosePlainText = false;
156 156
157 Document& document = context->ownerDocument(); 157 Document& document = context->ownerDocument();
158 if (dragData->containsCompatibleContent()) { 158 if (dragData->containsCompatibleContent()) {
159 if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context, allowPlainText, chosePlainText)) 159 if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context, allowPlainText, chosePlainText))
160 return fragment; 160 return fragment;
161 161
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 DragOperation DragController::operationForLoad(DragData* dragData) 417 DragOperation DragController::operationForLoad(DragData* dragData)
418 { 418 {
419 ASSERT(dragData); 419 ASSERT(dragData);
420 Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPositio n()); 420 Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPositio n());
421 421
422 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE ditable())) 422 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE ditable()))
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, RefPtr<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 = dragCaret.toNormalizedRange();
434 } 434 }
435 return !frame->selection().isNone() && frame->selection().isContentEditable( ); 435 return !frame->selection().isNone() && frame->selection().isContentEditable( );
436 } 436 }
437 437
(...skipping 38 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 RefPtr<Range> range = dragCaret.toNormalizedRange(); 486 RefPtrWillBeRawPtr<Range> range = dragCaret.toNormalizedRange();
487 RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl ement(); 487 RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl ement();
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // Don't use cachedImage->imageForRenderer() here as that may return BitmapI mages for cached SVG Images. 707 // Don't use cachedImage->imageForRenderer() here as that may return BitmapI mages for cached SVG Images.
708 // Users of getImage() want access to the SVGImage, in order to figure out t he filename extensions, 708 // Users of getImage() want access to the SVGImage, in order to figure out t he filename extensions,
709 // which would be empty when asking the cached BitmapImages. 709 // which would be empty when asking the cached BitmapImages.
710 return (cachedImage && !cachedImage->errorOccurred()) ? 710 return (cachedImage && !cachedImage->errorOccurred()) ?
711 cachedImage->image() : 0; 711 cachedImage->image() : 0;
712 } 712 }
713 713
714 static void prepareClipboardForImageDrag(LocalFrame* source, Clipboard* clipboar d, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label ) 714 static void prepareClipboardForImageDrag(LocalFrame* source, Clipboard* clipboar d, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label )
715 { 715 {
716 if (node->isContentRichlyEditable()) { 716 if (node->isContentRichlyEditable()) {
717 RefPtr<Range> range = source->document()->createRange(); 717 RefPtrWillBeRawPtr<Range> range = source->document()->createRange();
718 range->selectNode(node, ASSERT_NO_EXCEPTION); 718 range->selectNode(node, ASSERT_NO_EXCEPTION);
719 source->selection().setSelection(VisibleSelection(range.get(), DOWNSTREA M)); 719 source->selection().setSelection(VisibleSelection(range.get(), DOWNSTREA M));
720 } 720 }
721 clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : ima geURL, label); 721 clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : ima geURL, label);
722 } 722 }
723 723
724 bool DragController::populateDragClipboard(LocalFrame* src, const DragState& sta te, const IntPoint& dragOrigin) 724 bool DragController::populateDragClipboard(LocalFrame* src, const DragState& sta te, const IntPoint& dragOrigin)
725 { 725 {
726 ASSERT(dragTypeIsValid(state.m_dragType)); 726 ASSERT(dragTypeIsValid(state.m_dragType));
727 ASSERT(src); 727 ASSERT(src);
(...skipping 12 matching lines...) Expand all
740 const KURL& linkURL = hitTestResult.absoluteLinkURL(); 740 const KURL& linkURL = hitTestResult.absoluteLinkURL();
741 const KURL& imageURL = hitTestResult.absoluteImageURL(); 741 const KURL& imageURL = hitTestResult.absoluteImageURL();
742 742
743 Clipboard* clipboard = state.m_dragClipboard.get(); 743 Clipboard* clipboard = state.m_dragClipboard.get();
744 Node* node = state.m_dragSrc.get(); 744 Node* node = state.m_dragSrc.get();
745 745
746 if (state.m_dragType == DragSourceActionSelection) { 746 if (state.m_dragType == DragSourceActionSelection) {
747 if (enclosingTextFormControl(src->selection().start())) { 747 if (enclosingTextFormControl(src->selection().start())) {
748 clipboard->writePlainText(src->selectedTextForClipboard()); 748 clipboard->writePlainText(src->selectedTextForClipboard());
749 } else { 749 } else {
750 RefPtr<Range> selectionRange = src->selection().toNormalizedRange(); 750 RefPtrWillBeRawPtr<Range> selectionRange = src->selection().toNormal izedRange();
751 ASSERT(selectionRange); 751 ASSERT(selectionRange);
752 752
753 clipboard->writeRange(selectionRange.get(), src); 753 clipboard->writeRange(selectionRange.get(), src);
754 } 754 }
755 } else if (state.m_dragType == DragSourceActionImage) { 755 } else if (state.m_dragType == DragSourceActionImage) {
756 if (imageURL.isEmpty() || !node || !node->isElementNode()) 756 if (imageURL.isEmpty() || !node || !node->isElementNode())
757 return false; 757 return false;
758 Element* element = toElement(node); 758 Element* element = toElement(node);
759 prepareClipboardForImageDrag(src, clipboard, element, linkURL, imageURL, hitTestResult.altDisplayString()); 759 prepareClipboardForImageDrag(src, clipboard, element, linkURL, imageURL, hitTestResult.altDisplayString());
760 } else if (state.m_dragType == DragSourceActionLink) { 760 } else if (state.m_dragType == DragSourceActionLink) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 #else 958 #else
959 return keyState & PlatformEvent::CtrlKey; 959 return keyState & PlatformEvent::CtrlKey;
960 #endif 960 #endif
961 } 961 }
962 962
963 void DragController::cleanupAfterSystemDrag() 963 void DragController::cleanupAfterSystemDrag()
964 { 964 {
965 } 965 }
966 966
967 } // namespace WebCore 967 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698