| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; | 218 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn
derMouse->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // tryDHTMLDrag fires dragenter event. The event listener that listens | 345 // tryDHTMLDrag fires dragenter event. The event listener that listens |
| 346 // to this event may create a nested message loop (open a modal dialog), | 346 // to this event may create a nested message loop (open a modal dialog), |
| 347 // which could process dragleave event and reset m_documentUnderMouse in | 347 // which could process dragleave event and reset m_documentUnderMouse in |
| 348 // dragExited. | 348 // dragExited. |
| 349 if (!m_documentUnderMouse) | 349 if (!m_documentUnderMouse) |
| 350 return false; | 350 return false; |
| 351 } | 351 } |
| 352 | 352 |
| 353 // It's unclear why this check is after tryDHTMLDrag. | 353 // It's unclear why this check is after tryDHTMLDrag. |
| 354 // We send drag events in tryDHTMLDrag and that may be the reason. | 354 // We send drag events in tryDHTMLDrag and that may be the reason. |
| 355 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); | 355 RawPtr<FrameView> frameView = m_documentUnderMouse->view(); |
| 356 if (!frameView) | 356 if (!frameView) |
| 357 return false; | 357 return false; |
| 358 | 358 |
| 359 if (isHandlingDrag) { | 359 if (isHandlingDrag) { |
| 360 m_page->dragCaretController().clear(); | 360 m_page->dragCaretController().clear(); |
| 361 return true; | 361 return true; |
| 362 } | 362 } |
| 363 | 363 |
| 364 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { | 364 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
| 365 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition
()); | 365 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition
()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 DragOperation DragController::operationForLoad(DragData* dragData) | 418 DragOperation DragController::operationForLoad(DragData* dragData) |
| 419 { | 419 { |
| 420 ASSERT(dragData); | 420 ASSERT(dragData); |
| 421 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint(dragData
->clientPosition()); | 421 Document* doc = m_page->deprecatedLocalMainFrame()->documentAtPoint(dragData
->clientPosition()); |
| 422 | 422 |
| 423 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->hasEditable
Style())) | 423 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->hasEditable
Style())) |
| 424 return DragOperationNone; | 424 return DragOperationNone; |
| 425 return dragOperation(dragData); | 425 return dragOperation(dragData); |
| 426 } | 426 } |
| 427 | 427 |
| 428 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar
et, RefPtrWillBeRawPtr<Range>& range, const IntPoint& point) | 428 static bool setSelectionToDragCaret(LocalFrame* frame, VisibleSelection& dragCar
et, RawPtr<Range>& range, const IntPoint& point) |
| 429 { | 429 { |
| 430 frame->selection().setSelection(dragCaret); | 430 frame->selection().setSelection(dragCaret); |
| 431 if (frame->selection().isNone()) { | 431 if (frame->selection().isNone()) { |
| 432 dragCaret = VisibleSelection(frame->positionForPoint(point)); | 432 dragCaret = VisibleSelection(frame->positionForPoint(point)); |
| 433 frame->selection().setSelection(dragCaret); | 433 frame->selection().setSelection(dragCaret); |
| 434 range = createRange(dragCaret.toNormalizedEphemeralRange()); | 434 range = createRange(dragCaret.toNormalizedEphemeralRange()); |
| 435 } | 435 } |
| 436 return !frame->selection().isNone() && frame->selection().isContentEditable(
); | 436 return !frame->selection().isNone() && frame->selection().isContentEditable(
); |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData*
dragData) | 439 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData*
dragData) |
| 440 { | 440 { |
| 441 ASSERT(m_page->dragCaretController().hasCaret()); | 441 ASSERT(m_page->dragCaretController().hasCaret()); |
| 442 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" :
dragData->asPlainText(); | 442 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" :
dragData->asPlainText(); |
| 443 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection(
m_page->dragCaretController().caretPosition())); | 443 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection(
m_page->dragCaretController().caretPosition())); |
| 444 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
), text)); | 444 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
), text)); |
| 445 } | 445 } |
| 446 | 446 |
| 447 bool DragController::concludeEditDrag(DragData* dragData) | 447 bool DragController::concludeEditDrag(DragData* dragData) |
| 448 { | 448 { |
| 449 ASSERT(dragData); | 449 ASSERT(dragData); |
| 450 | 450 |
| 451 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; | 451 RawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; |
| 452 if (m_fileInputElementUnderMouse) { | 452 if (m_fileInputElementUnderMouse) { |
| 453 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 453 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 454 m_fileInputElementUnderMouse = nullptr; | 454 m_fileInputElementUnderMouse = nullptr; |
| 455 } | 455 } |
| 456 | 456 |
| 457 if (!m_documentUnderMouse) | 457 if (!m_documentUnderMouse) |
| 458 return false; | 458 return false; |
| 459 | 459 |
| 460 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData-
>clientPosition()); | 460 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData-
>clientPosition()); |
| 461 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 461 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 462 if (!element) | 462 if (!element) |
| 463 return false; | 463 return false; |
| 464 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); | 464 RawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(); |
| 465 ASSERT(innerFrame); | 465 ASSERT(innerFrame); |
| 466 | 466 |
| 467 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) | 467 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) |
| 468 return true; | 468 return true; |
| 469 | 469 |
| 470 if (dragData->containsFiles() && fileInput) { | 470 if (dragData->containsFiles() && fileInput) { |
| 471 // fileInput should be the element we hit tested for, unless it was made | 471 // fileInput should be the element we hit tested for, unless it was made |
| 472 // display:none in a drop event handler. | 472 // display:none in a drop event handler. |
| 473 ASSERT(fileInput == element || !fileInput->layoutObject()); | 473 ASSERT(fileInput == element || !fileInput->layoutObject()); |
| 474 if (fileInput->isDisabledFormControl()) | 474 if (fileInput->isDisabledFormControl()) |
| 475 return false; | 475 return false; |
| 476 | 476 |
| 477 return fileInput->receiveDroppedFiles(dragData); | 477 return fileInput->receiveDroppedFiles(dragData); |
| 478 } | 478 } |
| 479 | 479 |
| 480 if (!m_page->dragController().canProcessDrag(dragData)) { | 480 if (!m_page->dragController().canProcessDrag(dragData)) { |
| 481 m_page->dragCaretController().clear(); | 481 m_page->dragCaretController().clear(); |
| 482 return false; | 482 return false; |
| 483 } | 483 } |
| 484 | 484 |
| 485 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition()); | 485 VisibleSelection dragCaret(m_page->dragCaretController().caretPosition()); |
| 486 m_page->dragCaretController().clear(); | 486 m_page->dragCaretController().clear(); |
| 487 RefPtrWillBeRawPtr<Range> range = createRange(dragCaret.toNormalizedEphemera
lRange()); | 487 RawPtr<Range> range = createRange(dragCaret.toNormalizedEphemeralRange()); |
| 488 RefPtrWillBeRawPtr<Element> rootEditableElement = innerFrame->selection().ro
otEditableElement(); | 488 RawPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl
ement(); |
| 489 | 489 |
| 490 // For range to be null a WebKit client must have done something bad while | 490 // For range to be null a WebKit client must have done something bad while |
| 491 // manually controlling drag behaviour | 491 // manually controlling drag behaviour |
| 492 if (!range) | 492 if (!range) |
| 493 return false; | 493 return false; |
| 494 ResourceFetcher* fetcher = range->ownerDocument().fetcher(); | 494 ResourceFetcher* fetcher = range->ownerDocument().fetcher(); |
| 495 ResourceCacheValidationSuppressor validationSuppressor(fetcher); | 495 ResourceCacheValidationSuppressor validationSuppressor(fetcher); |
| 496 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich
lyEditable()) { | 496 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich
lyEditable()) { |
| 497 bool chosePlainText = false; | 497 bool chosePlainText = false; |
| 498 RefPtrWillBeRawPtr<DocumentFragment> fragment = documentFragmentFromDrag
Data(dragData, innerFrame.get(), range, true, chosePlainText); | 498 RawPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat
a, innerFrame.get(), range, true, chosePlainText); |
| 499 if (!fragment) | 499 if (!fragment) |
| 500 return false; | 500 return false; |
| 501 | 501 |
| 502 if (dragIsMove(innerFrame->selection(), dragData)) { | 502 if (dragIsMove(innerFrame->selection(), dragData)) { |
| 503 // NSTextView behavior is to always smart delete on moving a selecti
on, | 503 // NSTextView behavior is to always smart delete on moving a selecti
on, |
| 504 // but only to smart insert if the selection granularity is word gra
nularity. | 504 // but only to smart insert if the selection granularity is word gra
nularity. |
| 505 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); | 505 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); |
| 506 bool smartInsert = smartDelete && innerFrame->selection().granularit
y() == WordGranularity && dragData->canSmartReplace(); | 506 bool smartInsert = smartDelete && innerFrame->selection().granularit
y() == WordGranularity && dragData->canSmartReplace(); |
| 507 innerFrame->editor().moveSelectionAfterDragging(fragment, dragCaret.
base(), smartInsert, smartDelete); | 507 innerFrame->editor().moveSelectionAfterDragging(fragment, dragCaret.
base(), smartInsert, smartDelete); |
| 508 } else { | 508 } else { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 return DragOperationLink; | 581 return DragOperationLink; |
| 582 | 582 |
| 583 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? | 583 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? |
| 584 return DragOperationGeneric; | 584 return DragOperationGeneric; |
| 585 } | 585 } |
| 586 | 586 |
| 587 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) | 587 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
| 588 { | 588 { |
| 589 ASSERT(dragData); | 589 ASSERT(dragData); |
| 590 ASSERT(m_documentUnderMouse); | 590 ASSERT(m_documentUnderMouse); |
| 591 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); | 591 RawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); |
| 592 if (!mainFrame->view()) | 592 if (!mainFrame->view()) |
| 593 return false; | 593 return false; |
| 594 | 594 |
| 595 RefPtrWillBeRawPtr<FrameView> viewProtector(mainFrame->view()); | 595 RawPtr<FrameView> viewProtector(mainFrame->view()); |
| 596 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; | 596 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; |
| 597 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); | 597 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); |
| 598 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 598 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
| 599 dataTransfer->setSourceOperation(srcOpMask); | 599 dataTransfer->setSourceOperation(srcOpMask); |
| 600 | 600 |
| 601 PlatformMouseEvent event = createMouseEvent(dragData); | 601 PlatformMouseEvent event = createMouseEvent(dragData); |
| 602 if (mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer) == WebI
nputEventResult::NotHandled) { | 602 if (mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer) == WebI
nputEventResult::NotHandled) { |
| 603 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security | 603 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security |
| 604 return false; | 604 return false; |
| 605 } | 605 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 { | 702 { |
| 703 ASSERT(element); | 703 ASSERT(element); |
| 704 ImageResource* cachedImage = getImageResource(element); | 704 ImageResource* cachedImage = getImageResource(element); |
| 705 return (cachedImage && !cachedImage->errorOccurred()) ? | 705 return (cachedImage && !cachedImage->errorOccurred()) ? |
| 706 cachedImage->image() : nullptr; | 706 cachedImage->image() : nullptr; |
| 707 } | 707 } |
| 708 | 708 |
| 709 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da
taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri
ng& label) | 709 static void prepareDataTransferForImageDrag(LocalFrame* source, DataTransfer* da
taTransfer, Element* node, const KURL& linkURL, const KURL& imageURL, const Stri
ng& label) |
| 710 { | 710 { |
| 711 if (node->isContentRichlyEditable()) { | 711 if (node->isContentRichlyEditable()) { |
| 712 RefPtrWillBeRawPtr<Range> range = source->document()->createRange(); | 712 RawPtr<Range> range = source->document()->createRange(); |
| 713 range->selectNode(node, ASSERT_NO_EXCEPTION); | 713 range->selectNode(node, ASSERT_NO_EXCEPTION); |
| 714 source->selection().setSelection(VisibleSelection(EphemeralRange(range.g
et()))); | 714 source->selection().setSelection(VisibleSelection(EphemeralRange(range.g
et()))); |
| 715 } | 715 } |
| 716 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL :
imageURL, label); | 716 dataTransfer->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL :
imageURL, label); |
| 717 } | 717 } |
| 718 | 718 |
| 719 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState&
state, const IntPoint& dragOrigin) | 719 bool DragController::populateDragDataTransfer(LocalFrame* src, const DragState&
state, const IntPoint& dragOrigin) |
| 720 { | 720 { |
| 721 ASSERT(dragTypeIsValid(state.m_dragType)); | 721 ASSERT(dragTypeIsValid(state.m_dragType)); |
| 722 ASSERT(src); | 722 ASSERT(src); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 } | 931 } |
| 932 | 932 |
| 933 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) | 933 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) |
| 934 { | 934 { |
| 935 // TODO(dcheng): Drag and drop is not yet supported for OOPI. | 935 // TODO(dcheng): Drag and drop is not yet supported for OOPI. |
| 936 if (m_page->mainFrame()->isRemoteFrame()) | 936 if (m_page->mainFrame()->isRemoteFrame()) |
| 937 return; | 937 return; |
| 938 m_didInitiateDrag = true; | 938 m_didInitiateDrag = true; |
| 939 m_dragInitiator = frame->document(); | 939 m_dragInitiator = frame->document(); |
| 940 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame | 940 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame |
| 941 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); | 941 RawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); |
| 942 RefPtrWillBeRawPtr<FrameView> mainFrameView = mainFrame->view(); | 942 RawPtr<FrameView> mainFrameView = mainFrame->view(); |
| 943 | 943 |
| 944 m_client->startDrag(image, mainFrameView->rootFrameToContents(frame->view()-
>contentsToRootFrame(dragLocation)), | 944 m_client->startDrag(image, mainFrameView->rootFrameToContents(frame->view()-
>contentsToRootFrame(dragLocation)), |
| 945 mainFrameView->rootFrameToContents(frame->view()->contentsToRootFrame(ev
entPos)), dataTransfer, frame, forLink); | 945 mainFrameView->rootFrameToContents(frame->view()->contentsToRootFrame(ev
entPos)), dataTransfer, frame, forLink); |
| 946 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. | 946 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. |
| 947 if (!frame->page()) | 947 if (!frame->page()) |
| 948 return; | 948 return; |
| 949 | 949 |
| 950 cleanupAfterSystemDrag(); | 950 cleanupAfterSystemDrag(); |
| 951 } | 951 } |
| 952 | 952 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 977 | 977 |
| 978 DEFINE_TRACE(DragController) | 978 DEFINE_TRACE(DragController) |
| 979 { | 979 { |
| 980 visitor->trace(m_page); | 980 visitor->trace(m_page); |
| 981 visitor->trace(m_documentUnderMouse); | 981 visitor->trace(m_documentUnderMouse); |
| 982 visitor->trace(m_dragInitiator); | 982 visitor->trace(m_dragInitiator); |
| 983 visitor->trace(m_fileInputElementUnderMouse); | 983 visitor->trace(m_fileInputElementUnderMouse); |
| 984 } | 984 } |
| 985 | 985 |
| 986 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |