Eliminate DragSession structure
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Apr 2014 17:33:29 +0000 (17:33 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Apr 2014 17:33:29 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131465

Reviewed by Benjamin Poulain.

Source/WebCore:

DragSession is really just a transient response to NSDragDestination delegate methods.
The "session" name was quite misleading, and thankfully, we don't need a class for this
bag of data at all.

* WebCore.xcodeproj/project.pbxproj:
* page/DragController.cpp:
(WebCore::DragController::DragController):
(WebCore::DragController::dragEntered):
(WebCore::DragController::dragUpdated):
(WebCore::DragController::dragEnteredOrUpdated):
(WebCore::DragController::tryDocumentDrag):
* page/DragController.h:
(WebCore::DragController::mouseIsOverFileInput):
(WebCore::DragController::numberOfItemsToBeAccepted):
* page/DragSession.h: Removed.

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView draggingEntered:]):
(-[WebView draggingUpdated:]):

Source/WebKit/win:

* WebView.cpp:
(WebView::DragEnter):
(WebView::DragOver):

Source/WebKit2:

* Scripts/webkit2/messages.py:
(struct_or_class):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DragSession>::encode): Deleted.
(IPC::ArgumentCoder<DragSession>::decode): Deleted.
* Shared/WebCoreArgumentCoders.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView draggingEntered:]):
(-[WKView draggingUpdated:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::didPerformDragControllerAction):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::currentDragOperation):
(WebKit::WebPageProxy::currentDragIsOverFileInput):
(WebKit::WebPageProxy::currentDragNumberOfFilesToBeAccepted):
(WebKit::WebPageProxy::resetCurrentDragInformation):
(WebKit::WebPageProxy::dragSession): Deleted.
(WebKit::WebPageProxy::resetDragSession): Deleted.
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167074 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/page/DragSession.h [deleted file]
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 5cb1721..d14168e 100644 (file)
@@ -1,3 +1,26 @@
+2014-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Eliminate DragSession structure
+        https://bugs.webkit.org/show_bug.cgi?id=131465
+
+        Reviewed by Benjamin Poulain.
+
+        DragSession is really just a transient response to NSDragDestination delegate methods.
+        The "session" name was quite misleading, and thankfully, we don't need a class for this
+        bag of data at all.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/DragController.cpp:
+        (WebCore::DragController::DragController):
+        (WebCore::DragController::dragEntered):
+        (WebCore::DragController::dragUpdated):
+        (WebCore::DragController::dragEnteredOrUpdated):
+        (WebCore::DragController::tryDocumentDrag):
+        * page/DragController.h:
+        (WebCore::DragController::mouseIsOverFileInput):
+        (WebCore::DragController::numberOfItemsToBeAccepted):
+        * page/DragSession.h: Removed.
+
 2014-04-10  Youenn Fablet  <youenn.fablet@crf.canon.fr>
 
         [GStreamer] No CORS support for media elements
index fd8eafc..6ad097c 100644 (file)
                31611E610E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 31611E5E0E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h */; };
                31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31611E5F0E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm */; };
                31611E630E1C4E1400F6A579 /* DOMWebKitCSSTransformValueInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 31611E600E1C4E1400F6A579 /* DOMWebKitCSSTransformValueInternal.h */; };
-               3169379C14609C6C00C01362 /* DragSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 3169379A14609C5B00C01362 /* DragSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
                316FE0710E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.cpp */; };
                316FE0720E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.h */; };
                316FE0730E6CCBEE00BF6088 /* JSWebKitCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06F0E6CCBEE00BF6088 /* JSWebKitCSSKeyframesRule.cpp */; };
                31611E5E0E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitCSSTransformValue.h; sourceTree = "<group>"; };
                31611E5F0E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMWebKitCSSTransformValue.mm; sourceTree = "<group>"; };
                31611E600E1C4E1400F6A579 /* DOMWebKitCSSTransformValueInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitCSSTransformValueInternal.h; sourceTree = "<group>"; };
-               3169379A14609C5B00C01362 /* DragSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragSession.h; sourceTree = "<group>"; };
                316FE06D0E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSKeyframeRule.cpp; sourceTree = "<group>"; };
                316FE06E0E6CCBEE00BF6088 /* JSWebKitCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitCSSKeyframeRule.h; sourceTree = "<group>"; };
                316FE06F0E6CCBEE00BF6088 /* JSWebKitCSSKeyframesRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSKeyframesRule.cpp; sourceTree = "<group>"; };
                                A7CA59620B27C1F200FA021D /* DragClient.h */,
                                A7CA595C0B27BD9E00FA021D /* DragController.cpp */,
                                A7CA595B0B27BD9E00FA021D /* DragController.h */,
-                               3169379A14609C5B00C01362 /* DragSession.h */,
                                81F65FF513788FAA00FF6F2D /* DragState.h */,
                                1AF326770D78B9440068F0C4 /* EditorClient.h */,
                                93C09A800B064F00005ABD4D /* EventHandler.cpp */,
                                A7CA595D0B27BD9E00FA021D /* DragController.h in Headers */,
                                A7B6E69F0B291A9600D0529F /* DragData.h in Headers */,
                                A7CFB3D20B7ED10A0070C32D /* DragImage.h in Headers */,
-                               3169379C14609C6C00C01362 /* DragSession.h in Headers */,
                                81F65FF613788FAA00FF6F2D /* DragState.h in Headers */,
                                498770DC1242C535002226BA /* DrawingBuffer.h in Headers */,
                                E1BA66F11742BD8600C20251 /* DynamicLinkerInterposing.h in Headers */,
index 1cfde4a..8ade565 100644 (file)
@@ -37,7 +37,6 @@
 #include "DragClient.h"
 #include "DragData.h"
 #include "DragImage.h"
-#include "DragSession.h"
 #include "DragState.h"
 #include "Editor.h"
 #include "EditorClient.h"
@@ -101,9 +100,7 @@ static PlatformMouseEvent createMouseEvent(DragData& dragData)
 DragController::DragController(Page& page, DragClient& client)
     : m_page(page)
     , m_client(client)
-    , m_documentUnderMouse(0)
-    , m_dragInitiator(0)
-    , m_fileInputElementUnderMouse(0)
+    , m_numberOfItemsToBeAccepted(0)
     , m_documentIsHandlingDrag(false)
     , m_dragDestinationAction(DragDestinationActionNone)
     , m_dragSourceAction(DragSourceActionNone)
@@ -176,7 +173,7 @@ void DragController::dragEnded()
     m_client.dragEnded();
 }
 
-DragSession DragController::dragEntered(DragData& dragData)
+DragOperation DragController::dragEntered(DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
@@ -196,7 +193,7 @@ void DragController::dragExited(DragData& dragData)
     m_fileInputElementUnderMouse = 0;
 }
 
-DragSession DragController::dragUpdated(DragData& dragData)
+DragOperation DragController::dragUpdated(DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
@@ -247,21 +244,21 @@ void DragController::mouseMovedIntoDocument(Document* newDocument)
     m_documentUnderMouse = newDocument;
 }
 
-DragSession DragController::dragEnteredOrUpdated(DragData& dragData)
+DragOperation DragController::dragEnteredOrUpdated(DragData& dragData)
 {
     mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData.clientPosition()));
 
     m_dragDestinationAction = m_client.actionMaskForDrag(dragData);
     if (m_dragDestinationAction == DragDestinationActionNone) {
         cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)?
-        return DragSession();
+        return DragOperationNone;
     }
 
-    DragSession dragSession;
-    m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction, dragSession);
+    DragOperation dragOperation = DragOperationNone;
+    m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction, dragOperation);
     if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationActionLoad))
-        dragSession.operation = operationForLoad(dragData);
-    return dragSession;
+        dragOperation = operationForLoad(dragData);
+    return dragOperation;
 }
 
 static HTMLInputElement* asFileInput(Node* node)
@@ -297,7 +294,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
     return toElement(n);
 }
 
-bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction actionMask, DragSession& dragSession)
+bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation)
 {
     if (!m_documentUnderMouse)
         return false;
@@ -307,7 +304,7 @@ bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction a
 
     bool isHandlingDrag = false;
     if (actionMask & DragDestinationActionDHTML) {
-        isHandlingDrag = tryDHTMLDrag(dragData, dragSession.operation);
+        isHandlingDrag = tryDHTMLDrag(dragData, dragOperation);
         // Do not continue if m_documentUnderMouse has been reset by tryDHTMLDrag.
         // tryDHTMLDrag fires dragenter event. The event listener that listens
         // to this event may create a nested message loop (open a modal dialog),
@@ -330,7 +327,7 @@ bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction a
 
     if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) {
         if (dragData.containsColor()) {
-            dragSession.operation = DragOperationGeneric;
+            dragOperation = DragOperationGeneric;
             return true;
         }
 
@@ -350,28 +347,27 @@ bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction a
             m_page.dragCaretController().setCaretPosition(m_documentUnderMouse->frame()->visiblePositionForPoint(point));
 
         Frame* innerFrame = element->document().frame();
-        dragSession.operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
-        dragSession.mouseIsOverFileInput = m_fileInputElementUnderMouse;
-        dragSession.numberOfItemsToBeAccepted = 0;
+        dragOperation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
+        m_numberOfItemsToBeAccepted = 0;
 
         unsigned numberOfFiles = dragData.numberOfFiles();
         if (m_fileInputElementUnderMouse) {
             if (m_fileInputElementUnderMouse->isDisabledFormControl())
-                dragSession.numberOfItemsToBeAccepted = 0;
+                m_numberOfItemsToBeAccepted = 0;
             else if (m_fileInputElementUnderMouse->multiple())
-                dragSession.numberOfItemsToBeAccepted = numberOfFiles;
+                m_numberOfItemsToBeAccepted = numberOfFiles;
             else if (numberOfFiles > 1)
-                dragSession.numberOfItemsToBeAccepted = 0;
+                m_numberOfItemsToBeAccepted = 0;
             else
-                dragSession.numberOfItemsToBeAccepted = 1;
+                m_numberOfItemsToBeAccepted = 1;
             
-            if (!dragSession.numberOfItemsToBeAccepted)
-                dragSession.operation = DragOperationNone;
-            m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(dragSession.numberOfItemsToBeAccepted);
+            if (!m_numberOfItemsToBeAccepted)
+                dragOperation = DragOperationNone;
+            m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(m_numberOfItemsToBeAccepted);
         } else {
             // We are not over a file input element. The dragged item(s) will only
             // be loaded into the view the number of dragged items is 1.
-            dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1;
+            m_numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1;
         }
         
         return true;
index e371050..47e3cc9 100644 (file)
@@ -45,7 +45,6 @@ namespace WebCore {
     class Page;
     class PlatformMouseEvent;
 
-    struct DragSession;
     struct DragState;
 
     class DragController {
@@ -58,11 +57,14 @@ namespace WebCore {
 
         DragClient& client() const { return m_client; }
 
-        DragSession dragEntered(DragData&);
+        DragOperation dragEntered(DragData&);
         void dragExited(DragData&);
-        DragSession dragUpdated(DragData&);
+        DragOperation dragUpdated(DragData&);
         bool performDragOperation(DragData&);
-        
+
+        bool mouseIsOverFileInput() const { return m_fileInputElementUnderMouse; }
+        unsigned numberOfItemsToBeAccepted() const { return m_numberOfItemsToBeAccepted; }
+
         // FIXME: It should be possible to remove a number of these accessors once all
         // drag logic is in WebCore.
         void setDidInitiateDrag(bool initiated) { m_didInitiateDrag = initiated; } 
@@ -95,9 +97,9 @@ namespace WebCore {
         bool dispatchTextInputEventFor(Frame*, DragData&);
         bool canProcessDrag(DragData&);
         bool concludeEditDrag(DragData&);
-        DragSession dragEnteredOrUpdated(DragData&);
+        DragOperation dragEnteredOrUpdated(DragData&);
         DragOperation operationForLoad(DragData&);
-        bool tryDocumentDrag(DragData&, DragDestinationAction, DragSession&);
+        bool tryDocumentDrag(DragData&, DragDestinationAction, DragOperation&);
         bool tryDHTMLDrag(DragData&, DragOperation&);
         DragOperation dragOperation(DragData&);
         void cancelDrag();
@@ -117,6 +119,7 @@ namespace WebCore {
         RefPtr<Document> m_documentUnderMouse; // The document the mouse was last dragged over.
         RefPtr<Document> m_dragInitiator; // The Document (if any) that initiated the drag.
         RefPtr<HTMLInputElement> m_fileInputElementUnderMouse;
+        unsigned m_numberOfItemsToBeAccepted;
         bool m_documentIsHandlingDrag;
 
         DragDestinationAction m_dragDestinationAction;
diff --git a/Source/WebCore/page/DragSession.h b/Source/WebCore/page/DragSession.h
deleted file mode 100644 (file)
index 002ccd3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef DragSession_h
-#define DragSession_h
-
-#include "DragActions.h"
-
-namespace WebCore {
-    
-struct DragSession {
-    DragOperation operation;
-    bool mouseIsOverFileInput;
-    unsigned numberOfItemsToBeAccepted;
-
-    DragSession()
-        : operation(DragOperationNone)
-        , mouseIsOverFileInput(false)
-        , numberOfItemsToBeAccepted(0)
-    {
-    }
-};
-
-}
-
-#endif
index 8e7f49a..8529ed5 100644 (file)
@@ -1,5 +1,16 @@
 2014-04-09  Alexey Proskuryakov  <ap@apple.com>
 
+        Eliminate DragSession structure
+        https://bugs.webkit.org/show_bug.cgi?id=131465
+
+        Reviewed by Benjamin Poulain.
+
+        * WebView/WebView.mm:
+        (-[WebView draggingEntered:]):
+        (-[WebView draggingUpdated:]):
+
+2014-04-09  Alexey Proskuryakov  <ap@apple.com>
+
         Rename some dragging functions
         https://bugs.webkit.org/show_bug.cgi?id=131460
 
index 05638fd..08471cc 100644 (file)
 #import <WebCore/DocumentLoader.h>
 #import <WebCore/DragController.h>
 #import <WebCore/DragData.h>
-#import <WebCore/DragSession.h>
 #import <WebCore/Editor.h>
 #import <WebCore/EventHandler.h>
 #import <WebCore/ExceptionHandlers.h>
@@ -5980,7 +5979,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    return core(self)->dragController().dragEntered(dragData).operation;
+    return core(self)->dragController().dragEntered(dragData);
 }
 
 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
@@ -5992,7 +5991,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    return page->dragController().dragUpdated(dragData).operation;
+    return page->dragController().dragUpdated(dragData);
 }
 
 - (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
index 3725081..543a909 100644 (file)
@@ -1,5 +1,16 @@
 2014-04-09  Alexey Proskuryakov  <ap@apple.com>
 
+        Eliminate DragSession structure
+        https://bugs.webkit.org/show_bug.cgi?id=131465
+
+        Reviewed by Benjamin Poulain.
+
+        * WebView.cpp:
+        (WebView::DragEnter):
+        (WebView::DragOver):
+
+2014-04-09  Alexey Proskuryakov  <ap@apple.com>
+
         Rename some dragging functions
         https://bugs.webkit.org/show_bug.cgi?id=131460
 
index 608b2ad..14fa428 100644 (file)
@@ -85,7 +85,6 @@
 #include <WebCore/DocumentMarkerController.h>
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
-#include <WebCore/DragSession.h>
 #include <WebCore/Editor.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/EventNames.h>
@@ -5246,7 +5245,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragEnter(
     ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
     DragData data(pDataObject, IntPoint(localpt.x, localpt.y), 
         IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
-    *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(data).operation);
+    *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(data));
 
     m_lastDropEffect = *pdwEffect;
     m_dragData = pDataObject;
@@ -5265,7 +5264,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragOver(
         ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
         DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), 
             IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
-        *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(data).operation);
+        *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(data));
     } else
         *pdwEffect = DROPEFFECT_NONE;
 
index 1a28eb5..a645ded 100644 (file)
@@ -1,3 +1,33 @@
+2014-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Eliminate DragSession structure
+        https://bugs.webkit.org/show_bug.cgi?id=131465
+
+        Reviewed by Benjamin Poulain.
+
+        * Scripts/webkit2/messages.py:
+        (struct_or_class):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DragSession>::encode): Deleted.
+        (IPC::ArgumentCoder<DragSession>::decode): Deleted.
+        * Shared/WebCoreArgumentCoders.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView draggingEntered:]):
+        (-[WKView draggingUpdated:]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::didPerformDragControllerAction):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::currentDragOperation):
+        (WebKit::WebPageProxy::currentDragIsOverFileInput):
+        (WebKit::WebPageProxy::currentDragNumberOfFilesToBeAccepted):
+        (WebKit::WebPageProxy::resetCurrentDragInformation):
+        (WebKit::WebPageProxy::dragSession): Deleted.
+        (WebKit::WebPageProxy::resetDragSession): Deleted.
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction):
+
 2014-04-10  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] LayerTreeHostGtk is creating a software scene graph
index 8e046c8..3c6359f 100644 (file)
@@ -172,7 +172,6 @@ def struct_or_class(namespace, type):
         'WebCore::EditorCommandsForKeyEvent',
         'WebCore::CompositionUnderline',
         'WebCore::Cookie',
-        'WebCore::DragSession',
         'WebCore::FloatPoint3D',
         'WebCore::FileChooserSettings',
         'WebCore::GrammarDetail',
index ce28414..a7a3151 100644 (file)
@@ -35,7 +35,6 @@
 #include <WebCore/Cursor.h>
 #include <WebCore/DatabaseDetails.h>
 #include <WebCore/DictationAlternative.h>
-#include <WebCore/DragSession.h>
 #include <WebCore/Editor.h>
 #include <WebCore/FileChooser.h>
 #include <WebCore/FilterOperation.h>
@@ -1310,24 +1309,6 @@ bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextChe
     return true;
 }
 
-void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result)
-{
-    encoder.encodeEnum(result.operation);
-    encoder << result.mouseIsOverFileInput;
-    encoder << result.numberOfItemsToBeAccepted;
-}
-
-bool ArgumentCoder<DragSession>::decode(ArgumentDecoder& decoder, DragSession& result)
-{
-    if (!decoder.decodeEnum(result.operation))
-        return false;
-    if (!decoder.decode(result.mouseIsOverFileInput))
-        return false;
-    if (!decoder.decode(result.numberOfItemsToBeAccepted))
-        return false;
-    return true;
-}
-
 void ArgumentCoder<URL>::encode(ArgumentEncoder& encoder, const URL& result)
 {
     encoder << result.string();
index ba3e7b5..f61b1f8 100644 (file)
@@ -67,7 +67,6 @@ class URL;
 struct CompositionUnderline;
 struct Cookie;
 struct DictationAlternative;
-struct DragSession;
 struct FileChooserSettings;
 struct IDBDatabaseMetadata;
 struct IDBGetResult;
@@ -339,11 +338,6 @@ template<> struct ArgumentCoder<WebCore::TextCheckingResult> {
     static bool decode(ArgumentDecoder&, WebCore::TextCheckingResult&);
 };
     
-template<> struct ArgumentCoder<WebCore::DragSession> {
-    static void encode(ArgumentEncoder&, const WebCore::DragSession&);
-    static bool decode(ArgumentDecoder&, WebCore::DragSession&);
-};
-
 template<> struct ArgumentCoder<WebCore::URL> {
     static void encode(ArgumentEncoder&, const WebCore::URL&);
     static bool decode(ArgumentDecoder&, WebCore::URL&);
index ccdd0c8..162f428 100644 (file)
@@ -78,7 +78,6 @@
 #import <WebCore/ColorMac.h>
 #import <WebCore/DragController.h>
 #import <WebCore/DragData.h>
-#import <WebCore/DragSession.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/Image.h>
 #import <WebCore/IntRect.h>
@@ -2237,7 +2236,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
 
-    _data->_page->resetDragSession();
+    _data->_page->resetCurrentDragInformation();
     _data->_page->dragEntered(dragData, [[draggingInfo draggingPasteboard] name]);
     return NSDragOperationCopy;
 }
@@ -2249,10 +2248,9 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     _data->_page->dragUpdated(dragData, [[draggingInfo draggingPasteboard] name]);
     
-    WebCore::DragSession dragSession = _data->_page->dragSession();
-    NSInteger numberOfValidItemsForDrop = dragSession.numberOfItemsToBeAccepted;
+    NSInteger numberOfValidItemsForDrop = _data->_page->currentDragNumberOfFilesToBeAccepted();
     NSDraggingFormation draggingFormation = NSDraggingFormationNone;
-    if (dragSession.mouseIsOverFileInput && numberOfValidItemsForDrop > 0)
+    if (_data->_page->currentDragIsOverFileInput() && numberOfValidItemsForDrop > 0)
         draggingFormation = NSDraggingFormationList;
 
     if ([draggingInfo numberOfValidItemsForDrop] != numberOfValidItemsForDrop)
@@ -2260,7 +2258,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     if ([draggingInfo draggingFormation] != draggingFormation)
         [draggingInfo setDraggingFormation:draggingFormation];
 
-    return dragSession.operation;
+    return _data->_page->currentDragOperation();
 }
 
 - (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
@@ -2269,7 +2267,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     _data->_page->dragExited(dragData, [[draggingInfo draggingPasteboard] name]);
-    _data->_page->resetDragSession();
+    _data->_page->resetCurrentDragInformation();
 }
 
 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
index d74730d..a7bce8c 100644 (file)
@@ -89,7 +89,6 @@
 #include "WebSecurityOrigin.h"
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
-#include <WebCore/DragSession.h>
 #include <WebCore/FloatRect.h>
 #include <WebCore/FocusDirection.h>
 #include <WebCore/MIMETypeRegistry.h>
@@ -320,6 +319,9 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_hasSpellDocumentTag(false)
     , m_pendingLearnOrIgnoreWordMessageCount(0)
     , m_mainFrameHasCustomContentProvider(false)
+    , m_currentDragOperation(DragOperationNone)
+    , m_currentDragIsOverFileInput(false)
+    , m_currentDragNumberOfFilesToBeAccepted(0)
     , m_delegatesScrolling(false)
     , m_mainFrameHasHorizontalScrollbar(false)
     , m_mainFrameHasVerticalScrollbar(false)
@@ -1205,9 +1207,13 @@ void WebPageProxy::performDragControllerAction(DragControllerAction action, Drag
 #endif
 }
 
-void WebPageProxy::didPerformDragControllerAction(WebCore::DragSession dragSession)
+void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted)
 {
-    m_currentDragSession = dragSession;
+    MESSAGE_CHECK(dragOperation <= DragOperationDelete);
+
+    m_currentDragOperation = static_cast<DragOperation>(dragOperation);
+    m_currentDragIsOverFileInput = mouseIsOverFileInput;
+    m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted;
 }
 
 #if PLATFORM(GTK)
index 67202b9..df3b5e0 100644 (file)
@@ -62,7 +62,6 @@
 #include "WebPopupMenuProxy.h"
 #include <WebCore/Color.h>
 #include <WebCore/DragActions.h>
-#include <WebCore/DragSession.h>
 #include <WebCore/HitTestResult.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformScreen.h>
@@ -82,7 +81,6 @@
 
 #if ENABLE(DRAG_SUPPORT)
 #include <WebCore/DragActions.h>
-#include <WebCore/DragSession.h>
 #endif
 
 #if ENABLE(TOUCH_EVENTS)
@@ -853,7 +851,7 @@ public:
     void dragExited(WebCore::DragData&, const String& dragStorageName = String());
     void performDragOperation(WebCore::DragData&, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
 
-    void didPerformDragControllerAction(WebCore::DragSession);
+    void didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted);
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
 #if PLATFORM(COCOA)
     void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag);
@@ -903,8 +901,15 @@ public:
     FrameLoadState::State loadStateAtProcessExit() const { return m_loadStateAtProcessExit; }
 
 #if ENABLE(DRAG_SUPPORT)
-    WebCore::DragSession dragSession() const { return m_currentDragSession; }
-    void resetDragSession() { m_currentDragSession = WebCore::DragSession(); }
+    WebCore::DragOperation currentDragOperation() const { return m_currentDragOperation; }
+    bool currentDragIsOverFileInput() const { return m_currentDragIsOverFileInput; }
+    unsigned currentDragNumberOfFilesToBeAccepted() const { return m_currentDragNumberOfFilesToBeAccepted; }
+    void resetCurrentDragInformation()
+    {
+        m_currentDragOperation = WebCore::DragOperationNone;
+        m_currentDragIsOverFileInput = false;
+        m_currentDragNumberOfFilesToBeAccepted = 0;
+    }
 #endif
 
     void preferencesDidChange();
@@ -1576,7 +1581,11 @@ private:
     bool m_mainFrameHasCustomContentProvider;
 
 #if ENABLE(DRAG_SUPPORT)
-    WebCore::DragSession m_currentDragSession;
+    // Current drag destination details are delivered as an asynchronous response,
+    // so we preserve them to be used when the next dragging delegate call is made.
+    WebCore::DragOperation m_currentDragOperation;
+    bool m_currentDragIsOverFileInput;
+    unsigned m_currentDragNumberOfFilesToBeAccepted;
 #endif
 
     PageLoadState m_pageLoadState;
index 5354e15..0d71241 100644 (file)
@@ -255,7 +255,7 @@ messages -> WebPageProxy {
 
     # Drag and drop messages
 #if ENABLE(DRAG_SUPPORT)
-    DidPerformDragControllerAction(WebCore::DragSession dragSession)
+    DidPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted)
 #endif
 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
     SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
index 2113346..25196b6 100644 (file)
 #include <WebCore/DocumentMarkerController.h>
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
-#include <WebCore/DragSession.h>
 #include <WebCore/ElementIterator.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/FocusController.h>
@@ -2740,7 +2739,7 @@ bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt)
 void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dragData)
 {
     if (!m_page) {
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0));
         DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData());
         data->deref();
         return;
@@ -2776,20 +2775,23 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dra
 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsHandleArray)
 {
     if (!m_page) {
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0));
         return;
     }
 
     DragData dragData(dragStorageName, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
     switch (action) {
-    case DragControllerActionEntered:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(dragData)));
+    case DragControllerActionEntered: {
+        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted()));
         break;
 
-    case DragControllerActionUpdated:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(dragData)));
+    }
+    case DragControllerActionUpdated: {
+        DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted()));
         break;
-        
+    }
     case DragControllerActionExited:
         m_page->dragController().dragExited(dragData);
         break;