|
Lines 119-125
DragController::DragController(Page& page, DragClient& client)
a/Source/WebCore/page/DragController.cpp_sec1
|
| 119 |
: m_page(page) |
119 |
: m_page(page) |
| 120 |
, m_client(client) |
120 |
, m_client(client) |
| 121 |
, m_numberOfItemsToBeAccepted(0) |
121 |
, m_numberOfItemsToBeAccepted(0) |
| 122 |
, m_documentIsHandlingDrag(false) |
122 |
, m_documentDragHandlingMethod(DragHandlingMethod::None) |
| 123 |
, m_dragDestinationAction(DragDestinationActionNone) |
123 |
, m_dragDestinationAction(DragDestinationActionNone) |
| 124 |
, m_dragSourceAction(DragSourceActionNone) |
124 |
, m_dragSourceAction(DragSourceActionNone) |
| 125 |
, m_didInitiateDrag(false) |
125 |
, m_didInitiateDrag(false) |
|
Lines 228-234
bool DragController::performDragOperation(const DragData& dragData)
a/Source/WebCore/page/DragController.cpp_sec2
|
| 228 |
if (m_documentUnderMouse) |
228 |
if (m_documentUnderMouse) |
| 229 |
shouldOpenExternalURLsPolicy = m_documentUnderMouse->shouldOpenExternalURLsPolicyToPropagate(); |
229 |
shouldOpenExternalURLsPolicy = m_documentUnderMouse->shouldOpenExternalURLsPolicyToPropagate(); |
| 230 |
|
230 |
|
| 231 |
if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHandlingDrag) { |
231 |
if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentDragHandlingMethod != DragHandlingMethod::None) { |
| 232 |
m_client.willPerformDragDestinationAction(DragDestinationActionDHTML, dragData); |
232 |
m_client.willPerformDragDestinationAction(DragDestinationActionDHTML, dragData); |
| 233 |
Ref<MainFrame> mainFrame(m_page.mainFrame()); |
233 |
Ref<MainFrame> mainFrame(m_page.mainFrame()); |
| 234 |
bool preventedDefault = false; |
234 |
bool preventedDefault = false; |
|
Lines 288-295
DragOperation DragController::dragEnteredOrUpdated(const DragData& dragData)
a/Source/WebCore/page/DragController.cpp_sec3
|
| 288 |
} |
288 |
} |
| 289 |
|
289 |
|
| 290 |
DragOperation dragOperation = DragOperationNone; |
290 |
DragOperation dragOperation = DragOperationNone; |
| 291 |
m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction, dragOperation); |
291 |
m_documentDragHandlingMethod = tryDocumentDrag(dragData, m_dragDestinationAction, dragOperation); |
| 292 |
if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationActionLoad)) |
292 |
if (m_documentDragHandlingMethod == DragHandlingMethod::None && (m_dragDestinationAction & DragDestinationActionLoad)) |
| 293 |
dragOperation = operationForLoad(dragData); |
293 |
dragOperation = operationForLoad(dragData); |
| 294 |
return dragOperation; |
294 |
return dragOperation; |
| 295 |
} |
295 |
} |
|
Lines 329-341
static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
a/Source/WebCore/page/DragController.cpp_sec4
|
| 329 |
return downcast<Element>(node); |
329 |
return downcast<Element>(node); |
| 330 |
} |
330 |
} |
| 331 |
|
331 |
|
| 332 |
bool DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation) |
332 |
DragController::DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation) |
| 333 |
{ |
333 |
{ |
| 334 |
if (!m_documentUnderMouse) |
334 |
if (!m_documentUnderMouse) |
| 335 |
return false; |
335 |
return DragHandlingMethod::None; |
| 336 |
|
336 |
|
| 337 |
if (m_dragInitiator && !m_documentUnderMouse->securityOrigin().canReceiveDragData(m_dragInitiator->securityOrigin())) |
337 |
if (m_dragInitiator && !m_documentUnderMouse->securityOrigin().canReceiveDragData(m_dragInitiator->securityOrigin())) |
| 338 |
return false; |
338 |
return DragHandlingMethod::None; |
| 339 |
|
339 |
|
| 340 |
bool isHandlingDrag = false; |
340 |
bool isHandlingDrag = false; |
| 341 |
if (actionMask & DragDestinationActionDHTML) { |
341 |
if (actionMask & DragDestinationActionDHTML) { |
|
Lines 346-375
bool DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAc
a/Source/WebCore/page/DragController.cpp_sec5
|
| 346 |
// which could process dragleave event and reset m_documentUnderMouse in |
346 |
// which could process dragleave event and reset m_documentUnderMouse in |
| 347 |
// dragExited. |
347 |
// dragExited. |
| 348 |
if (!m_documentUnderMouse) |
348 |
if (!m_documentUnderMouse) |
| 349 |
return false; |
349 |
return DragHandlingMethod::None; |
| 350 |
} |
350 |
} |
| 351 |
|
351 |
|
| 352 |
// It's unclear why this check is after tryDHTMLDrag. |
352 |
// It's unclear why this check is after tryDHTMLDrag. |
| 353 |
// We send drag events in tryDHTMLDrag and that may be the reason. |
353 |
// We send drag events in tryDHTMLDrag and that may be the reason. |
| 354 |
RefPtr<FrameView> frameView = m_documentUnderMouse->view(); |
354 |
RefPtr<FrameView> frameView = m_documentUnderMouse->view(); |
| 355 |
if (!frameView) |
355 |
if (!frameView) |
| 356 |
return false; |
356 |
return DragHandlingMethod::None; |
| 357 |
|
357 |
|
| 358 |
if (isHandlingDrag) { |
358 |
if (isHandlingDrag) { |
| 359 |
clearDragCaret(); |
359 |
clearDragCaret(); |
| 360 |
return true; |
360 |
return DragHandlingMethod::NonDefault; |
| 361 |
} |
361 |
} |
| 362 |
|
362 |
|
| 363 |
if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
363 |
if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
| 364 |
if (dragData.containsColor()) { |
364 |
if (dragData.containsColor()) { |
| 365 |
dragOperation = DragOperationGeneric; |
365 |
dragOperation = DragOperationGeneric; |
| 366 |
return true; |
366 |
return DragHandlingMethod::Default; |
| 367 |
} |
367 |
} |
| 368 |
|
368 |
|
| 369 |
IntPoint point = frameView->windowToContents(dragData.clientPosition()); |
369 |
IntPoint point = frameView->windowToContents(dragData.clientPosition()); |
| 370 |
Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
370 |
Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 371 |
if (!element) |
371 |
if (!element) |
| 372 |
return false; |
372 |
return DragHandlingMethod::None; |
| 373 |
|
373 |
|
| 374 |
HTMLInputElement* elementAsFileInput = asFileInput(*element); |
374 |
HTMLInputElement* elementAsFileInput = asFileInput(*element); |
| 375 |
if (m_fileInputElementUnderMouse != elementAsFileInput) { |
375 |
if (m_fileInputElementUnderMouse != elementAsFileInput) { |
|
Lines 407-413
bool DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAc
a/Source/WebCore/page/DragController.cpp_sec6
|
| 407 |
m_numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; |
407 |
m_numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; |
| 408 |
} |
408 |
} |
| 409 |
|
409 |
|
| 410 |
return true; |
410 |
return DragHandlingMethod::Default; |
| 411 |
} |
411 |
} |
| 412 |
|
412 |
|
| 413 |
// We are not over an editable region. Make sure we're clearing any prior drag cursor. |
413 |
// We are not over an editable region. Make sure we're clearing any prior drag cursor. |
|
Lines 415-421
bool DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAc
a/Source/WebCore/page/DragController.cpp_sec7
|
| 415 |
if (m_fileInputElementUnderMouse) |
415 |
if (m_fileInputElementUnderMouse) |
| 416 |
m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
416 |
m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 417 |
m_fileInputElementUnderMouse = nullptr; |
417 |
m_fileInputElementUnderMouse = nullptr; |
| 418 |
return false; |
418 |
return DragHandlingMethod::None; |
| 419 |
} |
419 |
} |
| 420 |
|
420 |
|
| 421 |
DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootViewPoint) |
421 |
DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootViewPoint) |