| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 { | 425 { |
| 426 frame->selection().setSelection(dragCaret); | 426 frame->selection().setSelection(dragCaret); |
| 427 if (frame->selection().isNone()) { | 427 if (frame->selection().isNone()) { |
| 428 dragCaret = VisibleSelection(frame->positionForPoint(point)); | 428 dragCaret = VisibleSelection(frame->positionForPoint(point)); |
| 429 frame->selection().setSelection(dragCaret); | 429 frame->selection().setSelection(dragCaret); |
| 430 range = createRange(dragCaret.toNormalizedEphemeralRange()); | 430 range = createRange(dragCaret.toNormalizedEphemeralRange()); |
| 431 } | 431 } |
| 432 return !frame->selection().isNone() && frame->selection().isContentEditable(
); | 432 return !frame->selection().isNone() && frame->selection().isContentEditable(
); |
| 433 } | 433 } |
| 434 | 434 |
| 435 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData*
dragData) | 435 DispatchEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF
rame, DragData* dragData) |
| 436 { | 436 { |
| 437 ASSERT(m_page->dragCaretController().hasCaret()); | 437 ASSERT(m_page->dragCaretController().hasCaret()); |
| 438 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" :
dragData->asPlainText(); | 438 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" :
dragData->asPlainText(); |
| 439 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection(
m_page->dragCaretController().caretPosition())); | 439 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection(
m_page->dragCaretController().caretPosition())); |
| 440 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
), text)); | 440 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
), text)); |
| 441 } | 441 } |
| 442 | 442 |
| 443 bool DragController::concludeEditDrag(DragData* dragData) | 443 bool DragController::concludeEditDrag(DragData* dragData) |
| 444 { | 444 { |
| 445 ASSERT(dragData); | 445 ASSERT(dragData); |
| 446 | 446 |
| 447 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; | 447 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; |
| 448 if (m_fileInputElementUnderMouse) { | 448 if (m_fileInputElementUnderMouse) { |
| 449 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 449 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 450 m_fileInputElementUnderMouse = nullptr; | 450 m_fileInputElementUnderMouse = nullptr; |
| 451 } | 451 } |
| 452 | 452 |
| 453 if (!m_documentUnderMouse) | 453 if (!m_documentUnderMouse) |
| 454 return false; | 454 return false; |
| 455 | 455 |
| 456 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData-
>clientPosition()); | 456 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData-
>clientPosition()); |
| 457 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 457 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 458 if (!element) | 458 if (!element) |
| 459 return false; | 459 return false; |
| 460 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); | 460 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); |
| 461 ASSERT(innerFrame); | 461 ASSERT(innerFrame); |
| 462 | 462 |
| 463 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) | 463 if (m_page->dragCaretController().hasCaret() && dispatchTextInputEventFor(in
nerFrame.get(), dragData) != DispatchEventResult::NotCanceled) |
| 464 return true; | 464 return true; |
| 465 | 465 |
| 466 if (dragData->containsFiles() && fileInput) { | 466 if (dragData->containsFiles() && fileInput) { |
| 467 // fileInput should be the element we hit tested for, unless it was made | 467 // fileInput should be the element we hit tested for, unless it was made |
| 468 // display:none in a drop event handler. | 468 // display:none in a drop event handler. |
| 469 ASSERT(fileInput == element || !fileInput->layoutObject()); | 469 ASSERT(fileInput == element || !fileInput->layoutObject()); |
| 470 if (fileInput->isDisabledFormControl()) | 470 if (fileInput->isDisabledFormControl()) |
| 471 return false; | 471 return false; |
| 472 | 472 |
| 473 return fileInput->receiveDroppedFiles(dragData); | 473 return fileInput->receiveDroppedFiles(dragData); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 973 |
| 974 DEFINE_TRACE(DragController) | 974 DEFINE_TRACE(DragController) |
| 975 { | 975 { |
| 976 visitor->trace(m_page); | 976 visitor->trace(m_page); |
| 977 visitor->trace(m_documentUnderMouse); | 977 visitor->trace(m_documentUnderMouse); |
| 978 visitor->trace(m_dragInitiator); | 978 visitor->trace(m_dragInitiator); |
| 979 visitor->trace(m_fileInputElementUnderMouse); | 979 visitor->trace(m_fileInputElementUnderMouse); |
| 980 } | 980 } |
| 981 | 981 |
| 982 } // namespace blink | 982 } // namespace blink |
| OLD | NEW |