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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 , m_dragDestinationAction(DragDestinationActionNone) 134 , m_dragDestinationAction(DragDestinationActionNone)
135 , m_didInitiateDrag(false) 135 , m_didInitiateDrag(false)
136 { 136 {
137 ASSERT(m_client); 137 ASSERT(m_client);
138 } 138 }
139 139
140 DragController::~DragController() 140 DragController::~DragController()
141 { 141 {
142 } 142 }
143 143
144 PassOwnPtrWillBeRawPtr<DragController> DragController::create(Page* page, DragCl ient* client) 144 RawPtr<DragController> DragController::create(Page* page, DragClient* client)
145 { 145 {
146 return adoptPtrWillBeNoop(new DragController(page, client)); 146 return new DragController(page, client);
147 } 147 }
148 148
149 static PassRefPtrWillBeRawPtr<DocumentFragment> documentFragmentFromDragData(Dra gData* dragData, LocalFrame* frame, RefPtrWillBeRawPtr<Range> context, bool allo wPlainText, bool& chosePlainText) 149 static RawPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, LocalFrame* frame, RawPtr<Range> context, bool allowPlainText, bool& chosePlain Text)
150 { 150 {
151 ASSERT(dragData); 151 ASSERT(dragData);
152 chosePlainText = false; 152 chosePlainText = false;
153 153
154 Document& document = context->ownerDocument(); 154 Document& document = context->ownerDocument();
155 if (dragData->containsCompatibleContent()) { 155 if (dragData->containsCompatibleContent()) {
156 if (PassRefPtrWillBeRawPtr<DocumentFragment> fragment = dragData->asFrag ment(frame)) 156 if (RawPtr<DocumentFragment> fragment = dragData->asFragment(frame))
157 return fragment; 157 return fragment;
158 158
159 if (dragData->containsURL(DragData::DoNotConvertFilenames)) { 159 if (dragData->containsURL(DragData::DoNotConvertFilenames)) {
160 String title; 160 String title;
161 String url = dragData->asURL(DragData::DoNotConvertFilenames, &title ); 161 String url = dragData->asURL(DragData::DoNotConvertFilenames, &title );
162 if (!url.isEmpty()) { 162 if (!url.isEmpty()) {
163 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement ::create(document); 163 RawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(doc ument);
164 anchor->setHref(AtomicString(url)); 164 anchor->setHref(AtomicString(url));
165 if (title.isEmpty()) { 165 if (title.isEmpty()) {
166 // Try the plain text first because the url might be normali zed or escaped. 166 // Try the plain text first because the url might be normali zed or escaped.
167 if (dragData->containsPlainText()) 167 if (dragData->containsPlainText())
168 title = dragData->asPlainText(); 168 title = dragData->asPlainText();
169 if (title.isEmpty()) 169 if (title.isEmpty())
170 title = url; 170 title = url;
171 } 171 }
172 RefPtrWillBeRawPtr<Node> anchorText = document.createTextNode(ti tle); 172 RawPtr<Node> anchorText = document.createTextNode(title);
173 anchor->appendChild(anchorText); 173 anchor->appendChild(anchorText);
174 RefPtrWillBeRawPtr<DocumentFragment> fragment = document.createD ocumentFragment(); 174 RawPtr<DocumentFragment> fragment = document.createDocumentFragm ent();
175 fragment->appendChild(anchor); 175 fragment->appendChild(anchor);
176 return fragment.release(); 176 return fragment.release();
177 } 177 }
178 } 178 }
179 } 179 }
180 if (allowPlainText && dragData->containsPlainText()) { 180 if (allowPlainText && dragData->containsPlainText()) {
181 chosePlainText = true; 181 chosePlainText = true;
182 return createFragmentFromText(EphemeralRange(context.get()), dragData->a sPlainText()).get(); 182 return createFragmentFromText(EphemeralRange(context.get()), dragData->a sPlainText()).get();
183 } 183 }
184 184
(...skipping 21 matching lines...) Expand all
206 DragSession DragController::dragEntered(DragData* dragData) 206 DragSession DragController::dragEntered(DragData* dragData)
207 { 207 {
208 return dragEnteredOrUpdated(dragData); 208 return dragEnteredOrUpdated(dragData);
209 } 209 }
210 210
211 void DragController::dragExited(DragData* dragData) 211 void DragController::dragExited(DragData* dragData)
212 { 212 {
213 ASSERT(dragData); 213 ASSERT(dragData);
214 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); 214 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame();
215 215
216 RefPtrWillBeRawPtr<FrameView> frameView(mainFrame->view()); 216 RawPtr<FrameView> frameView(mainFrame->view());
217 if (frameView) { 217 if (frameView) {
218 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn derMouse->getSecurityOrigin()->isLocal()) ? DataTransferReadable : DataTransferT ypesReadable; 218 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn derMouse->getSecurityOrigin()->isLocal()) ? DataTransferReadable : DataTransferT ypesReadable;
219 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData ); 219 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData );
220 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask() ); 220 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask() );
221 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData), dataTransfer); 221 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData), dataTransfer);
222 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security 222 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security
223 } 223 }
224 mouseMovedIntoDocument(nullptr); 224 mouseMovedIntoDocument(nullptr);
225 if (m_fileInputElementUnderMouse) 225 if (m_fileInputElementUnderMouse)
226 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 226 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
227 m_fileInputElementUnderMouse = nullptr; 227 m_fileInputElementUnderMouse = nullptr;
228 } 228 }
229 229
230 DragSession DragController::dragUpdated(DragData* dragData) 230 DragSession DragController::dragUpdated(DragData* dragData)
231 { 231 {
232 return dragEnteredOrUpdated(dragData); 232 return dragEnteredOrUpdated(dragData);
233 } 233 }
234 234
235 bool DragController::performDrag(DragData* dragData) 235 bool DragController::performDrag(DragData* dragData)
236 { 236 {
237 ASSERT(dragData); 237 ASSERT(dragData);
238 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d ragData->clientPosition()); 238 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d ragData->clientPosition());
239 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) { 239 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) {
240 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFr ame(); 240 RawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame();
241 bool preventedDefault = false; 241 bool preventedDefault = false;
242 if (mainFrame->view()) { 242 if (mainFrame->view()) {
243 // Sending an event can result in the destruction of the view and pa rt. 243 // Sending an event can result in the destruction of the view and pa rt.
244 DataTransfer* dataTransfer = createDraggingDataTransfer(DataTransfer Readable, dragData); 244 DataTransfer* dataTransfer = createDraggingDataTransfer(DataTransfer Readable, dragData);
245 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa sk()); 245 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa sk());
246 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), dataTransfer) != WebInputEventResult::NotHandled; 246 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), dataTransfer) != WebInputEventResult::NotHandled;
247 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb oard here for security 247 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb oard here for security
248 } 248 }
249 if (preventedDefault) { 249 if (preventedDefault) {
250 m_documentUnderMouse = nullptr; 250 m_documentUnderMouse = nullptr;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // tryDHTMLDrag fires dragenter event. The event listener that listens 341 // tryDHTMLDrag fires dragenter event. The event listener that listens
342 // to this event may create a nested message loop (open a modal dialog), 342 // to this event may create a nested message loop (open a modal dialog),
343 // which could process dragleave event and reset m_documentUnderMouse in 343 // which could process dragleave event and reset m_documentUnderMouse in
344 // dragExited. 344 // dragExited.
345 if (!m_documentUnderMouse) 345 if (!m_documentUnderMouse)
346 return false; 346 return false;
347 } 347 }
348 348
349 // It's unclear why this check is after tryDHTMLDrag. 349 // It's unclear why this check is after tryDHTMLDrag.
350 // We send drag events in tryDHTMLDrag and that may be the reason. 350 // We send drag events in tryDHTMLDrag and that may be the reason.
351 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); 351 RawPtr<FrameView> frameView = m_documentUnderMouse->view();
352 if (!frameView) 352 if (!frameView)
353 return false; 353 return false;
354 354
355 if (isHandlingDrag) { 355 if (isHandlingDrag) {
356 m_page->dragCaretController().clear(); 356 m_page->dragCaretController().clear();
357 return true; 357 return true;
358 } 358 }
359 359
360 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { 360 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) {
361 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition ()); 361 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition ());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 DragOperation DragController::operationForLoad(DragData* dragData) 414 DragOperation DragController::operationForLoad(DragData* dragData)
415 { 415 {
416 ASSERT(dragData); 416 ASSERT(dragData);
417 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint(dragData ->clientPosition()); 417 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint(dragData ->clientPosition());
418 418
419 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->hasEditable Style())) 419 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->hasEditable Style()))
420 return DragOperationNone; 420 return DragOperationNone;
421 return dragOperation(dragData); 421 return dragOperation(dragData);
422 } 422 }
423 423
424 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point) 424 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar et, RawPtr<Range>& range, const IntPoint& point)
425 { 425 {
426 frame->selection().setSelection(dragCaret); 426 frame->selection().setSelection(dragCaret);
427 if (frame->selection().isNone()) { 427 if (frame->selection().isNone()) {
428 dragCaret = VisibleSelection(frame->positionForPoint(point)); 428 dragCaret = VisibleSelection(frame->positionForPoint(point));
429 frame->selection().setSelection(dragCaret); 429 frame->selection().setSelection(dragCaret);
430 range = createRange(dragCaret.toNormalizedEphemeralRange()); 430 range = createRange(dragCaret.toNormalizedEphemeralRange());
431 } 431 }
432 return !frame->selection().isNone() && frame->selection().isContentEditable( ); 432 return !frame->selection().isNone() && frame->selection().isContentEditable( );
433 } 433 }
434 434
435 DispatchEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF rame, DragData* dragData) 435 DispatchEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF rame, DragData* dragData)
436 { 436 {
437 ASSERT(m_page->dragCaretController().hasCaret()); 437 ASSERT(m_page->dragCaretController().hasCaret());
438 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(); 438 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText();
439 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition())); 439 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition()));
440 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text)); 440 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text));
441 } 441 }
442 442
443 bool DragController::concludeEditDrag(DragData* dragData) 443 bool DragController::concludeEditDrag(DragData* dragData)
444 { 444 {
445 ASSERT(dragData); 445 ASSERT(dragData);
446 446
447 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous e; 447 RawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse;
448 if (m_fileInputElementUnderMouse) { 448 if (m_fileInputElementUnderMouse) {
449 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 449 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
450 m_fileInputElementUnderMouse = nullptr; 450 m_fileInputElementUnderMouse = nullptr;
451 } 451 }
452 452
453 if (!m_documentUnderMouse) 453 if (!m_documentUnderMouse)
454 return false; 454 return false;
455 455
456 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData- >clientPosition()); 456 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData- >clientPosition());
457 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 457 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
458 if (!element) 458 if (!element)
459 return false; 459 return false;
460 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame( ); 460 RawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame();
461 ASSERT(innerFrame); 461 ASSERT(innerFrame);
462 462
463 if (m_page->dragCaretController().hasCaret() && dispatchTextInputEventFor(in nerFrame.get(), dragData) != DispatchEventResult::NotCanceled) 463 if (m_page->dragCaretController().hasCaret() && dispatchTextInputEventFor(in nerFrame.get(), dragData) != DispatchEventResult::NotCanceled)
464 return true; 464 return true;
465 465
466 if (dragData->containsFiles() && fileInput) { 466 if (dragData->containsFiles() && fileInput) {
467 // fileInput should be the element we hit tested for, unless it was made 467 // fileInput should be the element we hit tested for, unless it was made
468 // display:none in a drop event handler. 468 // display:none in a drop event handler.
469 ASSERT(fileInput == element || !fileInput->layoutObject()); 469 ASSERT(fileInput == element || !fileInput->layoutObject());
470 if (fileInput->isDisabledFormControl()) 470 if (fileInput->isDisabledFormControl())
471 return false; 471 return false;
472 472
473 return fileInput->receiveDroppedFiles(dragData); 473 return fileInput->receiveDroppedFiles(dragData);
474 } 474 }
475 475
476 if (!m_page->dragController().canProcessDrag(dragData)) { 476 if (!m_page->dragController().canProcessDrag(dragData)) {
477 m_page->dragCaretController().clear(); 477 m_page->dragCaretController().clear();
478 return false; 478 return false;
479 } 479 }
480 480
481 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition()); 481 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition());
482 m_page->dragCaretController().clear(); 482 m_page->dragCaretController().clear();
483 RefPtrWillBeRawPtr<Range> range = createRange(dragCaret.toNormalizedEphemera lRange()); 483 RawPtr<Range> range = createRange(dragCaret.toNormalizedEphemeralRange());
484 RefPtrWillBeRawPtr<Element> rootEditableElement = innerFrame->selection().ro otEditableElement(); 484 RawPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl ement();
485 485
486 // For range to be null a WebKit client must have done something bad while 486 // For range to be null a WebKit client must have done something bad while
487 // manually controlling drag behaviour 487 // manually controlling drag behaviour
488 if (!range) 488 if (!range)
489 return false; 489 return false;
490 ResourceFetcher* fetcher = range->ownerDocument().fetcher(); 490 ResourceFetcher* fetcher = range->ownerDocument().fetcher();
491 ResourceCacheValidationSuppressor validationSuppressor(fetcher); 491 ResourceCacheValidationSuppressor validationSuppressor(fetcher);
492 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) { 492 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) {
493 bool chosePlainText = false; 493 bool chosePlainText = false;
494 RefPtrWillBeRawPtr<DocumentFragment> fragment = documentFragmentFromDrag Data(dragData, innerFrame.get(), range, true, chosePlainText); 494 RawPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat a, innerFrame.get(), range, true, chosePlainText);
495 if (!fragment) 495 if (!fragment)
496 return false; 496 return false;
497 497
498 if (dragIsMove(innerFrame->selection(), dragData)) { 498 if (dragIsMove(innerFrame->selection(), dragData)) {
499 // NSTextView behavior is to always smart delete on moving a selecti on, 499 // NSTextView behavior is to always smart delete on moving a selecti on,
500 // but only to smart insert if the selection granularity is word gra nularity. 500 // but only to smart insert if the selection granularity is word gra nularity.
501 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); 501 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
502 bool smartInsert = smartDelete && innerFrame->selection().granularit y() == WordGranularity && dragData->canSmartReplace(); 502 bool smartInsert = smartDelete && innerFrame->selection().granularit y() == WordGranularity && dragData->canSmartReplace();
503 innerFrame->editor().moveSelectionAfterDragging(fragment, dragCaret. base(), smartInsert, smartDelete); 503 innerFrame->editor().moveSelectionAfterDragging(fragment, dragCaret. base(), smartInsert, smartDelete);
504 } else { 504 } else {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 return DragOperationLink; 577 return DragOperationLink;
578 578
579 // FIXME: Does IE really return "generic" even if no operations were allowed by the source? 579 // FIXME: Does IE really return "generic" even if no operations were allowed by the source?
580 return DragOperationGeneric; 580 return DragOperationGeneric;
581 } 581 }
582 582
583 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) 583 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
584 { 584 {
585 ASSERT(dragData); 585 ASSERT(dragData);
586 ASSERT(m_documentUnderMouse); 586 ASSERT(m_documentUnderMouse);
587 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame( ); 587 RawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame();
588 if (!mainFrame->view()) 588 if (!mainFrame->view())
589 return false; 589 return false;
590 590
591 RefPtrWillBeRawPtr<FrameView> viewProtector(mainFrame->view()); 591 RawPtr<FrameView> viewProtector(mainFrame->view());
592 DataTransferAccessPolicy policy = m_documentUnderMouse->getSecurityOrigin()- >isLocal() ? DataTransferReadable : DataTransferTypesReadable; 592 DataTransferAccessPolicy policy = m_documentUnderMouse->getSecurityOrigin()- >isLocal() ? DataTransferReadable : DataTransferTypesReadable;
593 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); 593 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData);
594 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); 594 DragOperation srcOpMask = dragData->draggingSourceOperationMask();
595 dataTransfer->setSourceOperation(srcOpMask); 595 dataTransfer->setSourceOperation(srcOpMask);
596 596
597 PlatformMouseEvent event = createMouseEvent(dragData); 597 PlatformMouseEvent event = createMouseEvent(dragData);
598 if (mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer) == WebI nputEventResult::NotHandled) { 598 if (mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer) == WebI nputEventResult::NotHandled) {
599 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security 599 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security
600 return false; 600 return false;
601 } 601 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 { 698 {
699 ASSERT(element); 699 ASSERT(element);
700 ImageResource* cachedImage = getImageResource(element); 700 ImageResource* cachedImage = getImageResource(element);
701 return (cachedImage && !cachedImage->errorOccurred()) ? 701 return (cachedImage && !cachedImage->errorOccurred()) ?
702 cachedImage->getImage() : nullptr; 702 cachedImage->getImage() : nullptr;
703 } 703 }
704 704
705 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri ng& label) 705 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri ng& label)
706 { 706 {
707 if (node->isContentRichlyEditable()) { 707 if (node->isContentRichlyEditable()) {
708 RefPtrWillBeRawPtr<Range> range = source->document()->createRange(); 708 RawPtr<Range> range = source->document()->createRange();
709 range->selectNode(node, ASSERT_NO_EXCEPTION); 709 range->selectNode(node, ASSERT_NO_EXCEPTION);
710 source->selection().setSelection(VisibleSelection(EphemeralRange(range.g et()))); 710 source->selection().setSelection(VisibleSelection(EphemeralRange(range.g et())));
711 } 711 }
712 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label); 712 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label);
713 } 713 }
714 714
715 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState& state, const IntPoint& dragOrigin) 715 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState& state, const IntPoint& dragOrigin)
716 { 716 {
717 ASSERT(dragTypeIsValid(state.m_dragType)); 717 ASSERT(dragTypeIsValid(state.m_dragType));
718 ASSERT(src); 718 ASSERT(src);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 927 }
928 928
929 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation , const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool forLink) 929 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation , const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool forLink)
930 { 930 {
931 // TODO(dcheng): Drag and drop is not yet supported for OOPI. 931 // TODO(dcheng): Drag and drop is not yet supported for OOPI.
932 if (m_page->mainFrame()->isRemoteFrame()) 932 if (m_page->mainFrame()->isRemoteFrame())
933 return; 933 return;
934 m_didInitiateDrag = true; 934 m_didInitiateDrag = true;
935 m_dragInitiator = frame->document(); 935 m_dragInitiator = frame->document();
936 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame 936 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
937 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame( ); 937 RawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame();
938 RefPtrWillBeRawPtr<FrameView> mainFrameView = mainFrame->view(); 938 RawPtr<FrameView> mainFrameView = mainFrame->view();
939 939
940 m_client->startDrag(image, mainFrameView->rootFrameToContents(frame->view()- >contentsToRootFrame(dragLocation)), 940 m_client->startDrag(image, mainFrameView->rootFrameToContents(frame->view()- >contentsToRootFrame(dragLocation)),
941 mainFrameView->rootFrameToContents(frame->view()->contentsToRootFrame(ev entPos)), dataTransfer, frame, forLink); 941 mainFrameView->rootFrameToContents(frame->view()->contentsToRootFrame(ev entPos)), dataTransfer, frame, forLink);
942 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. 942 // DragClient::startDrag can cause our Page to dispear, deallocating |this|.
943 if (!frame->page()) 943 if (!frame->page())
944 return; 944 return;
945 945
946 cleanupAfterSystemDrag(); 946 cleanupAfterSystemDrag();
947 } 947 }
948 948
(...skipping 24 matching lines...) Expand all
973 973
974 DEFINE_TRACE(DragController) 974 DEFINE_TRACE(DragController)
975 { 975 {
976 visitor->trace(m_page); 976 visitor->trace(m_page);
977 visitor->trace(m_documentUnderMouse); 977 visitor->trace(m_documentUnderMouse);
978 visitor->trace(m_dragInitiator); 978 visitor->trace(m_dragInitiator);
979 visitor->trace(m_fileInputElementUnderMouse); 979 visitor->trace(m_fileInputElementUnderMouse);
980 } 980 }
981 981
982 } // namespace blink 982 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/DragController.h ('k') | third_party/WebKit/Source/core/page/DragData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698