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

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

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Back out non-Oilpan experiment + tidy up by adding frame() ref accessors Created 6 years, 3 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 DragSession DragController::dragUpdated(DragData* dragData) 232 DragSession DragController::dragUpdated(DragData* dragData)
233 { 233 {
234 return dragEnteredOrUpdated(dragData); 234 return dragEnteredOrUpdated(dragData);
235 } 235 }
236 236
237 bool DragController::performDrag(DragData* dragData) 237 bool DragController::performDrag(DragData* dragData)
238 { 238 {
239 ASSERT(dragData); 239 ASSERT(dragData);
240 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d ragData->clientPosition()); 240 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d ragData->clientPosition());
241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) { 241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) {
242 RefPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); 242 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFr ame();
243 bool preventedDefault = false; 243 bool preventedDefault = false;
244 if (mainFrame->view()) { 244 if (mainFrame->view()) {
245 // Sending an event can result in the destruction of the view and pa rt. 245 // Sending an event can result in the destruction of the view and pa rt.
246 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTr ansfer(DataTransferReadable, dragData); 246 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTr ansfer(DataTransferReadable, dragData);
247 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa sk()); 247 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa sk());
248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), dataTransfer.get()); 248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), dataTransfer.get());
249 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb oard here for security 249 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb oard here for security
250 } 250 }
251 if (preventedDefault) { 251 if (preventedDefault) {
252 m_documentUnderMouse = nullptr; 252 m_documentUnderMouse = nullptr;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 m_fileInputElementUnderMouse = nullptr; 453 m_fileInputElementUnderMouse = nullptr;
454 } 454 }
455 455
456 if (!m_documentUnderMouse) 456 if (!m_documentUnderMouse)
457 return false; 457 return false;
458 458
459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition()); 459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition());
460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
461 if (!element) 461 if (!element)
462 return false; 462 return false;
463 RefPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(); 463 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame( );
464 ASSERT(innerFrame); 464 ASSERT(innerFrame);
465 465
466 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i nnerFrame.get(), dragData)) 466 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i nnerFrame.get(), dragData))
467 return true; 467 return true;
468 468
469 if (dragData->containsFiles() && fileInput) { 469 if (dragData->containsFiles() && fileInput) {
470 // fileInput should be the element we hit tested for, unless it was made 470 // fileInput should be the element we hit tested for, unless it was made
471 // display:none in a drop event handler. 471 // display:none in a drop event handler.
472 ASSERT(fileInput == element || !fileInput->renderer()); 472 ASSERT(fileInput == element || !fileInput->renderer());
473 if (fileInput->isDisabledFormControl()) 473 if (fileInput->isDisabledFormControl())
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return DragOperationLink; 583 return DragOperationLink;
584 584
585 // FIXME: Does IE really return "generic" even if no operations were allowed by the source? 585 // FIXME: Does IE really return "generic" even if no operations were allowed by the source?
586 return DragOperationGeneric; 586 return DragOperationGeneric;
587 } 587 }
588 588
589 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) 589 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
590 { 590 {
591 ASSERT(dragData); 591 ASSERT(dragData);
592 ASSERT(m_documentUnderMouse); 592 ASSERT(m_documentUnderMouse);
593 RefPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); 593 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame( );
594 RefPtr<FrameView> viewProtector = mainFrame->view(); 594 if (!mainFrame->view())
595 if (!viewProtector)
596 return false; 595 return false;
597 596
597 RefPtr<FrameView> viewProtector(mainFrame->view());
598 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is Local() ? DataTransferReadable : DataTransferTypesReadable; 598 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is Local() ? DataTransferReadable : DataTransferTypesReadable;
599 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p olicy, dragData); 599 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p olicy, dragData);
600 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); 600 DragOperation srcOpMask = dragData->draggingSourceOperationMask();
601 dataTransfer->setSourceOperation(srcOpMask); 601 dataTransfer->setSourceOperation(srcOpMask);
602 602
603 PlatformMouseEvent event = createMouseEvent(dragData); 603 PlatformMouseEvent event = createMouseEvent(dragData);
604 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer.get())) { 604 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer.get())) {
605 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security 605 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard here for security
606 return false; 606 return false;
607 } 607 }
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 921 }
922 922
923 return true; 923 return true;
924 } 924 }
925 925
926 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation , const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool forLink) 926 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation , const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool forLink)
927 { 927 {
928 m_didInitiateDrag = true; 928 m_didInitiateDrag = true;
929 m_dragInitiator = frame->document(); 929 m_dragInitiator = frame->document();
930 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame 930 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
931 RefPtr<LocalFrame> frameProtector = m_page->deprecatedLocalMainFrame(); 931 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame( );
932 RefPtr<FrameView> viewProtector = frameProtector->view(); 932 RefPtr<FrameView> mainFrameView = mainFrame->view();
933 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()-> contentsToRootView(dragLocation)), 933
934 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even tPos)), dataTransfer, frameProtector.get(), forLink); 934 m_client->startDrag(image, mainFrameView->rootViewToContents(frame->view()-> contentsToRootView(dragLocation)),
935 mainFrameView->rootViewToContents(frame->view()->contentsToRootView(even tPos)), dataTransfer, frame, forLink);
935 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. 936 // DragClient::startDrag can cause our Page to dispear, deallocating |this|.
936 if (!frameProtector->page()) 937 if (!frame->page())
937 return; 938 return;
938 939
939 cleanupAfterSystemDrag(); 940 cleanupAfterSystemDrag();
940 } 941 }
941 942
942 DragOperation DragController::dragOperation(DragData* dragData) 943 DragOperation DragController::dragOperation(DragData* dragData)
943 { 944 {
944 // FIXME: To match the MacOS behaviour we should return DragOperationNone 945 // FIXME: To match the MacOS behaviour we should return DragOperationNone
945 // if we are a modal window, we are the drag source, or the window is an 946 // if we are a modal window, we are the drag source, or the window is an
946 // attached sheet If this can be determined from within WebCore 947 // attached sheet If this can be determined from within WebCore
(...skipping 19 matching lines...) Expand all
966 967
967 void DragController::trace(Visitor* visitor) 968 void DragController::trace(Visitor* visitor)
968 { 969 {
969 visitor->trace(m_page); 970 visitor->trace(m_page);
970 visitor->trace(m_documentUnderMouse); 971 visitor->trace(m_documentUnderMouse);
971 visitor->trace(m_dragInitiator); 972 visitor->trace(m_dragInitiator);
972 visitor->trace(m_fileInputElementUnderMouse); 973 visitor->trace(m_fileInputElementUnderMouse);
973 } 974 }
974 975
975 } // namespace blink 976 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698