OLD | NEW |
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 DragSession DragController::dragEntered(DragData* dragData) | 208 DragSession DragController::dragEntered(DragData* dragData) |
209 { | 209 { |
210 return dragEnteredOrUpdated(dragData); | 210 return dragEnteredOrUpdated(dragData); |
211 } | 211 } |
212 | 212 |
213 void DragController::dragExited(DragData* dragData) | 213 void DragController::dragExited(DragData* dragData) |
214 { | 214 { |
215 ASSERT(dragData); | 215 ASSERT(dragData); |
216 LocalFrame* mainFrame = m_page->mainFrame(); | 216 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); |
217 | 217 |
218 if (RefPtr<FrameView> v = mainFrame->view()) { | 218 if (RefPtr<FrameView> v = mainFrame->view()) { |
219 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder
Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable
; | 219 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder
Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable
; |
220 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy
, dragData); | 220 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy
, dragData); |
221 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); | 221 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); |
222 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
clipboard.get()); | 222 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
clipboard.get()); |
223 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security | 223 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security |
224 } | 224 } |
225 mouseMovedIntoDocument(0); | 225 mouseMovedIntoDocument(0); |
226 if (m_fileInputElementUnderMouse) | 226 if (m_fileInputElementUnderMouse) |
227 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 227 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
228 m_fileInputElementUnderMouse = nullptr; | 228 m_fileInputElementUnderMouse = nullptr; |
229 } | 229 } |
230 | 230 |
231 DragSession DragController::dragUpdated(DragData* dragData) | 231 DragSession DragController::dragUpdated(DragData* dragData) |
232 { | 232 { |
233 return dragEnteredOrUpdated(dragData); | 233 return dragEnteredOrUpdated(dragData); |
234 } | 234 } |
235 | 235 |
236 bool DragController::performDrag(DragData* dragData) | 236 bool DragController::performDrag(DragData* dragData) |
237 { | 237 { |
238 ASSERT(dragData); | 238 ASSERT(dragData); |
239 m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->client
Position()); | 239 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition()); |
240 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { | 240 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { |
241 RefPtr<LocalFrame> mainFrame = m_page->mainFrame(); | 241 RefPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); |
242 bool preventedDefault = false; | 242 bool preventedDefault = false; |
243 if (mainFrame->view()) { | 243 if (mainFrame->view()) { |
244 // Sending an event can result in the destruction of the view and pa
rt. | 244 // Sending an event can result in the destruction of the view and pa
rt. |
245 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(Cl
ipboardReadable, dragData); | 245 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(Cl
ipboardReadable, dragData); |
246 clipboard->setSourceOperation(dragData->draggingSourceOperationMask(
)); | 246 clipboard->setSourceOperation(dragData->draggingSourceOperationMask(
)); |
247 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), clipboard.get()); | 247 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), clipboard.get()); |
248 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h
ere for security | 248 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h
ere for security |
249 } | 249 } |
250 if (preventedDefault) { | 250 if (preventedDefault) { |
251 m_documentUnderMouse = nullptr; | 251 m_documentUnderMouse = nullptr; |
252 return true; | 252 return true; |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra
g(dragData)) { | 256 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra
g(dragData)) { |
257 m_documentUnderMouse = nullptr; | 257 m_documentUnderMouse = nullptr; |
258 return true; | 258 return true; |
259 } | 259 } |
260 | 260 |
261 m_documentUnderMouse = nullptr; | 261 m_documentUnderMouse = nullptr; |
262 | 262 |
263 if (operationForLoad(dragData) == DragOperationNone) | 263 if (operationForLoad(dragData) == DragOperationNone) |
264 return false; | 264 return false; |
265 | 265 |
266 if (m_page->settings().navigateOnDragDrop()) | 266 if (m_page->settings().navigateOnDragDrop()) |
267 m_page->mainFrame()->loader().load(FrameLoadRequest(0, ResourceRequest(d
ragData->asURL()))); | 267 m_page->deprecatedLocalMainFrame()->loader().load(FrameLoadRequest(0, Re
sourceRequest(dragData->asURL()))); |
268 return true; | 268 return true; |
269 } | 269 } |
270 | 270 |
271 void DragController::mouseMovedIntoDocument(Document* newDocument) | 271 void DragController::mouseMovedIntoDocument(Document* newDocument) |
272 { | 272 { |
273 if (m_documentUnderMouse == newDocument) | 273 if (m_documentUnderMouse == newDocument) |
274 return; | 274 return; |
275 | 275 |
276 // If we were over another document clear the selection | 276 // If we were over another document clear the selection |
277 if (m_documentUnderMouse) | 277 if (m_documentUnderMouse) |
278 cancelDrag(); | 278 cancelDrag(); |
279 m_documentUnderMouse = newDocument; | 279 m_documentUnderMouse = newDocument; |
280 } | 280 } |
281 | 281 |
282 DragSession DragController::dragEnteredOrUpdated(DragData* dragData) | 282 DragSession DragController::dragEnteredOrUpdated(DragData* dragData) |
283 { | 283 { |
284 ASSERT(dragData); | 284 ASSERT(dragData); |
285 ASSERT(m_page->mainFrame()); | 285 ASSERT(m_page->mainFrame()); |
286 mouseMovedIntoDocument(m_page->mainFrame()->documentAtPoint(dragData->client
Position())); | 286 mouseMovedIntoDocument(m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition())); |
287 | 287 |
288 m_dragDestinationAction = m_client->actionMaskForDrag(dragData); | 288 m_dragDestinationAction = m_client->actionMaskForDrag(dragData); |
289 if (m_dragDestinationAction == DragDestinationActionNone) { | 289 if (m_dragDestinationAction == DragDestinationActionNone) { |
290 cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)? | 290 cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)? |
291 return DragSession(); | 291 return DragSession(); |
292 } | 292 } |
293 | 293 |
294 DragSession dragSession; | 294 DragSession dragSession; |
295 m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction
, dragSession); | 295 m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction
, dragSession); |
296 if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationA
ctionLoad)) | 296 if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationA
ctionLoad)) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 m_page->dragCaretController().clear(); | 409 m_page->dragCaretController().clear(); |
410 if (m_fileInputElementUnderMouse) | 410 if (m_fileInputElementUnderMouse) |
411 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 411 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
412 m_fileInputElementUnderMouse = nullptr; | 412 m_fileInputElementUnderMouse = nullptr; |
413 return false; | 413 return false; |
414 } | 414 } |
415 | 415 |
416 DragOperation DragController::operationForLoad(DragData* dragData) | 416 DragOperation DragController::operationForLoad(DragData* dragData) |
417 { | 417 { |
418 ASSERT(dragData); | 418 ASSERT(dragData); |
419 Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPositio
n()); | 419 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint(dragData
->clientPosition()); |
420 | 420 |
421 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE
ditable())) | 421 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE
ditable())) |
422 return DragOperationNone; | 422 return DragOperationNone; |
423 return dragOperation(dragData); | 423 return dragOperation(dragData); |
424 } | 424 } |
425 | 425 |
426 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar
et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point) | 426 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar
et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point) |
427 { | 427 { |
428 frame->selection().setSelection(dragCaret); | 428 frame->selection().setSelection(dragCaret); |
429 if (frame->selection().isNone()) { | 429 if (frame->selection().isNone()) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 return true; | 533 return true; |
534 } | 534 } |
535 | 535 |
536 bool DragController::canProcessDrag(DragData* dragData) | 536 bool DragController::canProcessDrag(DragData* dragData) |
537 { | 537 { |
538 ASSERT(dragData); | 538 ASSERT(dragData); |
539 | 539 |
540 if (!dragData->containsCompatibleContent()) | 540 if (!dragData->containsCompatibleContent()) |
541 return false; | 541 return false; |
542 | 542 |
543 IntPoint point = m_page->mainFrame()->view()->windowToContents(dragData->cli
entPosition()); | 543 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->windowToContent
s(dragData->clientPosition()); |
544 HitTestResult result = HitTestResult(point); | 544 HitTestResult result = HitTestResult(point); |
545 if (!m_page->mainFrame()->contentRenderer()) | 545 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) |
546 return false; | 546 return false; |
547 | 547 |
548 result = m_page->mainFrame()->eventHandler().hitTestResultAtPoint(point); | 548 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP
oint(point); |
549 | 549 |
550 if (!result.innerNonSharedNode()) | 550 if (!result.innerNonSharedNode()) |
551 return false; | 551 return false; |
552 | 552 |
553 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) | 553 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) |
554 return true; | 554 return true; |
555 | 555 |
556 if (isHTMLPlugInElement(*result.innerNonSharedNode())) { | 556 if (isHTMLPlugInElement(*result.innerNonSharedNode())) { |
557 HTMLPlugInElement* plugin = toHTMLPlugInElement(result.innerNonSharedNod
e()); | 557 HTMLPlugInElement* plugin = toHTMLPlugInElement(result.innerNonSharedNod
e()); |
558 if (!plugin->canProcessDrag() && !result.innerNonSharedNode()->rendererI
sEditable()) | 558 if (!plugin->canProcessDrag() && !result.innerNonSharedNode()->rendererI
sEditable()) |
(...skipping 23 matching lines...) Expand all Loading... |
582 return DragOperationLink; | 582 return DragOperationLink; |
583 | 583 |
584 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? | 584 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? |
585 return DragOperationGeneric; | 585 return DragOperationGeneric; |
586 } | 586 } |
587 | 587 |
588 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) | 588 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
589 { | 589 { |
590 ASSERT(dragData); | 590 ASSERT(dragData); |
591 ASSERT(m_documentUnderMouse); | 591 ASSERT(m_documentUnderMouse); |
592 RefPtr<LocalFrame> mainFrame = m_page->mainFrame(); | 592 RefPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); |
593 RefPtr<FrameView> viewProtector = mainFrame->view(); | 593 RefPtr<FrameView> viewProtector = mainFrame->view(); |
594 if (!viewProtector) | 594 if (!viewProtector) |
595 return false; | 595 return false; |
596 | 596 |
597 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; | 597 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; |
598 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy, dr
agData); | 598 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy, dr
agData); |
599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
600 clipboard->setSourceOperation(srcOpMask); | 600 clipboard->setSourceOperation(srcOpMask); |
601 | 601 |
602 PlatformMouseEvent event = createMouseEvent(dragData); | 602 PlatformMouseEvent event = createMouseEvent(dragData); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 } | 920 } |
921 | 921 |
922 return true; | 922 return true; |
923 } | 923 } |
924 | 924 |
925 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, Clipboard* clipboard, LocalFrame* frame, bool forLin
k) | 925 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, Clipboard* clipboard, LocalFrame* frame, bool forLin
k) |
926 { | 926 { |
927 m_didInitiateDrag = true; | 927 m_didInitiateDrag = true; |
928 m_dragInitiator = frame->document(); | 928 m_dragInitiator = frame->document(); |
929 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame | 929 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame |
930 RefPtr<LocalFrame> frameProtector = m_page->mainFrame(); | 930 RefPtr<LocalFrame> frameProtector = m_page->deprecatedLocalMainFrame(); |
931 RefPtr<FrameView> viewProtector = frameProtector->view(); | 931 RefPtr<FrameView> viewProtector = frameProtector->view(); |
932 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), | 932 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), |
933 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), clipboard, frameProtector.get(), forLink); | 933 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), clipboard, frameProtector.get(), forLink); |
934 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. | 934 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. |
935 if (!frameProtector->page()) | 935 if (!frameProtector->page()) |
936 return; | 936 return; |
937 | 937 |
938 cleanupAfterSystemDrag(); | 938 cleanupAfterSystemDrag(); |
939 } | 939 } |
940 | 940 |
(...skipping 24 matching lines...) Expand all Loading... |
965 | 965 |
966 void DragController::trace(Visitor* visitor) | 966 void DragController::trace(Visitor* visitor) |
967 { | 967 { |
968 visitor->trace(m_page); | 968 visitor->trace(m_page); |
969 visitor->trace(m_documentUnderMouse); | 969 visitor->trace(m_documentUnderMouse); |
970 visitor->trace(m_dragInitiator); | 970 visitor->trace(m_dragInitiator); |
971 visitor->trace(m_fileInputElementUnderMouse); | 971 visitor->trace(m_fileInputElementUnderMouse); |
972 } | 972 } |
973 | 973 |
974 } // namespace WebCore | 974 } // namespace WebCore |
OLD | NEW |