| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (m_isHandlingDrag) { | 306 if (m_isHandlingDrag) { |
| 307 m_page->dragCaretController()->clear(); | 307 m_page->dragCaretController()->clear(); |
| 308 return true; | 308 return true; |
| 309 } else if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragDa
ta)) { | 309 } else if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragDa
ta)) { |
| 310 if (dragData->containsColor()) { | 310 if (dragData->containsColor()) { |
| 311 operation = DragOperationGeneric; | 311 operation = DragOperationGeneric; |
| 312 return true; | 312 return true; |
| 313 } | 313 } |
| 314 | 314 |
| 315 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; | 315 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; |
| 316 Element* element = elementUnderMouse(m_documentUnderMouse, point); | 316 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 317 if (!asFileInput(element)) { | 317 if (!asFileInput(element)) { |
| 318 VisibleSelection dragCaret = m_documentUnderMouse->frame()->visibleP
ositionForPoint(point); | 318 VisibleSelection dragCaret = m_documentUnderMouse->frame()->visibleP
ositionForPoint(point); |
| 319 m_page->dragCaretController()->setSelection(dragCaret); | 319 m_page->dragCaretController()->setSelection(dragCaret); |
| 320 } | 320 } |
| 321 | 321 |
| 322 Frame* innerFrame = element->document()->frame(); | 322 Frame* innerFrame = element->document()->frame(); |
| 323 operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : Dr
agOperationCopy; | 323 operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : Dr
agOperationCopy; |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 // If we're not over an editable region, make sure we're clearing any prior
drag cursor. | 326 // If we're not over an editable region, make sure we're clearing any prior
drag cursor. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 356 | 356 |
| 357 bool DragController::concludeEditDrag(DragData* dragData) | 357 bool DragController::concludeEditDrag(DragData* dragData) |
| 358 { | 358 { |
| 359 ASSERT(dragData); | 359 ASSERT(dragData); |
| 360 ASSERT(!m_isHandlingDrag); | 360 ASSERT(!m_isHandlingDrag); |
| 361 | 361 |
| 362 if (!m_documentUnderMouse) | 362 if (!m_documentUnderMouse) |
| 363 return false; | 363 return false; |
| 364 | 364 |
| 365 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl
ientPosition()); | 365 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl
ientPosition()); |
| 366 Element* element = elementUnderMouse(m_documentUnderMouse, point); | 366 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 367 Frame* innerFrame = element->ownerDocument()->frame(); | 367 Frame* innerFrame = element->ownerDocument()->frame(); |
| 368 ASSERT(innerFrame); | 368 ASSERT(innerFrame); |
| 369 | 369 |
| 370 if (dragData->containsColor()) { | 370 if (dragData->containsColor()) { |
| 371 Color color = dragData->asColor(); | 371 Color color = dragData->asColor(); |
| 372 if (!color.isValid()) | 372 if (!color.isValid()) |
| 373 return false; | 373 return false; |
| 374 if (!innerFrame) | 374 if (!innerFrame) |
| 375 return false; | 375 return false; |
| 376 RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange(); | 376 RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); | 433 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); |
| 434 if (dragIsMove(innerFrame->selection())) { | 434 if (dragIsMove(innerFrame->selection())) { |
| 435 // NSTextView behavior is to always smart delete on moving a selecti
on, | 435 // NSTextView behavior is to always smart delete on moving a selecti
on, |
| 436 // but only to smart insert if the selection granularity is word gra
nularity. | 436 // but only to smart insert if the selection granularity is word gra
nularity. |
| 437 bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled(); | 437 bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled(); |
| 438 bool smartInsert = smartDelete && innerFrame->selectionGranularity()
== WordGranularity && dragData->canSmartReplace(); | 438 bool smartInsert = smartDelete && innerFrame->selectionGranularity()
== WordGranularity && dragData->canSmartReplace(); |
| 439 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base()
, smartInsert, smartDelete)); | 439 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base()
, smartInsert, smartDelete)); |
| 440 } else { | 440 } else { |
| 441 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) | 441 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) |
| 442 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMous
e, fragment, true, dragData->canSmartReplace(), chosePlainText)); | 442 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMous
e.get(), fragment, true, dragData->canSmartReplace(), chosePlainText)); |
| 443 } | 443 } |
| 444 } else { | 444 } else { |
| 445 String text = dragData->asPlainText(); | 445 String text = dragData->asPlainText(); |
| 446 if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, rang
e.get(), EditorInsertActionDropped)) { | 446 if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, rang
e.get(), EditorInsertActionDropped)) { |
| 447 loader->setAllowStaleResources(false); | 447 loader->setAllowStaleResources(false); |
| 448 return false; | 448 return false; |
| 449 } | 449 } |
| 450 | 450 |
| 451 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); | 451 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); |
| 452 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) | 452 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) |
| 453 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse, c
reateFragmentFromText(range.get(), text), true, false, true)); | 453 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.ge
t(), createFragmentFromText(range.get(), text), true, false, true)); |
| 454 } | 454 } |
| 455 loader->setAllowStaleResources(false); | 455 loader->setAllowStaleResources(false); |
| 456 | 456 |
| 457 return true; | 457 return true; |
| 458 } | 458 } |
| 459 | 459 |
| 460 bool DragController::canProcessDrag(DragData* dragData) | 460 bool DragController::canProcessDrag(DragData* dragData) |
| 461 { | 461 { |
| 462 ASSERT(dragData); | 462 ASSERT(dragData); |
| 463 | 463 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 if (!frameView) | 816 if (!frameView) |
| 817 return; | 817 return; |
| 818 IntPoint framePoint = frameView->windowToContents(windowPoint); | 818 IntPoint framePoint = frameView->windowToContents(windowPoint); |
| 819 VisibleSelection dragCaret(frame->visiblePositionForPoint(framePoint)); | 819 VisibleSelection dragCaret(frame->visiblePositionForPoint(framePoint)); |
| 820 m_page->dragCaretController()->setSelection(dragCaret); | 820 m_page->dragCaretController()->setSelection(dragCaret); |
| 821 } | 821 } |
| 822 | 822 |
| 823 } // namespace WebCore | 823 } // namespace WebCore |
| 824 | 824 |
| 825 #endif // ENABLE(DRAG_SUPPORT) | 825 #endif // ENABLE(DRAG_SUPPORT) |
| OLD | NEW |