| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 162                 RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(doc
     ument); | 162                 RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(doc
     ument); | 
| 163                 anchor->setHref(url); | 163                 anchor->setHref(url); | 
| 164                 if (title.isEmpty()) { | 164                 if (title.isEmpty()) { | 
| 165                     // Try the plain text first because the url might be normali
     zed or escaped. | 165                     // Try the plain text first because the url might be normali
     zed or escaped. | 
| 166                     if (dragData->containsPlainText()) | 166                     if (dragData->containsPlainText()) | 
| 167                         title = dragData->asPlainText(frame); | 167                         title = dragData->asPlainText(frame); | 
| 168                     if (title.isEmpty()) | 168                     if (title.isEmpty()) | 
| 169                         title = url; | 169                         title = url; | 
| 170                 } | 170                 } | 
| 171                 RefPtr<Node> anchorText = document->createTextNode(title); | 171                 RefPtr<Node> anchorText = document->createTextNode(title); | 
| 172                 anchor->appendChild(anchorText, IGNORE_EXCEPTION_STATE); | 172                 anchor->appendChild(anchorText, IGNORE_EXCEPTION); | 
| 173                 RefPtr<DocumentFragment> fragment = document->createDocumentFrag
     ment(); | 173                 RefPtr<DocumentFragment> fragment = document->createDocumentFrag
     ment(); | 
| 174                 fragment->appendChild(anchor, IGNORE_EXCEPTION_STATE); | 174                 fragment->appendChild(anchor, IGNORE_EXCEPTION); | 
| 175                 return fragment.get(); | 175                 return fragment.get(); | 
| 176             } | 176             } | 
| 177         } | 177         } | 
| 178     } | 178     } | 
| 179     if (allowPlainText && dragData->containsPlainText()) { | 179     if (allowPlainText && dragData->containsPlainText()) { | 
| 180         chosePlainText = true; | 180         chosePlainText = true; | 
| 181         return createFragmentFromText(context.get(), dragData->asPlainText(frame
     )).get(); | 181         return createFragmentFromText(context.get(), dragData->asPlainText(frame
     )).get(); | 
| 182     } | 182     } | 
| 183 | 183 | 
| 184     return 0; | 184     return 0; | 
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 436         range = dragCaret.toNormalizedRange(); | 436         range = dragCaret.toNormalizedRange(); | 
| 437     } | 437     } | 
| 438     return !frame->selection()->isNone() && frame->selection()->isContentEditabl
     e(); | 438     return !frame->selection()->isNone() && frame->selection()->isContentEditabl
     e(); | 
| 439 } | 439 } | 
| 440 | 440 | 
| 441 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* drag
     Data) | 441 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* drag
     Data) | 
| 442 { | 442 { | 
| 443     ASSERT(m_page->dragCaretController()->hasCaret()); | 443     ASSERT(m_page->dragCaretController()->hasCaret()); | 
| 444     String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" 
     : dragData->asPlainText(innerFrame); | 444     String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" 
     : dragData->asPlainText(innerFrame); | 
| 445     Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretCo
     ntroller()->caretPosition()); | 445     Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretCo
     ntroller()->caretPosition()); | 
| 446     return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
     ), text), IGNORE_EXCEPTION_STATE); | 446     return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(
     ), text), IGNORE_EXCEPTION); | 
| 447 } | 447 } | 
| 448 | 448 | 
| 449 bool DragController::concludeEditDrag(DragData* dragData) | 449 bool DragController::concludeEditDrag(DragData* dragData) | 
| 450 { | 450 { | 
| 451     ASSERT(dragData); | 451     ASSERT(dragData); | 
| 452 | 452 | 
| 453     RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; | 453     RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; | 
| 454     if (m_fileInputElementUnderMouse) { | 454     if (m_fileInputElementUnderMouse) { | 
| 455         m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 455         m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 
| 456         m_fileInputElementUnderMouse = 0; | 456         m_fileInputElementUnderMouse = 0; | 
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 679     // Users of getImage() want access to the SVGImage, in order to figure out t
     he filename extensions, | 679     // Users of getImage() want access to the SVGImage, in order to figure out t
     he filename extensions, | 
| 680     // which would be empty when asking the cached BitmapImages. | 680     // which would be empty when asking the cached BitmapImages. | 
| 681     return (cachedImage && !cachedImage->errorOccurred()) ? | 681     return (cachedImage && !cachedImage->errorOccurred()) ? | 
| 682         cachedImage->image() : 0; | 682         cachedImage->image() : 0; | 
| 683 } | 683 } | 
| 684 | 684 | 
| 685 static void prepareClipboardForImageDrag(Frame* source, Clipboard* clipboard, El
     ement* node, const KURL& linkURL, const KURL& imageURL, const String& label) | 685 static void prepareClipboardForImageDrag(Frame* source, Clipboard* clipboard, El
     ement* node, const KURL& linkURL, const KURL& imageURL, const String& label) | 
| 686 { | 686 { | 
| 687     if (node->isContentRichlyEditable()) { | 687     if (node->isContentRichlyEditable()) { | 
| 688         RefPtr<Range> range = source->document()->createRange(); | 688         RefPtr<Range> range = source->document()->createRange(); | 
| 689         range->selectNode(node, ASSERT_NO_EXCEPTION_STATE); | 689         range->selectNode(node, ASSERT_NO_EXCEPTION); | 
| 690         source->selection()->setSelection(VisibleSelection(range.get(), DOWNSTRE
     AM)); | 690         source->selection()->setSelection(VisibleSelection(range.get(), DOWNSTRE
     AM)); | 
| 691     } | 691     } | 
| 692     clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : ima
     geURL, label, source); | 692     clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : ima
     geURL, label, source); | 
| 693 } | 693 } | 
| 694 | 694 | 
| 695 bool DragController::populateDragClipboard(Frame* src, const DragState& state, c
     onst IntPoint& dragOrigin) | 695 bool DragController::populateDragClipboard(Frame* src, const DragState& state, c
     onst IntPoint& dragOrigin) | 
| 696 { | 696 { | 
| 697     ASSERT(dragTypeIsValid(state.m_dragType)); | 697     ASSERT(dragTypeIsValid(state.m_dragType)); | 
| 698     ASSERT(src); | 698     ASSERT(src); | 
| 699     if (!src->view() || !src->contentRenderer()) | 699     if (!src->view() || !src->contentRenderer()) | 
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 930     return false; | 930     return false; | 
| 931 #endif | 931 #endif | 
| 932 } | 932 } | 
| 933 | 933 | 
| 934 void DragController::cleanupAfterSystemDrag() | 934 void DragController::cleanupAfterSystemDrag() | 
| 935 { | 935 { | 
| 936 } | 936 } | 
| 937 | 937 | 
| 938 } // namespace WebCore | 938 } // namespace WebCore | 
| 939 | 939 | 
| OLD | NEW | 
|---|