Changeset 157058 in webkit
- Timestamp:
- Oct 7, 2013 1:34:35 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r157056 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 Use references to indicate non-nullness of DragController related 9 objects. 10 1 11 2013-10-07 Tim Horton <timothy_horton@apple.com> 2 12 -
trunk/Source/WebCore/WebCore.exp.in
r157056 r157058 743 743 __ZN7WebCore22URLWithUserTypedStringEP8NSStringP5NSURL 744 744 __ZN7WebCore22counterValueForElementEPNS_7ElementE 745 __ZN7WebCore22createFragmentFromTextE PNS_5RangeERKN3WTF6StringE745 __ZN7WebCore22createFragmentFromTextERNS_5RangeERKN3WTF6StringE 746 746 __ZN7WebCore22externalRepresentationEPNS_5FrameEj 747 747 __ZN7WebCore22externalRepresentationEPNS_7ElementEj … … 2457 2457 #if ENABLE(DRAG_SUPPORT) 2458 2458 __ZN7WebCore12EventHandler17dragSourceEndedAtERKNS_18PlatformMouseEventENS_13DragOperationE 2459 __ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE 2460 __ZN7WebCore14DragController10dragExitedEPNS_8DragDataE 2461 __ZN7WebCore14DragController11dragEnteredEPNS_8DragDataE 2462 __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE 2463 __ZN7WebCore14DragController11performDragEPNS_8DragDataE 2459 __ZN7WebCore14DragController10dragExitedERNS_8DragDataE 2460 __ZN7WebCore14DragController11dragEnteredERNS_8DragDataE 2461 __ZN7WebCore14DragController11dragUpdatedERNS_8DragDataE 2462 __ZN7WebCore14DragController11performDragERNS_8DragDataE 2464 2463 __ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE 2465 2464 __ZN7WebCore14DragController9dragEndedEv 2466 2465 __ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationENS_20DragApplicationFlagsE 2467 2466 __ZN7WebCore8DragDataC1ERKN3WTF6StringERKNS_8IntPointES7_NS_13DragOperationENS_20DragApplicationFlagsE 2467 __ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE 2468 2468 #endif 2469 2469 -
trunk/Source/WebCore/bindings/objc/DOMHTML.mm
r157002 r157058 63 63 { 64 64 // FIXME: Since this is not a contextual fragment, it won't handle whitespace properly. 65 return kit(createFragmentFromText( core(self)->createRange().get(), text).get());65 return kit(createFragmentFromText(*core(self)->createRange().get(), text).get()); 66 66 } 67 67 -
trunk/Source/WebCore/editing/Editor.cpp
r157018 r157058 441 441 { 442 442 RefPtr<Range> range = selectedRange(); 443 if (!range) 444 return; 445 443 446 bool chosePlainText; 444 RefPtr<DocumentFragment> fragment = pasteboard->documentFragment( &m_frame,range, allowPlainText, chosePlainText);447 RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText); 445 448 if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted)) 446 449 pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText); … … 494 497 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace) 495 498 { 496 replaceSelectionWithFragment(createFragmentFromText(selectedRange().get(), text), selectReplacement, smartReplace, true); 499 RefPtr<Range> range = selectedRange(); 500 if (!range) 501 return; 502 503 replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, true); 497 504 } 498 505 … … 1062 1069 #else 1063 1070 // FIXME: Convert all other platforms to match Mac and delete this. 1064 Pasteboard::createForCopyAndPaste()->writeSelection( selection.get(), canSmartCopyOrDelete(), &m_frame, IncludeImageAltTextForClipboard);1071 Pasteboard::createForCopyAndPaste()->writeSelection(*selection, canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard); 1065 1072 #endif 1066 1073 } … … 1088 1095 writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *imageElement, document().url(), document().title()); 1089 1096 #else 1090 Pasteboard::createForCopyAndPaste()->writeImage( imageElement, document().url(), document().title());1097 Pasteboard::createForCopyAndPaste()->writeImage(*imageElement, document().url(), document().title()); 1091 1098 #endif 1092 1099 } else { … … 1095 1102 #else 1096 1103 // FIXME: Convert all other platforms to match Mac and delete this. 1097 Pasteboard::createForCopyAndPaste()->writeSelection( selectedRange().get(), canSmartCopyOrDelete(), &m_frame, IncludeImageAltTextForClipboard);1104 Pasteboard::createForCopyAndPaste()->writeSelection(*selectedRange(), canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard); 1098 1105 #endif 1099 1106 } … … 1197 1204 writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *element, url, result.altDisplayString()); 1198 1205 #else 1199 Pasteboard::createForCopyAndPaste()->writeImage( element, url, result.altDisplayString());1206 Pasteboard::createForCopyAndPaste()->writeImage(*element, url, result.altDisplayString()); 1200 1207 #endif 1201 1208 } -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r156289 r157058 188 188 restoreAndRemoveTestRenderingNodesToFragment(holder.get()); 189 189 190 m_fragment = createFragmentFromText(selection.toNormalizedRange().get(), evt->text()); 190 RefPtr<Range> range = selection.toNormalizedRange(); 191 if (!range) 192 return; 193 194 m_fragment = createFragmentFromText(*range, evt->text()); 191 195 if (!m_fragment->firstChild()) 192 196 return; -
trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp
r154943 r157058 99 99 return; 100 100 101 RefPtr<DocumentFragment> fragment = createFragmentFromText(m_rangeToBeCorrected.get(), m_correction); 101 if (!m_rangeToBeCorrected) 102 return; 103 104 RefPtr<DocumentFragment> fragment = createFragmentFromText(*m_rangeToBeCorrected, m_correction); 102 105 if (!fragment) 103 106 return; -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r157002 r157058 565 565 return false; 566 566 567 fragment = createFragmentFromText( &context, [text precomposedStringWithCanonicalMapping]);567 fragment = createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]); 568 568 if (!fragment) 569 569 return false; -
trunk/Source/WebCore/editing/markup.cpp
r157032 r157058 753 753 } 754 754 755 PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text) 756 { 757 if (!context) 758 return 0; 759 760 Document& document = context->ownerDocument(); 755 PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text) 756 { 757 Document& document = context.ownerDocument(); 761 758 RefPtr<DocumentFragment> fragment = document.createDocumentFragment(); 762 759 … … 768 765 string.replace('\r', '\n'); 769 766 770 if (contextPreservesNewline( *context)) {767 if (contextPreservesNewline(context)) { 771 768 fragment->appendChild(document.createTextNode(string), ASSERT_NO_EXCEPTION); 772 769 if (string.endsWith('\n')) { … … 785 782 786 783 // Break string into paragraphs. Extra line breaks turn into empty paragraphs. 787 Node* blockNode = enclosingBlock(context ->firstNode());784 Node* blockNode = enclosingBlock(context.firstNode()); 788 785 Element* block = toElement(blockNode); 789 786 bool useClonesOfEnclosingBlock = blockNode … … 791 788 && !block->hasTagName(bodyTag) 792 789 && !block->hasTagName(htmlTag) 793 && block != editableRootForPosition(context ->startPosition());794 bool useLineBreak = enclosingTextFormControl(context ->startPosition());790 && block != editableRootForPosition(context.startPosition()); 791 bool useLineBreak = enclosingTextFormControl(context.startPosition()); 795 792 796 793 Vector<String> list; -
trunk/Source/WebCore/editing/markup.h
r157002 r157058 50 50 enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization }; 51 51 52 PassRefPtr<DocumentFragment> createFragmentFromText(Range *context, const String& text);52 PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text); 53 53 PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent); 54 54 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String&, Element*, ParserContentPolicy, ExceptionCode&); -
trunk/Source/WebCore/html/FileInputType.cpp
r156932 r157058 434 434 } 435 435 436 bool FileInputType::receiveDroppedFiles(const DragData *dragData)436 bool FileInputType::receiveDroppedFiles(const DragData& dragData) 437 437 { 438 438 Vector<String> paths; 439 dragData ->asFilenames(paths);439 dragData.asFilenames(paths); 440 440 if (paths.isEmpty()) 441 441 return false; -
trunk/Source/WebCore/html/FileInputType.h
r156692 r157058 68 68 virtual bool getTypeSpecificValue(String&) OVERRIDE; // Checked first, before internal storage or the value attribute. 69 69 virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE; 70 virtual bool receiveDroppedFiles(const DragData *) OVERRIDE;70 virtual bool receiveDroppedFiles(const DragData&) OVERRIDE; 71 71 virtual Icon* icon() const OVERRIDE; 72 72 virtual bool isFileUpload() const OVERRIDE; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r156981 r157058 1358 1358 } 1359 1359 1360 bool HTMLInputElement::receiveDroppedFiles(const DragData *dragData)1360 bool HTMLInputElement::receiveDroppedFiles(const DragData& dragData) 1361 1361 { 1362 1362 return m_inputType->receiveDroppedFiles(dragData); -
trunk/Source/WebCore/html/HTMLInputElement.h
r157044 r157058 244 244 245 245 // Returns true if the given DragData has more than one dropped files. 246 bool receiveDroppedFiles(const DragData *);246 bool receiveDroppedFiles(const DragData&); 247 247 248 248 Icon* icon() const; -
trunk/Source/WebCore/html/InputType.cpp
r156825 r157058 706 706 } 707 707 708 bool InputType::receiveDroppedFiles(const DragData *)708 bool InputType::receiveDroppedFiles(const DragData&) 709 709 { 710 710 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/html/InputType.h
r156825 r157058 240 240 virtual void setFiles(PassRefPtr<FileList>); 241 241 // Should return true if the given DragData has more than one dropped files. 242 virtual bool receiveDroppedFiles(const DragData *);242 virtual bool receiveDroppedFiles(const DragData&); 243 243 virtual Icon* icon() const; 244 244 // Should return true if the corresponding renderer for a type can display a suggested value. -
trunk/Source/WebCore/loader/EmptyClients.h
r157044 r157058 534 534 EmptyDragClient() { } 535 535 virtual ~EmptyDragClient() {} 536 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData *) OVERRIDE { }537 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard *) OVERRIDE { }538 virtual DragDestinationAction actionMaskForDrag(DragData *) OVERRIDE { return DragDestinationActionNone; }536 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData&) OVERRIDE { } 537 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) OVERRIDE { } 538 virtual DragDestinationAction actionMaskForDrag(DragData&) OVERRIDE { return DragDestinationActionNone; } 539 539 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) OVERRIDE { return DragSourceActionNone; } 540 virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard *, Frame*, bool) OVERRIDE { }540 virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool) OVERRIDE { } 541 541 virtual void dragControllerDestroyed() OVERRIDE { } 542 542 }; -
trunk/Source/WebCore/page/DragClient.h
r109147 r157058 32 32 #include "IntPoint.h" 33 33 34 namespace WebCore { 35 36 class Clipboard; 37 class DragData; 38 class Element; 39 class Frame; 40 class Image; 41 42 class DragClient { 43 public: 44 virtual void dragControllerDestroyed() = 0; 45 46 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData&) = 0; 47 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) = 0; 48 virtual DragDestinationAction actionMaskForDrag(DragData&) = 0; 49 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0; 50 51 virtual void startDrag(DragImageRef, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard&, Frame&, bool linkDrag = false) = 0; 52 virtual void dragEnded() { } 53 34 54 #if PLATFORM(MAC) 35 OBJC_CLASS DOMElement; 36 OBJC_CLASS NSURL; 37 OBJC_CLASS NSString; 55 // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit. 56 // This is not abstract as that would require another #if PLATFORM(MAC) for the SVGImage client empty implentation. 57 virtual void declareAndWriteDragImage(const String&, Element&, const URL&, const String&, Frame*) { } 38 58 #endif 39 59 40 namespace WebCore { 60 virtual ~DragClient() { } 61 }; 41 62 42 class Clipboard; 43 class DragData; 44 class Frame; 45 class Image; 46 class HTMLImageElement; 47 48 class DragClient { 49 public: 50 virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) = 0; 51 virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) = 0; 52 virtual DragDestinationAction actionMaskForDrag(DragData*) = 0; 63 } // namespace WebCore 53 64 54 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0; 55 56 virtual void startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false) = 0; 57 58 virtual void dragControllerDestroyed() = 0; 65 #endif // DragClient_h 59 66 60 #if PLATFORM(MAC)61 // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit.62 // This is not abstract as that would require another #if PLATFORM(MAC) for the SVGImage client empty implentation.63 virtual void declareAndWriteDragImage(const String&, DOMElement*, NSURL *, NSString *, Frame*) { }64 #endif65 66 virtual void dragEnded() { }67 68 virtual ~DragClient() { }69 };70 71 }72 73 #endif // !DragClient_h74 -
trunk/Source/WebCore/page/DragController.cpp
r156981 r157058 84 84 namespace WebCore { 85 85 86 static PlatformMouseEvent createMouseEvent(DragData *dragData)86 static PlatformMouseEvent createMouseEvent(DragData& dragData) 87 87 { 88 88 bool shiftKey, ctrlKey, altKey, metaKey; 89 89 shiftKey = ctrlKey = altKey = metaKey = false; 90 int keyState = dragData ->modifierKeyState();90 int keyState = dragData.modifierKeyState(); 91 91 shiftKey = static_cast<bool>(keyState & PlatformEvent::ShiftKey); 92 92 ctrlKey = static_cast<bool>(keyState & PlatformEvent::CtrlKey); … … 94 94 metaKey = static_cast<bool>(keyState & PlatformEvent::MetaKey); 95 95 96 return PlatformMouseEvent(dragData ->clientPosition(), dragData->globalPosition(),96 return PlatformMouseEvent(dragData.clientPosition(), dragData.globalPosition(), 97 97 LeftButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, 98 98 metaKey, currentTime()); … … 118 118 } 119 119 120 static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) 121 { 122 ASSERT(dragData); 120 static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame* frame, Range& context, bool allowPlainText, bool& chosePlainText) 121 { 123 122 chosePlainText = false; 124 123 125 Document& document = context ->ownerDocument();126 if (dragData ->containsCompatibleContent()) {127 if (PassRefPtr<DocumentFragment> fragment = dragData ->asFragment(frame, context.get(), allowPlainText, chosePlainText))124 Document& document = context.ownerDocument(); 125 if (dragData.containsCompatibleContent()) { 126 if (PassRefPtr<DocumentFragment> fragment = dragData.asFragment(frame, context, allowPlainText, chosePlainText)) 128 127 return fragment; 129 128 130 if (dragData ->containsURL(frame, DragData::DoNotConvertFilenames)) {129 if (dragData.containsURL(frame, DragData::DoNotConvertFilenames)) { 131 130 String title; 132 String url = dragData ->asURL(frame, DragData::DoNotConvertFilenames, &title);131 String url = dragData.asURL(frame, DragData::DoNotConvertFilenames, &title); 133 132 if (!url.isEmpty()) { 134 133 RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document); … … 136 135 if (title.isEmpty()) { 137 136 // Try the plain text first because the url might be normalized or escaped. 138 if (dragData ->containsPlainText())139 title = dragData ->asPlainText(frame);137 if (dragData.containsPlainText()) 138 title = dragData.asPlainText(frame); 140 139 if (title.isEmpty()) 141 140 title = url; … … 149 148 } 150 149 } 151 if (allowPlainText && dragData ->containsPlainText()) {150 if (allowPlainText && dragData.containsPlainText()) { 152 151 chosePlainText = true; 153 return createFragmentFromText(context .get(), dragData->asPlainText(frame)).get();152 return createFragmentFromText(context, dragData.asPlainText(frame)).get(); 154 153 } 155 154 … … 157 156 } 158 157 159 bool DragController::dragIsMove(FrameSelection& selection, DragData *dragData)158 bool DragController::dragIsMove(FrameSelection& selection, DragData& dragData) 160 159 { 161 160 return m_documentUnderMouse == m_dragInitiator && selection.isContentEditable() && selection.isRange() && !isCopyKeyDown(dragData); … … 177 176 } 178 177 179 DragSession DragController::dragEntered(DragData *dragData)178 DragSession DragController::dragEntered(DragData& dragData) 180 179 { 181 180 return dragEnteredOrUpdated(dragData); 182 181 } 183 182 184 void DragController::dragExited(DragData* dragData) 185 { 186 ASSERT(dragData); 187 183 void DragController::dragExited(DragData& dragData) 184 { 188 185 if (RefPtr<FrameView> v = m_page.mainFrame().view()) { 189 186 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable; 190 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, *dragData);191 clipboard->setSourceOperation(dragData ->draggingSourceOperationMask());187 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, dragData); 188 clipboard->setSourceOperation(dragData.draggingSourceOperationMask()); 192 189 m_page.mainFrame().eventHandler().cancelDragAndDrop(createMouseEvent(dragData), clipboard.get()); 193 190 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security … … 199 196 } 200 197 201 DragSession DragController::dragUpdated(DragData *dragData)198 DragSession DragController::dragUpdated(DragData& dragData) 202 199 { 203 200 return dragEnteredOrUpdated(dragData); 204 201 } 205 202 206 bool DragController::performDrag(DragData* dragData) 207 { 208 ASSERT(dragData); 209 m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData->clientPosition()); 203 bool DragController::performDrag(DragData& dragData) 204 { 205 m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData.clientPosition()); 210 206 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHandlingDrag) { 211 207 m_client.willPerformDragDestinationAction(DragDestinationActionDHTML, dragData); … … 214 210 if (mainFrame->view()) { 215 211 // Sending an event can result in the destruction of the view and part. 216 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(ClipboardReadable, *dragData);217 clipboard->setSourceOperation(dragData ->draggingSourceOperationMask());212 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(ClipboardReadable, dragData); 213 clipboard->setSourceOperation(dragData.draggingSourceOperationMask()); 218 214 preventedDefault = mainFrame->eventHandler().performDragAndDrop(createMouseEvent(dragData), clipboard.get()); 219 215 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard here for security … … 236 232 237 233 m_client.willPerformDragDestinationAction(DragDestinationActionLoad, dragData); 238 m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), ResourceRequest(dragData ->asURL(&m_page.mainFrame()))));234 m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), ResourceRequest(dragData.asURL(&m_page.mainFrame())))); 239 235 return true; 240 236 } … … 251 247 } 252 248 253 DragSession DragController::dragEnteredOrUpdated(DragData* dragData) 254 { 255 ASSERT(dragData); 256 mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData->clientPosition())); 249 DragSession DragController::dragEnteredOrUpdated(DragData& dragData) 250 { 251 mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData.clientPosition())); 257 252 258 253 m_dragDestinationAction = m_client.actionMaskForDrag(dragData); … … 302 297 } 303 298 304 bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask, DragSession& dragSession) 305 { 306 ASSERT(dragData); 307 299 bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction actionMask, DragSession& dragSession) 300 { 308 301 if (!m_documentUnderMouse) 309 302 return false; … … 336 329 337 330 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { 338 if (dragData ->containsColor()) {331 if (dragData.containsColor()) { 339 332 dragSession.operation = DragOperationGeneric; 340 333 return true; 341 334 } 342 335 343 IntPoint point = frameView->windowToContents(dragData ->clientPosition());336 IntPoint point = frameView->windowToContents(dragData.clientPosition()); 344 337 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 345 338 if (!element) … … 361 354 dragSession.numberOfItemsToBeAccepted = 0; 362 355 363 unsigned numberOfFiles = dragData ->numberOfFiles();356 unsigned numberOfFiles = dragData.numberOfFiles(); 364 357 if (m_fileInputElementUnderMouse) { 365 358 if (m_fileInputElementUnderMouse->isDisabledFormControl()) … … 398 391 } 399 392 400 DragOperation DragController::operationForLoad(DragData* dragData) 401 { 402 ASSERT(dragData); 403 Document* doc = m_page.mainFrame().documentAtPoint(dragData->clientPosition()); 393 DragOperation DragController::operationForLoad(DragData& dragData) 394 { 395 Document* doc = m_page.mainFrame().documentAtPoint(dragData.clientPosition()); 404 396 405 397 bool pluginDocumentAcceptsDrags = false; … … 429 421 } 430 422 431 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData *dragData)423 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData& dragData) 432 424 { 433 425 ASSERT(m_page.dragCaretController().hasCaret()); 434 String text = m_page.dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);426 String text = m_page.dragCaretController().isContentRichlyEditable() ? emptyString() : dragData.asPlainText(innerFrame); 435 427 Node* target = innerFrame->editor().findEventTargetFrom(m_page.dragCaretController().caretPosition()); 436 428 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document()->domWindow(), text), IGNORE_EXCEPTION); 437 429 } 438 430 439 bool DragController::concludeEditDrag(DragData* dragData) 440 { 441 ASSERT(dragData); 442 431 bool DragController::concludeEditDrag(DragData& dragData) 432 { 443 433 RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; 444 434 if (m_fileInputElementUnderMouse) { … … 450 440 return false; 451 441 452 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData ->clientPosition());442 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData.clientPosition()); 453 443 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 454 444 if (!element) … … 460 450 return true; 461 451 462 if (dragData ->containsColor()) {463 Color color = dragData ->asColor();452 if (dragData.containsColor()) { 453 Color color = dragData.asColor(); 464 454 if (!color.isValid()) 465 455 return false; … … 474 464 } 475 465 476 if (dragData ->containsFiles() && fileInput) {466 if (dragData.containsFiles() && fileInput) { 477 467 // fileInput should be the element we hit tested for, unless it was made 478 468 // display:none in a drop event handler. … … 498 488 if (!range) 499 489 return false; 490 500 491 CachedResourceLoader* cachedResourceLoader = range->ownerDocument().cachedResourceLoader(); 501 492 ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader); 502 493 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) { 503 494 bool chosePlainText = false; 504 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame.get(), range, true, chosePlainText);495 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame.get(), *range, true, chosePlainText); 505 496 if (!fragment || !innerFrame->editor().shouldInsertFragment(fragment, range, EditorInsertActionDropped)) { 506 497 return false; … … 512 503 // but only to smart insert if the selection granularity is word granularity. 513 504 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); 514 bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData ->canSmartReplace();505 bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData.canSmartReplace(); 515 506 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete)); 516 507 } else { 517 508 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) { 518 509 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; 519 if (dragData ->canSmartReplace())510 if (dragData.canSmartReplace()) 520 511 options |= ReplaceSelectionCommand::SmartReplace; 521 512 if (chosePlainText) … … 525 516 } 526 517 } else { 527 String text = dragData ->asPlainText(innerFrame.get());518 String text = dragData.asPlainText(innerFrame.get()); 528 519 if (text.isEmpty() || !innerFrame->editor().shouldInsertText(text, range.get(), EditorInsertActionDropped)) { 529 520 return false; … … 532 523 m_client.willPerformDragDestinationAction(DragDestinationActionEdit, dragData); 533 524 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) 534 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText( range.get(), text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));525 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting)); 535 526 } 536 527 … … 543 534 } 544 535 545 bool DragController::canProcessDrag(DragData* dragData) 546 { 547 ASSERT(dragData); 548 549 if (!dragData->containsCompatibleContent()) 550 return false; 551 552 IntPoint point = m_page.mainFrame().view()->windowToContents(dragData->clientPosition()); 536 bool DragController::canProcessDrag(DragData& dragData) 537 { 538 if (!dragData.containsCompatibleContent()) 539 return false; 540 541 IntPoint point = m_page.mainFrame().view()->windowToContents(dragData.clientPosition()); 553 542 HitTestResult result = HitTestResult(point); 554 543 if (!m_page.mainFrame().contentRenderer()) … … 560 549 return false; 561 550 562 if (dragData ->containsFiles() && asFileInput(result.innerNonSharedNode()))551 if (dragData.containsFiles() && asFileInput(result.innerNonSharedNode())) 563 552 return true; 564 553 … … 595 584 } 596 585 597 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) 598 { 599 ASSERT(dragData); 586 bool DragController::tryDHTMLDrag(DragData& dragData, DragOperation& operation) 587 { 600 588 ASSERT(m_documentUnderMouse); 601 589 Ref<MainFrame> mainFrame(m_page.mainFrame()); … … 605 593 606 594 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? ClipboardReadable : ClipboardTypesReadable; 607 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, *dragData);608 DragOperation srcOpMask = dragData ->draggingSourceOperationMask();595 RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, dragData); 596 DragOperation srcOpMask = dragData.draggingSourceOperationMask(); 609 597 clipboard->setSourceOperation(srcOpMask); 610 598 … … 665 653 } 666 654 667 static CachedImage* getCachedImage(Element* element) 668 { 669 ASSERT(element); 670 RenderObject* renderer = element->renderer(); 655 static CachedImage* getCachedImage(Element& element) 656 { 657 RenderObject* renderer = element.renderer(); 671 658 if (!renderer || !renderer->isImage()) 672 659 return 0; … … 675 662 } 676 663 677 static Image* getImage(Element* element) 678 { 679 ASSERT(element); 664 static Image* getImage(Element& element) 665 { 680 666 CachedImage* cachedImage = getCachedImage(element); 681 667 // Don't use cachedImage->imageForRenderer() here as that may return BitmapImages for cached SVG Images. … … 686 672 } 687 673 688 static void selectElement(Element *element)689 { 690 RefPtr<Range> range = element ->document().createRange();691 range->selectNode( element);692 element ->document().frame()->selection().setSelection(VisibleSelection(range.get(), DOWNSTREAM));674 static void selectElement(Element& element) 675 { 676 RefPtr<Range> range = element.document().createRange(); 677 range->selectNode(&element); 678 element.document().frame()->selection().setSelection(VisibleSelection(range.get(), DOWNSTREAM)); 693 679 } 694 680 … … 709 695 } 710 696 711 static IntPoint dragLocForSelectionDrag(Frame *src)712 { 713 IntRect draggingRect = enclosingIntRect(src ->selection().bounds());697 static IntPoint dragLocForSelectionDrag(Frame& src) 698 { 699 IntRect draggingRect = enclosingIntRect(src.selection().bounds()); 714 700 int xpos = draggingRect.maxX(); 715 701 xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos; … … 724 710 } 725 711 726 bool DragController::startDrag(Frame* src, const DragState& state, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin) 727 { 728 ASSERT(src); 729 730 if (!src->view() || !src->contentRenderer()) 731 return false; 732 733 HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active); 712 bool DragController::startDrag(Frame& src, const DragState& state, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin) 713 { 714 if (!src.view() || !src.contentRenderer()) 715 return false; 716 717 HitTestResult hitTestResult = src.eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active); 734 718 if (!state.source->contains(hitTestResult.innerNode())) 735 719 // The original node being dragged isn't under the drag origin anymore... maybe it was … … 740 724 URL imageURL = hitTestResult.absoluteImageURL(); 741 725 742 IntPoint mouseDraggedPoint = src ->view()->windowToContents(dragEvent.position());726 IntPoint mouseDraggedPoint = src.view()->windowToContents(dragEvent.position()); 743 727 744 728 m_draggingImageURL = URL(); … … 749 733 IntPoint dragImageOffset(0, 0); 750 734 751 Clipboard* clipboard = state.clipboard.get(); 735 ASSERT(state.clipboard); 736 737 Clipboard& clipboard = *state.clipboard; 752 738 if (state.type == DragSourceActionDHTML) 753 dragImage = clipboard ->createDragImage(dragImageOffset);739 dragImage = clipboard.createDragImage(dragImageOffset); 754 740 if (state.type == DragSourceActionSelection || !imageURL.isEmpty() || !linkURL.isEmpty()) 755 741 // Selection, image, and link drags receive a default set of allowed drag operations that … … 767 753 bool startedDrag = true; // optimism - we almost always manage to start the drag 768 754 769 Element* element = state.source.get(); 755 ASSERT(state.source); 756 Element& element = *state.source; 770 757 771 758 Image* image = getImage(element); 772 759 if (state.type == DragSourceActionSelection) { 773 if (!clipboard ->pasteboard().hasData()) {760 if (!clipboard.pasteboard().hasData()) { 774 761 // FIXME: This entire block is almost identical to the code in Editor::copy, and the code should be shared. 775 762 776 RefPtr<Range> selectionRange = src ->selection().toNormalizedRange();763 RefPtr<Range> selectionRange = src.selection().toNormalizedRange(); 777 764 ASSERT(selectionRange); 778 765 779 src ->editor().willWriteSelectionToPasteboard(selectionRange.get());780 781 if (enclosingTextFormControl(src ->selection().start()))782 clipboard ->pasteboard().writePlainText(src->editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);766 src.editor().willWriteSelectionToPasteboard(selectionRange.get()); 767 768 if (enclosingTextFormControl(src.selection().start())) 769 clipboard.pasteboard().writePlainText(src.editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace); 783 770 else { 784 771 #if PLATFORM(MAC) || PLATFORM(EFL) 785 src ->editor().writeSelectionToPasteboard(clipboard->pasteboard());772 src.editor().writeSelectionToPasteboard(clipboard.pasteboard()); 786 773 #else 787 774 // FIXME: Convert all other platforms to match Mac and delete this. 788 clipboard ->pasteboard().writeSelection(selectionRange.get(), src->editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForClipboard);775 clipboard.pasteboard().writeSelection(*selectionRange, src.editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForClipboard); 789 776 #endif 790 777 } 791 778 792 src ->editor().didWriteSelectionToPasteboard();779 src.editor().didWriteSelectionToPasteboard(); 793 780 } 794 781 m_client.willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard); 795 782 if (!dragImage) { 796 dragImage = dissolveDragImageToFraction(src ->dragImageForSelection(), DragImageAlpha);783 dragImage = dissolveDragImageToFraction(src.dragImageForSelection(), DragImageAlpha); 797 784 dragLoc = dragLocForSelectionDrag(src); 798 785 m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y()); 799 786 } 800 787 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); 801 } else if (!imageURL.isEmpty() && element &&image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) {788 } else if (!imageURL.isEmpty() && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) { 802 789 // We shouldn't be starting a drag for an image that can't provide an extension. 803 790 // This is an early detection for problems encountered later upon drop. 804 791 ASSERT(!image->filenameExtension().isEmpty()); 805 if (!clipboard ->pasteboard().hasData()) {792 if (!clipboard.pasteboard().hasData()) { 806 793 m_draggingImageURL = imageURL; 807 if (element ->isContentRichlyEditable())794 if (element.isContentRichlyEditable()) 808 795 selectElement(element); 809 796 declareAndWriteDragImage(clipboard, element, !linkURL.isEmpty() ? linkURL : imageURL, hitTestResult.altDisplayString()); … … 814 801 if (!dragImage) { 815 802 IntRect imageRect = hitTestResult.imageRect(); 816 imageRect.setLocation(m_page.mainFrame().view()->rootViewToContents(src ->view()->contentsToRootView(imageRect.location())));803 imageRect.setLocation(m_page.mainFrame().view()->rootViewToContents(src.view()->contentsToRootView(imageRect.location()))); 817 804 doImageDrag(element, dragOrigin, hitTestResult.imageRect(), clipboard, src, m_dragOffset); 818 } else 805 } else { 819 806 // DHTML defined drag image 820 807 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); 821 808 } 822 809 } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) { 823 if (!clipboard ->pasteboard().hasData())810 if (!clipboard.pasteboard().hasData()) 824 811 // Simplify whitespace so the title put on the clipboard resembles what the user sees 825 812 // on the web page. This includes replacing newlines with spaces. 826 src ->editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard->pasteboard());827 828 if (src ->selection().isCaret() && src->selection().isContentEditable()) {813 src.editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard.pasteboard()); 814 815 if (src.selection().isCaret() && src.selection().isContentEditable()) { 829 816 // a user can initiate a drag on a link without having any text 830 817 // selected. In this case, we should expand the selection to 831 818 // the enclosing anchor element 832 Position pos = src ->selection().base();819 Position pos = src.selection().base(); 833 820 Node* node = enclosingAnchorElement(pos); 834 821 if (node) 835 src ->selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));822 src.selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node)); 836 823 } 837 824 838 825 m_client.willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard); 839 826 if (!dragImage) { 840 dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src ->settings().fontRenderingMode());827 dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src.settings().fontRenderingMode()); 841 828 IntSize size = dragImageSize(dragImage); 842 829 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); … … 862 849 } 863 850 864 void DragController::doImageDrag(Element * element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard* clipboard, Frame*frame, IntPoint& dragImageOffset)851 void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard& clipboard, Frame& frame, IntPoint& dragImageOffset) 865 852 { 866 853 IntPoint mouseDownPoint = dragOrigin; … … 870 857 Image* image = getImage(element); 871 858 if (image && image->size().height() * image->size().width() <= MaxOriginalImageArea 872 && (dragImage = createDragImageFromImage(image, element ->renderer() ? ImageOrientationDescription(element->renderer()->shouldRespectImageOrientation()) : ImageOrientationDescription()))) {859 && (dragImage = createDragImageFromImage(image, element.renderer() ? ImageOrientationDescription(element.renderer()->shouldRespectImageOrientation()) : ImageOrientationDescription()))) { 873 860 IntSize originalSize = rect.size(); 874 861 origin = rect.location(); … … 904 891 } 905 892 906 void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, const IntPoint& eventPos, Clipboard * clipboard, Frame*frame, bool forLink)893 void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool forLink) 907 894 { 908 895 m_didInitiateDrag = true; 909 m_dragInitiator = frame ->document();896 m_dragInitiator = frame.document(); 910 897 // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame 911 898 Ref<MainFrame> frameProtector(m_page.mainFrame()); 912 899 RefPtr<FrameView> viewProtector = frameProtector->view(); 913 m_client.startDrag(image, viewProtector->rootViewToContents(frame ->view()->contentsToRootView(dragLoc)),914 viewProtector->rootViewToContents(frame ->view()->contentsToRootView(eventPos)), clipboard, &frameProtector.get(), forLink);900 m_client.startDrag(image, viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc)), 901 viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos)), clipboard, frameProtector.get(), forLink); 915 902 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. 916 903 if (!frameProtector->page()) -
trunk/Source/WebCore/page/DragController.h
r156550 r157058 59 59 DragClient& client() const { return m_client; } 60 60 61 DragSession dragEntered(DragData *);62 void dragExited(DragData *);63 DragSession dragUpdated(DragData *);64 bool performDrag(DragData *);61 DragSession dragEntered(DragData&); 62 void dragExited(DragData&); 63 DragSession dragUpdated(DragData&); 64 bool performDrag(DragData&); 65 65 66 66 // FIXME: It should be possible to remove a number of these accessors once all … … 83 83 void placeDragCaret(const IntPoint&); 84 84 85 bool startDrag(Frame *src, const DragState&, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);85 bool startDrag(Frame& src, const DragState&, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin); 86 86 static const IntSize& maxDragImageSize(); 87 87 … … 93 93 94 94 private: 95 bool dispatchTextInputEventFor(Frame*, DragData *);96 bool canProcessDrag(DragData *);97 bool concludeEditDrag(DragData *);98 DragSession dragEnteredOrUpdated(DragData *);99 DragOperation operationForLoad(DragData *);100 bool tryDocumentDrag(DragData *, DragDestinationAction, DragSession&);101 bool tryDHTMLDrag(DragData *, DragOperation&);102 DragOperation dragOperation(DragData *);95 bool dispatchTextInputEventFor(Frame*, DragData&); 96 bool canProcessDrag(DragData&); 97 bool concludeEditDrag(DragData&); 98 DragSession dragEnteredOrUpdated(DragData&); 99 DragOperation operationForLoad(DragData&); 100 bool tryDocumentDrag(DragData&, DragDestinationAction, DragSession&); 101 bool tryDHTMLDrag(DragData&, DragOperation&); 102 DragOperation dragOperation(DragData&); 103 103 void cancelDrag(); 104 bool dragIsMove(FrameSelection&, DragData *);105 bool isCopyKeyDown(DragData *);104 bool dragIsMove(FrameSelection&, DragData&); 105 bool isCopyKeyDown(DragData&); 106 106 107 107 void mouseMovedIntoDocument(Document*); 108 108 109 void doImageDrag(Element *, const IntPoint&, const IntRect&, Clipboard*, Frame*, IntPoint&);110 void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard *, Frame*, bool forLink);109 void doImageDrag(Element&, const IntPoint&, const IntRect&, Clipboard&, Frame&, IntPoint&); 110 void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool forLink); 111 111 void cleanupAfterSystemDrag(); 112 void declareAndWriteDragImage(Clipboard *, Element*, const URL&, const String& label);112 void declareAndWriteDragImage(Clipboard&, Element&, const URL&, const String& label); 113 113 114 114 Page& m_page; -
trunk/Source/WebCore/page/EventHandler.cpp
r157018 r157058 3669 3669 if (m_mouseDownMayStartDrag) { 3670 3670 Page* page = m_frame.page(); 3671 m_didStartDrag = page && page->dragController().startDrag( &m_frame, dragState(), srcOp, event.event(), m_mouseDownPos);3671 m_didStartDrag = page && page->dragController().startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos); 3672 3672 // In WebKit2 we could re-enter this code and start another drag. 3673 3673 // On OS X this causes problems with the ownership of the pasteboard and the promised types. -
trunk/Source/WebCore/page/efl/DragControllerEfl.cpp
r156550 r157058 44 44 const float DragController::DragImageAlpha = 0.75f; 45 45 46 bool DragController::isCopyKeyDown(DragData *)46 bool DragController::isCopyKeyDown(DragData&) 47 47 { 48 48 return false; 49 49 } 50 50 51 DragOperation DragController::dragOperation(DragData *dragData)51 DragOperation DragController::dragOperation(DragData& dragData) 52 52 { 53 if (dragData ->containsURL(0))53 if (dragData.containsURL(0)) 54 54 return DragOperationCopy; 55 55 … … 68 68 } 69 69 70 void DragController::declareAndWriteDragImage(Clipboard *, Element*, const URL&, const String&)70 void DragController::declareAndWriteDragImage(Clipboard&, Element&, const URL&, const String&) 71 71 { 72 72 } -
trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp
r156550 r157058 46 46 const float DragController::DragImageAlpha = 0.75f; 47 47 48 bool DragController::isCopyKeyDown(DragData *)48 bool DragController::isCopyKeyDown(DragData&) 49 49 { 50 50 return false; 51 51 } 52 52 53 DragOperation DragController::dragOperation(DragData *dragData)53 DragOperation DragController::dragOperation(DragData& dragData) 54 54 { 55 // FIXME: This logic is incomplete56 if (dragData->containsURL(0))55 // FIXME: This logic is incomplete 56 if (dragData.containsURL(0)) 57 57 return DragOperationCopy; 58 58 … … 70 70 } 71 71 72 void DragController::declareAndWriteDragImage(Clipboard * clipboard, Element*element, const URL& url, const String& label)72 void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label) 73 73 { 74 clipboard ->pasteboard().writeImage(element, url, label);74 clipboard.pasteboard().writeImage(element, url, label); 75 75 } 76 76 -
trunk/Source/WebCore/page/mac/DragControllerMac.mm
r156550 r157058 30 30 31 31 #import "Clipboard.h" 32 #import "DOMElementInternal.h"33 32 #import "DragClient.h" 34 33 #import "DragData.h" … … 49 48 const float DragController::DragImageAlpha = 0.75f; 50 49 51 bool DragController::isCopyKeyDown(DragData *dragData)50 bool DragController::isCopyKeyDown(DragData& dragData) 52 51 { 53 return dragData ->flags() & DragApplicationIsCopyKeyDown;52 return dragData.flags() & DragApplicationIsCopyKeyDown; 54 53 } 55 54 56 DragOperation DragController::dragOperation(DragData *dragData)55 DragOperation DragController::dragOperation(DragData& dragData) 57 56 { 58 ASSERT(dragData); 59 60 if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(&m_page.mainFrame())) 57 if ((dragData.flags() & DragApplicationIsModal) || !dragData.containsURL(&m_page.mainFrame())) 61 58 return DragOperationNone; 62 59 63 if (!m_documentUnderMouse || (!(dragData ->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))60 if (!m_documentUnderMouse || (!(dragData.flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource)))) 64 61 return DragOperationCopy; 65 62 … … 86 83 } 87 84 88 void DragController::declareAndWriteDragImage(Clipboard * clipboard, Element*element, const URL& url, const String& label)85 void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label) 89 86 { 90 m_client.declareAndWriteDragImage(clipboard ->pasteboard().name(), kit(element), url, label, element->document().frame());87 m_client.declareAndWriteDragImage(clipboard.pasteboard().name(), element, url, label, element.document().frame()); 91 88 } 92 89 -
trunk/Source/WebCore/page/win/DragControllerWin.cpp
r157012 r157058 45 45 const float DragController::DragImageAlpha = 0.75f; 46 46 47 DragOperation DragController::dragOperation(DragData *dragData)47 DragOperation DragController::dragOperation(DragData& dragData) 48 48 { 49 49 //FIXME: to match the macos behaviour we should return DragOperationNone … … 51 51 //If this can be determined from within WebCore operationForDrag can be pulled into 52 52 //WebCore itself 53 ASSERT(dragData); 54 return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone; 53 return dragData.containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone; 55 54 } 56 55 57 bool DragController::isCopyKeyDown(DragData *)56 bool DragController::isCopyKeyDown(DragData&) 58 57 { 59 58 return ::GetAsyncKeyState(VK_CONTROL); … … 71 70 } 72 71 73 void DragController::declareAndWriteDragImage(Clipboard * clipboard, Element*element, const URL& url, const String& label)72 void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label) 74 73 { 75 Pasteboard& pasteboard = clipboard ->pasteboard();74 Pasteboard& pasteboard = clipboard.pasteboard(); 76 75 77 76 // FIXME: Do we really need this check? … … 82 81 pasteboard.writeURLToWritableDataObject(url, label); 83 82 pasteboard.writeImageToDataObject(element, url); 84 pasteboard.writeMarkup(createMarkup( *element, IncludeNode, 0, ResolveAllURLs));83 pasteboard.writeMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs)); 85 84 } 86 85 -
trunk/Source/WebCore/platform/DragData.h
r156795 r157058 105 105 void asFilenames(Vector<String>&) const; 106 106 Color asColor() const; 107 PassRefPtr<DocumentFragment> asFragment(Frame*, PassRefPtr<Range> context, 108 bool allowPlainText, bool& chosePlainText) const; 107 PassRefPtr<DocumentFragment> asFragment(Frame*, Range& context, bool allowPlainText, bool& chosePlainText) const; 109 108 bool canSmartReplace() const; 110 109 bool containsColor() const; -
trunk/Source/WebCore/platform/Pasteboard.h
r156795 r157058 165 165 166 166 #if PLATFORM(GTK) || PLATFORM(WIN) 167 PassRefPtr<DocumentFragment> documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation. 168 #endif 169 170 #if PLATFORM(GTK) || PLATFORM(WIN) 171 void writeImage(Node*, const URL&, const String& title); // FIXME: Layering violation. 172 void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard = DefaultSelectedTextType); // FIXME: Layering violation. 167 PassRefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation. 168 void writeImage(Element&, const URL&, const String& title); // FIXME: Layering violation. 169 void writeSelection(Range&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForClipboard = DefaultSelectedTextType); // FIXME: Layering violation. 173 170 #endif 174 171 … … 177 174 static PassOwnPtr<Pasteboard> create(GtkClipboard*); 178 175 PassRefPtr<DataObjectGtk> dataObject() const; 179 #endif180 181 #if PLATFORM(GTK)182 176 static PassOwnPtr<Pasteboard> createForGlobalSelection(); 183 177 #endif … … 200 194 void writeURLToWritableDataObject(const URL&, const String&); 201 195 COMPtr<WCDataObject> writableDataObject() const { return m_writableDataObject; } 202 void writeImageToDataObject(Element *, const URL&); // FIXME: Layering violation.196 void writeImageToDataObject(Element&, const URL&); // FIXME: Layering violation. 203 197 #endif 204 198 … … 217 211 218 212 void finishCreatingPasteboard(); 219 void writeRangeToDataObject(Range *, Frame*); // FIXME: Layering violation.213 void writeRangeToDataObject(Range&, Frame&); // FIXME: Layering violation. 220 214 void writeURLToDataObject(const URL&, const String&); 221 215 void writePlainTextToDataObject(const String&, SmartReplaceOption); -
trunk/Source/WebCore/platform/efl/DragDataEfl.cpp
r128570 r157058 81 81 } 82 82 83 PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const83 PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, Range&, bool, bool&) const 84 84 { 85 85 return 0; -
trunk/Source/WebCore/platform/gtk/DragDataGtk.cpp
r157002 r157058 93 93 94 94 95 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const95 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range&, bool, bool&) const 96 96 { 97 97 if (!m_platformDragData->hasMarkup()) -
trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp
r157013 r157058 96 96 convertWidgetPointToScreenPoint(m_widget, position), 97 97 DragOperationNone); 98 context->exitedCallback(m_widget, &dragData, context->dropHappened);98 context->exitedCallback(m_widget, dragData, context->dropHappened); 99 99 100 100 m_droppingContexts.remove(iterator); -
trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h
r157013 r157058 29 29 class DragData; 30 30 31 typedef void (*DragExitedCallback)(GtkWidget*, DragData *, bool dropHappened);31 typedef void (*DragExitedCallback)(GtkWidget*, DragData&, bool dropHappened); 32 32 33 33 class GtkDragAndDropHelper { -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r157002 r157058 158 158 } 159 159 160 void Pasteboard::writeSelection(Range * selectedRange, bool canSmartCopyOrDelete, Frame*frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)160 void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard) 161 161 { 162 162 m_dataObject->clearAll(); 163 m_dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame ->editor().selectedTextForClipboard() : frame->editor().selectedText());164 m_dataObject->setMarkup(createMarkup( *selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));163 m_dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame.editor().selectedTextForClipboard() : frame.editor().selectedText()); 164 m_dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs)); 165 165 166 166 if (m_gtkClipboard) … … 188 188 } 189 189 190 static URL getURLForImage Node(Node* node)190 static URL getURLForImageElement(Element& element) 191 191 { 192 192 // FIXME: Later this code should be shared with Chromium somehow. Chances are all platforms want it. 193 193 AtomicString urlString; 194 if (isHTMLImageElement( node) || isHTMLInputElement(node))195 urlString = toElement(node)->getAttribute(HTMLNames::srcAttr);194 if (isHTMLImageElement(element) || isHTMLInputElement(element)) 195 urlString = element.getAttribute(HTMLNames::srcAttr); 196 196 #if ENABLE(SVG) 197 else if ( node->hasTagName(SVGNames::imageTag))198 urlString = toElement(node)->getAttribute(XLinkNames::hrefAttr);197 else if (element.hasTagName(SVGNames::imageTag)) 198 urlString = element.getAttribute(XLinkNames::hrefAttr); 199 199 #endif 200 else if (node->hasTagName(HTMLNames::embedTag) || isHTMLObjectElement(node)) { 201 Element* element = toElement(node); 202 urlString = element->imageSourceURL(); 203 } 204 return urlString.isEmpty() ? URL() : node->document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); 205 } 206 207 void Pasteboard::writeImage(Node* node, const URL&, const String& title) 208 { 209 ASSERT(node); 210 211 if (!(node->renderer() && node->renderer()->isImage())) 200 else if (element.hasTagName(HTMLNames::embedTag) || isHTMLObjectElement(element)) 201 urlString = element.imageSourceURL(); 202 203 return urlString.isEmpty() ? URL() : element.document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); 204 } 205 206 void Pasteboard::writeImage(Element& element, const URL&, const String& title) 207 { 208 if (!(element.renderer() && element.renderer()->isImage())) 212 209 return; 213 210 214 RenderImage* renderer = toRenderImage( node->renderer());211 RenderImage* renderer = toRenderImage(element.renderer()); 215 212 CachedImage* cachedImage = renderer->cachedImage(); 216 213 if (!cachedImage || cachedImage->errorOccurred()) … … 221 218 m_dataObject->clearAll(); 222 219 223 URL url = getURLForImage Node(node);220 URL url = getURLForImageElement(element); 224 221 if (!url.isEmpty()) { 225 222 m_dataObject->setURL(url, title); 226 223 227 m_dataObject->setMarkup(createMarkup( *toElement(node), IncludeNode, 0, ResolveAllURLs));224 m_dataObject->setMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs)); 228 225 } 229 226 … … 303 300 #endif 304 301 305 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, 306 bool allowPlainText, bool& chosePlainText) 302 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText) 307 303 { 308 304 if (m_gtkClipboard) … … 312 308 313 309 if (m_dataObject->hasMarkup()) { 314 if (frame ->document()) {315 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame ->document(), m_dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent);310 if (frame.document()) { 311 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), m_dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent); 316 312 if (fragment) 317 313 return fragment.release(); … … 324 320 if (m_dataObject->hasText()) { 325 321 chosePlainText = true; 326 RefPtr<DocumentFragment> fragment = createFragmentFromText(context .get(), m_dataObject->text());322 RefPtr<DocumentFragment> fragment = createFragmentFromText(context, m_dataObject->text()); 327 323 if (fragment) 328 324 return fragment.release(); -
trunk/Source/WebCore/platform/mac/DragDataMac.mm
r155700 r157058 190 190 } 191 191 192 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>range, bool allowPlainText, bool& chosePlainText) const192 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range& range, bool allowPlainText, bool& chosePlainText) const 193 193 { 194 194 Pasteboard pasteboard(m_pasteboardName); 195 return frame->editor().webContentFromPasteboard(pasteboard, *range, allowPlainText, chosePlainText);195 return frame->editor().webContentFromPasteboard(pasteboard, range, allowPlainText, chosePlainText); 196 196 } 197 197 -
trunk/Source/WebCore/platform/win/DragDataWin.cpp
r149280 r157058 207 207 } 208 208 209 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const209 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range&, bool, bool&) const 210 210 { 211 211 /* -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r157003 r157058 423 423 #endif 424 424 425 void Pasteboard::writeRangeToDataObject(Range* selectedRange, Frame* frame) 426 { 427 ASSERT(selectedRange); 425 void Pasteboard::writeRangeToDataObject(Range& selectedRange, Frame& frame) 426 { 428 427 if (!m_writableDataObject) 429 428 return; … … 433 432 434 433 Vector<char> data; 435 markupToCFHTML(createMarkup( *selectedRange, 0, AnnotateForInterchange),436 selectedRange ->startContainer()->document().url().string(), data);434 markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange), 435 selectedRange.startContainer()->document().url().string(), data); 437 436 medium.hGlobal = createGlobalData(data); 438 437 if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE))) 439 438 ::GlobalFree(medium.hGlobal); 440 439 441 String str = frame ->editor().selectedTextForClipboard();440 String str = frame.editor().selectedTextForClipboard(); 442 441 replaceNewlinesWithWindowsStyleNewlines(str); 443 442 replaceNBSPWithSpace(str); … … 447 446 448 447 medium.hGlobal = 0; 449 if (frame ->editor().canSmartCopyOrDelete())448 if (frame.editor().canSmartCopyOrDelete()) 450 449 m_writableDataObject->SetData(smartPasteFormat(), &medium, TRUE); 451 450 } 452 451 453 void Pasteboard::writeSelection(Range * selectedRange, bool canSmartCopyOrDelete, Frame*frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)452 void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard) 454 453 { 455 454 clear(); … … 458 457 if (::OpenClipboard(m_owner)) { 459 458 Vector<char> data; 460 markupToCFHTML(createMarkup( *selectedRange, 0, AnnotateForInterchange),461 selectedRange ->startContainer()->document().url().string(), data);459 markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange), 460 selectedRange.startContainer()->document().url().string(), data); 462 461 HGLOBAL cbData = createGlobalData(data); 463 462 if (!::SetClipboardData(HTMLClipboardFormat, cbData)) … … 467 466 468 467 // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well 469 String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame ->editor().selectedTextForClipboard() : frame->editor().selectedText();468 String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame.editor().selectedTextForClipboard() : frame.editor().selectedText(); 470 469 replaceNewlinesWithWindowsStyleNewlines(str); 471 470 replaceNBSPWithSpace(str); … … 726 725 } 727 726 728 void Pasteboard::writeImage(Node* node, const URL&, const String&) 729 { 730 ASSERT(node); 731 732 if (!(node->renderer() && node->renderer()->isImage())) 733 return; 734 735 RenderImage* renderer = toRenderImage(node->renderer()); 727 void Pasteboard::writeImage(Element& element, const URL&, const String&) 728 { 729 if (!(element.renderer() && element.renderer()->isImage())) 730 return; 731 732 RenderImage* renderer = toRenderImage(element.renderer()); 736 733 CachedImage* cachedImage = renderer->cachedImage(); 737 734 if (!cachedImage || cachedImage->errorOccurred()) … … 799 796 } 800 797 801 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame * frame, PassRefPtr<Range>context, bool allowPlainText, bool& chosePlainText)798 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText) 802 799 { 803 800 chosePlainText = false; … … 812 809 ::CloseClipboard(); 813 810 814 PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame->document(), cfhtml);811 RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame.document(), cfhtml); 815 812 if (fragment) 816 return fragment ;813 return fragment.release(); 817 814 } else 818 815 ::CloseClipboard(); … … 828 825 GlobalUnlock(cbData); 829 826 ::CloseClipboard(); 830 RefPtr<DocumentFragment> fragment = createFragmentFromText(context .get(), str);827 RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str); 831 828 if (fragment) 832 829 return fragment.release(); … … 845 842 GlobalUnlock(cbData); 846 843 ::CloseClipboard(); 847 RefPtr<DocumentFragment> fragment = createFragmentFromText(context .get(), str);844 RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str); 848 845 if (fragment) 849 846 return fragment.release(); … … 862 859 } 863 860 864 static CachedImage* getCachedImage(Element *element)861 static CachedImage* getCachedImage(Element& element) 865 862 { 866 863 // Attempt to pull CachedImage from element 867 ASSERT(element); 868 RenderObject* renderer = element->renderer(); 864 RenderObject* renderer = element.renderer(); 869 865 if (!renderer || !renderer->isImage()) 870 866 return 0; … … 1002 998 } 1003 999 1004 void Pasteboard::writeImageToDataObject(Element *element, const URL& url)1000 void Pasteboard::writeImageToDataObject(Element& element, const URL& url) 1005 1001 { 1006 1002 // Shove image data into a DataObject for use as a file 1007 1003 CachedImage* cachedImage = getCachedImage(element); 1008 if (!cachedImage || !cachedImage->imageForRenderer(element ->renderer()) || !cachedImage->isLoaded())1009 return; 1010 1011 SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element ->renderer())->data();1004 if (!cachedImage || !cachedImage->imageForRenderer(element.renderer()) || !cachedImage->isLoaded()) 1005 return; 1006 1007 SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element.renderer())->data(); 1012 1008 if (!imageBuffer || !imageBuffer->size()) 1013 1009 return; 1014 1010 1015 HGLOBAL imageFileDescriptor = createGlobalImageFileDescriptor(url.string(), element ->getAttribute(HTMLNames::altAttr), cachedImage);1011 HGLOBAL imageFileDescriptor = createGlobalImageFileDescriptor(url.string(), element.getAttribute(HTMLNames::altAttr), cachedImage); 1016 1012 if (!imageFileDescriptor) 1017 1013 return; -
trunk/Source/WebKit/efl/ChangeLog
r156946 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 * WebCoreSupport/DragClientEfl.cpp: 9 (WebCore::DragClientEfl::willPerformDragDestinationAction): 10 (WebCore::DragClientEfl::willPerformDragSourceAction): 11 (WebCore::DragClientEfl::actionMaskForDrag): 12 (WebCore::DragClientEfl::startDrag): 13 * WebCoreSupport/DragClientEfl.h: 14 1 15 2013-10-04 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/WebKit/efl/WebCoreSupport/DragClientEfl.cpp
r95901 r157058 36 36 namespace WebCore { 37 37 38 void DragClientEfl::willPerformDragDestinationAction(DragDestinationAction, DragData *)38 void DragClientEfl::willPerformDragDestinationAction(DragDestinationAction, DragData&) 39 39 { 40 40 notImplemented(); 41 41 } 42 42 43 void DragClientEfl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard *)43 void DragClientEfl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) 44 44 { 45 45 notImplemented(); 46 46 } 47 47 48 DragDestinationAction DragClientEfl::actionMaskForDrag(DragData *)48 DragDestinationAction DragClientEfl::actionMaskForDrag(DragData&) 49 49 { 50 50 return DragDestinationActionAny; … … 56 56 } 57 57 58 void DragClientEfl::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard *, Frame*, bool)58 void DragClientEfl::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool) 59 59 { 60 60 notImplemented(); -
trunk/Source/WebKit/efl/WebCoreSupport/DragClientEfl.h
r95901 r157058 37 37 38 38 namespace WebCore { 39 39 40 class DragClientEfl : public WebCore::DragClient { 40 41 public: 41 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*); 42 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); 43 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*); 42 virtual void dragControllerDestroyed(); 44 43 44 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&); 45 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&); 46 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&); 45 47 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); 48 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false); 49 }; 46 50 47 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false);48 49 virtual void dragControllerDestroyed();50 };51 51 } 52 52 -
trunk/Source/WebKit/gtk/ChangeLog
r157042 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 * WebCoreSupport/DragClientGtk.cpp: 9 (WebKit::DragClient::willPerformDragDestinationAction): 10 (WebKit::DragClient::willPerformDragSourceAction): 11 (WebKit::DragClient::actionMaskForDrag): 12 (WebKit::DragClient::startDrag): 13 * WebCoreSupport/DragClientGtk.h: 14 * webkit/webkitwebview.cpp: 15 (dragExitedCallback): 16 (webkit_web_view_drag_motion): 17 (webkit_web_view_drag_data_received): 18 (webkit_web_view_drag_drop): 19 1 20 2013-10-04 Philippe Normand <pnormand@igalia.com> 2 21 -
trunk/Source/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
r156345 r157058 56 56 } 57 57 58 void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData *)58 void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData&) 59 59 { 60 60 } 61 61 62 void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard *)62 void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard&) 63 63 { 64 64 m_startPos = startPos; 65 65 } 66 66 67 DragDestinationAction DragClient::actionMaskForDrag(DragData *)67 DragDestinationAction DragClient::actionMaskForDrag(DragData&) 68 68 { 69 69 notImplemented(); … … 77 77 } 78 78 79 void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard * clipboard, Frame*frame, bool linkDrag)79 void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool linkDrag) 80 80 { 81 WebKitWebView* webView = webkit_web_frame_get_web_view(kit( frame));82 RefPtr<DataObjectGtk> dataObject = clipboard ->pasteboard().dataObject();81 WebKitWebView* webView = webkit_web_frame_get_web_view(kit(&frame)); 82 RefPtr<DataObjectGtk> dataObject = clipboard.pasteboard().dataObject(); 83 83 GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get())); 84 84 GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event()); 85 85 86 GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragOperationToGdkDragActions(clipboard ->sourceOperation()), 1, currentEvent.get());86 GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragOperationToGdkDragActions(clipboard.sourceOperation()), 1, currentEvent.get()); 87 87 webView->priv->dragAndDropHelper.startedDrag(context, dataObject.get()); 88 88 -
trunk/Source/WebKit/gtk/WebCoreSupport/DragClientGtk.h
r156345 r157058 41 41 namespace WebKit { 42 42 43 44 45 46 43 class DragClient : public WebCore::DragClient { 44 public: 45 DragClient(WebKitWebView*); 46 ~DragClient(); 47 47 48 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*); 49 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); 50 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*); 48 virtual void dragControllerDestroyed(); 51 49 52 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); 50 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&); 51 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&); 52 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&); 53 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); 54 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false); 53 55 54 virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false); 55 56 virtual void dragControllerDestroyed(); 57 58 private: 59 WebKitWebView* m_webView; 60 WebCore::IntPoint m_startPos; 61 WebCore::DragIcon m_dragIcon; 62 }; 56 private: 57 WebKitWebView* m_webView; 58 WebCore::IntPoint m_startPos; 59 WebCore::DragIcon m_dragIcon; 60 }; 63 61 } 64 62 -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r156550 r157058 1530 1530 } 1531 1531 1532 static void dragExitedCallback(GtkWidget* widget, DragData *dragData, bool dropHappened)1532 static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened) 1533 1533 { 1534 1534 // Don't call dragExited if we have just received a drag-drop signal. This … … 1553 1553 1554 1554 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1555 DragOperation operation = core(webView)->dragController().dragUpdated( &dragData).operation;1555 DragOperation operation = core(webView)->dragController().dragUpdated(dragData).operation; 1556 1556 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 1557 1557 return TRUE; … … 1567 1567 1568 1568 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1569 DragOperation operation = core(webView)->dragController().dragEntered( &dragData).operation;1569 DragOperation operation = core(webView)->dragController().dragEntered(dragData).operation; 1570 1570 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 1571 1571 } … … 1580 1580 IntPoint position(x, y); 1581 1581 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1582 core(webView)->dragController().performDrag( &dragData);1582 core(webView)->dragController().performDrag(dragData); 1583 1583 gtk_drag_finish(context, TRUE, FALSE, time); 1584 1584 return TRUE; -
trunk/Source/WebKit/mac/ChangeLog
r157002 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 * WebCoreSupport/WebDragClient.h: 9 * WebCoreSupport/WebDragClient.mm: 10 (WebDragClient::actionMaskForDrag): 11 (WebDragClient::willPerformDragDestinationAction): 12 (WebDragClient::willPerformDragSourceAction): 13 (WebDragClient::startDrag): 14 (WebDragClient::declareAndWriteDragImage): 15 * WebView/WebFrame.mm: 16 (-[WebFrame _replaceSelectionWithText:selectReplacement:smartReplace:]): 17 * WebView/WebHTMLView.mm: 18 (-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]): 19 * WebView/WebView.mm: 20 (-[WebView draggingEntered:]): 21 (-[WebView draggingUpdated:]): 22 (-[WebView draggingExited:]): 23 (-[WebView performDragOperation:]): 24 1 25 2013-10-05 Sam Weinig <sam@webkit.org> 2 26 -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h
r117695 r157058 33 33 public: 34 34 WebDragClient(WebView*); 35 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData *) OVERRIDE;36 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard *) OVERRIDE;37 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData *) OVERRIDE;35 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&) OVERRIDE; 36 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&) OVERRIDE; 37 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&) OVERRIDE; 38 38 virtual void dragControllerDestroyed() OVERRIDE; 39 39 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) OVERRIDE; 40 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard *, WebCore::Frame*, bool linkDrag) OVERRIDE;41 virtual void declareAndWriteDragImage(const String& pasteboardName, DOMElement*, NSURL*, NSString*, WebCore::Frame*) OVERRIDE;40 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag) OVERRIDE; 41 virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) OVERRIDE; 42 42 private: 43 43 WebView* m_webView; -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
r156860 r157058 28 28 #if ENABLE(DRAG_SUPPORT) 29 29 30 #import "DOMElementInternal.h" 30 31 #import "WebArchive.h" 31 32 #import "WebDOMOperations.h" … … 67 68 } 68 69 69 WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(WebCore::DragData *dragData)70 WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(WebCore::DragData& dragData) 70 71 { 71 return (WebCore::DragDestinationAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragDestinationActionMaskForDraggingInfo:dragData ->platformData()];72 return (WebCore::DragDestinationAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragDestinationActionMaskForDraggingInfo:dragData.platformData()]; 72 73 } 73 74 74 void WebDragClient::willPerformDragDestinationAction(WebCore::DragDestinationAction action, WebCore::DragData *dragData)75 void WebDragClient::willPerformDragDestinationAction(WebCore::DragDestinationAction action, WebCore::DragData& dragData) 75 76 { 76 [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:dragData ->platformData()];77 [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:dragData.platformData()]; 77 78 } 78 79 … … 84 85 } 85 86 86 void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::Clipboard *clipboard)87 void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::Clipboard& clipboard) 87 88 { 88 ASSERT(clipboard); 89 [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:clipboard->pasteboard().name()]]; 89 [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:clipboard.pasteboard().name()]]; 90 90 } 91 91 92 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard * clipboard, Frame*frame, bool linkDrag)92 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool linkDrag) 93 93 { 94 if (!frame) 95 return; 96 ASSERT(clipboard); 97 RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(frame) frameView] documentView]; 94 RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(&frame) frameView] documentView]; 98 95 if (![htmlView.get() isKindOfClass:[WebHTMLView class]]) 99 96 return; 100 97 101 NSEvent *event = linkDrag ? frame ->eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];102 WebHTMLView* topHTMLView = getTopHTMLView( frame);98 NSEvent *event = linkDrag ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent]; 99 WebHTMLView* topHTMLView = getTopHTMLView(&frame); 103 100 RetainPtr<WebHTMLView> topViewProtector = topHTMLView; 104 101 105 102 [topHTMLView _stopAutoscrollTimer]; 106 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:clipboard ->pasteboard().name()];103 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:clipboard.pasteboard().name()]; 107 104 108 105 NSImage *dragNSImage = dragImage.get(); … … 124 121 } 125 122 126 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame* frame)123 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& title, WebCore::Frame* frame) 127 124 { 128 125 ASSERT(pasteboardName); 129 ASSERT(element); 130 WebHTMLView *source = getTopHTMLView(frame); 131 WebArchive *archive = [element webArchive]; 126 WebHTMLView *source = getTopHTMLView(frame); 127 WebArchive *archive = [kit(&element) webArchive]; 132 128 133 [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement: element URL:URLtitle:title archive:archive source:source];129 [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:title archive:archive source:source]; 134 130 } 135 131 -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r157002 r157058 999 999 1000 1000 - (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace 1001 { 1002 DOMDocumentFragment* fragment = kit(createFragmentFromText(_private->coreFrame->selection().toNormalizedRange().get(), text).get()); 1001 { 1002 RefPtr<Range> range = _private->coreFrame->selection().toNormalizedRange(); 1003 1004 DOMDocumentFragment* fragment = range ? kit(createFragmentFromText(*range, text).get()) : nil; 1003 1005 [self _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:YES]; 1004 1006 } -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r157018 r157058 2066 2066 return fragment; 2067 2067 } 2068 if (pboardType == NSStringPboardType) 2069 return kit(createFragmentFromText(core(context), [[pasteboard stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]).get()); 2068 if (pboardType == NSStringPboardType) { 2069 if (!context) 2070 return nil; 2071 return kit(createFragmentFromText(*core(context), [[pasteboard stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]).get()); 2072 } 2070 2073 return nil; 2071 2074 } -
trunk/Source/WebKit/mac/WebView/WebView.mm
r156949 r157058 4333 4333 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 4334 4334 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 4335 return core(self)->dragController().dragEntered( &dragData).operation;4335 return core(self)->dragController().dragEntered(dragData).operation; 4336 4336 } 4337 4337 … … 4345 4345 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 4346 4346 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 4347 return page->dragController().dragUpdated( &dragData).operation;4347 return page->dragController().dragUpdated(dragData).operation; 4348 4348 } 4349 4349 … … 4357 4357 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 4358 4358 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 4359 page->dragController().dragExited( &dragData);4359 page->dragController().dragExited(dragData); 4360 4360 } 4361 4361 … … 4370 4370 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 4371 4371 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 4372 return core(self)->dragController().performDrag( &dragData);4372 return core(self)->dragController().performDrag(dragData); 4373 4373 } 4374 4374 -
trunk/Source/WebKit/win/ChangeLog
r156946 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 * WebCoreSupport/WebDragClient.cpp: 9 (WebDragClient::actionMaskForDrag): 10 (WebDragClient::willPerformDragDestinationAction): 11 (WebDragClient::willPerformDragSourceAction): 12 (WebDragClient::startDrag): 13 * WebCoreSupport/WebDragClient.h: 14 1 15 2013-10-04 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp
r156543 r157058 66 66 } 67 67 68 DragDestinationAction WebDragClient::actionMaskForDrag(DragData *dragData)68 DragDestinationAction WebDragClient::actionMaskForDrag(DragData& dragData) 69 69 { 70 70 COMPtr<IWebUIDelegate> delegateRef = 0; … … 73 73 WebDragDestinationAction mask = WebDragDestinationActionAny; 74 74 if (SUCCEEDED(m_webView->uiDelegate(&delegateRef))) 75 delegateRef->dragDestinationActionMaskForDraggingInfo(m_webView, dragData ->platformData(), &mask);75 delegateRef->dragDestinationActionMaskForDraggingInfo(m_webView, dragData.platformData(), &mask); 76 76 77 77 return (DragDestinationAction)mask; 78 78 } 79 79 80 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData *dragData)80 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData& dragData) 81 81 { 82 82 //Default delegate for willPerformDragDestinationAction has no side effects … … 84 84 COMPtr<IWebUIDelegate> delegateRef = 0; 85 85 if (SUCCEEDED(m_webView->uiDelegate(&delegateRef))) 86 delegateRef->willPerformDragDestinationAction(m_webView, (WebDragDestinationAction)action, dragData ->platformData());86 delegateRef->willPerformDragDestinationAction(m_webView, (WebDragDestinationAction)action, dragData.platformData()); 87 87 } 88 88 … … 97 97 } 98 98 99 void WebDragClient::willPerformDragSourceAction(DragSourceAction action, const IntPoint& intPoint, Clipboard *clipboard)99 void WebDragClient::willPerformDragSourceAction(DragSourceAction action, const IntPoint& intPoint, Clipboard& clipboard) 100 100 { 101 101 COMPtr<IWebUIDelegate> uiDelegate; … … 104 104 105 105 POINT point = intPoint; 106 COMPtr<IDataObject> dataObject = clipboard ->pasteboard().dataObject();106 COMPtr<IDataObject> dataObject = clipboard.pasteboard().dataObject(); 107 107 108 108 COMPtr<IDataObject> newDataObject; 109 109 HRESULT result = uiDelegate->willPerformDragSourceAction(m_webView, static_cast<WebDragSourceAction>(action), &point, dataObject.get(), &newDataObject); 110 110 if (result == S_OK && newDataObject != dataObject) 111 const_cast<Pasteboard&>(clipboard ->pasteboard()).setExternalDataObject(newDataObject.get());111 const_cast<Pasteboard&>(clipboard.pasteboard()).setExternalDataObject(newDataObject.get()); 112 112 } 113 113 114 void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, Clipboard * clipboard, Frame*frame, bool isLink)114 void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, Clipboard& clipboard, Frame& frame, bool isLink) 115 115 { 116 116 //FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953> 117 117 118 118 //We liberally protect everything, to protect against a load occurring mid-drag 119 RefPtr<Frame> frameProtector = frame;119 RefPtr<Frame> frameProtector = &frame; 120 120 COMPtr<IDragSourceHelper> helper; 121 121 COMPtr<IDataObject> dataObject; … … 125 125 return; 126 126 127 dataObject = clipboard ->pasteboard().dataObject();127 dataObject = clipboard.pasteboard().dataObject(); 128 128 if (source && (image || dataObject)) { 129 129 if (image) { … … 167 167 operation = DragOperationMove; 168 168 } 169 frame ->eventHandler().dragSourceEndedAt(generateMouseEvent(m_webView, false), operation);169 frame.eventHandler().dragSourceEndedAt(generateMouseEvent(m_webView, false), operation); 170 170 } 171 171 } -
trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.h
r77870 r157058 34 34 public: 35 35 WebDragClient(WebView*); 36 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);37 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);38 36 virtual void dragControllerDestroyed(); 37 38 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&); 39 39 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint&); 40 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); 41 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint&, const WebCore::IntPoint&, WebCore::Clipboard*, WebCore::Frame*, bool); 40 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&); 41 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&); 42 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint&, const WebCore::IntPoint&, WebCore::Clipboard&, WebCore::Frame&, bool); 43 42 44 private: 43 45 WebView* m_webView; -
trunk/Source/WebKit/win/WebView.cpp
r156550 r157058 5256 5256 DragData data(pDataObject, IntPoint(localpt.x, localpt.y), 5257 5257 IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); 5258 *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered( &data).operation);5258 *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(data).operation); 5259 5259 5260 5260 m_lastDropEffect = *pdwEffect; … … 5275 5275 DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), 5276 5276 IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); 5277 *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated( &data).operation);5277 *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(data).operation); 5278 5278 } else 5279 5279 *pdwEffect = DROPEFFECT_NONE; … … 5291 5291 DragData data(m_dragData.get(), IntPoint(), IntPoint(), 5292 5292 DragOperationNone); 5293 m_page->dragController().dragExited( &data);5293 m_page->dragController().dragExited(data); 5294 5294 m_dragData = 0; 5295 5295 } … … 5309 5309 DragData data(pDataObject, IntPoint(localpt.x, localpt.y), 5310 5310 IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); 5311 m_page->dragController().performDrag( &data);5311 m_page->dragController().performDrag(data); 5312 5312 return S_OK; 5313 5313 } -
trunk/Source/WebKit2/ChangeLog
r157056 r157058 1 2013-10-07 Sam Weinig <sam@webkit.org> 2 3 CTTE: Use references in and around DragController 4 https://bugs.webkit.org/show_bug.cgi?id=122427 5 6 Reviewed by Andreas Kling. 7 8 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 9 (webkitWebViewBaseDragDataReceived): 10 (webkitWebViewBaseDragMotion): 11 (dragExitedCallback): 12 (webkitWebViewBaseDragDrop): 13 * UIProcess/API/mac/WKView.mm: 14 (-[WKView draggingEntered:]): 15 (-[WKView draggingUpdated:]): 16 (-[WKView draggingExited:]): 17 (-[WKView performDragOperation:]): 18 * UIProcess/WebPageProxy.cpp: 19 (WebKit::WebPageProxy::dragEntered): 20 (WebKit::WebPageProxy::dragUpdated): 21 (WebKit::WebPageProxy::dragExited): 22 (WebKit::WebPageProxy::performDrag): 23 (WebKit::WebPageProxy::performDragControllerAction): 24 * UIProcess/WebPageProxy.h: 25 * WebProcess/WebCoreSupport/WebDragClient.cpp: 26 (WebKit::WebDragClient::willPerformDragDestinationAction): 27 (WebKit::WebDragClient::willPerformDragSourceAction): 28 (WebKit::WebDragClient::actionMaskForDrag): 29 (WebKit::WebDragClient::dragSourceActionMaskForPoint): 30 (WebKit::WebDragClient::startDrag): 31 * WebProcess/WebCoreSupport/WebDragClient.h: 32 * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp: 33 (WebKit::WebDragClient::startDrag): 34 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 35 (WebKit::WebDragClient::startDrag): 36 (WebKit::cachedImage): 37 (WebKit::WebDragClient::declareAndWriteDragImage): 38 * WebProcess/WebPage/WebPage.cpp: 39 (WebKit::WebPage::performDragControllerAction): 40 1 41 2013-10-07 Tim Horton <timothy_horton@apple.com> 2 42 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r156345 r157058 724 724 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 725 725 webViewBase->priv->pageProxy->resetDragOperation(); 726 webViewBase->priv->pageProxy->dragEntered( &dragData);726 webViewBase->priv->pageProxy->dragEntered(dragData); 727 727 DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation; 728 728 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); … … 768 768 769 769 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 770 webViewBase->priv->pageProxy->dragUpdated( &dragData);770 webViewBase->priv->pageProxy->dragUpdated(dragData); 771 771 DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation; 772 772 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); … … 774 774 } 775 775 776 static void dragExitedCallback(GtkWidget* widget, DragData *dragData, bool dropHappened)776 static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened) 777 777 { 778 778 // Don't call dragExited if we have just received a drag-drop signal. This … … 802 802 SandboxExtension::Handle handle; 803 803 SandboxExtension::HandleArray sandboxExtensionForUpload; 804 webViewBase->priv->pageProxy->performDrag( &dragData, String(), handle, sandboxExtensionForUpload);804 webViewBase->priv->pageProxy->performDrag(dragData, String(), handle, sandboxExtensionForUpload); 805 805 gtk_drag_finish(context, TRUE, FALSE, time); 806 806 return TRUE; -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r156968 r157058 1774 1774 1775 1775 _data->_page->resetDragOperation(); 1776 _data->_page->dragEntered( &dragData, [[draggingInfo draggingPasteboard] name]);1776 _data->_page->dragEntered(dragData, [[draggingInfo draggingPasteboard] name]); 1777 1777 return NSDragOperationCopy; 1778 1778 } … … 1783 1783 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 1784 1784 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 1785 _data->_page->dragUpdated( &dragData, [[draggingInfo draggingPasteboard] name]);1785 _data->_page->dragUpdated(dragData, [[draggingInfo draggingPasteboard] name]); 1786 1786 1787 1787 WebCore::DragSession dragSession = _data->_page->dragSession(); … … 1804 1804 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 1805 1805 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 1806 _data->_page->dragExited( &dragData, [[draggingInfo draggingPasteboard] name]);1806 _data->_page->dragExited(dragData, [[draggingInfo draggingPasteboard] name]); 1807 1807 _data->_page->resetDragOperation(); 1808 1808 } … … 1868 1868 createSandboxExtensionsForFileUpload([draggingInfo draggingPasteboard], sandboxExtensionForUpload); 1869 1869 1870 _data->_page->performDrag( &dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle, sandboxExtensionForUpload);1870 _data->_page->performDrag(dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle, sandboxExtensionForUpload); 1871 1871 1872 1872 return YES; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r156924 r157058 1195 1195 1196 1196 #if ENABLE(DRAG_SUPPORT) 1197 void WebPageProxy::dragEntered(DragData *dragData, const String& dragStorageName)1197 void WebPageProxy::dragEntered(DragData& dragData, const String& dragStorageName) 1198 1198 { 1199 1199 SandboxExtension::Handle sandboxExtensionHandle; … … 1202 1202 } 1203 1203 1204 void WebPageProxy::dragUpdated(DragData *dragData, const String& dragStorageName)1204 void WebPageProxy::dragUpdated(DragData& dragData, const String& dragStorageName) 1205 1205 { 1206 1206 SandboxExtension::Handle sandboxExtensionHandle; … … 1209 1209 } 1210 1210 1211 void WebPageProxy::dragExited(DragData *dragData, const String& dragStorageName)1211 void WebPageProxy::dragExited(DragData& dragData, const String& dragStorageName) 1212 1212 { 1213 1213 SandboxExtension::Handle sandboxExtensionHandle; … … 1216 1216 } 1217 1217 1218 void WebPageProxy::performDrag(DragData *dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)1218 void WebPageProxy::performDrag(DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload) 1219 1219 { 1220 1220 performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload); 1221 1221 } 1222 1222 1223 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData *dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)1223 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload) 1224 1224 { 1225 1225 if (!isValid()) 1226 1226 return; 1227 1227 #if PLATFORM(GTK) 1228 m_process->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID);1228 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID); 1229 1229 #else 1230 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData ->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);1230 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID); 1231 1231 #endif 1232 1232 } -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r156924 r157058 575 575 #if ENABLE(DRAG_SUPPORT) 576 576 // Drag and drop support. 577 void dragEntered(WebCore::DragData *, const String& dragStorageName = String());578 void dragUpdated(WebCore::DragData *, const String& dragStorageName = String());579 void dragExited(WebCore::DragData *, const String& dragStorageName = String());580 void performDrag(WebCore::DragData *, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);577 void dragEntered(WebCore::DragData&, const String& dragStorageName = String()); 578 void dragUpdated(WebCore::DragData&, const String& dragStorageName = String()); 579 void dragExited(WebCore::DragData&, const String& dragStorageName = String()); 580 void performDrag(WebCore::DragData&, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&); 581 581 582 582 void didPerformDragControllerAction(WebCore::DragSession); … … 1016 1016 void clearLoadDependentCallbacks(); 1017 1017 1018 void performDragControllerAction(DragControllerAction, WebCore::DragData *, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);1018 void performDragControllerAction(DragControllerAction, WebCore::DragData&, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&); 1019 1019 1020 1020 void updateBackingStoreDiscardableState(); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
r156847 r157058 35 35 namespace WebKit { 36 36 37 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData *)37 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData&) 38 38 { 39 39 if (action == DragDestinationActionLoad) … … 43 43 } 44 44 45 void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard *)45 void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) 46 46 { 47 47 } 48 48 49 DragDestinationAction WebDragClient::actionMaskForDrag(DragData *)49 DragDestinationAction WebDragClient::actionMaskForDrag(DragData&) 50 50 { 51 51 return DragDestinationActionAny; 52 52 } 53 53 54 DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& /*windowPoint*/)54 DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&) 55 55 { 56 56 return DragSourceActionAny; … … 58 58 59 59 #if !PLATFORM(MAC) && !PLATFORM(GTK) 60 void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard *, Frame*, bool)60 void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool) 61 61 { 62 62 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
r117695 r157058 43 43 44 44 private: 45 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData *) OVERRIDE;46 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard *) OVERRIDE;47 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData *) OVERRIDE;45 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&) OVERRIDE; 46 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&) OVERRIDE; 47 virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&) OVERRIDE; 48 48 virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) OVERRIDE; 49 49 50 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard *, WebCore::Frame*, bool linkDrag = false) OVERRIDE;50 virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false) OVERRIDE; 51 51 52 52 #if PLATFORM(MAC) 53 virtual void declareAndWriteDragImage(const String& pasteboardName, DOMElement*, NSURL*, NSString*, WebCore::Frame*) OVERRIDE;53 virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) OVERRIDE; 54 54 #endif 55 55 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
r156700 r157058 57 57 } 58 58 59 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, Clipboard * clipboard, Frame*, bool)59 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, Clipboard& clipboard, Frame&, bool) 60 60 { 61 61 RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage); … … 66 66 return; 67 67 68 RefPtr<DataObjectGtk> dataObject = clipboard ->pasteboard().dataObject();69 DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard ->sourceOperation());68 RefPtr<DataObjectGtk> dataObject = clipboard.pasteboard().dataObject(); 69 DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard.sourceOperation()); 70 70 m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle)); 71 71 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r156688 r157058 77 77 } 78 78 79 void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard *, Frame*frame, bool linkDrag)79 void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard&, Frame& frame, bool linkDrag) 80 80 { 81 81 IntSize bitmapSize([image.get() size]); 82 bitmapSize.scale(frame ->page()->deviceScaleFactor());82 bitmapSize.scale(frame.page()->deviceScaleFactor()); 83 83 RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize); 84 84 ShareableBitmap::Handle handle; … … 87 87 88 88 // FIXME: Seems this message should be named StartDrag, not SetDragImage. 89 m_page->send(Messages::WebPageProxy::SetDragImage(frame ->view()->contentsToWindow(point), handle, linkDrag));89 m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, linkDrag)); 90 90 } 91 91 92 static WebCore::CachedImage* cachedImage(Element *element)92 static WebCore::CachedImage* cachedImage(Element& element) 93 93 { 94 RenderObject* renderer = element ->renderer();94 RenderObject* renderer = element.renderer(); 95 95 if (!renderer) 96 96 return 0; … … 103 103 } 104 104 105 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*)105 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*) 106 106 { 107 ASSERT(element);108 107 ASSERT(pasteboardName == String(NSDragPboard)); 109 108 110 Element* coreElement = core(element);109 WebCore::CachedImage* image = cachedImage(element); 111 110 112 WebCore::CachedImage* image = cachedImage(coreElement); 113 114 NSString *extension = @""; 111 String extension; 115 112 if (image) { 116 113 extension = image->image()->filenameExtension(); 117 if ( ![extension length])114 if (extension.isEmpty()) 118 115 return; 119 116 } 120 117 121 if (![title length]) { 122 title = [[URL path] lastPathComponent]; 123 if (![title length]) 124 title = [URL _web_userVisibleString]; 118 String title = label; 119 if (title.isEmpty()) { 120 title = url.lastPathComponent(); 121 if (title.isEmpty()) 122 title = [(NSURL *)url _web_userVisibleString]; 125 123 } 126 124 127 RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create( coreElement);125 RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&element); 128 126 129 127 NSURLResponse *response = image->response().nsURLResponse(); … … 147 145 sharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly); 148 146 } 149 m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), String(extension), String(title), String([[response URL] absoluteString]), String([URL_web_userVisibleString]), archiveHandle, archiveSize));147 m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), String([(NSURL *)url _web_userVisibleString]), archiveHandle, archiveSize)); 150 148 } 151 149 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r156924 r157058 2541 2541 switch (action) { 2542 2542 case DragControllerActionEntered: 2543 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered( &dragData)));2543 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(dragData))); 2544 2544 break; 2545 2545 2546 2546 case DragControllerActionUpdated: 2547 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated( &dragData)));2547 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(dragData))); 2548 2548 break; 2549 2549 2550 2550 case DragControllerActionExited: 2551 m_page->dragController().dragExited( &dragData);2551 m_page->dragController().dragExited(dragData); 2552 2552 break; 2553 2553 2554 2554 case DragControllerActionPerformDrag: { 2555 m_page->dragController().performDrag( &dragData);2555 m_page->dragController().performDrag(dragData); 2556 2556 break; 2557 2557 } … … 2576 2576 switch (action) { 2577 2577 case DragControllerActionEntered: 2578 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered( &dragData)));2578 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(dragData))); 2579 2579 break; 2580 2580 2581 2581 case DragControllerActionUpdated: 2582 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated( &dragData)));2582 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(dragData))); 2583 2583 break; 2584 2584 2585 2585 case DragControllerActionExited: 2586 m_page->dragController().dragExited( &dragData);2586 m_page->dragController().dragExited(dragData); 2587 2587 break; 2588 2588 … … 2596 2596 } 2597 2597 2598 m_page->dragController().performDrag( &dragData);2598 m_page->dragController().performDrag(dragData); 2599 2599 2600 2600 // If we started loading a local file, the sandbox extension tracker would have adopted this
Note: See TracChangeset
for help on using the changeset viewer.