| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void DragController::cancelDrag() { | 201 void DragController::cancelDrag() { |
| 202 m_page->dragCaretController().clear(); | 202 m_page->dragCaretController().clear(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void DragController::dragEnded() { | 205 void DragController::dragEnded() { |
| 206 m_dragInitiator = nullptr; | 206 m_dragInitiator = nullptr; |
| 207 m_didInitiateDrag = false; | 207 m_didInitiateDrag = false; |
| 208 m_page->dragCaretController().clear(); | 208 m_page->dragCaretController().clear(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void DragController::dragExited(DragData* dragData) { | 211 void DragController::dragExited(DragData* dragData, LocalFrame& localRoot) { |
| 212 DCHECK(dragData); | 212 DCHECK(dragData); |
| 213 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); | |
| 214 | 213 |
| 215 FrameView* frameView(mainFrame->view()); | 214 FrameView* frameView(localRoot.view()); |
| 216 if (frameView) { | 215 if (frameView) { |
| 217 DataTransferAccessPolicy policy = | 216 DataTransferAccessPolicy policy = |
| 218 (!m_documentUnderMouse || | 217 (!m_documentUnderMouse || |
| 219 m_documentUnderMouse->getSecurityOrigin()->isLocal()) | 218 m_documentUnderMouse->getSecurityOrigin()->isLocal()) |
| 220 ? DataTransferReadable | 219 ? DataTransferReadable |
| 221 : DataTransferTypesReadable; | 220 : DataTransferTypesReadable; |
| 222 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); | 221 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); |
| 223 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); | 222 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); |
| 224 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData), | 223 localRoot.eventHandler().cancelDragAndDrop(createMouseEvent(dragData), |
| 225 dataTransfer); | 224 dataTransfer); |
| 226 dataTransfer->setAccessPolicy( | 225 dataTransfer->setAccessPolicy( |
| 227 DataTransferNumb); // invalidate clipboard here for security | 226 DataTransferNumb); // invalidate clipboard here for security |
| 228 } | 227 } |
| 229 mouseMovedIntoDocument(nullptr); | 228 mouseMovedIntoDocument(nullptr); |
| 230 if (m_fileInputElementUnderMouse) | 229 if (m_fileInputElementUnderMouse) |
| 231 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 230 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 232 m_fileInputElementUnderMouse = nullptr; | 231 m_fileInputElementUnderMouse = nullptr; |
| 233 } | 232 } |
| 234 | 233 |
| 235 bool DragController::performDrag(DragData* dragData) { | 234 bool DragController::performDrag(DragData* dragData, LocalFrame& localRoot) { |
| 236 DCHECK(dragData); | 235 DCHECK(dragData); |
| 237 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint( | 236 m_documentUnderMouse = localRoot.documentAtPoint(dragData->clientPosition()); |
| 238 dragData->clientPosition()); | |
| 239 UserGestureIndicator gesture(DocumentUserGestureToken::create( | 237 UserGestureIndicator gesture(DocumentUserGestureToken::create( |
| 240 m_documentUnderMouse, UserGestureToken::NewGesture)); | 238 m_documentUnderMouse, UserGestureToken::NewGesture)); |
| 241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && | 239 if ((m_dragDestinationAction & DragDestinationActionDHTML) && |
| 242 m_documentIsHandlingDrag) { | 240 m_documentIsHandlingDrag) { |
| 243 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); | |
| 244 bool preventedDefault = false; | 241 bool preventedDefault = false; |
| 245 if (mainFrame->view()) { | 242 if (localRoot.view()) { |
| 246 // Sending an event can result in the destruction of the view and part. | 243 // Sending an event can result in the destruction of the view and part. |
| 247 DataTransfer* dataTransfer = | 244 DataTransfer* dataTransfer = |
| 248 createDraggingDataTransfer(DataTransferReadable, dragData); | 245 createDraggingDataTransfer(DataTransferReadable, dragData); |
| 249 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); | 246 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); |
| 250 EventHandler& eventHandler = mainFrame->eventHandler(); | 247 EventHandler& eventHandler = localRoot.eventHandler(); |
| 251 preventedDefault = eventHandler.performDragAndDrop( | 248 preventedDefault = eventHandler.performDragAndDrop( |
| 252 createMouseEvent(dragData), dataTransfer) != | 249 createMouseEvent(dragData), dataTransfer) != |
| 253 WebInputEventResult::NotHandled; | 250 WebInputEventResult::NotHandled; |
| 254 if (!preventedDefault) { | 251 if (!preventedDefault) { |
| 255 // When drop target is plugin element and it can process drag, we | 252 // When drop target is plugin element and it can process drag, we |
| 256 // should prevent default behavior. | 253 // should prevent default behavior. |
| 257 const IntPoint point = | 254 const IntPoint point = |
| 258 mainFrame->view()->rootFrameToContents(dragData->clientPosition()); | 255 localRoot.view()->rootFrameToContents(dragData->clientPosition()); |
| 259 const HitTestResult result = eventHandler.hitTestResultAtPoint(point); | 256 const HitTestResult result = eventHandler.hitTestResultAtPoint(point); |
| 260 preventedDefault |= | 257 preventedDefault |= |
| 261 isHTMLPlugInElement(*result.innerNode()) && | 258 isHTMLPlugInElement(*result.innerNode()) && |
| 262 toHTMLPlugInElement(result.innerNode())->canProcessDrag(); | 259 toHTMLPlugInElement(result.innerNode())->canProcessDrag(); |
| 263 } | 260 } |
| 264 | 261 |
| 265 // Invalidate clipboard here for security. | 262 // Invalidate clipboard here for security. |
| 266 dataTransfer->setAccessPolicy(DataTransferNumb); | 263 dataTransfer->setAccessPolicy(DataTransferNumb); |
| 267 } | 264 } |
| 268 if (preventedDefault) { | 265 if (preventedDefault) { |
| 269 m_documentUnderMouse = nullptr; | 266 m_documentUnderMouse = nullptr; |
| 270 cancelDrag(); | 267 cancelDrag(); |
| 271 return true; | 268 return true; |
| 272 } | 269 } |
| 273 } | 270 } |
| 274 | 271 |
| 275 if ((m_dragDestinationAction & DragDestinationActionEdit) && | 272 if ((m_dragDestinationAction & DragDestinationActionEdit) && |
| 276 concludeEditDrag(dragData)) { | 273 concludeEditDrag(dragData)) { |
| 277 m_documentUnderMouse = nullptr; | 274 m_documentUnderMouse = nullptr; |
| 278 return true; | 275 return true; |
| 279 } | 276 } |
| 280 | 277 |
| 281 m_documentUnderMouse = nullptr; | 278 m_documentUnderMouse = nullptr; |
| 282 | 279 |
| 283 if (operationForLoad(dragData) == DragOperationNone) | 280 if (operationForLoad(dragData, localRoot) == DragOperationNone) |
| 284 return false; | 281 return false; |
| 285 | 282 |
| 286 if (m_page->settings().navigateOnDragDrop()) { | 283 if (m_page->settings().navigateOnDragDrop()) { |
| 287 m_page->mainFrame()->navigate( | 284 m_page->mainFrame()->navigate( |
| 288 FrameLoadRequest(nullptr, ResourceRequest(dragData->asURL()))); | 285 FrameLoadRequest(nullptr, ResourceRequest(dragData->asURL()))); |
| 289 } | 286 } |
| 290 return true; | 287 return true; |
| 291 } | 288 } |
| 292 | 289 |
| 293 void DragController::mouseMovedIntoDocument(Document* newDocument) { | 290 void DragController::mouseMovedIntoDocument(Document* newDocument) { |
| 294 if (m_documentUnderMouse == newDocument) | 291 if (m_documentUnderMouse == newDocument) |
| 295 return; | 292 return; |
| 296 | 293 |
| 297 // If we were over another document clear the selection | 294 // If we were over another document clear the selection |
| 298 if (m_documentUnderMouse) | 295 if (m_documentUnderMouse) |
| 299 cancelDrag(); | 296 cancelDrag(); |
| 300 m_documentUnderMouse = newDocument; | 297 m_documentUnderMouse = newDocument; |
| 301 } | 298 } |
| 302 | 299 |
| 303 DragSession DragController::dragEnteredOrUpdated(DragData* dragData) { | 300 DragSession DragController::dragEnteredOrUpdated(DragData* dragData, |
| 301 LocalFrame& localRoot) { |
| 304 DCHECK(dragData); | 302 DCHECK(dragData); |
| 305 DCHECK(m_page->mainFrame()); | 303 |
| 306 mouseMovedIntoDocument(m_page->deprecatedLocalMainFrame()->documentAtPoint( | 304 mouseMovedIntoDocument(localRoot.documentAtPoint(dragData->clientPosition())); |
| 307 dragData->clientPosition())); | |
| 308 | 305 |
| 309 // TODO(esprehn): Replace acceptsLoadDrops with a Setting used in core. | 306 // TODO(esprehn): Replace acceptsLoadDrops with a Setting used in core. |
| 310 m_dragDestinationAction = | 307 m_dragDestinationAction = |
| 311 m_page->chromeClient().acceptsLoadDrops() | 308 m_page->chromeClient().acceptsLoadDrops() |
| 312 ? DragDestinationActionAny | 309 ? DragDestinationActionAny |
| 313 : static_cast<DragDestinationAction>(DragDestinationActionDHTML | | 310 : static_cast<DragDestinationAction>(DragDestinationActionDHTML | |
| 314 DragDestinationActionEdit); | 311 DragDestinationActionEdit); |
| 315 | 312 |
| 316 DragSession dragSession; | 313 DragSession dragSession; |
| 317 m_documentIsHandlingDrag = | 314 m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction, |
| 318 tryDocumentDrag(dragData, m_dragDestinationAction, dragSession); | 315 dragSession, localRoot); |
| 319 if (!m_documentIsHandlingDrag && | 316 if (!m_documentIsHandlingDrag && |
| 320 (m_dragDestinationAction & DragDestinationActionLoad)) | 317 (m_dragDestinationAction & DragDestinationActionLoad)) |
| 321 dragSession.operation = operationForLoad(dragData); | 318 dragSession.operation = operationForLoad(dragData, localRoot); |
| 322 return dragSession; | 319 return dragSession; |
| 323 } | 320 } |
| 324 | 321 |
| 325 static HTMLInputElement* asFileInput(Node* node) { | 322 static HTMLInputElement* asFileInput(Node* node) { |
| 326 DCHECK(node); | 323 DCHECK(node); |
| 327 for (; node; node = node->ownerShadowHost()) { | 324 for (; node; node = node->ownerShadowHost()) { |
| 328 if (isHTMLInputElement(*node) && | 325 if (isHTMLInputElement(*node) && |
| 329 toHTMLInputElement(node)->type() == InputTypeNames::file) | 326 toHTMLInputElement(node)->type() == InputTypeNames::file) |
| 330 return toHTMLInputElement(node); | 327 return toHTMLInputElement(node); |
| 331 } | 328 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 343 while (n && !n->isElementNode()) | 340 while (n && !n->isElementNode()) |
| 344 n = n->parentOrShadowHostNode(); | 341 n = n->parentOrShadowHostNode(); |
| 345 if (n && n->isInShadowTree()) | 342 if (n && n->isInShadowTree()) |
| 346 n = n->ownerShadowHost(); | 343 n = n->ownerShadowHost(); |
| 347 | 344 |
| 348 return toElement(n); | 345 return toElement(n); |
| 349 } | 346 } |
| 350 | 347 |
| 351 bool DragController::tryDocumentDrag(DragData* dragData, | 348 bool DragController::tryDocumentDrag(DragData* dragData, |
| 352 DragDestinationAction actionMask, | 349 DragDestinationAction actionMask, |
| 353 DragSession& dragSession) { | 350 DragSession& dragSession, |
| 351 LocalFrame& localRoot) { |
| 354 DCHECK(dragData); | 352 DCHECK(dragData); |
| 355 | 353 |
| 356 if (!m_documentUnderMouse) | 354 if (!m_documentUnderMouse) |
| 357 return false; | 355 return false; |
| 358 | 356 |
| 359 if (m_dragInitiator && | 357 if (m_dragInitiator && |
| 360 !m_documentUnderMouse->getSecurityOrigin()->canAccess( | 358 !m_documentUnderMouse->getSecurityOrigin()->canAccess( |
| 361 m_dragInitiator->getSecurityOrigin())) | 359 m_dragInitiator->getSecurityOrigin())) |
| 362 return false; | 360 return false; |
| 363 | 361 |
| 364 bool isHandlingDrag = false; | 362 bool isHandlingDrag = false; |
| 365 if (actionMask & DragDestinationActionDHTML) { | 363 if (actionMask & DragDestinationActionDHTML) { |
| 366 isHandlingDrag = tryDHTMLDrag(dragData, dragSession.operation); | 364 isHandlingDrag = tryDHTMLDrag(dragData, dragSession.operation, localRoot); |
| 367 // Do not continue if m_documentUnderMouse has been reset by tryDHTMLDrag. | 365 // Do not continue if m_documentUnderMouse has been reset by tryDHTMLDrag. |
| 368 // tryDHTMLDrag fires dragenter event. The event listener that listens | 366 // tryDHTMLDrag fires dragenter event. The event listener that listens |
| 369 // to this event may create a nested message loop (open a modal dialog), | 367 // to this event may create a nested message loop (open a modal dialog), |
| 370 // which could process dragleave event and reset m_documentUnderMouse in | 368 // which could process dragleave event and reset m_documentUnderMouse in |
| 371 // dragExited. | 369 // dragExited. |
| 372 if (!m_documentUnderMouse) | 370 if (!m_documentUnderMouse) |
| 373 return false; | 371 return false; |
| 374 } | 372 } |
| 375 | 373 |
| 376 // It's unclear why this check is after tryDHTMLDrag. | 374 // It's unclear why this check is after tryDHTMLDrag. |
| 377 // We send drag events in tryDHTMLDrag and that may be the reason. | 375 // We send drag events in tryDHTMLDrag and that may be the reason. |
| 378 FrameView* frameView = m_documentUnderMouse->view(); | 376 FrameView* frameView = m_documentUnderMouse->view(); |
| 379 if (!frameView) | 377 if (!frameView) |
| 380 return false; | 378 return false; |
| 381 | 379 |
| 382 if (isHandlingDrag) { | 380 if (isHandlingDrag) { |
| 383 m_page->dragCaretController().clear(); | 381 m_page->dragCaretController().clear(); |
| 384 return true; | 382 return true; |
| 385 } | 383 } |
| 386 | 384 |
| 387 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { | 385 if ((actionMask & DragDestinationActionEdit) && |
| 386 canProcessDrag(dragData, localRoot)) { |
| 388 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition()); | 387 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition()); |
| 389 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 388 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 390 if (!element) | 389 if (!element) |
| 391 return false; | 390 return false; |
| 392 | 391 |
| 393 HTMLInputElement* elementAsFileInput = asFileInput(element); | 392 HTMLInputElement* elementAsFileInput = asFileInput(element); |
| 394 if (m_fileInputElementUnderMouse != elementAsFileInput) { | 393 if (m_fileInputElementUnderMouse != elementAsFileInput) { |
| 395 if (m_fileInputElementUnderMouse) | 394 if (m_fileInputElementUnderMouse) |
| 396 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 395 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 397 m_fileInputElementUnderMouse = elementAsFileInput; | 396 m_fileInputElementUnderMouse = elementAsFileInput; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 434 |
| 436 // We are not over an editable region. Make sure we're clearing any prior drag | 435 // We are not over an editable region. Make sure we're clearing any prior drag |
| 437 // cursor. | 436 // cursor. |
| 438 m_page->dragCaretController().clear(); | 437 m_page->dragCaretController().clear(); |
| 439 if (m_fileInputElementUnderMouse) | 438 if (m_fileInputElementUnderMouse) |
| 440 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 439 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 441 m_fileInputElementUnderMouse = nullptr; | 440 m_fileInputElementUnderMouse = nullptr; |
| 442 return false; | 441 return false; |
| 443 } | 442 } |
| 444 | 443 |
| 445 DragOperation DragController::operationForLoad(DragData* dragData) { | 444 DragOperation DragController::operationForLoad(DragData* dragData, |
| 445 LocalFrame& localRoot) { |
| 446 DCHECK(dragData); | 446 DCHECK(dragData); |
| 447 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint( | 447 Document* doc = localRoot.documentAtPoint(dragData->clientPosition()); |
| 448 dragData->clientPosition()); | |
| 449 | 448 |
| 450 if (doc && | 449 if (doc && |
| 451 (m_didInitiateDrag || doc->isPluginDocument() || hasEditableStyle(*doc))) | 450 (m_didInitiateDrag || doc->isPluginDocument() || hasEditableStyle(*doc))) |
| 452 return DragOperationNone; | 451 return DragOperationNone; |
| 453 return dragOperation(dragData); | 452 return dragOperation(dragData); |
| 454 } | 453 } |
| 455 | 454 |
| 456 // Returns true if node at |point| is editable with populating |dragCaret| and | 455 // Returns true if node at |point| is editable with populating |dragCaret| and |
| 457 // |range|, otherwise returns false. | 456 // |range|, otherwise returns false. |
| 458 // TODO(yosin): We should return |VisibleSelection| rather than three values. | 457 // TODO(yosin): We should return |VisibleSelection| rather than three values. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // fileInput should be the element we hit tested for, unless it was made | 526 // fileInput should be the element we hit tested for, unless it was made |
| 528 // display:none in a drop event handler. | 527 // display:none in a drop event handler. |
| 529 if (fileInput->layoutObject()) | 528 if (fileInput->layoutObject()) |
| 530 DCHECK_EQ(fileInput, element); | 529 DCHECK_EQ(fileInput, element); |
| 531 if (fileInput->isDisabledFormControl()) | 530 if (fileInput->isDisabledFormControl()) |
| 532 return false; | 531 return false; |
| 533 | 532 |
| 534 return fileInput->receiveDroppedFiles(dragData); | 533 return fileInput->receiveDroppedFiles(dragData); |
| 535 } | 534 } |
| 536 | 535 |
| 537 if (!m_page->dragController().canProcessDrag(dragData)) { | 536 // TODO(paulmeyer): Isn't |m_page->dragController()| the same as |this|? |
| 537 if (!m_page->dragController().canProcessDrag(dragData, |
| 538 *innerFrame->localFrameRoot())) { |
| 538 m_page->dragCaretController().clear(); | 539 m_page->dragCaretController().clear(); |
| 539 return false; | 540 return false; |
| 540 } | 541 } |
| 541 | 542 |
| 542 if (m_page->dragCaretController().hasCaret()) { | 543 if (m_page->dragCaretController().hasCaret()) { |
| 543 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 544 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 544 // needs to be audited. See http://crbug.com/590369 for more details. | 545 // needs to be audited. See http://crbug.com/590369 for more details. |
| 545 m_page->dragCaretController() | 546 m_page->dragCaretController() |
| 546 .caretPosition() | 547 .caretPosition() |
| 547 .position() | 548 .position() |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 if (rootEditableElement) { | 649 if (rootEditableElement) { |
| 649 if (LocalFrame* frame = rootEditableElement->document().frame()) { | 650 if (LocalFrame* frame = rootEditableElement->document().frame()) { |
| 650 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( | 651 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( |
| 651 rootEditableElement); | 652 rootEditableElement); |
| 652 } | 653 } |
| 653 } | 654 } |
| 654 | 655 |
| 655 return true; | 656 return true; |
| 656 } | 657 } |
| 657 | 658 |
| 658 bool DragController::canProcessDrag(DragData* dragData) { | 659 bool DragController::canProcessDrag(DragData* dragData, LocalFrame& localRoot) { |
| 659 DCHECK(dragData); | 660 DCHECK(dragData); |
| 660 | 661 |
| 661 if (!dragData->containsCompatibleContent()) | 662 if (!dragData->containsCompatibleContent()) |
| 662 return false; | 663 return false; |
| 663 | 664 |
| 664 IntPoint point = | 665 if (localRoot.contentLayoutItem().isNull()) |
| 665 m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents( | |
| 666 dragData->clientPosition()); | |
| 667 if (m_page->deprecatedLocalMainFrame()->contentLayoutItem().isNull()) | |
| 668 return false; | 666 return false; |
| 669 | 667 |
| 670 HitTestResult result = | 668 IntPoint point = |
| 671 m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint( | 669 localRoot.view()->rootFrameToContents(dragData->clientPosition()); |
| 672 point); | 670 |
| 671 HitTestResult result = localRoot.eventHandler().hitTestResultAtPoint(point); |
| 673 | 672 |
| 674 if (!result.innerNode()) | 673 if (!result.innerNode()) |
| 675 return false; | 674 return false; |
| 676 | 675 |
| 677 if (dragData->containsFiles() && asFileInput(result.innerNode())) | 676 if (dragData->containsFiles() && asFileInput(result.innerNode())) |
| 678 return true; | 677 return true; |
| 679 | 678 |
| 680 if (isHTMLPlugInElement(*result.innerNode())) { | 679 if (isHTMLPlugInElement(*result.innerNode())) { |
| 681 HTMLPlugInElement* plugin = toHTMLPlugInElement(result.innerNode()); | 680 HTMLPlugInElement* plugin = toHTMLPlugInElement(result.innerNode()); |
| 682 if (!plugin->canProcessDrag() && !hasEditableStyle(*result.innerNode())) | 681 if (!plugin->canProcessDrag() && !hasEditableStyle(*result.innerNode())) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 705 return DragOperationCopy; | 704 return DragOperationCopy; |
| 706 if (srcOpMask & DragOperationLink) | 705 if (srcOpMask & DragOperationLink) |
| 707 return DragOperationLink; | 706 return DragOperationLink; |
| 708 | 707 |
| 709 // FIXME: Does IE really return "generic" even if no operations were allowed | 708 // FIXME: Does IE really return "generic" even if no operations were allowed |
| 710 // by the source? | 709 // by the source? |
| 711 return DragOperationGeneric; | 710 return DragOperationGeneric; |
| 712 } | 711 } |
| 713 | 712 |
| 714 bool DragController::tryDHTMLDrag(DragData* dragData, | 713 bool DragController::tryDHTMLDrag(DragData* dragData, |
| 715 DragOperation& operation) { | 714 DragOperation& operation, |
| 715 LocalFrame& localRoot) { |
| 716 DCHECK(dragData); | 716 DCHECK(dragData); |
| 717 DCHECK(m_documentUnderMouse); | 717 DCHECK(m_documentUnderMouse); |
| 718 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); | 718 if (!localRoot.view()) |
| 719 if (!mainFrame->view()) | |
| 720 return false; | 719 return false; |
| 721 | 720 |
| 722 DataTransferAccessPolicy policy = | 721 DataTransferAccessPolicy policy = |
| 723 m_documentUnderMouse->getSecurityOrigin()->isLocal() | 722 m_documentUnderMouse->getSecurityOrigin()->isLocal() |
| 724 ? DataTransferReadable | 723 ? DataTransferReadable |
| 725 : DataTransferTypesReadable; | 724 : DataTransferTypesReadable; |
| 726 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); | 725 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); |
| 727 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 726 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
| 728 dataTransfer->setSourceOperation(srcOpMask); | 727 dataTransfer->setSourceOperation(srcOpMask); |
| 729 | 728 |
| 730 PlatformMouseEvent event = createMouseEvent(dragData); | 729 PlatformMouseEvent event = createMouseEvent(dragData); |
| 731 if (mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer) == | 730 if (localRoot.eventHandler().updateDragAndDrop(event, dataTransfer) == |
| 732 WebInputEventResult::NotHandled) { | 731 WebInputEventResult::NotHandled) { |
| 733 dataTransfer->setAccessPolicy( | 732 dataTransfer->setAccessPolicy( |
| 734 DataTransferNumb); // invalidate clipboard here for security | 733 DataTransferNumb); // invalidate clipboard here for security |
| 735 return false; | 734 return false; |
| 736 } | 735 } |
| 737 | 736 |
| 738 operation = dataTransfer->destinationOperation(); | 737 operation = dataTransfer->destinationOperation(); |
| 739 if (dataTransfer->dropEffectIsUninitialized()) { | 738 if (dataTransfer->dropEffectIsUninitialized()) { |
| 740 operation = defaultOperationForDrag(srcOpMask); | 739 operation = defaultOperationForDrag(srcOpMask); |
| 741 } else if (!(srcOpMask & operation)) { | 740 } else if (!(srcOpMask & operation)) { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 } | 1221 } |
| 1223 | 1222 |
| 1224 DEFINE_TRACE(DragController) { | 1223 DEFINE_TRACE(DragController) { |
| 1225 visitor->trace(m_page); | 1224 visitor->trace(m_page); |
| 1226 visitor->trace(m_documentUnderMouse); | 1225 visitor->trace(m_documentUnderMouse); |
| 1227 visitor->trace(m_dragInitiator); | 1226 visitor->trace(m_dragInitiator); |
| 1228 visitor->trace(m_fileInputElementUnderMouse); | 1227 visitor->trace(m_fileInputElementUnderMouse); |
| 1229 } | 1228 } |
| 1230 | 1229 |
| 1231 } // namespace blink | 1230 } // namespace blink |
| OLD | NEW |