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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 return DragOperationNone; | 308 return DragOperationNone; |
309 return dragOperation(dragData); | 309 return dragOperation(dragData); |
310 } | 310 } |
311 | 311 |
312 static bool setSelectionToDragCaret(Frame* frame, Selection& dragCaret, RefPtr<R
ange>& range, const IntPoint& point) | 312 static bool setSelectionToDragCaret(Frame* frame, Selection& dragCaret, RefPtr<R
ange>& range, const IntPoint& point) |
313 { | 313 { |
314 frame->selection()->setSelection(dragCaret); | 314 frame->selection()->setSelection(dragCaret); |
315 if (frame->selection()->isNone()) { | 315 if (frame->selection()->isNone()) { |
316 dragCaret = frame->visiblePositionForPoint(point); | 316 dragCaret = frame->visiblePositionForPoint(point); |
317 frame->selection()->setSelection(dragCaret); | 317 frame->selection()->setSelection(dragCaret); |
318 range = dragCaret.toRange(); | 318 range = dragCaret.toNormalizedRange(); |
319 } | 319 } |
320 return !frame->selection()->isNone() && frame->selection()->isContentEditabl
e(); | 320 return !frame->selection()->isNone() && frame->selection()->isContentEditabl
e(); |
321 } | 321 } |
322 | 322 |
323 bool DragController::concludeEditDrag(DragData* dragData) | 323 bool DragController::concludeEditDrag(DragData* dragData) |
324 { | 324 { |
325 ASSERT(dragData); | 325 ASSERT(dragData); |
326 ASSERT(!m_isHandlingDrag); | 326 ASSERT(!m_isHandlingDrag); |
327 | 327 |
328 if (!m_document) | 328 if (!m_document) |
329 return false; | 329 return false; |
330 | 330 |
331 IntPoint point = m_document->view()->windowToContents(dragData->clientPositi
on()); | 331 IntPoint point = m_document->view()->windowToContents(dragData->clientPositi
on()); |
332 Element* element = m_document->elementFromPoint(point.x(), point.y()); | 332 Element* element = m_document->elementFromPoint(point.x(), point.y()); |
333 ASSERT(element); | 333 ASSERT(element); |
334 Frame* innerFrame = element->ownerDocument()->frame(); | 334 Frame* innerFrame = element->ownerDocument()->frame(); |
335 ASSERT(innerFrame); | 335 ASSERT(innerFrame); |
336 | 336 |
337 if (dragData->containsColor()) { | 337 if (dragData->containsColor()) { |
338 Color color = dragData->asColor(); | 338 Color color = dragData->asColor(); |
339 if (!color.isValid()) | 339 if (!color.isValid()) |
340 return false; | 340 return false; |
341 if (!innerFrame) | 341 if (!innerFrame) |
342 return false; | 342 return false; |
343 RefPtr<Range> innerRange = innerFrame->selection()->toRange(); | 343 RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange(); |
344 RefPtr<CSSStyleDeclaration> style = m_document->createCSSStyleDeclaratio
n(); | 344 RefPtr<CSSStyleDeclaration> style = m_document->createCSSStyleDeclaratio
n(); |
345 ExceptionCode ec; | 345 ExceptionCode ec; |
346 style->setProperty("color", color.name(), ec); | 346 style->setProperty("color", color.name(), ec); |
347 if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get(
))) | 347 if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get(
))) |
348 return false; | 348 return false; |
349 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); | 349 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr
agData); |
350 innerFrame->editor()->applyStyle(style.get(), EditActionSetColor); | 350 innerFrame->editor()->applyStyle(style.get(), EditActionSetColor); |
351 return true; | 351 return true; |
352 } | 352 } |
353 | 353 |
(...skipping 22 matching lines...) Expand all Loading... |
376 | 376 |
377 if (!renderer) | 377 if (!renderer) |
378 return false; | 378 return false; |
379 | 379 |
380 renderer->receiveDroppedFiles(filenames); | 380 renderer->receiveDroppedFiles(filenames); |
381 return true; | 381 return true; |
382 } | 382 } |
383 | 383 |
384 Selection dragCaret(m_page->dragCaretController()->selection()); | 384 Selection dragCaret(m_page->dragCaretController()->selection()); |
385 m_page->dragCaretController()->clear(); | 385 m_page->dragCaretController()->clear(); |
386 RefPtr<Range> range = dragCaret.toRange(); | 386 RefPtr<Range> range = dragCaret.toNormalizedRange(); |
387 | 387 |
388 // For range to be null a WebKit client must have done something bad while | 388 // For range to be null a WebKit client must have done something bad while |
389 // manually controlling drag behaviour | 389 // manually controlling drag behaviour |
390 if (!range) | 390 if (!range) |
391 return false; | 391 return false; |
392 DocLoader* loader = range->ownerDocument()->docLoader(); | 392 DocLoader* loader = range->ownerDocument()->docLoader(); |
393 loader->setAllowStaleResources(true); | 393 loader->setAllowStaleResources(true); |
394 if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable
()) { | 394 if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable
()) { |
395 bool chosePlainText = false; | 395 bool chosePlainText = false; |
396 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat
a, range, true, chosePlainText); | 396 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat
a, range, true, chosePlainText); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 666 |
667 m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin,
clipboard); | 667 m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin,
clipboard); |
668 if (!dragImage) { | 668 if (!dragImage) { |
669 dragImage = m_client->createDragImageForLink(linkURL, dragSource.tex
tContent(), src); | 669 dragImage = m_client->createDragImageForLink(linkURL, dragSource.tex
tContent(), src); |
670 IntSize size = dragImageSize(dragImage); | 670 IntSize size = dragImageSize(dragImage); |
671 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); | 671 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); |
672 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDr
aggedPoint.y() + m_dragOffset.y()); | 672 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDr
aggedPoint.y() + m_dragOffset.y()); |
673 } | 673 } |
674 doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, clipboard, src, true
); | 674 doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, clipboard, src, true
); |
675 } else if (isSelected && (m_dragSourceAction & DragSourceActionSelection)) { | 675 } else if (isSelected && (m_dragSourceAction & DragSourceActionSelection)) { |
676 RefPtr<Range> selectionRange = src->selection()->toRange(); | 676 RefPtr<Range> selectionRange = src->selection()->toNormalizedRange(); |
677 ASSERT(selectionRange); | 677 ASSERT(selectionRange); |
678 if (!clipboard->hasData()) | 678 if (!clipboard->hasData()) |
679 clipboard->writeRange(selectionRange.get(), src); | 679 clipboard->writeRange(selectionRange.get(), src); |
680 m_client->willPerformDragSourceAction(DragSourceActionSelection, dragOri
gin, clipboard); | 680 m_client->willPerformDragSourceAction(DragSourceActionSelection, dragOri
gin, clipboard); |
681 if (!dragImage) { | 681 if (!dragImage) { |
682 dragImage = createDragImageForSelection(src); | 682 dragImage = createDragImageForSelection(src); |
683 dragLoc = dragLocForSelectionDrag(src); | 683 dragLoc = dragLocForSelectionDrag(src); |
684 m_dragOffset = IntPoint((int)(dragOrigin.x() - dragLoc.x()), (int)(d
ragOrigin.y() - dragLoc.y())); | 684 m_dragOffset = IntPoint((int)(dragOrigin.x() - dragLoc.x()), (int)(d
ragOrigin.y() - dragLoc.y())); |
685 } | 685 } |
686 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); | 686 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 ASSERT(frame); | 769 ASSERT(frame); |
770 FrameView* frameView = frame->view(); | 770 FrameView* frameView = frame->view(); |
771 if (!frameView) | 771 if (!frameView) |
772 return; | 772 return; |
773 IntPoint framePoint = frameView->windowToContents(windowPoint); | 773 IntPoint framePoint = frameView->windowToContents(windowPoint); |
774 Selection dragCaret(frame->visiblePositionForPoint(framePoint)); | 774 Selection dragCaret(frame->visiblePositionForPoint(framePoint)); |
775 m_page->dragCaretController()->setSelection(dragCaret); | 775 m_page->dragCaretController()->setSelection(dragCaret); |
776 } | 776 } |
777 | 777 |
778 } | 778 } |
OLD | NEW |