diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 23:24:58 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 23:24:58 +0000 |
commit | e80c73be12cc2211d5a72a5ff85eb97366b2458f (patch) | |
tree | 5c395779776b368ed6cafdbc5c6bc929776c18a4 /webkit/glue/webview_impl.cc | |
parent | 25a3f6b52228bc68ce63c4032ed6b17cecd7b3c5 (diff) | |
download | chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.zip chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.gz chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.bz2 |
Switch to using WebDragData in WebView and WebViewDelegate.
I also cleaned up some of the WebView and WebViewDelegate methods to pass
WebPoint instead of pairs of ints or gfx::Point.
With this change, I am keeping webkit/glue/webdropdata.{h,cc}, which is what
Chrome uses to pass around the equivalent data. Now, it is possible to
construct a WebDropData from a WebKit::WebDragData and to also get a
WebKit::WebDragData from a WebDropData. Hence, the conversion between
WebDropData and ChromiumDataObject (see clipboard_conversion.{h,cc}) is now
removed in favor of conversion between WebDropData and WebKit::WebDragData.
Conversion between WebKit::WebDragData and WebCore::ChromiumDataObject is very
cheap (just reference counting).
Finally, this change also brings in WebData, which is now used by the return
value of WebKitClient::loadResource. As a companion to that change, I also
changed webkit_glue::GetDataResource to return StringPiece instead of
std::string. That also saves on an unnecessary buffer copy.
R=dglazkov
Review URL: http://codereview.chromium.org/63084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r-- | webkit/glue/webview_impl.cc | 85 |
1 files changed, 54 insertions, 31 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 6860e09..408246b 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -84,9 +84,10 @@ MSVC_POP_WARNING(); #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "webkit/glue/chrome_client_impl.h" -#include "webkit/glue/clipboard_conversion.h" #include "webkit/glue/context_menu_client_impl.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dragclient_impl.h" @@ -114,10 +115,12 @@ MSVC_POP_WARNING(); using namespace WebCore; +using WebKit::WebDragData; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; +using WebKit::WebPoint; // Change the text zoom level by kTextSizeMultiplierRatio each time the user // zooms text in or out (ie., change by 20%). The min and max values limit @@ -1554,18 +1557,20 @@ void WebViewImpl::ShowJavaScriptConsole() { } void WebViewImpl::DragSourceEndedAt( - int client_x, int client_y, int screen_x, int screen_y) { - PlatformMouseEvent pme(IntPoint(client_x, client_y), - IntPoint(screen_x, screen_y), + const WebPoint& client_point, + const WebPoint& screen_point) { + PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), NoButton, MouseEventMoved, 0, false, false, false, false, 0); page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationCopy); } void WebViewImpl::DragSourceMovedTo( - int client_x, int client_y, int screen_x, int screen_y) { - PlatformMouseEvent pme(IntPoint(client_x, client_y), - IntPoint(screen_x, screen_y), + const WebPoint& client_point, + const WebPoint& screen_point) { + PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), LeftButton, MouseEventMoved, 0, false, false, false, false, 0); page_->mainFrame()->eventHandler()->dragSourceMovedTo(pme); @@ -1577,15 +1582,22 @@ void WebViewImpl::DragSourceSystemDragEnded() { doing_drag_and_drop_ = false; } -bool WebViewImpl::DragTargetDragEnter(const WebDropData& drop_data, - int client_x, int client_y, int screen_x, int screen_y) { - DCHECK(!current_drop_data_.get()); +bool WebViewImpl::DragTargetDragEnter( + const WebDragData& web_drag_data, + int identity, + const WebPoint& client_point, + const WebPoint& screen_point) { + DCHECK(!current_drag_data_.get()); - current_drop_data_ = webkit_glue::WebDropDataToChromiumDataObject(drop_data); - drag_identity_ = drop_data.identity; + current_drag_data_ = + webkit_glue::WebDragDataToChromiumDataObject(web_drag_data); + drag_identity_ = identity; - DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y), - IntPoint(screen_x, screen_y), kDropTargetOperation); + DragData drag_data( + current_drag_data_.get(), + webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), + kDropTargetOperation); drag_target_dispatch_ = true; DragOperation effect = page_->dragController()->dragEntered(&drag_data); drag_target_dispatch_ = false; @@ -1594,11 +1606,15 @@ bool WebViewImpl::DragTargetDragEnter(const WebDropData& drop_data, } bool WebViewImpl::DragTargetDragOver( - int client_x, int client_y, int screen_x, int screen_y) { - DCHECK(current_drop_data_.get()); - - DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y), - IntPoint(screen_x, screen_y), kDropTargetOperation); + const WebPoint& client_point, + const WebPoint& screen_point) { + DCHECK(current_drag_data_.get()); + + DragData drag_data( + current_drag_data_.get(), + webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), + kDropTargetOperation); drag_target_dispatch_ = true; DragOperation effect = page_->dragController()->dragUpdated(&drag_data); drag_target_dispatch_ = false; @@ -1607,29 +1623,36 @@ bool WebViewImpl::DragTargetDragOver( } void WebViewImpl::DragTargetDragLeave() { - DCHECK(current_drop_data_.get()); + DCHECK(current_drag_data_.get()); - DragData drag_data(current_drop_data_.get(), IntPoint(), IntPoint(), - DragOperationNone); + DragData drag_data( + current_drag_data_.get(), + IntPoint(), + IntPoint(), + kDropTargetOperation); drag_target_dispatch_ = true; page_->dragController()->dragExited(&drag_data); drag_target_dispatch_ = false; - current_drop_data_ = NULL; + current_drag_data_ = NULL; drag_identity_ = 0; } void WebViewImpl::DragTargetDrop( - int client_x, int client_y, int screen_x, int screen_y) { - DCHECK(current_drop_data_.get()); - - DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y), - IntPoint(screen_x, screen_y), kDropTargetOperation); + const WebPoint& client_point, + const WebPoint& screen_point) { + DCHECK(current_drag_data_.get()); + + DragData drag_data( + current_drag_data_.get(), + webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), + kDropTargetOperation); drag_target_dispatch_ = true; page_->dragController()->performDrag(&drag_data); drag_target_dispatch_ = false; - current_drop_data_ = NULL; + current_drag_data_ = NULL; drag_identity_ = 0; } @@ -1738,11 +1761,11 @@ void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { observed_new_navigation_ = false; } -void WebViewImpl::StartDragging(const WebDropData& drop_data) { +void WebViewImpl::StartDragging(const WebDragData& drag_data) { if (delegate_) { DCHECK(!doing_drag_and_drop_); doing_drag_and_drop_ = true; - delegate_->StartDragging(this, drop_data); + delegate_->StartDragging(this, drag_data); } } |