Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| diff --git a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| index 26d39f4023ffc31cfd03dc57a06ab91ce218fde8..e5e32c75a54e012bd5b211b8fa945fc9415ebd0f 100644 |
| --- a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| +++ b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| @@ -14,11 +14,26 @@ |
| #include "core/page/Page.h" |
| #include "public/web/WebAutofillClient.h" |
| #include "public/web/WebDocument.h" |
| +#include "public/web/WebWidgetClient.h" |
| #include "web/WebLocalFrameImpl.h" |
| #include "web/WebViewImpl.h" |
| namespace blink { |
| +// Ensure that the WebDragOperation enum values stay in sync with the original |
| +// DragOperation constants. |
| +#define STATIC_ASSERT_ENUM(a, b) \ |
| + static_assert(static_cast<int>(a) == static_cast<int>(b), \ |
| + "mismatching enum : " #a) |
| +STATIC_ASSERT_ENUM(DragOperationNone, WebDragOperationNone); |
| +STATIC_ASSERT_ENUM(DragOperationCopy, WebDragOperationCopy); |
| +STATIC_ASSERT_ENUM(DragOperationLink, WebDragOperationLink); |
| +STATIC_ASSERT_ENUM(DragOperationGeneric, WebDragOperationGeneric); |
| +STATIC_ASSERT_ENUM(DragOperationPrivate, WebDragOperationPrivate); |
| +STATIC_ASSERT_ENUM(DragOperationMove, WebDragOperationMove); |
| +STATIC_ASSERT_ENUM(DragOperationDelete, WebDragOperationDelete); |
| +STATIC_ASSERT_ENUM(DragOperationEvery, WebDragOperationEvery); |
| + |
| WebDragOperation WebFrameWidgetBase::dragTargetDragEnter( |
| const WebDragData& webDragData, |
| const WebPoint& pointInViewport, |
| @@ -51,12 +66,15 @@ void WebFrameWidgetBase::dragTargetDragLeave() { |
| DragData dragData(m_currentDragData.get(), IntPoint(), IntPoint(), |
| static_cast<DragOperation>(m_operationsAllowed)); |
| - page()->dragController().dragExited(&dragData); |
| + page()->dragController().dragExited(&dragData, localFrameRoot()); |
| // FIXME: why is the drag scroll timer not stopped here? |
| m_dragOperation = WebDragOperationNone; |
| m_currentDragData = nullptr; |
| + |
| + page()->dragController().dragEnded(); |
|
dcheng
2016/11/17 18:02:58
Why does this need to call dragEnded()?
paulmeyer
2016/11/17 20:22:25
Because the state needs to be cleared in DragContr
|
| + m_doingDragAndDrop = false; |
| } |
| void WebFrameWidgetBase::dragTargetDrop(const WebDragData& webDragData, |
| @@ -86,10 +104,13 @@ void WebFrameWidgetBase::dragTargetDrop(const WebDragData& webDragData, |
| DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint, |
| static_cast<DragOperation>(m_operationsAllowed)); |
| - page()->dragController().performDrag(&dragData); |
| + page()->dragController().performDrag(&dragData, localFrameRoot()); |
| m_dragOperation = WebDragOperationNone; |
| m_currentDragData = nullptr; |
| + |
| + page()->dragController().dragEnded(); |
|
dcheng
2016/11/17 18:02:58
Why does this need to call dragEnded() now?
paulmeyer
2016/11/17 20:22:25
See above comment.
dcheng
2016/11/17 20:30:29
How come this Just Worked before?
paulmeyer
2016/11/17 21:14:45
To be honest, I'm not entirely sure. That is, I do
|
| + m_doingDragAndDrop = false; |
| } |
| void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport, |
| @@ -103,19 +124,28 @@ void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport, |
| PlatformEvent::MouseMoved, 0, PlatformEvent::NoModifiers, |
| PlatformMouseEvent::RealOrIndistinguishable, |
| WTF::monotonicallyIncreasingTime()); |
| - page()->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt( |
| + localFrameRoot()->eventHandler().dragSourceEndedAt( |
| pme, static_cast<DragOperation>(operation)); |
| } |
| void WebFrameWidgetBase::dragSourceSystemDragEnded() { |
| // It's possible for us to get this callback while not doing a drag if it's |
| // from a previous page that got unloaded. |
| - if (view()->doingDragAndDrop()) { |
| + if (m_doingDragAndDrop) { |
| page()->dragController().dragEnded(); |
| - view()->setDoingDragAndDrop(false); |
| + m_doingDragAndDrop = false; |
| } |
| } |
| +void WebFrameWidgetBase::startDragging(WebReferrerPolicy policy, |
| + const WebDragData& data, |
| + WebDragOperationsMask mask, |
| + const WebImage& dragImage, |
| + const WebPoint& dragImageOffset) { |
| + m_doingDragAndDrop = true; |
| + client()->startDragging(policy, data, mask, dragImage, dragImageOffset); |
| +} |
| + |
| WebDragOperation WebFrameWidgetBase::dragTargetDragEnterOrOver( |
| const WebPoint& pointInViewport, |
| const WebPoint& screenPoint, |
| @@ -125,12 +155,14 @@ WebDragOperation WebFrameWidgetBase::dragTargetDragEnterOrOver( |
| WebPoint pointInRootFrame(viewportToRootFrame(pointInViewport)); |
| + m_doingDragAndDrop = true; |
| m_currentDragData->setModifiers(modifiers); |
| DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint, |
| static_cast<DragOperation>(m_operationsAllowed)); |
| DragSession dragSession; |
| - dragSession = page()->dragController().dragEnteredOrUpdated(&dragData); |
| + dragSession = page()->dragController().dragEnteredOrUpdated(&dragData, |
| + localFrameRoot()); |
| DragOperation dropEffect = dragSession.operation; |
| @@ -150,6 +182,10 @@ WebPoint WebFrameWidgetBase::viewportToRootFrame( |
| pointInViewport); |
| } |
| +LocalFrame* WebFrameWidgetBase::localFrameRoot() const { |
| + return static_cast<WebLocalFrameImpl*>(localRoot())->frame(); |
|
dcheng
2016/11/17 18:02:58
toCoreFrame(localRoot())
paulmeyer
2016/11/17 20:22:25
Done.
|
| +} |
| + |
| WebViewImpl* WebFrameWidgetBase::view() const { |
| return static_cast<WebLocalFrameImpl*>(localRoot())->viewImpl(); |
| } |