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..712263043bf018bb187a06b6b449b8c4a8076036 100644 |
| --- a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| +++ b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp |
| @@ -14,11 +14,36 @@ |
| #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 { |
| +namespace { |
| + |
| +// Helper to get LocalFrame* from WebLocalFrame*. |
| +// TODO(dcheng): This should be moved into WebLocalFrame. |
| +LocalFrame* toCoreFrame(WebLocalFrame* frame) { |
| + return toWebLocalFrameImpl(frame)->frame(); |
| +} |
| + |
| +} // namespace |
| + |
| +// 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 +76,15 @@ void WebFrameWidgetBase::dragTargetDragLeave() { |
| DragData dragData(m_currentDragData.get(), IntPoint(), IntPoint(), |
| static_cast<DragOperation>(m_operationsAllowed)); |
| - page()->dragController().dragExited(&dragData); |
| + page()->dragController().dragExited(&dragData, *toCoreFrame(localRoot())); |
| // FIXME: why is the drag scroll timer not stopped here? |
| m_dragOperation = WebDragOperationNone; |
| m_currentDragData = nullptr; |
| + |
| + page()->dragController().dragEnded(); |
| + m_doingDragAndDrop = false; |
| } |
| void WebFrameWidgetBase::dragTargetDrop(const WebDragData& webDragData, |
| @@ -86,10 +114,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, *toCoreFrame(localRoot())); |
| m_dragOperation = WebDragOperationNone; |
| m_currentDragData = nullptr; |
| + |
| + page()->dragController().dragEnded(); |
|
dcheng
2016/11/17 21:58:13
I'm having trouble understanding why the dragEnded
paulmeyer
2016/11/18 01:25:54
Okay, I was able to remove this.
|
| + m_doingDragAndDrop = false; |
| } |
| void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport, |
| @@ -103,19 +134,29 @@ void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport, |
| PlatformEvent::MouseMoved, 0, PlatformEvent::NoModifiers, |
| PlatformMouseEvent::RealOrIndistinguishable, |
| WTF::monotonicallyIncreasingTime()); |
| - page()->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt( |
| - pme, static_cast<DragOperation>(operation)); |
| + toCoreFrame(localRoot()) |
| + ->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 +166,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, *toCoreFrame(localRoot())); |
| DragOperation dropEffect = dragSession.operation; |
| @@ -151,7 +194,7 @@ WebPoint WebFrameWidgetBase::viewportToRootFrame( |
| } |
| WebViewImpl* WebFrameWidgetBase::view() const { |
| - return static_cast<WebLocalFrameImpl*>(localRoot())->viewImpl(); |
| + return toWebLocalFrameImpl(localRoot())->viewImpl(); |
| } |
| Page* WebFrameWidgetBase::page() const { |