diff options
28 files changed, 270 insertions, 183 deletions
@@ -19,7 +19,7 @@ deps = { "http://googletest.googlecode.com/svn/trunk@214", "src/third_party/WebKit": - "/trunk/deps/third_party/WebKit@12860", + "/trunk/deps/third_party/WebKit@12875", "src/third_party/icu38": "/trunk/deps/third_party/icu38@12390", diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index b3699b8..d80401d 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -23,7 +23,6 @@ #include "chrome/browser/tab_contents/web_contents.h" #include "chrome/browser/tab_contents/web_contents_view.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/pref_service.h" #include "chrome/test/automation/automation_messages.h" @@ -1914,9 +1913,10 @@ void AutomationProvider::HandleFindInPageRequest( return; } -void AutomationProvider::HandleFindRequest(int handle, - const FindInPageRequest& request, - IPC::Message* reply_message) { +void AutomationProvider::HandleFindRequest( + int handle, + const AutomationMsg_Find_Params& params, + IPC::Message* reply_message) { if (!tab_tracker_->ContainsHandle(handle)) { AutomationMsg_FindInPage::WriteReplyParams(reply_message, -1, -1); Send(reply_message); @@ -1937,8 +1937,8 @@ void AutomationProvider::HandleFindRequest(int handle, FindInPageNotificationObserver::kFindInPageRequestId); web_contents->render_view_host()->StartFinding( FindInPageNotificationObserver::kFindInPageRequestId, - request.search_string, request.forward, request.match_case, - request.find_next); + params.search_string, params.forward, params.match_case, + params.find_next); } } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 38008d0..1bf0892 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -26,7 +26,6 @@ #include "chrome/common/notification_observer.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/views/event.h" -#include "webkit/glue/find_in_page_request.h" #if defined(OS_WIN) // TODO(port): enable these. @@ -234,7 +233,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Responds to the FindInPage request, retrieves the search query parameters, // launches an observer to listen for results and issues a StartFind request. void HandleFindRequest(int handle, - const FindInPageRequest& request, + const AutomationMsg_Find_Params& params, IPC::Message* reply_message); // Responds to requests to open the FindInPage window. diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 8222ec3..0f0a889 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -34,9 +34,11 @@ #include "chrome/common/thumbnail_score.h" #include "net/base/net_util.h" #include "skia/include/SkBitmap.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" #include "webkit/glue/autofill_form.h" using base::TimeDelta; +using WebKit::WebFindInPageRequest; using WebKit::WebInputEvent; namespace { @@ -351,12 +353,12 @@ void RenderViewHost::StartFinding(int request_id, if (search_string.empty()) return; - FindInPageRequest request; - request.request_id = request_id; - request.search_string = search_string; + WebFindInPageRequest request; + request.identifier = request_id; + request.text = search_string; request.forward = forward; - request.match_case = match_case; - request.find_next = find_next; + request.matchCase = match_case; + request.findNext = find_next; Send(new ViewMsg_Find(routing_id(), request)); // This call is asynchronous and returns immediately. diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index e016074..bfdc54d 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -20,7 +20,6 @@ #include "chrome/common/thumbnail_score.h" #include "chrome/common/transport_dib.h" #include "webkit/glue/console_message_level.h" -#include "webkit/glue/find_in_page_request.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/window_open_disposition.h" @@ -1390,30 +1389,6 @@ class MessageWithReply : public SyncMessage { } }; -// Traits for ViewMsg_FindInPageMsg_Request structure to pack/unpack. -template <> -struct ParamTraits<FindInPageRequest> { - typedef FindInPageRequest param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.request_id); - WriteParam(m, p.search_string); - WriteParam(m, p.forward); - WriteParam(m, p.match_case); - WriteParam(m, p.find_next); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->request_id) && - ReadParam(m, iter, &p->search_string) && - ReadParam(m, iter, &p->forward) && - ReadParam(m, iter, &p->match_case) && - ReadParam(m, iter, &p->find_next); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<FindInPageRequest>"); - } -}; - //----------------------------------------------------------------------------- } // namespace IPC diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 284ac51..e144a3a 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -25,6 +25,7 @@ #include "net/http/http_response_headers.h" #include "net/url_request/url_request_status.h" #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/context_menu.h" @@ -370,6 +371,27 @@ struct ViewHostMsg_Audio_CreateStream { namespace IPC { template <> +struct ParamTraits<WebKit::WebString> { + typedef WebKit::WebString param_type; + static void Write(Message* m, const param_type& p) { + m->WriteData(reinterpret_cast<const char*>(p.data()), + static_cast<int>(p.length())); + } + static bool Read(const Message* m, void** iter, param_type* p) { + const char* data; + int length; + if (!m->ReadData(iter, &data, &length)) + return false; + p->assign(reinterpret_cast<const WebKit::WebUChar*>(data), + static_cast<size_t>(length)); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(UTF16ToWideHack(p)); + } +}; + +template <> struct ParamTraits<ResourceType::Type> { typedef ResourceType::Type param_type; static void Write(Message* m, const param_type& p) { @@ -1923,6 +1945,29 @@ struct ParamTraits<AudioOutputStream::State> { } }; +template <> +struct ParamTraits<WebKit::WebFindInPageRequest> { + typedef WebKit::WebFindInPageRequest param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.identifier); + WriteParam(m, p.text); + WriteParam(m, p.forward); + WriteParam(m, p.matchCase); + WriteParam(m, p.findNext); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->identifier) && + ReadParam(m, iter, &p->text) && + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->matchCase) && + ReadParam(m, iter, &p->findNext); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<FindInPageRequest>"); + } +}; + } // namespace IPC diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index cc0ad9e..2dda292 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -160,7 +160,7 @@ IPC_BEGIN_MESSAGES(View) // Sent when the user wants to search for a word on the page (find in page). // Request parameters are passed in as a FindInPageMsg_Request struct. - IPC_MESSAGE_ROUTED1(ViewMsg_Find, FindInPageRequest) + IPC_MESSAGE_ROUTED1(ViewMsg_Find, WebKit::WebFindInPageRequest) // Sent when the headers are available for a resource request. IPC_MESSAGE_ROUTED2(ViewMsg_Resource_ReceivedResponse, diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 1802a66..7b9533d 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -8,8 +8,12 @@ #include "chrome/common/resource_bundle.h" #include "chrome/renderer/render_view.h" #include "grit/renderer_resources.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" +using WebKit::WebScriptSource; +using WebKit::WebString; + namespace extensions_v8 { const char kExtensionProcessExtensionName[] = "v8/ExtensionProcess"; @@ -108,14 +112,14 @@ void ExtensionProcessBindings::ExecuteCallbackInFrame( std::string code = "chromium._dispatchCallback("; code += IntToString(callback_id); code += ", '"; - + size_t offset = code.length(); code += response; ReplaceSubstringsAfterOffset(&code, offset, "\\", "\\\\"); ReplaceSubstringsAfterOffset(&code, offset, "'", "\\'"); code += "')"; - frame->ExecuteScript(webkit_glue::WebScriptSource(code)); + frame->ExecuteScript(WebScriptSource(WebString::fromUTF8(code))); } } // namespace extensions_v8 diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc index 4a095ac..9301579 100755 --- a/chrome/renderer/extensions/renderer_extension_bindings.cc +++ b/chrome/renderer/extensions/renderer_extension_bindings.cc @@ -6,8 +6,12 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/render_thread.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" +using WebKit::WebScriptSource; +using WebKit::WebString; + namespace { const char* kExtensionName = "v8/RendererExtensionBindings"; @@ -94,7 +98,7 @@ void RendererExtensionBindings::HandleExtensionMessage( std::string script = StringPrintf( "void(chromium.Extension.dispatchOnMessage(\"%s\", %d))", message.c_str(), channel_id); - webframe->ExecuteScript(webkit_glue::WebScriptSource(script)); + webframe->ExecuteScript(WebScriptSource(WebString::fromUTF8(script))); } } // namespace extensions_v8 diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index faf8d7c..8cc7c43 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -49,6 +49,7 @@ #include "printing/units.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/image_operations.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/default_plugin/default_plugin_shared.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dom_serializer.h" @@ -84,6 +85,7 @@ using base::TimeDelta; using webkit_glue::WebAccessibility; +using WebKit::WebScriptSource; //----------------------------------------------------------------------------- @@ -2083,7 +2085,7 @@ GURL RenderView::GetAlternateErrorPageURL(const GURL& failedURL, return url; } -void RenderView::OnFind(const FindInPageRequest& request) { +void RenderView::OnFind(const WebKit::WebFindInPageRequest& request) { WebFrame* main_frame = webview()->GetMainFrame(); WebFrame* frame_after_main = webview()->GetNextFrameAfter(main_frame, true); WebFrame* focused_frame = webview()->GetFocusedFrame(); @@ -2143,9 +2145,9 @@ void RenderView::OnFind(const FindInPageRequest& request) { // fix for 792423. webview()->SetFocusedFrame(NULL); - if (request.find_next) { + if (request.findNext) { // Force the main_frame to report the actual count. - main_frame->IncreaseMatchCount(0, request.request_id); + main_frame->IncreaseMatchCount(0, request.identifier); } else { // If nothing is found, set result to "0 of 0", otherwise, set it to // "-1 of 1" to indicate that we found at least one item, but we don't know @@ -2158,7 +2160,8 @@ void RenderView::OnFind(const FindInPageRequest& request) { bool final_status_update = !result; // Send the search result over to the browser process. - Send(new ViewHostMsg_Find_Reply(routing_id_, request.request_id, + Send(new ViewHostMsg_Find_Reply(routing_id_, + request.identifier, match_count, selection_rect, ordinal, @@ -2434,8 +2437,7 @@ void RenderView::EvaluateScript(const std::wstring& frame_xpath, if (!web_frame) return; - web_frame->ExecuteScript( - webkit_glue::WebScriptSource(WideToUTF8(script))); + web_frame->ExecuteScript(WebScriptSource(WideToUTF16Hack(script))); } void RenderView::InsertCSS(const std::wstring& frame_xpath, diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index b2a7759..a9b4b9a 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -72,9 +72,10 @@ class WaitableEvent; namespace webkit_glue { struct FileUploadData; -//class WebAccessibility; -//struct InParams; -//struct OutParams; +} + +namespace WebKit { +struct WebFindInPageRequest; } // We need to prevent a page from trying to create infinite popups. It is not @@ -484,7 +485,7 @@ class RenderView : public RenderWidget, void OnShowJavaScriptConsole(); void OnSetupDevToolsClient(); void OnCancelDownload(int32 download_id); - void OnFind(const FindInPageRequest& request); + void OnFind(const WebKit::WebFindInPageRequest& request); void OnZoom(int function); void OnSetPageEncoding(const std::wstring& encoding_name); void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index fa26b44..88c4fa7 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -10,11 +10,14 @@ #include "chrome/renderer/renderer_webkitclient_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webscriptsource.h" #include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview.h" +using WebKit::WebScriptSource; +using WebKit::WebString; + namespace { const int32 kRouteId = 5; @@ -42,7 +45,7 @@ class RenderViewTest : public testing::Test { // Executes the given JavaScript in the context of the main frame. The input // is a NULL-terminated UTF-8 string. void ExecuteJavaScript(const char* js) { - GetMainFrame()->ExecuteScript(webkit_glue::WebScriptSource(js)); + GetMainFrame()->ExecuteScript(WebScriptSource(WebString::fromUTF8(js))); } // Loads the given HTML into the main frame as a data: URL. diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index 04957ad..9b424f0 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -9,13 +9,17 @@ #include "base/perftimer.h" #include "base/pickle.h" #include "base/shared_memory.h" +#include "base/string_util.h" #include "chrome/common/resource_bundle.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webscriptsource.h" #include "grit/renderer_resources.h" +using WebKit::WebScriptSource; +using WebKit::WebString; + // These two strings are injected before and after the Greasemonkey API and // user script to wrap it in an anonymous scope. static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; @@ -104,7 +108,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, PerfTimer timer; int num_matched = 0; - std::vector<webkit_glue::WebScriptSource> sources; + std::vector<WebScriptSource> sources; for (size_t i = 0; i < scripts_.size(); ++i) { UserScript* script = scripts_[i]; if (!script->MatchesUrl(frame->GetURL())) @@ -121,15 +125,15 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (script->run_location() == location) { for (size_t j = 0; j < script->js_scripts().size(); ++j) { UserScript::File &file = script->js_scripts()[j]; - sources.push_back(webkit_glue::WebScriptSource( - file.GetContent().as_string(), file.url())); + sources.push_back(WebScriptSource( + WebString::fromUTF8(file.GetContent()), file.url())); } } } if (!sources.empty()) { - sources.insert(sources.begin(), - webkit_glue::WebScriptSource(api_js_.as_string())); + sources.insert( + sources.begin(), WebScriptSource(WebString::fromUTF8(api_js_))); frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); } diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index 52a9945..5968f78 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -13,9 +13,49 @@ #include "chrome/common/ipc_message_utils.h" #include "chrome/test/automation/automation_constants.h" +struct AutomationMsg_Find_Params { + // Unused value, which exists only for backwards compat. + int unused; + + // The word(s) to find on the page. + string16 search_string; + + // Whether to search forward or backward within the page. + bool forward; + + // Whether search should be Case sensitive. + bool match_case; + + // Whether this operation is first request (Find) or a follow-up (FindNext). + bool find_next; +}; + namespace IPC { template <> +struct ParamTraits<AutomationMsg_Find_Params> { + typedef AutomationMsg_Find_Params param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.unused); + WriteParam(m, p.search_string); + WriteParam(m, p.forward); + WriteParam(m, p.match_case); + WriteParam(m, p.find_next); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->unused) && + ReadParam(m, iter, &p->search_string) && + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->match_case) && + ReadParam(m, iter, &p->find_next); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<AutomationMsg_Find_Params>"); + } +}; + +template <> struct ParamTraits<AutomationMsg_NavigationResponseValues> { typedef AutomationMsg_NavigationResponseValues param_type; static void Write(Message* m, const param_type& p) { diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 89e401b..59599b1 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -13,11 +13,11 @@ #include "base/basictypes.h" #include "base/gfx/rect.h" +#include "base/string16.h" #include "chrome/common/ipc_message_macros.h" #include "chrome/common/navigation_types.h" #include "chrome/test/automation/autocomplete_edit_proxy.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/find_in_page_request.h" // NOTE: All IPC messages have either a routing_id of 0 (for asynchronous // messages), or one that's been assigned by the proxy (for calls @@ -299,8 +299,8 @@ IPC_BEGIN_MESSAGES(Automation) // (1=case sensitive, 0=case insensitive). If an error occurs, matches_found // will be -1. // - // NOTE: These two messages have been deprecated, please use the new messages - // AutomationMsg_FindRequest and AutomationMsg_FindInPageResponse2 below. + // NOTE: This message has been deprecated, please use the new message + // AutomationMsg_Find below. // IPC_SYNC_MESSAGE_ROUTED4_2(AutomationMsg_FindInPage, // DEPRECATED. int, /* tab_handle */ @@ -746,12 +746,11 @@ IPC_BEGIN_MESSAGES(Automation) // This message starts a find within a tab corresponding to the supplied // tab handle. The parameter |request| specifies what to search for. - // If an error occurs, |matches_found| will be -1 (see response message - // AutomationMsg_FindInPageResponse2). + // If an error occurs, |matches_found| will be -1. // IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_Find, - int, /* tab_handle */ - FindInPageRequest /* request */, + int /* tab_handle */, + AutomationMsg_Find_Params /* params */, int /* active_ordinal */, int /* matches_found */) diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 550dc5d..bf69a78 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -51,17 +51,17 @@ int TabProxy::FindInPage(const std::wstring& search_string, if (!is_valid()) return -1; - FindInPageRequest request = {0}; - request.search_string = WideToUTF16(search_string); - request.find_next = find_next; - // The explicit comparison to TRUE avoids a warning (C4800). - request.match_case = match_case == TRUE; - request.forward = forward == TRUE; + AutomationMsg_Find_Params params; + params.unused = 0; + params.search_string = WideToUTF16Hack(search_string); + params.find_next = find_next; + params.match_case = (match_case == CASE_SENSITIVE); + params.forward = (forward == FWD); int matches = 0; int ordinal2 = 0; bool succeeded = sender_->Send(new AutomationMsg_Find(0, handle_, - request, + params, &ordinal2, &matches)); if (!succeeded) @@ -622,4 +622,3 @@ void TabProxy::Reposition(HWND window, HWND window_insert_after, int left, sender_->Send(new AutomationMsg_TabReposition(0, handle_, params)); } #endif // defined(OS_WIN) - diff --git a/webkit/build/WebKit/WebKit.vcproj b/webkit/build/WebKit/WebKit.vcproj index 216bdbf..a61dd47f 100644 --- a/webkit/build/WebKit/WebKit.vcproj +++ b/webkit/build/WebKit/WebKit.vcproj @@ -152,6 +152,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebFindInPageRequest.h" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebImage.h" > </File> @@ -176,6 +180,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebScriptSource.h" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebSize.h" > </File> diff --git a/webkit/glue/find_in_page_request.h b/webkit/glue/find_in_page_request.h deleted file mode 100644 index 8594f05..0000000 --- a/webkit/glue/find_in_page_request.h +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -#ifndef WEBKIT_GLUE_FIND_IN_PAGE_REQUEST_H__ -#define WEBKIT_GLUE_FIND_IN_PAGE_REQUEST_H__ - -#include "base/string16.h" - -// Parameters for a find in page request. -struct FindInPageRequest { - // The id for the request, this message is passed in by the caller and - // returned back with the reply so that the caller can start a new search and - // choose to ignore packets that belonged to the last search. - int request_id; - - // The word(s) to find on the page. - string16 search_string; - - // Whether to search forward or backward within the page. - bool forward; - - // Whether search should be Case sensitive. - bool match_case; - - // Whether this operation is first request (Find) or a follow-up (FindNext). - bool find_next; -}; - -#endif // WEBKIT_GLUE_FIND_IN_PAGE_REQUEST_H__ diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc index 05a395a..2601970 100644 --- a/webkit/glue/glue_util.cc +++ b/webkit/glue/glue_util.cc @@ -2,6 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(darin): This file will be deleted once we complete the move to +// third_party/WebKit/WebKit/chromium + +// In this file, we pretend to be part of the WebKit implementation. +// This is just a temporary hack while glue is still being moved into +// third_party/WebKit/WebKit/chromium. +#define WEBKIT_IMPLEMENTATION 1 + #include "config.h" #include "webkit/glue/glue_util.h" @@ -20,11 +28,7 @@ #include "base/sys_string_conversions.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" - - -// TODO(darin): This file will be deleted once we complete the move to -// third_party/WebKit/WebKit/chromium - +#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" namespace webkit_glue { @@ -82,6 +86,22 @@ WebCore::String StdStringToString(const std::string& str) { static_cast<unsigned>(str.length())); } +WebKit::WebString StringToWebString(const WebCore::String& str) { + return str; +} + +WebCore::String WebStringToString(const WebKit::WebString& str) { + return str; +} + +WebKit::WebCString CStringToWebCString(const WebCore::CString& str) { + return str; +} + +WebCore::CString WebCStringToCString(const WebKit::WebCString& str) { + return str; +} + FilePath::StringType StringToFilePathString(const WebCore::String& str) { #if defined(OS_WIN) return StringToStdWString(str); @@ -127,6 +147,14 @@ GURL StringToGURL(const WebCore::String& spec) { return GURL(WideToUTF8(StringToStdWString(spec))); } +WebKit::WebURL KURLToWebURL(const WebCore::KURL& url) { + return url; +} + +WebCore::KURL WebURLToKURL(const WebKit::WebURL& url) { + return url; +} + // Rect conversions ------------------------------------------------------------ gfx::Rect FromIntRect(const WebCore::IntRect& r) { diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h index adbaffc..5c9f90b 100644 --- a/webkit/glue/glue_util.h +++ b/webkit/glue/glue_util.h @@ -18,7 +18,9 @@ class String; } namespace WebKit { +class WebCString; class WebString; +class WebURL; } namespace gfx { @@ -47,6 +49,14 @@ WebCore::String String16ToString(const string16& str); std::string StringToStdString(const WebCore::String& str); WebCore::String StdStringToString(const std::string& str); +// WebCore::String <-> WebString. No charset conversion. +WebKit::WebString StringToWebString(const WebCore::String& str); +WebCore::String WebStringToString(const WebKit::WebString& str); + +// WebCore::CString <-> WebCString. No charset conversion. +WebKit::WebCString CStringToWebCString(const WebCore::CString& str); +WebCore::CString WebCStringToCString(const WebKit::WebCString& str); + FilePath::StringType StringToFilePathString(const WebCore::String& str); WebCore::String FilePathStringToString(const FilePath::StringType& str); @@ -57,6 +67,9 @@ GURL KURLToGURL(const WebCore::KURL& url); WebCore::KURL GURLToKURL(const GURL& url); GURL StringToGURL(const WebCore::String& spec); +WebKit::WebURL KURLToWebURL(const WebCore::KURL& url); +WebCore::KURL WebURLToKURL(const WebKit::WebURL& url); + gfx::Rect FromIntRect(const WebCore::IntRect& r); WebCore::IntRect ToIntRect(const gfx::Rect& r); diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index 231b4cf..53f1632 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -21,7 +21,7 @@ #include "base/json_writer.h" #include "base/string_util.h" #include "base/values.h" - +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/devtools/debugger_agent.h" #include "webkit/glue/devtools/devtools_rpc_js.h" #include "webkit/glue/devtools/dom_agent.h" @@ -40,6 +40,8 @@ using WebCore::Node; using WebCore::Page; using WebCore::SecurityOrigin; using WebCore::String; +using WebKit::WebScriptSource; +using WebKit::WebString; DEFINE_RPC_JS_BOUND_OBJ(DebuggerAgent, DEBUGGER_AGENT_STRUCT, DebuggerAgentDelegate, DEBUGGER_AGENT_DELEGATE_STRUCT) @@ -126,7 +128,8 @@ void WebDevToolsClientImpl::DispatchMessageFromAgent( || net_agent_obj_->Dispatch(*message.get(), &expr) || tools_agent_obj_->Dispatch(*message.get(), &expr) || debugger_agent_obj_->Dispatch(*message.get(), &expr)) { - web_view_impl_->GetMainFrame()->ExecuteScript(expr); + web_view_impl_->GetMainFrame()->ExecuteScript( + WebScriptSource(WebString::fromUTF8(expr))); } } diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 8f38362..ddd1b21 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -11,8 +11,6 @@ #include "skia/ext/platform_canvas.h" #include "webkit/glue/console_message_level.h" #include "webkit/glue/feed.h" -#include "webkit/glue/find_in_page_request.h" -#include "webkit/glue/webscriptsource.h" class WebDataSource; class WebError; @@ -26,6 +24,11 @@ class Rect; class Size; } +namespace WebKit { +struct WebFindInPageRequest; +struct WebScriptSource; +} + // Every frame in a web page is represented by one WebFrame, including the // outermost frame. class WebFrame { @@ -91,14 +94,14 @@ class WebFrame { const GURL& fake_url) = 0; // Executes JavaScript in the web frame. - virtual void ExecuteScript(const webkit_glue::WebScriptSource& source) = 0; + virtual void ExecuteScript(const WebKit::WebScriptSource& source) = 0; // Executes JavaScript in a new context associated with the web frame. The // script gets its own global scope and its own prototypes for intrinsic // JavaScript objects (String, Array, and so-on). It shares the wrappers for // all DOM nodes and DOM constructors. virtual void ExecuteScriptInNewContext( - const webkit_glue::WebScriptSource* sources, int num_sources) = 0; + const WebKit::WebScriptSource* sources, int num_sources) = 0; // Inserts the given CSS styles at the beginning of the document. virtual bool InsertCSSStyles(const std::string& css) = 0; @@ -212,7 +215,7 @@ class WebFrame { // If no match is found, this function clears all tickmarks and highlighting. // // Returns true if the search string was found, false otherwise. - virtual bool Find(const FindInPageRequest& request, + virtual bool Find(const WebKit::WebFindInPageRequest& request, bool wrap_within_frame, gfx::Rect* selection_rect) = 0; @@ -235,7 +238,7 @@ class WebFrame { // cancel at any time (see CancelPendingScopingEffort). The parameter Request // specifies what to look for and Reset signals whether this is a brand new // request or a continuation of the last scoping effort. - virtual void ScopeStringMatches(FindInPageRequest request, + virtual void ScopeStringMatches(const WebKit::WebFindInPageRequest& request, bool reset) = 0; // Cancels any outstanding requests for scoping string matches on a frame. diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 099d92c..d33b45f 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -135,6 +135,8 @@ MSVC_POP_WARNING(); #include "net/base/net_errors.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/platform_canvas.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/alt_error_page_resource_fetcher.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dom_operations_private.h" @@ -191,6 +193,8 @@ using WebCore::SubstituteData; using WebCore::TextIterator; using WebCore::VisiblePosition; using WebCore::XPathResult; +using WebKit::WebFindInPageRequest; +using WebKit::WebScriptSource; // Key for a StatsCounter tracking how many WebFrames are active. static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; @@ -932,16 +936,16 @@ void WebFrameImpl::ResetMatchCount() { frames_scoping_count_ = 0; } -bool WebFrameImpl::Find(const FindInPageRequest& request, +bool WebFrameImpl::Find(const WebFindInPageRequest& request, bool wrap_within_frame, gfx::Rect* selection_rect) { WebCore::String webcore_string = - webkit_glue::String16ToString(request.search_string); + webkit_glue::WebStringToString(request.text); WebFrameImpl* const main_frame_impl = static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); - if (!request.find_next) + if (!request.findNext) frame()->page()->unmarkAllTextMatches(); // Starts the search from the current selection. @@ -949,7 +953,7 @@ bool WebFrameImpl::Find(const FindInPageRequest& request, DCHECK(frame() && frame()->view()); bool found = frame()->findString(webcore_string, request.forward, - request.match_case, wrap_within_frame, + request.matchCase, wrap_within_frame, start_in_selection); if (found) { #if defined(OS_WIN) @@ -978,7 +982,7 @@ bool WebFrameImpl::Find(const FindInPageRequest& request, curr_selection_rect = active_match_->boundingBox(); } - if (!request.find_next) { + if (!request.findNext) { // This is a Find operation, so we set the flag to ask the scoping effort // to find the active rect for us so we can update the ordinal (n of m). locating_active_rect_ = true; @@ -1011,7 +1015,7 @@ bool WebFrameImpl::Find(const FindInPageRequest& request, ReportFindInPageSelection(rect, active_match_index_ + 1, - request.request_id); + request.identifier); } #endif } @@ -1043,7 +1047,7 @@ int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const { return ordinal; } -bool WebFrameImpl::ShouldScopeMatches(FindInPageRequest request) { +bool WebFrameImpl::ShouldScopeMatches(const WebFindInPageRequest& request) { // Don't scope if we can't find a frame or if the frame is not visible. // The user may have closed the tab/application, so abort. if (!frame() || !Visible()) @@ -1058,7 +1062,7 @@ bool WebFrameImpl::ShouldScopeMatches(FindInPageRequest request) { !last_search_string_.empty() && last_match_count_ == 0) { // Check to see if the search string prefixes match. string16 previous_search_prefix = - request.search_string.substr(0, last_search_string_.length()); + string16(request.text).substr(0, last_search_string_.length()); if (previous_search_prefix == last_search_string_) { return false; // Don't search this frame, it will be fruitless. @@ -1119,7 +1123,7 @@ void WebFrameImpl::AddMarker(WebCore::Range* range) { } } -void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, +void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, bool reset) { if (!ShouldScopeMatches(request)) return; @@ -1152,7 +1156,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, } WebCore::String webcore_string = - webkit_glue::String16ToString(request.search_string); + webkit_glue::WebStringToString(request.text); RefPtr<Range> search_range(rangeOfContents(frame()->document())); @@ -1187,7 +1191,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, RefPtr<Range> result_range(findPlainText(search_range.get(), webcore_string, true, - request.match_case)); + request.matchCase)); if (result_range->collapsed(ec)) { if (!result_range->startContainer()->isInShadowTree()) break; @@ -1251,7 +1255,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, webkit_glue::FromIntRect( frame()->view()->convertToContainingWindow(result_bounds)), active_match_index_ + 1, - request.request_id); + request.identifier); #endif } } @@ -1262,7 +1266,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, // Remember what we search for last time, so we can skip searching if more // letters are added to the search string (and last outcome was 0). - last_search_string_ = request.search_string; + last_search_string_ = request.text; if (match_count > 0) { frame()->setMarkedTextMatchesAreHighlighted(true); @@ -1270,7 +1274,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, last_match_count_ += match_count; // Let the mainframe know how much we found during this pass. - main_frame_impl->IncreaseMatchCount(match_count, request.request_id); + main_frame_impl->IncreaseMatchCount(match_count, request.identifier); } if (timeout) { @@ -1298,7 +1302,7 @@ void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, // If this is the last frame to finish scoping we need to trigger the final // update to be sent. if (main_frame_impl->frames_scoping_count_ == 0) - main_frame_impl->IncreaseMatchCount(0, request.request_id); + main_frame_impl->IncreaseMatchCount(0, request.identifier); // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. InvalidateArea(INVALIDATE_SCROLLBAR); @@ -1695,12 +1699,12 @@ void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebRequest* request, error_page_url)); } -void WebFrameImpl::ExecuteScript(const webkit_glue::WebScriptSource& source) { +void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { frame_->loader()->executeScript( WebCore::ScriptSourceCode( - webkit_glue::StdStringToString(source.source), - webkit_glue::GURLToKURL(source.url), - source.start_line)); + webkit_glue::WebStringToString(source.code), + webkit_glue::WebURLToKURL(source.url), + source.startLine)); } bool WebFrameImpl::InsertCSSStyles(const std::string& css) { @@ -1723,14 +1727,14 @@ bool WebFrameImpl::InsertCSSStyles(const std::string& css) { } void WebFrameImpl::ExecuteScriptInNewContext( - const webkit_glue::WebScriptSource* sources_in, int num_sources) { + const WebScriptSource* sources_in, int num_sources) { Vector<WebCore::ScriptSourceCode> sources; for (int i = 0; i < num_sources; ++i) { sources.append(WebCore::ScriptSourceCode( - webkit_glue::StdStringToString(sources_in[i].source), - webkit_glue::GURLToKURL(sources_in[i].url), - sources_in[i].start_line)); + webkit_glue::WebStringToString(sources_in[i].code), + webkit_glue::WebURLToKURL(sources_in[i].url), + sources_in[i].startLine)); } frame_->script()->evaluateInNewContext(sources); diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 004c5ad..ec622c4 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -91,9 +91,9 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { const GURL& error_page_url, bool replace, const GURL& fake_url); - virtual void ExecuteScript(const webkit_glue::WebScriptSource& source); + virtual void ExecuteScript(const WebKit::WebScriptSource& source); virtual void ExecuteScriptInNewContext( - const webkit_glue::WebScriptSource* sources, int num_sources); + const WebKit::WebScriptSource* sources, int num_sources); virtual bool InsertCSSStyles(const std::string& css); virtual bool GetPreviousHistoryState(std::string* history_state) const; virtual bool GetCurrentHistoryState(std::string* history_state) const; @@ -124,11 +124,12 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { virtual NPObject* GetWindowNPObject(); virtual void GetContentAsPlainText(int max_chars, std::wstring* text) const; - virtual bool Find(const FindInPageRequest& request, - bool wrap_within_frame, - gfx::Rect* selection_rect); + virtual bool Find( + const WebKit::WebFindInPageRequest& request, bool wrap_within_frame, + gfx::Rect* selection_rect); virtual void StopFinding(bool clear_selection); - virtual void ScopeStringMatches(FindInPageRequest request, bool reset); + virtual void ScopeStringMatches( + const WebKit::WebFindInPageRequest& request, bool reset); virtual void CancelPendingScopingEffort(); virtual void ResetMatchCount(); virtual bool Visible(); @@ -386,7 +387,7 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // It is not necessary if the frame is invisible, for example, or if this // is a repeat search that already returned nothing last time the same prefix // was searched. - bool ShouldScopeMatches(FindInPageRequest request); + bool ShouldScopeMatches(const WebKit::WebFindInPageRequest& request); // Only for test_shell int PendingFrameUnloadEventCount() const; diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index 3362c03..409ee0e 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -254,6 +254,11 @@ bool DecodeImage(const std::string& image_data, SkBitmap* image) { return false; } +// NOTE: This pair of conversion functions are here instead of in glue_util.cc +// since that file will eventually die. This pair of functions will need to +// remain as the concept of a file-path specific character encoding string type +// will most likely not make its way into WebKit. + FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str) { #if defined(OS_POSIX) return base::SysWideToNativeMB(UTF16ToWideHack(str)); diff --git a/webkit/glue/webscriptsource.h b/webkit/glue/webscriptsource.h deleted file mode 100644 index 5f9fd23..0000000 --- a/webkit/glue/webscriptsource.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2006-2009 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. - -#ifndef WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_ -#define WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_ - -namespace webkit_glue { - -// Describes some script that can be executed within a frame. -// NOTE: start_line is 1-based (like the corresponding object in WebCore). -// TODO(aa): Allow clients to specify external data intead of strings to avoid -// copies. -struct WebScriptSource { - WebScriptSource(const std::string& source) - : source(source), start_line(1) {} - WebScriptSource(const std::string& source, const GURL& url) - : source(source), url(url), start_line(1) {} - WebScriptSource(const std::string& source, const GURL& url, int start_line) - : source(source), url(url), start_line(start_line) {} - - std::string source; - GURL url; - int start_line; -}; - -} // namespace webkit_glue - -#endif // WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_ diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc index e672c7b..64824e4 100644 --- a/webkit/tools/test_shell/plugin_tests.cc +++ b/webkit/tools/test_shell/plugin_tests.cc @@ -8,12 +8,14 @@ #include "base/path_service.h" #include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webscriptsource.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebScriptSource; +using WebKit::WebString; // Provides functionality for creating plugin tests. class PluginTest : public TestShellTest { @@ -69,8 +71,10 @@ TEST_F(PluginTest, DISABLED_Refresh) { test_shell_->WaitTestFinished(); std::wstring text; - webkit_glue::WebScriptSource call_check("check();"); - webkit_glue::WebScriptSource refresh("navigator.plugins.refresh(false)"); + WebScriptSource call_check( + WebString::fromUTF8("check();")); + WebScriptSource refresh( + WebString::fromUTF8("navigator.plugins.refresh(false)")); test_shell_->webView()->GetMainFrame()->ExecuteScript(call_check); test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 72f2ec8..b57e75a 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4108,12 +4108,14 @@ '../third_party/WebKit/WebKit/chromium/public/WebCString.h', '../third_party/WebKit/WebKit/chromium/public/WebClipboard.h', '../third_party/WebKit/WebKit/chromium/public/WebCommon.h', + '../third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h', '../third_party/WebKit/WebKit/chromium/public/WebImage.h', '../third_party/WebKit/WebKit/chromium/public/WebKit.h', '../third_party/WebKit/WebKit/chromium/public/WebKitClient.h', '../third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h', '../third_party/WebKit/WebKit/chromium/public/WebPoint.h', '../third_party/WebKit/WebKit/chromium/public/WebRect.h', + '../third_party/WebKit/WebKit/chromium/public/WebScriptSource.h', '../third_party/WebKit/WebKit/chromium/public/WebSize.h', '../third_party/WebKit/WebKit/chromium/public/WebString.h', '../third_party/WebKit/WebKit/chromium/public/WebURL.h', @@ -4315,7 +4317,6 @@ 'glue/event_conversion.h', 'glue/feed_preview.cc', 'glue/feed_preview.h', - 'glue/find_in_page_request.h', 'glue/form_data.h', 'glue/glue_accessibility.cc', 'glue/glue_serialize.cc', @@ -4403,7 +4404,6 @@ 'glue/webplugin_impl.cc', 'glue/webplugin_impl.h', 'glue/webpreferences.h', - 'glue/webscriptsource.h', 'glue/webresponse.h', 'glue/webresponse_impl.h', 'glue/webtextinput.h', |