Changeset 19689 in webkit
- Timestamp:
- Feb 18, 2007 4:30:55 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19687 r19689 1 2007-02-18 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Adam. 4 5 More drag and drop migration, now the entirety of the 6 drag initiation logic has been rendered platform independent 7 This has required a number of new interfaces, and a reasonable 8 amount of logic migration. 9 10 As a side effect, this patch also fixes rdar://problem/4945341 11 12 There are some basic Qt stubs that should stop the build from failing, 13 however the absence of ClipboardQt means any attempt to initiate a drag 14 may cause a crash. 15 16 * WebCore.exp: 17 Exporting new symbols 18 19 * WebCore.xcodeproj/project.pbxproj: 20 New files 21 22 * dom/Clipboard.cpp: 23 (WebCore::Clipboard::canSaveAsWebArchive): 24 Migrated from WebKit 25 26 * dom/Clipboard.h: 27 Added more methods to allow Clipboard to be used as a 28 platform independent container for drag and drop 29 30 * page/DragClient.h: 31 (WebCore::DragClient::declareAndWriteDragImage): 32 This is a mac only helper function, so i've made it have an empty implementation, 33 that way we won't need a PLATFORM(MAC) block in SVGImageEmptyClients 34 35 * page/DragController.cpp: 36 (WebCore::DragController::dragExited): 37 (WebCore::DragController::performDrag): 38 (WebCore::DragController::tryDocumentDrag): 39 (WebCore::DragController::tryDHTMLDrag): 40 Using RefPtrs now 41 (WebCore::getCachedImage): 42 (WebCore::getImage): 43 Helper functions 44 (WebCore::dragLocForDHTMLDrag): 45 (WebCore::dragLocForSelectionDrag): 46 (WebCore::DragController::startDrag): 47 (WebCore::DragController::doImageDrag): 48 (WebCore::DragController::doSystemDrag): 49 Logic that generates drag images and clipboard content, and 50 initiates the actual system drag operation 51 52 * page/DragController.h: 53 Method and variable declarations 54 55 * page/EventHandler.cpp: 56 (WebCore::EventHandler::handleDrag): 57 handleDrag is now platform independent 58 (WebCore::EventHandler::handleTextInputEvent): 59 formatting 60 61 * page/EventHandler.h: 62 (WebCore::EventHandler::eventLoopHandleMouseDragged): 63 Forgot to define this stub function 64 65 * page/Frame.h: 66 Declaring dragImageForSelection to provide drag image for selected content 67 68 * page/mac/DragControllerMac.mm: 69 Defining drag images control vars 70 71 * page/mac/EventHandlerMac.mm: 72 (WebCore::EventHandler::createDraggingClipboard): 73 Migrated old clipboard creation to here 74 75 * page/mac/FrameMac.mm: 76 (WebCore::Frame::dragImageForSelection): 77 Wrap FrameMac::selectionImage 78 79 * page/qt/DragControllerQt.cpp: 80 Defining drag images control vars 81 82 * page/qt/EventHandlerQt.cpp: 83 (WebCore::EventHandler::createDraggingClipboard): 84 stub 85 86 * page/qt/FrameQt.cpp: 87 (WebCore::Frame::dragImageForSelection): 88 stub 89 90 * platform/DragImage.cpp: Added. 91 (WebCore::fitDragImageToMaxSize): 92 (WebCore::createDragImageForSelection): 93 Platform independent processing for drag images 94 95 * platform/DragImage.h: Added. 96 Declaring typedefs and wrapper functions to abstract the handling 97 of drag images 98 99 * platform/Pasteboard.h: 100 Declaring extracted writeURL and writeSelection methods 101 102 * platform/graphics/svg/SVGImageEmptyClients.h: 103 (WebCore::SVGEmptyDragClient::willPerformDragSourceAction): 104 (WebCore::SVGEmptyDragClient::startDrag): 105 (WebCore::SVGEmptyDragClient::createDragImageForLink): 106 Stubs FTW! 107 108 * platform/mac/ClipboardMac.h: 109 (WebCore::ClipboardMac::pasteboard): 110 Provide accessor for underlying NSPasteboard 111 112 * platform/mac/ClipboardMac.mm: 113 (WebCore::ClipboardMac::hasData): 114 (WebCore::ClipboardMac::writeRange): 115 (WebCore::ClipboardMac::writeURL): 116 (WebCore::ClipboardMac::declareAndWriteDragImage): 117 (WebCore::ClipboardMac::createDragImage): 118 Implemented new Clipboarid functionality. 119 (WebCore::ClipboardMac::dragNSImage): 120 Made this a const method 121 122 * platform/mac/DragImageMac.mm: Added. 123 (WebCore::dragImageSize): 124 (WebCore::deleteDragImage): 125 (WebCore::scaleDragImage): 126 (WebCore::dissolveDragImageToFraction): 127 (WebCore::createDragImageFromImage): 128 (WebCore::createDragImageIconForCachedImage): 129 Implemented platform specific DragImage functions 130 131 * platform/mac/PasteboardMac.mm: 132 (WebCore::writeSelection): 133 (WebCore::Pasteboard::writeSelection): 134 (WebCore::writeURL): 135 (WebCore::Pasteboard::writeURL): 136 Extracted member implementations of these functions, so that 137 Clipboard could also make use of this functionality. 138 Pasteboard methods now call the new non-member implementations. 139 Also fixed implementations to respect the list of requested types. 140 141 * platform/qt/DragImageQt.cpp: Added. 142 (WebCore::dragImageSize): 143 (WebCore::deleteDragImage): 144 (WebCore::scaleDragImage): 145 (WebCore::dissolveDragImageToFraction): 146 (WebCore::createDragImageFromImage): 147 (WebCore::createDragImageIconForCachedImage): 148 Stubs 149 1 150 2007-02-17 David Hyatt <hyatt@apple.com> 2 151 -
trunk/WebCore/WebCore.exp
r19579 r19689 198 198 __ZN7WebCore12EventHandler10wheelEventEP7NSEvent 199 199 __ZN7WebCore12EventHandler12mouseDraggedEP7NSEvent 200 __ZN7WebCore12EventHandler14currentNSEventEv 200 201 __ZN7WebCore12EventHandler20handleTextInputEventERKNS_6StringEPNS_5EventEbb 201 202 __ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEb -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r19650 r19689 1656 1656 A7CA595E0B27BD9E00FA021D /* DragController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CA595C0B27BD9E00FA021D /* DragController.cpp */; }; 1657 1657 A7CA59630B27C1F200FA021D /* DragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA59620B27C1F200FA021D /* DragClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1658 A7CFB3D10B7ED10A0070C32D /* DragImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */; }; 1659 A7CFB3D20B7ED10A0070C32D /* DragImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CFB3D00B7ED10A0070C32D /* DragImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1660 A7CFB3D50B7ED1180070C32D /* DragImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */; }; 1658 1661 A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1659 1662 A809F1470B73793A002E4D7F /* RenderSVGGradientStop.h in Headers */ = {isa = PBXBuildFile; fileRef = A809F1450B73793A002E4D7F /* RenderSVGGradientStop.h */; }; … … 4668 4671 A7B6E69D0B291A9600D0529F /* DragData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragData.h; sourceTree = "<group>"; }; 4669 4672 A7CA595B0B27BD9E00FA021D /* DragController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragController.h; sourceTree = "<group>"; }; 4670 A7CA595C0B27BD9E00FA021D /* DragController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DragController.cpp; sourceTree = "<group>"; };4673 A7CA595C0B27BD9E00FA021D /* DragController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = DragController.cpp; sourceTree = "<group>"; }; 4671 4674 A7CA59620B27C1F200FA021D /* DragClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragClient.h; sourceTree = "<group>"; }; 4675 A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DragImage.cpp; sourceTree = "<group>"; }; 4676 A7CFB3D00B7ED10A0070C32D /* DragImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DragImage.h; sourceTree = "<group>"; }; 4677 A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragImageMac.mm; sourceTree = "<group>"; }; 4672 4678 A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHelper.h; sourceTree = "<group>"; }; 4673 4679 A809F1450B73793A002E4D7F /* RenderSVGGradientStop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGGradientStop.h; sourceTree = "<group>"; }; … … 6802 6808 isa = PBXGroup; 6803 6809 children = ( 6810 A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */, 6804 6811 A795463D0B5C4C80007B438F /* DragDataMac.mm */, 6805 6812 06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */, … … 9053 9060 F587853B02DE375901EA4122 /* DeprecatedValueListImpl.h */, 9054 9061 A7B6E69D0B291A9600D0529F /* DragData.h */, 9062 A7CFB3D00B7ED10A0070C32D /* DragImage.h */, 9063 A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */, 9055 9064 934FE9E40B5CA539003E4A73 /* FileChooser.cpp */, 9056 9065 066C772A0AB603B700238CC4 /* FileChooser.h */, … … 9641 9650 buildActionMask = 2147483647; 9642 9651 files = ( 9652 A7CFB3D20B7ED10A0070C32D /* DragImage.h in Headers */, 9643 9653 A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */, 9644 9654 A718760E0B2A120100A16ECE /* DragActions.h in Headers */, … … 11150 11160 isa = PBXProject; 11151 11161 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 11162 compatibilityVersion = "Xcode 2.4"; 11152 11163 hasScannedForEncodings = 1; 11153 11164 knownRegions = ( … … 11164 11175 projectDirPath = ""; 11165 11176 projectRoot = ""; 11177 shouldCheckCompatibility = 1; 11166 11178 targets = ( 11167 11179 93F198A508245E59001E9ABC /* WebCore */, … … 12470 12482 933A14AA0B7D1D0900A53FFD /* DOMTextEvent.mm in Sources */, 12471 12483 933A14B80B7D1D5200A53FFD /* JSTextEvent.cpp in Sources */, 12484 A7CFB3D10B7ED10A0070C32D /* DragImage.cpp in Sources */, 12485 A7CFB3D50B7ED1180070C32D /* DragImageMac.mm in Sources */, 12472 12486 ); 12473 12487 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/Clipboard.cpp
r19327 r19689 27 27 #include "Clipboard.h" 28 28 29 #include "DOMImplementation.h" 30 #include "Frame.h" 31 #include "FrameLoader.h" 32 #include "Image.h" 33 #include "PlugInInfoStore.h" 34 29 35 namespace WebCore { 30 36 37 bool Clipboard::canSaveAsWebArchive(Frame* frame) 38 { 39 ASSERT(frame); 40 String mimeType = frame->loader()->responseMIMEType(); 41 42 return !(DOMImplementation::isTextMIMEType(mimeType) || 43 Image::supportsType(mimeType) || 44 PlugInInfoStore::supportsMIMEType(mimeType)); 45 } 46 31 47 void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy) 32 48 { -
trunk/WebCore/dom/Clipboard.h
r19327 r19689 31 31 #include "ClipboardAccessPolicy.h" 32 32 #include "DragActions.h" 33 #include "DragImage.h" 33 34 #include "Node.h" 34 35 #include "Shared.h" … … 37 38 38 39 class CachedImage; 40 class Element; 41 class Frame; 42 class Image; 39 43 class IntPoint; 44 class KURL; 45 class Range; 46 class String; 40 47 41 48 // State available during IE's events for drag and drop and copy/paste … … 66 73 virtual Node* dragImageElement() = 0; 67 74 virtual void setDragImageElement(Node*, const IntPoint&) = 0; 75 76 //Provides the DOM specified 77 virtual DragImageRef createDragImage(IntPoint& dragLoc) const = 0; 78 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0; 79 virtual void writeURL(const KURL&, const String&, Frame*) = 0; 80 virtual void writeRange(Range*, Frame*) = 0; 68 81 82 virtual bool hasData() = 0; 83 69 84 void setAccessPolicy(ClipboardAccessPolicy); 70 85 … … 75 90 76 91 void setDragHasStarted() { m_dragStarted = true; } 92 static bool canSaveAsWebArchive(Frame*); 77 93 protected: 78 94 ClipboardAccessPolicy policy() const { return m_policy; } -
trunk/WebCore/page/DragClient.h
r19327 r19689 29 29 30 30 #include "DragActions.h" 31 #include "DragImage.h" 31 32 #include "IntPoint.h" 32 33 34 #if PLATFORM(MAC) 35 #ifdef __OBJC__ 36 @class DOMElement; 37 @class NSURL; 38 @class NSString; 39 @class NSPasteboard; 40 #else 41 class DOMElement; 42 class NSURL; 43 class NSString; 44 class NSPasteboard; 45 #endif 46 #endif 47 33 48 namespace WebCore { 34 49 50 class Clipboard; 35 51 class DragData; 52 class Frame; 53 class Image; 54 class HTMLImageElement; 36 55 37 56 class DragClient { 38 57 public: 39 58 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) = 0; 59 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) = 0; 40 60 virtual DragDestinationAction actionMaskForDrag(DragData*) = 0; 41 virtual void dragControllerDestroyed() = 0;42 43 61 //We work in window rather than view coordinates here 44 62 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& windowPoint) = 0; 45 63 64 virtual void startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false) = 0; 65 virtual DragImageRef createDragImageForLink(KURL&, const String& label, Frame*) = 0; 66 67 virtual void dragControllerDestroyed() = 0; 68 #if PLATFORM(MAC) 69 //Mac specific helper functions to allow access to functionality in webkit -- such as 70 //web archives and NSPasteboard extras 71 //not abstract as that would require another #if PLATFORM(MAC) for the SVGImage client empty impl 72 virtual void declareAndWriteDragImage(NSPasteboard*, DOMElement*, NSURL*, NSString*, Frame*, bool canSaveAsWebArchive) {}; 73 #endif 74 46 75 virtual ~DragClient() {}; 47 76 }; -
trunk/WebCore/page/DragController.cpp
r19327 r19689 39 39 #include "DragClient.h" 40 40 #include "DragData.h" 41 #include "FloatRect.h" 41 42 #include "Frame.h" 42 43 #include "FrameLoader.h" 43 44 #include "FrameView.h" 44 45 #include "HTMLAnchorElement.h" 46 #include "Image.h" 45 47 #include "markup.h" 46 48 #include "MoveSelectionCommand.h" 47 49 #include "Node.h" 48 50 #include "Page.h" 51 #include "PlugInInfoStore.h" 52 #include "RenderImage.h" 49 53 #include "ReplaceSelectionCommand.h" 50 54 #include "ResourceRequest.h" … … 53 57 #include "SystemTime.h" 54 58 #include "Text.h" 55 #include "wtf/RefPtr.h"59 #include <wtf/RefPtr.h> 56 60 57 61 namespace WebCore { … … 168 172 Frame* mainFrame = m_page->mainFrame(); 169 173 170 if ( mainFrame->view()) {174 if (RefPtr<FrameView> v = mainFrame->view()) { 171 175 ClipboardAccessPolicy policy = mainFrame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable; 172 176 RefPtr<Clipboard> clipboard = dragData->createClipboard(policy); … … 192 196 ASSERT(m_dragDestinationAction & DragDestinationActionDHTML); 193 197 m_client->willPerformDragDestinationAction(DragDestinationActionDHTML, dragData); 194 Frame*mainFrame = m_page->mainFrame();198 RefPtr<Frame> mainFrame = m_page->mainFrame(); 195 199 if (mainFrame->view()) { 196 200 // Sending an event can result in the destruction of the view and part. … … 252 256 m_isHandlingDrag = operation != DragOperationNone; 253 257 254 FrameView *frameView = 0;258 RefPtr<FrameView> frameView = 0; 255 259 if (!m_document || !(frameView = m_document->view())) 256 260 return operation; … … 387 391 ASSERT(dragData); 388 392 DragOperation op = DragOperationNone; 389 Frame* frame = m_page->mainFrame(); 390 if (!frame->view()) 393 RefPtr<Frame> frame = m_page->mainFrame(); 394 RefPtr<FrameView> viewProtector = frame->view(); 395 if (!viewProtector) 391 396 return DragOperationNone; 392 397 … … 449 454 450 455 } 451 452 } 456 457 static CachedImage* getCachedImage(Element* element) 458 { 459 ASSERT(element); 460 RenderObject* renderer = element->renderer(); 461 if (!renderer || !renderer->isImage()) 462 return 0; 463 RenderImage* image = static_cast<RenderImage*>(renderer); 464 return image->cachedImage(); 465 } 466 467 static Image* getImage(Element* element) 468 { 469 ASSERT(element); 470 RenderObject* renderer = element->renderer(); 471 if (!renderer || !renderer->isImage()) 472 return 0; 473 474 RenderImage* image = static_cast<RenderImage*>(renderer); 475 if (image->cachedImage() && !image->cachedImage()->isErrorImage()) 476 return image->cachedImage()->image(); 477 return 0; 478 } 479 480 static void prepareClipboardForImageDrag(Frame* src, Clipboard* clipboard, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label) 481 { 482 RefPtr<Range> range = src->document()->createRange(); 483 ExceptionCode ec = 0; 484 range->selectNode(node, ec); 485 ASSERT(ec == 0); 486 src->selectionController()->setSelection(Selection(range.get(), DOWNSTREAM)); 487 clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label, src); 488 } 489 490 static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const IntPoint& dragOrigin, const IntPoint& dragImageOffset, bool isLinkImage) 491 { 492 // dragImageOffset is the cursor position relative to the lower-left corner of the image. 493 #if PLATFORM(MAC) 494 // We add in the Y dimension because we are a flipped view, so adding moves the image down. 495 const int yOffset = dragImageOffset.y(); 496 #else 497 const int yOffset = -dragImageOffset.y(); 498 #endif 499 500 if (isLinkImage) 501 return IntPoint(mouseDraggedPoint.x() - dragImageOffset.x(), mouseDraggedPoint.y() + yOffset); 502 503 return IntPoint(dragOrigin.x() - dragImageOffset.x(), dragOrigin.y() + yOffset); 504 } 505 506 static IntPoint dragLocForSelectionDrag(Frame* src) 507 { 508 IntRect draggingRect = enclosingIntRect(src->visibleSelectionRect()); 509 int xpos = draggingRect.right(); 510 xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos; 511 int ypos = draggingRect.bottom(); 512 #if PLATFORM(MAC) 513 // Deal with flipped coordinates on Mac 514 ypos = draggingRect.y() > ypos ? draggingRect.y() : ypos; 515 #else 516 ypos = draggingRect.y() < ypos ? draggingRect.y() : ypos; 517 #endif 518 return IntPoint(xpos, ypos); 519 } 520 521 bool DragController::startDrag(Frame* src, Clipboard* clipboard, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, bool isDHTMLDrag) 522 { 523 ASSERT(src); 524 ASSERT(clipboard); 525 526 if (!src->view() || !src->renderer()) 527 return false; 528 529 HitTestResult dragSource = HitTestResult(dragOrigin); 530 dragSource = src->eventHandler()->hitTestResultAtPoint(dragOrigin, true); 531 KURL linkURL = dragSource.absoluteLinkURL(); 532 KURL imageURL = dragSource.absoluteImageURL(); 533 bool isSelected = dragSource.isSelected(); 534 535 IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.pos()); 536 537 m_draggingImageURL = KURL(); 538 m_dragOperation = srcOp; 539 540 DragImageRef dragImage = 0; 541 IntPoint dragLoc(0, 0); 542 IntPoint dragImageOffset(0, 0); 543 544 if (isDHTMLDrag) 545 dragImage = clipboard->createDragImage(dragImageOffset); 546 547 // We allow DHTML/JS to set the drag image, even if its a link, image or text we're dragging. 548 // This is in the spirit of the IE API, which allows overriding of pasteboard data and DragOp. 549 if (dragImage) { 550 dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOffset, !linkURL.isEmpty()); 551 m_dragOffset = dragImageOffset; 552 } 553 554 bool startedDrag = true; // optimism - we almost always manage to start the drag 555 556 Node* node = dragSource.innerNonSharedNode(); 557 558 if (!imageURL.isEmpty() && node && node->isElementNode() 559 && getImage(static_cast<Element*>(node)) 560 && (m_dragSourceAction & DragSourceActionImage)) { 561 Element* element = static_cast<Element*>(node); 562 if (!clipboard->hasData()) { 563 m_draggingImageURL = imageURL; 564 prepareClipboardForImageDrag(src, clipboard, element, linkURL, imageURL, dragSource.altDisplayString()); 565 } 566 567 m_client->willPerformDragSourceAction(DragSourceActionImage, dragOrigin, clipboard); 568 569 if (!dragImage) { 570 IntRect imageRect = dragSource.imageRect(); 571 imageRect.setLocation(m_page->mainFrame()->view()->windowToContents(src->view()->contentsToWindow(imageRect.location()))); 572 doImageDrag(element, dragOrigin, dragSource.imageRect(), clipboard, src, m_dragOffset); 573 } else 574 // DHTML defined drag image 575 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); 576 577 } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) { 578 if (!clipboard->hasData()) 579 clipboard->writeURL(linkURL, dragSource.textContent(), src); 580 581 m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard); 582 if (!dragImage) { 583 dragImage = m_client->createDragImageForLink(linkURL, dragSource.textContent(), src); 584 IntSize size = dragImageSize(dragImage); 585 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); 586 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y()); 587 } 588 doSystemDrag(dragImage, dragLoc, src->view()->contentsToWindow(mouseDraggedPoint), clipboard, src, true); 589 } else if (isSelected && (m_dragSourceAction & DragSourceActionSelection)) { 590 RefPtr<Range> selectionRange = src->selectionController()->toRange(); 591 ASSERT(selectionRange); 592 if (!clipboard->hasData()) 593 clipboard->writeRange(selectionRange.get(), src); 594 m_client->willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard); 595 if (!dragImage) { 596 dragImage = createDragImageForSelection(src); 597 dragLoc = dragLocForSelectionDrag(src); 598 m_dragOffset = IntPoint((int)(dragOrigin.x() - dragLoc.x()), (int)(dragOrigin.y() - dragLoc.y())); 599 } 600 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); 601 } else if (isDHTMLDrag) { 602 ASSERT(m_dragSourceAction & DragSourceActionDHTML); 603 m_client->willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, clipboard); 604 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); 605 } else { 606 // Only way I know to get here is if to get here is if the original element clicked on in the mousedown is no longer 607 // under the mousedown point, so linkURL, imageURL and isSelected are all false/empty. 608 startedDrag = false; 609 } 610 611 if (dragImage) 612 deleteDragImage(dragImage); 613 return startedDrag; 614 } 615 616 void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard* clipboard, Frame* frame, IntPoint& dragImageOffset) 617 { 618 IntPoint mouseDownPoint = dragOrigin; 619 DragImageRef dragImage; 620 IntPoint origin; 621 622 Image* image = getImage(element); 623 if (image && image->size().height() * image->size().width() <= MaxOriginalImageArea) { 624 IntSize originalSize = rect.size(); 625 origin = rect.location(); 626 627 dragImage = createDragImageFromImage(image); 628 629 IntSize newSize; 630 if (dragImage) { 631 dragImage = fitDragImageToMaxSize(dragImage, MaxDragImageSize); 632 dragImage = dissolveDragImageToFraction(dragImage, DragImageAlpha); 633 newSize = dragImageSize(dragImage); 634 } 635 636 // Properly orient the drag image and orient it differently if it's smaller than the original 637 float scale = newSize.width() / (float)originalSize.width(); 638 float dx = origin.x() - mouseDownPoint.x(); 639 dx *= scale; 640 origin.setX((int)(dx + 0.5)); 641 #if PLATFORM(MAC) 642 //Compensate for accursed flipped coordinates in cocoa 643 origin.setY(origin.y() + originalSize.height()); 644 #endif 645 float dy = origin.y() - mouseDownPoint.y(); 646 dy *= scale; 647 origin.setY((int)(dy + 0.5)); 648 } else { 649 dragImage = createDragImageIconForCachedImage(getCachedImage(element)); 650 if (dragImage) 651 origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset); 652 } 653 654 dragImageOffset.setX(mouseDownPoint.x() + origin.x()); 655 dragImageOffset.setY(mouseDownPoint.y() + origin.y()); 656 doSystemDrag(dragImage, dragImageOffset, dragOrigin, clipboard, frame, false); 657 658 deleteDragImage(dragImage); 659 } 660 661 void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool forLink) 662 { 663 m_didInitiateDrag = true; 664 m_dragInitiator = frame->document(); 665 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame 666 RefPtr<Frame> frameProtector = m_page->mainFrame(); 667 RefPtr<FrameView> viewProtector = frameProtector->view(); 668 m_client->startDrag(image, viewProtector->windowToContents(frame->view()->contentsToWindow(dragLoc)), eventPos, clipboard, frameProtector.get(), forLink); 669 670 // Drag has ended, dragEnded *should* have been called, however it is possible 671 // for the UIDelegate to take over the drag, and fail to send the appropriate 672 // drag termination event. As dragEnded just resets drag variables, we just 673 // call it anyway to be on the safe side 674 dragEnded(); 675 } 676 677 } -
trunk/WebCore/page/DragController.h
r19327 r19689 28 28 29 29 #include "DragActions.h" 30 #include "DragImage.h" 30 31 #include "IntPoint.h" 32 #include "IntRect.h" 31 33 #include "KURL.h" 32 34 … … 37 39 class DragClient; 38 40 class DragData; 41 class Element; 39 42 class Frame; 43 class Image; 44 class Node; 40 45 class Page; 46 class PlatformMouseEvent; 47 class Range; 41 48 class SelectionController; 42 49 … … 75 82 void dragEnded() { m_dragInitiator = 0; m_didInitiateDrag = false; } 76 83 84 bool startDrag(Frame* src, Clipboard*, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, bool isDHTMLDrag); 85 86 static const int LinkDragBorderInset; 87 static const IntSize MaxDragImageSize; 88 static const int MaxOriginalImageArea; 89 static const int DragIconRightInset; 90 static const int DragIconBottomInset; 91 static const float DragImageAlpha; 77 92 private: 78 93 bool canProcessDrag(DragData*); … … 86 101 bool dragIsMove(SelectionController*, DragData*); 87 102 bool isCopyKeyDown(); 88 103 104 IntRect selectionDraggingRect(Frame*); 105 bool doDrag(Frame* src, Clipboard* clipboard, DragImageRef dragImage, const KURL& linkURL, const KURL& imageURL, Node* node, IntPoint& dragLoc, IntPoint& dragImageOffset); 106 void doImageDrag(Element*, const IntPoint&, const IntRect&, Clipboard*, Frame*, IntPoint&); 107 void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool forLink); 89 108 Page* m_page; 90 109 DragClient* m_client; -
trunk/WebCore/page/EventHandler.cpp
r19682 r19689 1354 1354 return !dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, dragState().m_dragClipboard.get()); 1355 1355 } 1356 1356 1357 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) 1358 { 1359 if (event.event().button() != LeftButton || event.event().eventType() != MouseEventMoved) { 1360 // If we allowed the other side of the bridge to handle a drag 1361 // last time, then m_mousePressed might still be set. So we 1362 // clear it now to make sure the next move after a drag 1363 // doesn't look like a drag. 1364 m_mousePressed = false; 1365 return false; 1366 } 1367 1368 if (eventLoopHandleMouseDragged(event)) 1369 return true; 1370 1371 // Careful that the drag starting logic stays in sync with eventMayStartDrag() 1372 1373 if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { 1374 allowDHTMLDrag(dragState().m_dragSrcMayBeDHTML, dragState().m_dragSrcMayBeUA); 1375 if (!dragState().m_dragSrcMayBeDHTML && !dragState().m_dragSrcMayBeUA) 1376 m_mouseDownMayStartDrag = false; // no element is draggable 1377 } 1378 1379 if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { 1380 // try to find an element that wants to be dragged 1381 HitTestRequest request(true, false); 1382 HitTestResult result(m_mouseDownPos); 1383 m_frame->renderer()->layer()->hitTest(request, result); 1384 Node* node = result.innerNode(); 1385 if (node && node->renderer()) 1386 dragState().m_dragSrc = node->renderer()->draggableNode(dragState().m_dragSrcMayBeDHTML, dragState().m_dragSrcMayBeUA, 1387 m_mouseDownPos.x(), m_mouseDownPos.y(), dragState().m_dragSrcIsDHTML); 1388 else 1389 dragState().m_dragSrc = 0; 1390 1391 if (!dragState().m_dragSrc) 1392 m_mouseDownMayStartDrag = false; // no element is draggable 1393 else { 1394 // remember some facts about this source, while we have a HitTestResult handy 1395 node = result.URLElement(); 1396 dragState().m_dragSrcIsLink = node && node->isLink(); 1397 1398 node = result.innerNonSharedNode(); 1399 dragState().m_dragSrcIsImage = node && node->renderer() && node->renderer()->isImage(); 1400 1401 dragState().m_dragSrcInSelection = m_frame->selectionController()->contains(m_mouseDownPos); 1402 } 1403 } 1404 1405 // For drags starting in the selection, the user must wait between the mousedown and mousedrag, 1406 // or else we bail on the dragging stuff and allow selection to occur 1407 if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) { 1408 m_mouseDownMayStartDrag = false; 1409 // ...but if this was the first click in the window, we don't even want to start selection 1410 if (eventActivatedView(event.event())) 1411 m_mouseDownMayStartSelect = false; 1412 } 1413 1414 if (!m_mouseDownMayStartDrag) 1415 return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll; 1416 1417 // We are starting a text/image/url drag, so the cursor should be an arrow 1418 m_frame->view()->setCursor(pointerCursor()); 1419 1420 if (!dragHysteresisExceeded(event.event().pos())) 1421 return true; 1422 1423 // Once we're past the hysteresis point, we don't want to treat this gesture as a click 1424 invalidateClick(); 1425 1426 DragOperation srcOp = DragOperationNone; 1427 if (dragState().m_dragSrcMayBeDHTML) { 1428 freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway, just 1429 // to make sure it gets numbified 1430 1431 dragState().m_dragClipboard = createDraggingClipboard(); 1432 1433 // Check to see if the is a DOM based drag, if it is get the DOM specified drag 1434 // image and offset 1435 if (dragState().m_dragSrcIsDHTML) { 1436 int srcX, srcY; 1437 dragState().m_dragSrc->renderer()->absolutePosition(srcX, srcY); 1438 IntSize delta = m_mouseDownPos - IntPoint(srcX, srcY); 1439 dragState().m_dragClipboard->setDragImageElement(dragState().m_dragSrc.get(), IntPoint() + delta); 1440 } 1441 1442 m_mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown) 1443 && !m_frame->selectionController()->isInPasswordField(); 1444 1445 // Invalidate clipboard here against anymore pasteboard writing for security. The drag 1446 // image can still be changed as we drag, but not the pasteboard data. 1447 dragState().m_dragClipboard->setAccessPolicy(ClipboardImageWritable); 1448 1449 if (m_mouseDownMayStartDrag) { 1450 // gather values from DHTML element, if it set any 1451 dragState().m_dragClipboard->sourceOperation(srcOp); 1452 1453 // Yuck, dragSourceMovedTo() can be called as a result of kicking off the drag with 1454 // dragImage! Because of that dumb reentrancy, we may think we've not started the 1455 // drag when that happens. So we have to assume it's started before we kick it off. 1456 dragState().m_dragClipboard->setDragHasStarted(); 1457 } 1458 } 1459 1460 if (m_mouseDownMayStartDrag) { 1461 DragController* dragController = m_frame->page() ? m_frame->page()->dragController() : 0; 1462 bool startedDrag = dragController && dragController->startDrag(m_frame, dragState().m_dragClipboard.get(), srcOp, event.event(), m_mouseDownPos, dragState().m_dragSrcIsDHTML); 1463 if (!startedDrag && dragState().m_dragSrcMayBeDHTML) { 1464 // Drag was canned at the last minute - we owe m_dragSrc a DRAGEND event 1465 PlatformMouseEvent event(PlatformMouseEvent::currentEvent); 1466 dispatchDragSrcEvent(dragendEvent, event); 1467 m_mouseDownMayStartDrag = false; 1468 } 1469 } 1470 1471 if (!m_mouseDownMayStartDrag) { 1472 // something failed to start the drag, cleanup 1473 freeClipboard(); 1474 dragState().m_dragSrc = 0; 1475 } 1476 1477 // No more default handling (like selection), whether we're past the hysteresis bounds or not 1478 return true; 1479 } 1480 1357 1481 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, 1358 bool isLineBreak, bool isBackTab)1482 bool isLineBreak, bool isBackTab) 1359 1483 { 1360 1484 if (!m_frame) … … 1374 1498 return target->dispatchEvent(event.release(), ec, true); 1375 1499 } 1376 1500 1501 1377 1502 void EventHandler::defaultTextInputEventHandler(TextEvent* event) 1378 1503 { -
trunk/WebCore/page/EventHandler.h
r19579 r19689 171 171 }; 172 172 static EventHandlerDragState& dragState(); 173 173 174 Clipboard* createDraggingClipboard() const; 175 174 176 bool eventActivatedView(const PlatformMouseEvent&) const; 175 177 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& event); … … 244 246 #else 245 247 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) { return false; } 248 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&) { return false; } 246 249 #endif 247 250 … … 286 289 IntPoint m_mouseDownPos; // in our view's coords 287 290 double m_mouseDownTimestamp; 291 PlatformMouseEvent m_mouseDown; 288 292 289 293 #if PLATFORM(MAC) 290 294 NSView *m_mouseDownView; 291 295 bool m_sendingEventToSubview; 292 PlatformMouseEvent m_mouseDown;293 296 int m_activationEventNumber; 294 297 #endif -
trunk/WebCore/page/Frame.h
r19522 r19689 31 31 #include "Color.h" 32 32 #include "EditAction.h" 33 #include "DragImage.h" 33 34 #include "RenderLayer.h" 34 35 #include "TextGranularity.h" … … 126 127 friend class FrameWin; 127 128 129 DragImageRef dragImageForSelection(); 130 128 131 private: 129 132 FramePrivate* d; -
trunk/WebCore/page/mac/DragControllerMac.mm
r19084 r19689 34 34 namespace WebCore { 35 35 36 const int DragController::LinkDragBorderInset = -2; 37 38 const IntSize DragController::MaxDragImageSize(400, 400); 39 const int DragController::MaxOriginalImageArea = 1500 * 1500; 40 const int DragController::DragIconRightInset = 7; 41 const int DragController::DragIconBottomInset = 3; 42 43 const float DragController::DragImageAlpha = 0.75f; 44 36 45 bool DragController::isCopyKeyDown() 37 46 { -
trunk/WebCore/page/mac/EventHandlerMac.mm
r19579 r19689 31 31 #include "Cursor.h" 32 32 #include "Document.h" 33 #include "DragController.h" 33 34 #include "EventNames.h" 34 35 #include "FloatPoint.h" … … 341 342 } 342 343 343 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) 344 { 345 BEGIN_BLOCK_OBJC_EXCEPTIONS; 346 if (event.event().button() != LeftButton || event.event().eventType() != MouseEventMoved) { 347 // If we allowed the other side of the bridge to handle a drag 348 // last time, then m_mousePressed might still be set. So we 349 // clear it now to make sure the next move after a drag 350 // doesn't look like a drag. 351 m_mousePressed = false; 352 return false; 353 } 354 355 if (eventLoopHandleMouseDragged(event)) 356 return true; 357 358 // Careful that the drag starting logic stays in sync with eventMayStartDrag() 359 360 if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { 361 allowDHTMLDrag(dragState().m_dragSrcMayBeDHTML, dragState().m_dragSrcMayBeUA); 362 if (!dragState().m_dragSrcMayBeDHTML && !dragState().m_dragSrcMayBeUA) 363 m_mouseDownMayStartDrag = false; // no element is draggable 364 } 365 366 if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { 367 // try to find an element that wants to be dragged 368 HitTestRequest request(true, false); 369 HitTestResult result(m_mouseDownPos); 370 m_frame->renderer()->layer()->hitTest(request, result); 371 Node* node = result.innerNode(); 372 if (node && node->renderer()) 373 dragState().m_dragSrc = node->renderer()->draggableNode(dragState().m_dragSrcMayBeDHTML, dragState().m_dragSrcMayBeUA, 374 m_mouseDownPos.x(), m_mouseDownPos.y(), dragState().m_dragSrcIsDHTML); 375 else 376 dragState().m_dragSrc = 0; 377 378 if (!dragState().m_dragSrc) 379 m_mouseDownMayStartDrag = false; // no element is draggable 380 else { 381 // remember some facts about this source, while we have a HitTestResult handy 382 node = result.URLElement(); 383 dragState().m_dragSrcIsLink = node && node->isLink(); 384 385 node = result.innerNonSharedNode(); 386 dragState().m_dragSrcIsImage = node && node->renderer() && node->renderer()->isImage(); 387 388 dragState().m_dragSrcInSelection = m_frame->selectionController()->contains(m_mouseDownPos); 389 } 390 } 391 392 // For drags starting in the selection, the user must wait between the mousedown and mousedrag, 393 // or else we bail on the dragging stuff and allow selection to occur 394 if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) { 395 m_mouseDownMayStartDrag = false; 396 // ...but if this was the first click in the window, we don't even want to start selection 397 if (eventActivatedView(event.event())) 398 m_mouseDownMayStartSelect = false; 399 } 400 401 if (!m_mouseDownMayStartDrag) 402 return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll; 403 404 // We are starting a text/image/url drag, so the cursor should be an arrow 405 m_frame->view()->setCursor(pointerCursor()); 406 407 if (!dragHysteresisExceeded(event.event().pos())) 408 return true; 409 410 // Once we're past the hysteresis point, we don't want to treat this gesture as a click 411 invalidateClick(); 412 413 NSImage *dragImage = nil; // we use these values if WC is out of the loop 414 NSPoint dragLoc = NSZeroPoint; 415 DragOperation srcOp = DragOperationNone; 416 BOOL wcWrotePasteboard = NO; 417 if (dragState().m_dragSrcMayBeDHTML) { 418 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; 419 // Must be done before ondragstart adds types and data to the pboard, 420 // also done for security, as it erases data from the last drag 421 [pasteboard declareTypes:[NSArray array] owner:nil]; 422 423 freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway, just 424 // to make sure it gets numbified 425 dragState().m_dragClipboard = new ClipboardMac(true, pasteboard, ClipboardWritable, Mac(m_frame)); 426 427 // If this is drag of an element, get set up to generate a default image. Otherwise 428 // WebKit will generate the default, the element doesn't override. 429 if (dragState().m_dragSrcIsDHTML) { 430 int srcX, srcY; 431 dragState().m_dragSrc->renderer()->absolutePosition(srcX, srcY); 432 IntSize delta = m_mouseDownPos - IntPoint(srcX, srcY); 433 dragState().m_dragClipboard->setDragImageElement(dragState().m_dragSrc.get(), IntPoint() + delta); 434 } 435 436 m_mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown) 437 && !m_frame->selectionController()->isInPasswordField(); 438 439 // Invalidate clipboard here against anymore pasteboard writing for security. The drag 440 // image can still be changed as we drag, but not the pasteboard data. 441 dragState().m_dragClipboard->setAccessPolicy(ClipboardImageWritable); 442 443 if (m_mouseDownMayStartDrag) { 444 // gather values from DHTML element, if it set any 445 dragState().m_dragClipboard->sourceOperation(srcOp); 446 447 NSArray *types = [pasteboard types]; 448 wcWrotePasteboard = types && [types count] > 0; 449 450 if (dragState().m_dragSrcMayBeDHTML) 451 dragImage = static_cast<ClipboardMac*>(dragState().m_dragClipboard.get())->dragNSImage(dragLoc); 452 453 // Yuck, dragSourceMovedTo() can be called as a result of kicking off the drag with 454 // dragImage! Because of that dumb reentrancy, we may think we've not started the 455 // drag when that happens. So we have to assume it's started before we kick it off. 456 dragState().m_dragClipboard->setDragHasStarted(); 457 } 458 } 459 460 if (m_mouseDownMayStartDrag) { 461 bool startedDrag = [Mac(m_frame)->bridge() startDraggingImage:dragImage at:dragLoc operation:srcOp event:currentEvent sourceIsDHTML:dragState().m_dragSrcIsDHTML DHTMLWroteData:wcWrotePasteboard]; 462 if (!startedDrag && dragState().m_dragSrcMayBeDHTML) { 463 // WebKit canned the drag at the last minute - we owe m_dragSrc a DRAGEND event 464 PlatformMouseEvent event(PlatformMouseEvent::currentEvent); 465 dispatchDragSrcEvent(dragendEvent, event); 466 m_mouseDownMayStartDrag = false; 467 } 468 } 469 470 if (!m_mouseDownMayStartDrag) { 471 // something failed to start the drag, cleanup 472 freeClipboard(); 473 dragState().m_dragSrc = 0; 474 } 475 476 // No more default handling (like selection), whether we're past the hysteresis bounds or not 477 return true; 478 479 END_BLOCK_OBJC_EXCEPTIONS; 480 481 return false; 482 483 } 484 344 Clipboard* EventHandler::createDraggingClipboard() const 345 { 346 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; 347 // Must be done before ondragstart adds types and data to the pboard, 348 // also done for security, as it erases data from the last drag 349 [pasteboard declareTypes:[NSArray array] owner:nil]; 350 return new ClipboardMac(true, pasteboard, ClipboardWritable, Mac(m_frame)); 351 } 485 352 486 353 bool EventHandler::eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) -
trunk/WebCore/page/mac/FrameMac.mm
r19522 r19689 983 983 [_bridge paintCustomHighlight:type forBox:boxRect onLine:lineRect behindText:text entireLine:line]; 984 984 } 985 986 DragImageRef Frame::dragImageForSelection() 987 { 988 if (!selectionController()->isRange()) 989 return nil; 990 return static_cast<FrameMac*>(this)->selectionImage(); 991 } 985 992 986 993 } // namespace WebCore -
trunk/WebCore/page/qt/DragControllerQt.cpp
r19039 r19689 35 35 { 36 36 37 // FIXME: These values are straight out of DragControllerMac, so probably have 38 // little correlation with Qt standards... 39 const int DragController::LinkDragBorderInset = 2; 40 const IntSize DragController::MaxDragImageSize(400, 400); 41 const int DragController::MaxOriginalImageArea = 1500 * 1500; 42 const int DragController::DragIconRightInset = 7; 43 const int DragController::DragIconBottomInset = 3; 44 45 const float DragController::DragImageAlpha = 0.75f; 46 47 37 48 bool DragController::isCopyKeyDown() 38 49 { -
trunk/WebCore/page/qt/EventHandlerQt.cpp
r19465 r19689 101 101 } 102 102 103 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)104 {105 //notImplemented();106 return false;107 }108 109 103 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const 110 104 { … … 125 119 notImplemented(); 126 120 return false; 121 } 122 123 Clipboard* EventHandler::createDraggingClipboard() const 124 { 125 notImplemented(); 126 return 0; 127 127 } 128 128 -
trunk/WebCore/page/qt/FrameQt.cpp
r19297 r19689 273 273 } 274 274 275 DragImageRef Frame::dragImageForSelection() 276 { 277 return 0; 278 } 279 280 275 281 } 276 282 // vim: ts=4 sw=4 et -
trunk/WebCore/platform/Pasteboard.h
r18960 r19689 37 37 #if PLATFORM(MAC) 38 38 class NSPasteboard; 39 class NSArray; 39 40 #endif 40 41 … … 60 61 class Range; 61 62 class String; 62 63 63 64 class Pasteboard : Noncopyable { 64 65 public: 66 #if PLATFORM(MAC) 67 //Helper functions to allow Clipboard to share code 68 static void writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame); 69 static void writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame); 70 #endif 71 65 72 static Pasteboard* generalPasteboard(); 66 73 void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*); -
trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
r19650 r19689 348 348 virtual ~SVGEmptyDragClient() {} 349 349 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) { } 350 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) { } 350 351 virtual DragDestinationAction actionMaskForDrag(DragData*) { return DragDestinationActionNone; } 351 352 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) { return DragSourceActionNone; } 353 virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) { } 354 virtual DragImageRef createDragImageForLink(KURL&, const String& label, Frame*) { return 0; } 352 355 virtual void dragControllerDestroyed() { } 353 356 }; -
trunk/WebCore/platform/mac/ClipboardMac.h
r19327 r19689 59 59 String getData(const String& type, bool& success) const; 60 60 bool setData(const String& type, const String& data); 61 61 62 virtual bool hasData(); 63 62 64 // extensions beyond IE's API 63 65 virtual HashSet<String> types() const; … … 68 70 Node* dragImageElement(); 69 71 void setDragImageElement(Node *, const IntPoint&); 70 72 73 virtual DragImageRef createDragImage(IntPoint& dragLoc) const; 74 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*); 75 virtual void writeRange(Range*, Frame* frame); 76 virtual void writeURL(const KURL&, const String&, Frame* frame); 77 71 78 // Methods for getting info in Cocoa's type system 72 NSImage *dragNSImage(NSPoint&) ; // loc converted from dragLoc, based on whole image size73 79 NSImage *dragNSImage(NSPoint&) const; // loc converted from dragLoc, based on whole image size 80 NSPasteboard *pasteboard() { return m_pasteboard.get(); } 74 81 private: 75 82 void setDragImage(CachedImage*, Node*, const IntPoint&); -
trunk/WebCore/platform/mac/ClipboardMac.mm
r19327 r19689 28 28 29 29 #import "CachedImage.h" 30 #import "Document.h" 31 #import "DOMElementInternal.h" 32 #import "DragClient.h" 33 #import "DragController.h" 34 #import "Editor.h" 30 35 #import "EventHandler.h" 31 36 #import "FloatRect.h" 32 37 #import "FoundationExtras.h" 33 38 #import "FrameMac.h" 39 #import "HTMLImageElement.h" 34 40 #import "Image.h" 41 #import "Page.h" 42 #import "Pasteboard.h" 43 #import "Range.h" 44 #import "RenderImage.h" 45 #import "WebCoreFrameBridge.h" 35 46 #import "WebCoreSystemInterface.h" 47 48 @class WebArchive; 36 49 37 50 namespace WebCore { … … 51 64 } 52 65 66 bool ClipboardMac::hasData() 67 { 68 return m_pasteboard && [m_pasteboard.get() types] && [[m_pasteboard.get() types] count] > 0; 69 } 70 53 71 bool ClipboardMac::isForDragging() const 54 72 { … … 318 336 } 319 337 } 320 321 NSImage *ClipboardMac::dragNSImage(NSPoint& loc) 338 339 void ClipboardMac::writeRange(Range* range, Frame* frame) 340 { 341 ASSERT(range); 342 ASSERT(frame); 343 Pasteboard::writeSelection(m_pasteboard.get(), range, frame->editor()->smartInsertDeleteEnabled() && frame->selectionGranularity() == WordGranularity, frame); 344 } 345 346 void ClipboardMac::writeURL(const KURL& url, const String& title, Frame* frame) 347 { 348 ASSERT(frame); 349 ASSERT(m_pasteboard); 350 Pasteboard::writeURL(m_pasteboard.get(), nil, url, title, frame); 351 } 352 353 void ClipboardMac::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame) 354 { 355 ASSERT(frame); 356 if (Page* page = frame->page()) 357 page->dragController()->client()->declareAndWriteDragImage(m_pasteboard.get(), [DOMElement _elementWith:element], url.getNSURL(), title, frame, Clipboard::canSaveAsWebArchive(frame)); 358 } 359 360 DragImageRef ClipboardMac::createDragImage(IntPoint& loc) const 361 { 362 NSPoint nsloc = {loc.x(), loc.y()}; 363 DragImageRef result = dragNSImage(nsloc); 364 loc = IntPoint(nsloc.x, nsloc.y); 365 return result; 366 } 367 368 NSImage *ClipboardMac::dragNSImage(NSPoint& loc) const 322 369 { 323 370 NSImage *result = nil; -
trunk/WebCore/platform/mac/PasteboardMac.mm
r18962 r19689 115 115 } 116 116 117 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) 118 { 117 void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) 118 { 119 if (WebArchivePboardType == nil) 120 Pasteboard::generalPasteboard(); //Initialises pasteboard types 121 119 122 NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:[DOMRange _rangeWith:selectedRange]] autorelease]; 120 123 #ifdef BUILDING_ON_TIGER … … 131 134 types = mutableTypes; 132 135 } 133 [ m_pasteboard declareTypes:types owner:nil];136 [pasteboard declareTypes:types owner:nil]; 134 137 #else 135 138 NSArray *types = selectionPasteboardTypes(canSmartCopyOrDelete, [attributedString containsAttachments]); 136 [ m_pasteboard declareTypes:types owner:nil];139 [pasteboard declareTypes:types owner:nil]; 137 140 frame->editor()->client()->didSetSelectionTypesForPasteboard(); 138 141 #endif 139 142 140 143 // Put HTML on the pasteboard. 141 144 if ([types containsObject:WebArchivePboardType]) { 142 [ m_pasteboard setData:frame->editor()->client()->dataForArchivedSelection(frame) forType:WebArchivePboardType];143 } 144 145 [pasteboard setData:frame->editor()->client()->dataForArchivedSelection(frame) forType:WebArchivePboardType]; 146 } 147 145 148 // Put the attributed string on the pasteboard (RTF/RTFD format). 146 149 if ([types containsObject:NSRTFDPboardType]) { 147 150 NSData *RTFDData = [attributedString RTFDFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil]; 148 [ m_pasteboard setData:RTFDData forType:NSRTFDPboardType];151 [pasteboard setData:RTFDData forType:NSRTFDPboardType]; 149 152 } 150 153 if ([types containsObject:NSRTFPboardType]) { … … 152 155 attributedString = stripAttachmentCharacters(attributedString); 153 156 NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil]; 154 [ m_pasteboard setData:RTFData forType:NSRTFPboardType];157 [pasteboard setData:RTFData forType:NSRTFPboardType]; 155 158 } 156 159 … … 165 168 NSString *NonBreakingSpaceString = [NSString stringWithCharacters:&noBreakSpace length:1]; 166 169 [s replaceOccurrencesOfString:NonBreakingSpaceString withString:@" " options:0 range:NSMakeRange(0, [s length])]; 167 [ m_pasteboard setString:s forType:NSStringPboardType];170 [pasteboard setString:s forType:NSStringPboardType]; 168 171 [s release]; 169 172 } 170 173 171 174 if ([types containsObject:WebSmartPastePboardType]) { 172 [m_pasteboard setData:nil forType:WebSmartPastePboardType]; 173 } 174 } 175 176 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) 177 { 175 [pasteboard setData:nil forType:WebSmartPastePboardType]; 176 } 177 } 178 179 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) 180 { 181 Pasteboard::writeSelection(m_pasteboard, selectedRange, canSmartCopyOrDelete, frame); 182 } 183 184 void Pasteboard::writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame) 185 { 186 if (WebArchivePboardType == nil) 187 Pasteboard::generalPasteboard(); //Initialises pasteboard types 188 189 if (types == nil) { 190 types = writableTypesForURL(); 191 [pasteboard declareTypes:types owner:nil]; 192 } 193 178 194 ASSERT(!url.isEmpty()); 179 195 180 196 NSURL *URL = url.getNSURL(); 181 197 NSString *userVisibleString = frame->editor()->client()->userVisibleString(URL); 182 198 183 199 NSString *title = (NSString*)titleStr; 184 200 if ([title length] == 0) { … … 187 203 title = userVisibleString; 188 204 } 189 190 NSArray *types = writableTypesForURL(); 191 [m_pasteboard declareTypes:types owner:nil]; 192 193 [m_pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:userVisibleString], 194 [NSArray arrayWithObject:(NSString*)titleStr.stripWhiteSpace()], 195 nil] 196 forType:WebURLsWithTitlesPboardType]; 197 [URL writeToPasteboard:m_pasteboard]; 198 [m_pasteboard setString:userVisibleString forType:WebURLPboardType]; 199 [m_pasteboard setString:title forType:WebURLNamePboardType]; 200 [m_pasteboard setString:userVisibleString forType:NSStringPboardType]; 205 206 if ([types containsObject:WebURLsWithTitlesPboardType]) 207 [pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:userVisibleString], 208 [NSArray arrayWithObject:(NSString*)titleStr.stripWhiteSpace()], 209 nil] 210 forType:WebURLsWithTitlesPboardType]; 211 if ([types containsObject:NSURLPboardType]) 212 [URL writeToPasteboard:pasteboard]; 213 if ([types containsObject:WebURLPboardType]) 214 [pasteboard setString:userVisibleString forType:WebURLPboardType]; 215 if ([types containsObject:WebURLNamePboardType]) 216 [pasteboard setString:title forType:WebURLNamePboardType]; 217 if ([types containsObject:NSStringPboardType]) 218 [pasteboard setString:userVisibleString forType:NSStringPboardType]; 219 } 220 221 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) 222 { 223 Pasteboard::writeURL(m_pasteboard, nil, url, titleStr, frame); 201 224 } 202 225 -
trunk/WebKit/ChangeLog
r19670 r19689 1 2007-02-18 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Adam. 4 5 Moving the drag initiation logic to WebCore. 6 The redundant code in webkit will be moved out in a later patch. 7 8 * WebCoreSupport/WebDragClient.h: 9 * WebCoreSupport/WebDragClient.mm: 10 (getTopHTMLView): 11 Helper function 12 (WebDragClient::willPerformDragSourceAction): 13 (WebDragClient::startDrag): 14 (WebDragClient::createDragImageForLink): 15 Implemented new DragClient methods 16 (WebDragClient::declareAndWriteDragImage): 17 Helper function for the Mac to allow new drag and drop 18 code to match behaviour 19 20 * WebView/WebHTMLView.mm: 21 (-[WebHTMLView _dragImageForURL:withLabel:]): 22 (-[WebHTMLView _dragImageForLinkElement:]): 23 Refactoring old _dragImageForLinkElement function so that 24 the link drag image can be created with just a URL and label, 25 rather than requiring the original element 26 (-[WebHTMLView dragImage:at:offset:event:pasteboard:source:slideBack:]): 27 Removed logic that is no longer necessary 28 (-[WebHTMLView _mouseDownEvent]): 29 The WebDragClient may need the original mouseDownEvent of a drag when initiating 30 a drag 31 * WebView/WebHTMLViewInternal.h: 32 Declaring _mouseDownEvent 33 34 * WebView/WebHTMLViewPrivate.h: 35 Declaring _dragImageForURL 36 1 37 2007-02-16 John Sullivan <sullivan@apple.com> 2 38 -
trunk/WebKit/WebCoreSupport/WebDragClient.h
r19230 r19689 32 32 WebDragClient(WebView*); 33 33 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*); 34 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); 34 35 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*); 35 36 virtual void dragControllerDestroyed(); 36 37 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); 38 virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag); 39 virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL& url, const WebCore::String& label, WebCore::Frame*); 40 virtual void declareAndWriteDragImage(NSPasteboard*, DOMElement*, NSURL*, NSString*, WebCore::Frame*, bool canSaveAsWebArchive); 37 41 private: 38 42 WebView* m_webView; -
trunk/WebKit/WebCoreSupport/WebDragClient.mm
r19230 r19689 26 26 #import "WebDragClient.h" 27 27 28 #import "WebArchive.h" 29 #import "WebArchiver.h" 30 #import "WebDOMOperations.h" 28 31 #import "WebFrame.h" 32 #import "WebFrameInternal.h" 33 #import "WebHTMLViewInternal.h" 34 #import "WebHTMLViewPrivate.h" 35 #import "WebNSPasteboardExtras.h" 36 #import "WebNSURLExtras.h" 29 37 #import "WebUIDelegate.h" 38 #import "WebUIDelegatePrivate.h" 30 39 #import "WebViewInternal.h" 40 #import <WebCore/ClipboardMac.h> 31 41 #import <WebCore/DragData.h> 42 #import <WebCore/EventHandler.h> 43 #import <WebCore/FrameMac.h> 44 #import <WebCore/FrameView.h> 45 #import <WebCore/Image.h> 46 #import <WebCore/Page.h> 47 48 using namespace WebCore; 32 49 33 50 WebDragClient::WebDragClient(WebView* webView) 34 51 : m_webView(webView) 35 52 { 53 } 54 55 static WebHTMLView *getTopHTMLView(Frame* frame) 56 { 57 ASSERT(frame); 58 ASSERT(frame->page()); 59 return (WebHTMLView*)[[kit(frame->page()->mainFrame()) frameView] documentView]; 36 60 } 37 61 … … 47 71 48 72 49 WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint)73 WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint) 50 74 { 51 75 NSPoint viewPoint = [m_webView convertPoint:windowPoint fromView:nil]; 52 return (WebCore::DragSourceAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragSourceActionMaskForPoint:viewPoint]; 76 return (DragSourceAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragSourceActionMaskForPoint:viewPoint]; 77 } 78 79 void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::Clipboard* clipboard) 80 { 81 ASSERT(clipboard); 82 [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:static_cast<WebCore::ClipboardMac*>(clipboard)->pasteboard()]; 83 } 84 85 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) 86 { 87 if (!frame) 88 return; 89 ASSERT(clipboard); 90 RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(frame) frameView] documentView]; 91 if (![htmlView.get() isKindOfClass:[WebHTMLView class]]) 92 return; 93 94 NSEvent *event = linkDrag ? frame->eventHandler()->currentNSEvent() : [htmlView.get() _mouseDownEvent]; 95 WebHTMLView* topHTMLView = getTopHTMLView(frame); 96 RetainPtr<WebHTMLView> topViewProtector = topHTMLView; 97 98 [topHTMLView _stopAutoscrollTimer]; 99 NSPasteboard *pasteboard = static_cast<ClipboardMac*>(clipboard)->pasteboard(); 100 101 // note per kwebster, the offset arg below is always ignored in positioning the image 102 id UIDelegate = [m_webView UIDelegate]; 103 if ([UIDelegate respondsToSelector:@selector(webView:dragImage:at:offset:event:pasteboard:source:slideBack:forView:)]) 104 [UIDelegate webView:m_webView dragImage:dragImage.get() at:(NSPoint)at offset:NSMakeSize(0, 0) event:event pasteboard:pasteboard source:htmlView.get() slideBack:YES forView:topHTMLView]; 105 else 106 [topHTMLView dragImage:dragImage.get() at:(NSPoint)at offset:NSMakeSize(0, 0) event:event pasteboard:pasteboard source:htmlView.get() slideBack:YES]; 107 } 108 109 DragImageRef WebDragClient::createDragImageForLink(KURL& url, const String& title, Frame* frame) 110 { 111 if (!frame) 112 return nil; 113 WebHTMLView* htmlView = (WebHTMLView*)[[kit(frame) frameView] documentView]; 114 NSString *label = 0; 115 if (!title.isEmpty()) 116 label = (NSString*)title; 117 return [htmlView _dragImageForURL:[url.getNSURL() _web_userVisibleString] withLabel:label]; 118 } 119 120 121 void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame* frame, bool canSaveAsWebArchive) 122 { 123 ASSERT(pasteboard); 124 ASSERT(element); 125 id source = (WebHTMLView*)[[kit(frame) frameView] documentView]; 126 127 WebArchive *archive; 128 129 // If the image element comes from an ImageDocument, we don't want to 130 // create a web archive from the image element. 131 if (canSaveAsWebArchive) 132 archive = [element webArchive]; 133 else 134 archive = [WebArchiver archiveMainResourceForFrame:kit(frame)]; 135 ASSERT(archive); 136 [pasteboard _web_declareAndWriteDragImageForElement:element URL:URL title:title archive:archive source:source]; 53 137 } 54 138 -
trunk/WebKit/WebView/WebHTMLView.mm
r19614 r19689 175 175 176 176 #define DRAG_LABEL_BORDER_X 4.0f 177 //Keep border_y in synch with DragController::LinkDragBorderInset 177 178 #define DRAG_LABEL_BORDER_Y 2.0f 178 179 #define DRAG_LABEL_RADIUS 5.0f … … 1256 1257 } 1257 1258 1258 - (NSImage *)_dragImageForLinkElement:(NSDictionary *)element 1259 { 1260 NSURL *linkURL = [element objectForKey: WebElementLinkURLKey]; 1261 1259 - (NSImage *)_dragImageForURL:(NSString*)urlString withLabel:(NSString*)label 1260 { 1262 1261 BOOL drawURLString = YES; 1263 1262 BOOL clipURLString = NO, clipLabelString = NO; 1264 1265 NSString *label = [element objectForKey: WebElementLinkLabelKey];1266 NSString *urlString = [linkURL _web_userVisibleString];1267 1263 1268 1264 if (!label) { … … 1272 1268 1273 1269 NSFont *labelFont = [[NSFontManager sharedFontManager] convertFont:[NSFont systemFontOfSize:DRAG_LINK_LABEL_FONT_SIZE] 1274 toHaveTrait:NSBoldFontMask];1270 toHaveTrait:NSBoldFontMask]; 1275 1271 NSFont *urlFont = [NSFont systemFontOfSize: DRAG_LINK_URL_FONT_SIZE]; 1276 1272 NSSize labelSize; … … 1312 1308 [path appendBezierPathWithRect: NSMakeRect(imageSize.width - DRAG_LABEL_RADIUS - 20.0f, DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS + 20.0f, imageSize.height - 2.0f * DRAG_LABEL_RADIUS)]; 1313 1309 [path fill]; 1314 1310 1315 1311 NSColor *topColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.75f]; 1316 1312 NSColor *bottomColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f]; … … 1318 1314 if (clipURLString) 1319 1315 urlString = [WebStringTruncator centerTruncateString: urlString toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2.0f) withFont:urlFont]; 1320 1316 1321 1317 [urlString _web_drawDoubledAtPoint:NSMakePoint(DRAG_LABEL_BORDER_X, DRAG_LABEL_BORDER_Y - [urlFont descender]) 1322 withTopColor:topColor bottomColor:bottomColor font:urlFont];1323 } 1324 1318 withTopColor:topColor bottomColor:bottomColor font:urlFont]; 1319 } 1320 1325 1321 if (clipLabelString) 1326 1322 label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2.0f) withFont:labelFont]; 1327 1323 [label _web_drawDoubledAtPoint:NSMakePoint (DRAG_LABEL_BORDER_X, imageSize.height - DRAG_LABEL_BORDER_Y_OFFSET - [labelFont pointSize]) 1328 withTopColor:topColor bottomColor:bottomColor font:labelFont];1324 withTopColor:topColor bottomColor:bottomColor font:labelFont]; 1329 1325 1330 1326 [dragImage unlockFocus]; 1331 1327 1332 1328 return dragImage; 1329 } 1330 1331 - (NSImage *)_dragImageForLinkElement:(NSDictionary *)element 1332 { 1333 NSURL *linkURL = [element objectForKey: WebElementLinkURLKey]; 1334 1335 NSString *label = [element objectForKey: WebElementLinkLabelKey]; 1336 NSString *urlString = [linkURL _web_userVisibleString]; 1337 return [self _dragImageForURL:urlString withLabel:label]; 1333 1338 } 1334 1339 … … 2884 2889 slideBack:(BOOL)slideBack 2885 2890 { 2886 [self _stopAutoscrollTimer]; 2887 2888 WebHTMLView *topHTMLView = [self _topHTMLView]; 2889 if (self != topHTMLView) { 2890 [topHTMLView dragImage:dragImage at:[self convertPoint:at toView:topHTMLView] 2891 offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack]; 2892 return; 2893 } 2894 2895 WebView *webView = [self _webView]; 2896 Page *page = core(webView); 2897 ASSERT(page); 2898 page->dragController()->setDidInitiateDrag(true); 2899 2900 // Retain this view during the drag because it may be released before the drag ends. 2901 [self retain]; 2902 2903 id UIDelegate = [webView UIDelegate]; 2904 // If a delegate takes over the drag but never calls draggedImage: endedAt:, we'll leak the WebHTMLView. 2905 if ([UIDelegate respondsToSelector:@selector(webView:dragImage:at:offset:event:pasteboard:source:slideBack:forView:)]) 2906 [UIDelegate webView:webView dragImage:dragImage at:at offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack forView:self]; 2907 else 2908 [super dragImage:dragImage at:at offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack]; 2891 ASSERT(self == [self _topHTMLView]); 2892 [super dragImage:dragImage at:at offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack]; 2909 2893 } 2910 2894 … … 2982 2966 eventNumber:0 clickCount:0 pressure:0]; 2983 2967 [self mouseUp:fakeEvent]; // This will also update the mouseover state. 2984 2985 // Balance the previous retain from when the drag started.2986 [self release];2987 2968 } 2988 2969 … … 4937 4918 { 4938 4919 return textView == _private->firstResponderTextViewAtMouseDownTime; 4920 } 4921 4922 4923 - (NSEvent *)_mouseDownEvent 4924 { 4925 return _private->mouseDownEvent; 4939 4926 } 4940 4927 -
trunk/WebKit/WebView/WebHTMLViewInternal.h
r19579 r19689 113 113 - (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent *)event; 114 114 - (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard; 115 - (NSEvent *)_mouseDownEvent; 115 116 #ifndef BUILDING_ON_TIGER 116 117 - (BOOL)isGrammarCheckingEnabled; -
trunk/WebKit/WebView/WebHTMLViewPrivate.h
r19327 r19689 70 70 71 71 - (NSImage *)_dragImageForLinkElement:(NSDictionary *)element; 72 - (NSImage *)_dragImageForURL:(NSString*)linkURL withLabel:(NSString*)label; 72 73 - (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData; 73 74 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
Note: See TracChangeset
for help on using the changeset viewer.