summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
commite80c73be12cc2211d5a72a5ff85eb97366b2458f (patch)
tree5c395779776b368ed6cafdbc5c6bc929776c18a4 /webkit/glue
parent25a3f6b52228bc68ce63c4032ed6b17cecd7b3c5 (diff)
downloadchromium_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')
-rw-r--r--webkit/glue/clipboard_conversion.cc78
-rw-r--r--webkit/glue/clipboard_conversion.h28
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc12
-rw-r--r--webkit/glue/dragclient_impl.cc13
-rw-r--r--webkit/glue/feed_preview.cc3
-rw-r--r--webkit/glue/glue.vcproj12
-rw-r--r--webkit/glue/glue_util.cc26
-rw-r--r--webkit/glue/glue_util.h18
-rw-r--r--webkit/glue/webdropdata.cc63
-rw-r--r--webkit/glue/webdropdata.h27
-rw-r--r--webkit/glue/webdropdata_win.cc32
-rw-r--r--webkit/glue/webkit_glue.h3
-rw-r--r--webkit/glue/webkitclient_impl.cc14
-rw-r--r--webkit/glue/webkitclient_impl.h2
-rw-r--r--webkit/glue/webview.h24
-rw-r--r--webkit/glue/webview_delegate.h10
-rw-r--r--webkit/glue/webview_impl.cc85
-rw-r--r--webkit/glue/webview_impl.h24
18 files changed, 260 insertions, 214 deletions
diff --git a/webkit/glue/clipboard_conversion.cc b/webkit/glue/clipboard_conversion.cc
deleted file mode 100644
index 28f191d..0000000
--- a/webkit/glue/clipboard_conversion.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-#include "webkit/glue/clipboard_conversion.h"
-
-#include "build/build_config.h"
-
-#include "ChromiumDataObject.h"
-#include "ClipboardUtilitiesChromium.h"
-#include "KURL.h"
-#include "SharedBuffer.h"
-#include <wtf/Vector.h>
-
-#include "webkit/glue/glue_util.h"
-
-namespace webkit_glue {
-
-WebDropData ChromiumDataObjectToWebDropData(
- WebCore::ChromiumDataObject* data_object) {
- WebDropData drop_data;
- drop_data.url = KURLToGURL(data_object->url);
- drop_data.url_title = StringToStdWString(data_object->urlTitle);
-
- drop_data.file_extension = StringToStdWString(data_object->fileExtension);
-
- for (size_t i = 0; i < data_object->filenames.size(); ++i) {
- drop_data.filenames.push_back(StringToStdWString(
- data_object->filenames[i]));
- }
-
- drop_data.plain_text = StringToStdWString(data_object->plainText);
-
- drop_data.text_html = StringToStdWString(data_object->textHtml);
- drop_data.html_base_url = KURLToGURL(data_object->htmlBaseUrl);
-
- drop_data.file_description_filename = StringToStdWString(
- data_object->fileContentFilename);
- if (data_object->fileContent) {
- drop_data.file_contents.assign(data_object->fileContent->data(),
- data_object->fileContent->size());
- }
-
- return drop_data;
-}
-
-PassRefPtr<WebCore::ChromiumDataObject> WebDropDataToChromiumDataObject(
- const WebDropData& drop_data) {
- RefPtr<WebCore::ChromiumDataObject> data_object =
- WebCore::ChromiumDataObject::create();
- data_object->url = GURLToKURL(drop_data.url);
- data_object->urlTitle = StdWStringToString(drop_data.url_title);
-
- data_object->fileExtension = StdWStringToString(drop_data.file_extension);
-
- for (size_t i = 0; i < drop_data.filenames.size(); ++i) {
- data_object->filenames.append(StdWStringToString(drop_data.filenames[i]));
- }
-
- data_object->plainText = StdWStringToString(drop_data.plain_text);
-
- data_object->textHtml = StdWStringToString(drop_data.text_html);
- data_object->htmlBaseUrl = GURLToKURL(drop_data.html_base_url);
-
- data_object->fileContentFilename = StdWStringToString(
- drop_data.file_description_filename);
- if (!drop_data.file_contents.empty()) {
- data_object->fileContent =
- WebCore::SharedBuffer::create(drop_data.file_contents.data(),
- drop_data.file_contents.size());
- }
-
- return data_object;
-}
-
-} // namespace webkit_glue
diff --git a/webkit/glue/clipboard_conversion.h b/webkit/glue/clipboard_conversion.h
deleted file mode 100644
index d6acd2f..0000000
--- a/webkit/glue/clipboard_conversion.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This file contains helper methods for converting WebDropData objects to
-// WebKit ChromiumDataObject and back.
-#ifndef WEBKIT_GLUE_CLIPBOARD_CONVERSION_H_
-#define WEBKIT_GLUE_CLIPBOARD_CONVERSION_H_
-
-#include "webkit/glue/webdropdata.h"
-
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-class ChromiumDataObject;
-}
-
-namespace webkit_glue {
-
-WebDropData ChromiumDataObjectToWebDropData(
- WebCore::ChromiumDataObject* data_object);
-
-PassRefPtr<WebCore::ChromiumDataObject> WebDropDataToChromiumDataObject(
- const WebDropData& drop_data);
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_GLUE_CLIPBOARD_CONVERSION_H_
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index 4edd3db..6838d5b 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -54,12 +54,12 @@ void DebuggerAgentImpl::SetDocument(Document* document) {
V8Proxy::GetContext(document->frame()));
v8::Context::Scope context_scope(context_);
- std::string basejs = webkit_glue::GetDataResource(IDR_DEVTOOLS_BASE_JS);
- v8::Script::Compile(v8::String::New(basejs.c_str()))->Run();
- std::string jsonjs = webkit_glue::GetDataResource(IDR_DEVTOOLS_JSON_JS);
- v8::Script::Compile(v8::String::New(jsonjs.c_str()))->Run();
- std::string injectjs = webkit_glue::GetDataResource(IDR_DEVTOOLS_INJECT_JS);
- v8::Script::Compile(v8::String::New(injectjs.c_str()))->Run();
+ StringPiece basejs = webkit_glue::GetDataResource(IDR_DEVTOOLS_BASE_JS);
+ v8::Script::Compile(v8::String::New(basejs.as_string().c_str()))->Run();
+ StringPiece jsonjs = webkit_glue::GetDataResource(IDR_DEVTOOLS_JSON_JS);
+ v8::Script::Compile(v8::String::New(jsonjs.as_string().c_str()))->Run();
+ StringPiece injectjs = webkit_glue::GetDataResource(IDR_DEVTOOLS_INJECT_JS);
+ v8::Script::Compile(v8::String::New(injectjs.as_string().c_str()))->Run();
}
String DebuggerAgentImpl::ExecuteUtilityFunction(
diff --git a/webkit/glue/dragclient_impl.cc b/webkit/glue/dragclient_impl.cc
index c3e7865..6547e27 100644
--- a/webkit/glue/dragclient_impl.cc
+++ b/webkit/glue/dragclient_impl.cc
@@ -20,13 +20,15 @@ MSVC_POP_WARNING();
#include "base/logging.h"
#include "base/string_util.h"
-#include "webkit/glue/clipboard_conversion.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
#include "webkit/glue/context_menu.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webview_impl.h"
+using WebKit::WebDragData;
+
void DragClientImpl::willPerformDragDestinationAction(
WebCore::DragDestinationAction,
WebCore::DragData*) {
@@ -60,13 +62,10 @@ void DragClientImpl::startDrag(WebCore::DragImageRef drag_image,
// Add a ref to the frame just in case a load occurs mid-drag.
RefPtr<WebCore::Frame> frame_protector = frame;
- RefPtr<WebCore::ChromiumDataObject> data_object =
- static_cast<WebCore::ClipboardChromium*>(clipboard)->dataObject();
- DCHECK(data_object.get());
- WebDropData drop_data = webkit_glue::ChromiumDataObjectToWebDropData(
- data_object.get());
+ WebDragData drag_data = webkit_glue::ChromiumDataObjectToWebDragData(
+ static_cast<WebCore::ClipboardChromium*>(clipboard)->dataObject());
- webview_->StartDragging(drop_data);
+ webview_->StartDragging(drag_data);
}
WebCore::DragImageRef DragClientImpl::createDragImageForLink(
diff --git a/webkit/glue/feed_preview.cc b/webkit/glue/feed_preview.cc
index 7b2cdedb..11ddf53 100644
--- a/webkit/glue/feed_preview.cc
+++ b/webkit/glue/feed_preview.cc
@@ -34,7 +34,8 @@ static std::string MakeFeedPreview(const std::string& url,
// The feed preview template has {{URL}} in place of where the URL should go.
const std::string kUrlTemplate = "{{URL}}";
- std::string feed_template(webkit_glue::GetDataResource(IDR_FEED_PREVIEW));
+ const std::string& feed_template =
+ webkit_glue::GetDataResource(IDR_FEED_PREVIEW).as_string();
std::string::size_type template_offset = feed_template.find(kUrlTemplate);
DCHECK(template_offset != std::string::npos);
// TODO(evanm): URL-escape URL!
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index 8ba8ddc..f86e41a 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -342,14 +342,6 @@
>
</File>
<File
- RelativePath=".\clipboard_conversion.cc"
- >
- </File>
- <File
- RelativePath=".\clipboard_conversion.h"
- >
- </File>
- <File
RelativePath=".\context_menu_client_impl.cc"
>
</File>
@@ -634,6 +626,10 @@
>
</File>
<File
+ RelativePath=".\webdropdata_win.cc"
+ >
+ </File>
+ <File
RelativePath=".\weberror_impl.cc"
>
</File>
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index 2601970..da506ce 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -15,7 +15,9 @@
#include <string>
+#include "ChromiumDataObject.h"
#include "CString.h"
+#include "IntPoint.h"
#include "IntRect.h"
#include "PlatformString.h"
#include "KURL.h"
@@ -27,6 +29,8 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "googleurl/src/gurl.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
@@ -166,4 +170,26 @@ WebCore::IntRect ToIntRect(const gfx::Rect& r) {
return WebCore::IntRect(r.x(), r.y(), r.width(), r.height());
}
+// Point conversions -----------------------------------------------------------
+
+WebCore::IntPoint WebPointToIntPoint(const WebKit::WebPoint& point) {
+ return point;
+}
+
+WebKit::WebPoint IntPointToWebPoint(const WebCore::IntPoint& point) {
+ return point;
+}
+
+// DragData conversions --------------------------------------------------------
+
+WebKit::WebDragData ChromiumDataObjectToWebDragData(
+ const PassRefPtr<WebCore::ChromiumDataObject>& data) {
+ return data;
+}
+
+PassRefPtr<WebCore::ChromiumDataObject> WebDragDataToChromiumDataObject(
+ const WebKit::WebDragData& data) {
+ return data;
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index 5c9f90b..8f02767 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -11,7 +11,9 @@
class GURL;
namespace WebCore {
+class ChromiumDataObject;
class CString;
+class IntPoint;
class IntRect;
class KURL;
class String;
@@ -19,8 +21,14 @@ class String;
namespace WebKit {
class WebCString;
+class WebDragData;
class WebString;
class WebURL;
+struct WebPoint;
+}
+
+namespace WTF {
+template <typename T> class PassRefPtr;
}
namespace gfx {
@@ -73,6 +81,16 @@ WebCore::KURL WebURLToKURL(const WebKit::WebURL& url);
gfx::Rect FromIntRect(const WebCore::IntRect& r);
WebCore::IntRect ToIntRect(const gfx::Rect& r);
+// WebPoint <-> IntPoint
+WebCore::IntPoint WebPointToIntPoint(const WebKit::WebPoint&);
+WebKit::WebPoint IntPointToWebPoint(const WebCore::IntPoint&);
+
+// WebDragData <-> ChromiumDataObject
+WebKit::WebDragData ChromiumDataObjectToWebDragData(
+ const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
+WTF::PassRefPtr<WebCore::ChromiumDataObject> WebDragDataToChromiumDataObject(
+ const WebKit::WebDragData&);
+
} // namespace webkit_glue
#endif // #ifndef WEBKIT_GLUE_GLUE_UTIL_H_
diff --git a/webkit/glue/webdropdata.cc b/webkit/glue/webdropdata.cc
index bf6ef50..b48c04c 100644
--- a/webkit/glue/webdropdata.cc
+++ b/webkit/glue/webdropdata.cc
@@ -4,27 +4,48 @@
#include "webkit/glue/webdropdata.h"
-#include "base/clipboard_util.h"
-#include "googleurl/src/gurl.h"
-#include <shellapi.h>
-#include <shlobj.h>
+#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
-/* static */
-void WebDropData::PopulateWebDropData(IDataObject* data_object,
- WebDropData* drop_data) {
- std::wstring url_str;
- if (ClipboardUtil::GetUrl(data_object, &url_str, &drop_data->url_title)) {
- GURL test_url(url_str);
- if (test_url.is_valid())
- drop_data->url = test_url;
- }
- ClipboardUtil::GetFilenames(data_object, &drop_data->filenames);
- ClipboardUtil::GetPlainText(data_object, &drop_data->plain_text);
- std::string base_url;
- ClipboardUtil::GetHtml(data_object, &drop_data->text_html, &base_url);
- if (!base_url.empty()) {
- drop_data->html_base_url = GURL(base_url);
+using WebKit::WebData;
+using WebKit::WebDragData;
+using WebKit::WebString;
+using WebKit::WebVector;
+
+WebDropData::WebDropData(const WebDragData& drag_data)
+ : identity(0),
+ url(drag_data.url()),
+ url_title(drag_data.urlTitle()),
+ file_extension(drag_data.fileExtension()),
+ plain_text(drag_data.plainText()),
+ text_html(drag_data.htmlText()),
+ html_base_url(drag_data.htmlBaseURL()),
+ file_description_filename(drag_data.fileContentFileName()) {
+ if (drag_data.hasFileNames()) {
+ WebVector<WebString> fileNames;
+ drag_data.fileNames(fileNames);
+ for (size_t i = 0; i < fileNames.size(); ++i)
+ filenames.push_back(fileNames[i]);
}
- ClipboardUtil::GetFileContents(data_object,
- &drop_data->file_description_filename, &drop_data->file_contents);
+ WebData contents = drag_data.fileContent();
+ if (!contents.isEmpty())
+ file_contents.assign(contents.data(), contents.size());
+}
+
+WebDragData WebDropData::ToDragData() const {
+ WebDragData result;
+ result.initialize();
+ result.setURL(url);
+ result.setURLTitle(url_title);
+ result.setFileExtension(file_extension);
+ result.setFileNames(filenames);
+ result.setPlainText(plain_text);
+ result.setHTMLText(text_html);
+ result.setHTMLBaseURL(html_base_url);
+ result.setFileContentFileName(file_description_filename);
+ result.setFileContent(WebData(file_contents.data(), file_contents.size()));
+ return result;
}
diff --git a/webkit/glue/webdropdata.h b/webkit/glue/webdropdata.h
index f74dcaf..fe8db6a 100644
--- a/webkit/glue/webdropdata.h
+++ b/webkit/glue/webdropdata.h
@@ -11,42 +11,55 @@
#include <string>
#include <vector>
+
+#include "base/string16.h"
#include "googleurl/src/gurl.h"
struct IDataObject;
+namespace WebKit {
+class WebDragData;
+}
+
struct WebDropData {
// Construct with a given drag identity. Note: identity is an int32 because
// it is passed over the renderer NPAPI interface to gears.
explicit WebDropData(int32 drag_identity) : identity(drag_identity) {}
- int32 identity;
+
+ // Construct from a WebDragData object.
+ explicit WebDropData(const WebKit::WebDragData&);
// For default constructions, use drag |identity| 0.
WebDropData() : identity(0) {}
+ int32 identity;
+
// User is dragging a link into the webview.
GURL url;
- std::wstring url_title; // The title associated with |url|.
+ string16 url_title; // The title associated with |url|.
// File extension for dragging images from a webview to the desktop.
- std::wstring file_extension;
+ string16 file_extension;
// User is dropping one or more files on the webview.
- std::vector<std::wstring> filenames;
+ std::vector<string16> filenames;
// User is dragging plain text into the webview.
- std::wstring plain_text;
+ string16 plain_text;
// User is dragging text/html into the webview (e.g., out of Firefox).
// |html_base_url| is the URL that the html fragment is taken from (used to
// resolve relative links). It's ok for |html_base_url| to be empty.
- std::wstring text_html;
+ string16 text_html;
GURL html_base_url;
// User is dragging data from the webview (e.g., an image).
- std::wstring file_description_filename;
+ string16 file_description_filename;
std::string file_contents;
+ // Convert to a WebDragData object.
+ WebKit::WebDragData ToDragData() const;
+
// Helper method for converting Window's specific IDataObject to a WebDropData
// object. TODO(tc): Move this to the browser side since it's Windows
// specific and no longer used in webkit.
diff --git a/webkit/glue/webdropdata_win.cc b/webkit/glue/webdropdata_win.cc
new file mode 100644
index 0000000..d3a67b5
--- /dev/null
+++ b/webkit/glue/webdropdata_win.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/glue/webdropdata.h"
+
+#include <windows.h>
+#include <shellapi.h>
+#include <shlobj.h>
+
+#include "base/clipboard_util.h"
+#include "googleurl/src/gurl.h"
+
+// static
+void WebDropData::PopulateWebDropData(IDataObject* data_object,
+ WebDropData* drop_data) {
+ std::wstring url_str;
+ if (ClipboardUtil::GetUrl(data_object, &url_str, &drop_data->url_title)) {
+ GURL test_url(url_str);
+ if (test_url.is_valid())
+ drop_data->url = test_url;
+ }
+ ClipboardUtil::GetFilenames(data_object, &drop_data->filenames);
+ ClipboardUtil::GetPlainText(data_object, &drop_data->plain_text);
+ std::string base_url;
+ ClipboardUtil::GetHtml(data_object, &drop_data->text_html, &base_url);
+ if (!base_url.empty()) {
+ drop_data->html_base_url = GURL(base_url);
+ }
+ ClipboardUtil::GetFileContents(data_object,
+ &drop_data->file_description_filename, &drop_data->file_contents);
+}
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index db9e238..e9f5ed8 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -18,6 +18,7 @@
#include "base/file_path.h"
#include "base/gfx/native_widget_types.h"
#include "base/string16.h"
+#include "base/string_piece.h"
class GURL;
class SkBitmap;
@@ -136,7 +137,7 @@ string16 GetLocalizedString(int message_id);
// Returns the raw data for a resource. This resource must have been
// specified as BINDATA in the relevant .rc file.
-std::string GetDataResource(int resource_id);
+StringPiece GetDataResource(int resource_id);
#if defined(OS_WIN)
// Loads and returns a cursor.
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index b9ef492..9c916b6 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -8,10 +8,10 @@
#include "base/stats_counters.h"
#include "base/trace_event.h"
#include "grit/webkit_resources.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "webkit/glue/webkit_glue.h"
-using WebKit::WebCString;
+using WebKit::WebData;
using WebKit::WebThemeEngine;
namespace webkit_glue {
@@ -47,7 +47,7 @@ void WebKitClientImpl::traceEventEnd(const char* name, void* id,
TRACE_EVENT_END(name, id, extra);
}
-WebCString WebKitClientImpl::loadResource(const char* name) {
+WebData WebKitClientImpl::loadResource(const char* name) {
struct {
const char* name;
int id;
@@ -68,11 +68,13 @@ WebCString WebKitClientImpl::loadResource(const char* name) {
#endif
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
- if (!strcmp(name, resources[i].name))
- return webkit_glue::GetDataResource(resources[i].id);
+ if (!strcmp(name, resources[i].name)) {
+ StringPiece resource = webkit_glue::GetDataResource(resources[i].id);
+ return WebData(resource.data(), resource.size());
+ }
}
NOTREACHED() << "Unknown image resource " << name;
- return WebCString();
+ return WebData();
}
double WebKitClientImpl::currentTime() {
diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h
index 9fc95fa..3e7b1ab 100644
--- a/webkit/glue/webkitclient_impl.h
+++ b/webkit/glue/webkitclient_impl.h
@@ -25,7 +25,7 @@ class WebKitClientImpl : public WebKit::WebKitClient {
virtual void incrementStatsCounter(const char* name);
virtual void traceEventBegin(const char* name, void* id, const char* extra);
virtual void traceEventEnd(const char* name, void* id, const char* extra);
- virtual WebKit::WebCString loadResource(const char* name);
+ virtual WebKit::WebData loadResource(const char* name);
virtual double currentTime();
virtual void setSharedTimerFiredFunction(void (*func)());
virtual void setSharedTimerFireTime(double fireTime);
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index 344dd26..35c7fe8 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -12,7 +12,11 @@
#include "base/string16.h"
#include "webkit/glue/webwidget.h"
-struct WebDropData;
+namespace WebKit {
+class WebDragData;
+struct WebPoint;
+}
+
struct WebPreferences;
class GURL;
class WebDevToolsAgent;
@@ -174,25 +178,31 @@ class WebView : public WebWidget {
// Notifies the webview that a drag has terminated.
virtual void DragSourceEndedAt(
- int client_x, int client_y, int screen_x, int screen_y) = 0;
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point) = 0;
// Notifies the webview that a drag and drop operation is in progress, with
// dropable items over the view.
virtual void DragSourceMovedTo(
- int client_x, int client_y, int screen_x, int screen_y) = 0;
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point) = 0;
// Notfies the webview that the system drag and drop operation has ended.
virtual void DragSourceSystemDragEnded() = 0;
// Callback methods when a drag and drop operation is trying to drop
// something on the renderer.
- virtual bool DragTargetDragEnter(const WebDropData& drop_data,
- int client_x, int client_y, int screen_x, int screen_y) = 0;
+ virtual bool DragTargetDragEnter(
+ const WebKit::WebDragData& drag_data, int identity,
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point) = 0;
virtual bool DragTargetDragOver(
- int client_x, int client_y, int screen_x, int screen_y) = 0;
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point) = 0;
virtual void DragTargetDragLeave() = 0;
virtual void DragTargetDrop(
- int client_x, int client_y, int screen_x, int screen_y) = 0;
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point) = 0;
virtual int32 GetDragIdentity() = 0;
// Notifies the webview that autofill suggestions are available for a node.
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index c206ef8..4c8775a 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -42,8 +42,12 @@ namespace webkit_glue {
class WebMediaPlayerDelegate;
}
+namespace WebKit {
+class WebDragData;
+struct WebPoint;
+}
+
struct PasswordForm;
-struct WebDropData;
struct WebPreferences;
class AutofillForm;
class FilePath;
@@ -601,7 +605,9 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
// webview: The WebView sending the delegate method.
// drop_data: a WebDropData struct which should contain all the necessary
// information for dragging data out of the webview.
- virtual void StartDragging(WebView* webview, const WebDropData& drop_data) { }
+ virtual void StartDragging(WebView* webview,
+ const WebKit::WebDragData& drag_data) {
+ }
// Returns the focus to the client.
// reverse: Whether the focus should go to the previous (if true) or the next
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);
}
}
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index 2baf9de..e52a8d2 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -13,7 +13,6 @@
#include "base/gfx/size.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/back_forward_list_client_impl.h"
-#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webframe_impl.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
@@ -44,7 +43,6 @@ class WebMouseWheelEvent;
class AutocompletePopupMenuClient;
class ImageResourceFetcher;
class SearchableFormData;
-struct WebDropData;
class WebHistoryItemImpl;
class WebDevToolsAgent;
class WebDevToolsAgentImpl;
@@ -98,17 +96,23 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void InspectElement(int x, int y);
virtual void ShowJavaScriptConsole();
virtual void DragSourceEndedAt(
- int client_x, int client_y, int screen_x, int screen_y);
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point);
virtual void DragSourceMovedTo(
- int client_x, int client_y, int screen_x, int screen_y);
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point);
virtual void DragSourceSystemDragEnded();
- virtual bool DragTargetDragEnter(const WebDropData& drop_data,
- int client_x, int client_y, int screen_x, int screen_y);
+ virtual bool DragTargetDragEnter(
+ const WebKit::WebDragData& drag_data, int identity,
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point);
virtual bool DragTargetDragOver(
- int client_x, int client_y, int screen_x, int screen_y);
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point);
virtual void DragTargetDragLeave();
virtual void DragTargetDrop(
- int client_x, int client_y, int screen_x, int screen_y);
+ const WebKit::WebPoint& client_point,
+ const WebKit::WebPoint& screen_point);
virtual int32 GetDragIdentity();
virtual void AutofillSuggestionsForNode(
int64 node_id,
@@ -193,7 +197,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
}
// Start a system drag and drop operation.
- void StartDragging(const WebDropData& drop_data);
+ void StartDragging(const WebKit::WebDragData& drag_data);
// ImageResourceFetcher callback.
void ImageResourceDownloadDone(ImageResourceFetcher* fetcher,
@@ -258,7 +262,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
WebPreferences webprefs_;
// A copy of the web drop data object we received from the browser.
- RefPtr<WebCore::ChromiumDataObject> current_drop_data_;
+ RefPtr<WebCore::ChromiumDataObject> current_drag_data_;
private:
// Returns true if the event was actually processed.