Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1083)

Unified Diff: third_party/WebKit/Source/web/WebFrameWidgetBase.cpp

Issue 2508013002: Drag-and-drop across OOPIFs. (Closed)
Patch Set: Addressed comments by dcheng@. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8b5c9562fd81f2c0c4c137cfab01e3c06bc8e201 100644
--- a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp
+++ b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp
@@ -14,18 +14,35 @@
#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,
const WebPoint& screenPoint,
WebDragOperationsMask operationsAllowed,
int modifiers) {
- DCHECK(!m_currentDragData);
+ // TODO(paulmeyer): DragEnter is received twice when starting a drag in an
+ // OOPIF, which results in |m_currentDragData| being set twice. Once this is
+ // corrected, "DCHECK(!m_currentDragData);" should be added here.
dcheng 2016/11/17 20:30:29 What's causing this to be called twice?
paulmeyer 2016/11/17 21:14:45 Sorry, that's not true anymore. This TODO was in h
m_currentDragData = DataObject::create(webDragData);
m_operationsAllowed = operationsAllowed;
@@ -51,12 +68,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();
+ m_doingDragAndDrop = false;
}
void WebFrameWidgetBase::dragTargetDrop(const WebDragData& webDragData,
@@ -86,10 +106,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();
+ m_doingDragAndDrop = false;
}
void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport,
@@ -103,19 +126,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 +157,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,8 +184,12 @@ WebPoint WebFrameWidgetBase::viewportToRootFrame(
pointInViewport);
}
+LocalFrame* WebFrameWidgetBase::localFrameRoot() const {
+ return toWebLocalFrameImpl(localRoot())->frame();
dcheng 2016/11/17 20:30:29 Nit: the naming here is a bit confusing, we hvae b
paulmeyer 2016/11/17 21:14:45 I had named it in line with the function with the
+}
+
WebViewImpl* WebFrameWidgetBase::view() const {
- return static_cast<WebLocalFrameImpl*>(localRoot())->viewImpl();
+ return toWebLocalFrameImpl(localRoot())->viewImpl();
}
Page* WebFrameWidgetBase::page() const {

Powered by Google App Engine
This is Rietveld 408576698