diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-10 05:46:45 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-10 05:46:45 +0000 |
commit | dd7daa80d25deb78ab365e28df4d93437357793b (patch) | |
tree | fb4dd2331820f5e32ddeb7e2bfb731f0604fbc0d | |
parent | 64c40aa34646a198a04029ee6b78dd9559595dc5 (diff) | |
download | chromium_src-dd7daa80d25deb78ab365e28df4d93437357793b.zip chromium_src-dd7daa80d25deb78ab365e28df4d93437357793b.tar.gz chromium_src-dd7daa80d25deb78ab365e28df4d93437357793b.tar.bz2 |
Switch to WebFrame from the WebKit API.
I tried to avoid unnecessary changes in this CL to help make it easier to
review.
As part of this CL, glue/webtextinput* are folded into WebFrame / WebFrameImpl.
R=dglazkov
BUG=10034
TEST=none
Review URL: http://codereview.chromium.org/164225
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22896 0039d316-1c4b-4281-b951-d872f2087c98
89 files changed, 1385 insertions, 1710 deletions
diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index e4cdf50..b879670 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -134,10 +134,6 @@ class ResourceDispatcherTest : public testing::Test, } protected: - static ResourceDispatcher* GetResourceDispatcher(WebFrame* unused) { - return dispatcher_.get(); - } - // testing::Test virtual void SetUp() { dispatcher_.reset(new ResourceDispatcher(this)); diff --git a/chrome/renderer/extensions/bindings_utils.cc b/chrome/renderer/extensions/bindings_utils.cc index 13738ca..3d29f4b 100644 --- a/chrome/renderer/extensions/bindings_utils.cc +++ b/chrome/renderer/extensions/bindings_utils.cc @@ -6,7 +6,9 @@ #include "base/string_util.h" #include "chrome/renderer/render_view.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" + +using WebKit::WebFrame; namespace bindings_utils { @@ -78,12 +80,12 @@ PendingRequestMap& GetPendingRequestMap() { } RenderView* GetRenderViewForCurrentContext() { - WebFrame* webframe = WebFrame::RetrieveFrameForCurrentContext(); + WebFrame* webframe = WebFrame::frameForCurrentContext(); DCHECK(webframe) << "RetrieveCurrentFrame called when not in a V8 context."; if (!webframe) return NULL; - WebView* webview = webframe->GetView(); + WebView* webview = webframe->view(); if (!webview) return NULL; // can happen during closing diff --git a/chrome/renderer/extensions/bindings_utils.h b/chrome/renderer/extensions/bindings_utils.h index 324a73c..604cb2c 100644 --- a/chrome/renderer/extensions/bindings_utils.h +++ b/chrome/renderer/extensions/bindings_utils.h @@ -15,7 +15,6 @@ #include <string> class RenderView; -class WebFrame; namespace bindings_utils { diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc index d771580..fcc0bcf 100644 --- a/chrome/renderer/extensions/event_bindings.cc +++ b/chrome/renderer/extensions/event_bindings.cc @@ -15,8 +15,8 @@ #include "chrome/renderer/render_view.h" #include "grit/renderer_resources.h" #include "webkit/api/public/WebDataSource.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebURLRequest.h" -#include "webkit/glue/webframe.h" using bindings_utils::CallFunctionInContext; using bindings_utils::ContextInfo; @@ -26,6 +26,7 @@ using bindings_utils::GetStringResource; using bindings_utils::ExtensionBase; using bindings_utils::GetPendingRequestMap; using bindings_utils::PendingRequestMap; +using WebKit::WebFrame; namespace { @@ -199,17 +200,17 @@ void EventBindings::HandleContextCreated(WebFrame* frame, bool content_script) { v8::HandleScope handle_scope; ContextList& contexts = GetContexts(); - v8::Local<v8::Context> frame_context = frame->GetMainWorldScriptContext(); + v8::Local<v8::Context> frame_context = frame->mainWorldScriptContext(); v8::Local<v8::Context> context = v8::Context::GetCurrent(); DCHECK(!context.IsEmpty()); DCHECK(bindings_utils::FindContext(context) == contexts.end()); // Figure out the URL for the toplevel frame. If the top frame is loading, // use its provisional URL, since we get this notification before commit. - WebFrame* main_frame = frame->GetView()->GetMainFrame(); - WebKit::WebDataSource* ds = main_frame->GetProvisionalDataSource(); + WebFrame* main_frame = frame->view()->GetMainFrame(); + WebKit::WebDataSource* ds = main_frame->provisionalDataSource(); if (!ds) - ds = main_frame->GetDataSource(); + ds = main_frame->dataSource(); GURL url = ds->request().url(); std::string extension_id; if (url.SchemeIs(chrome::kExtensionScheme)) { @@ -238,8 +239,8 @@ void EventBindings::HandleContextCreated(WebFrame* frame, bool content_script) { } RenderView* render_view = NULL; - if (frame->GetView() && frame->GetView()->GetDelegate()) - render_view = static_cast<RenderView*>(frame->GetView()->GetDelegate()); + if (frame->view() && frame->view()->GetDelegate()) + render_view = static_cast<RenderView*>(frame->view()->GetDelegate()); contexts.push_back(linked_ptr<ContextInfo>( new ContextInfo(persistent_context, extension_id, parent_context, @@ -256,7 +257,7 @@ void EventBindings::HandleContextDestroyed(WebFrame* frame) { return; v8::HandleScope handle_scope; - v8::Local<v8::Context> context = frame->GetMainWorldScriptContext(); + v8::Local<v8::Context> context = frame->mainWorldScriptContext(); DCHECK(!context.IsEmpty()); ContextList::iterator context_iter = bindings_utils::FindContext(context); diff --git a/chrome/renderer/extensions/event_bindings.h b/chrome/renderer/extensions/event_bindings.h index c9f81da..022fe09 100644 --- a/chrome/renderer/extensions/event_bindings.h +++ b/chrome/renderer/extensions/event_bindings.h @@ -5,13 +5,16 @@ #ifndef CHROME_RENDERER_EXTENSIONS_EVENT_BINDINGS_H_ #define CHROME_RENDERER_EXTENSIONS_EVENT_BINDINGS_H_ -#include "v8/include/v8.h" - #include <string> +#include "v8/include/v8.h" + class RenderThreadBase; class RenderView; + +namespace WebKit { class WebFrame; +} // This class deals with the javascript bindings related to Event objects. class EventBindings { @@ -24,8 +27,9 @@ class EventBindings { static RenderThreadBase* GetRenderThread(); // Handle a script context coming / going away. - static void HandleContextCreated(WebFrame* frame, bool content_script); - static void HandleContextDestroyed(WebFrame* frame); + static void HandleContextCreated(WebKit::WebFrame* frame, + bool content_script); + static void HandleContextDestroyed(WebKit::WebFrame* frame); // Calls the given function in each registered context which is listening for // events. If render_view is non-NULL, only call the function in contexts diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 09a1311..78afca5 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -15,7 +15,7 @@ #include "chrome/renderer/render_view.h" #include "grit/common_resources.h" #include "grit/renderer_resources.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" using bindings_utils::GetStringResource; using bindings_utils::ContextInfo; @@ -82,7 +82,7 @@ class ExtensionImpl : public ExtensionBase { static std::string ExtensionIdForCurrentContext() { RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); DCHECK(renderview); - GURL url = renderview->webview()->GetMainFrame()->GetURL(); + GURL url = renderview->webview()->GetMainFrame()->url(); if (url.SchemeIs(chrome::kExtensionScheme)) return url.host(); return std::string(); @@ -192,7 +192,7 @@ class ExtensionImpl : public ExtensionBase { if (!renderview) return v8::Undefined(); - if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() || + if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() || !args[2]->IsInt32() || !args[3]->IsBoolean()) return v8::Undefined(); diff --git a/chrome/renderer/external_extension.cc b/chrome/renderer/external_extension.cc index 100f311..777e883 100644 --- a/chrome/renderer/external_extension.cc +++ b/chrome/renderer/external_extension.cc @@ -4,7 +4,9 @@ #include "chrome/renderer/external_extension.h" #include "chrome/renderer/render_view.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" + +using WebKit::WebFrame; namespace extensions_v8 { @@ -35,12 +37,12 @@ class ExternalExtensionWrapper : public v8::Extension { if (!args.Length()) return v8::Undefined(); - WebFrame* webframe = WebFrame::RetrieveFrameForEnteredContext(); + WebFrame* webframe = WebFrame::frameForEnteredContext(); DCHECK(webframe) << "There should be an active frame since we just got " "a native function called."; if (!webframe) return v8::Undefined(); - WebView* webview = webframe->GetView(); + WebView* webview = webframe->view(); if (!webview) return v8::Undefined(); // can happen during closing RenderView* renderview = static_cast<RenderView*>(webview->GetDelegate()); diff --git a/chrome/renderer/external_host_bindings.cc b/chrome/renderer/external_host_bindings.cc index 7aaf139..70b867c 100644 --- a/chrome/renderer/external_host_bindings.cc +++ b/chrome/renderer/external_host_bindings.cc @@ -7,7 +7,6 @@ #include "base/values.h" #include "chrome/common/render_messages.h" #include "webkit/api/public/WebBindings.h" -#include "webkit/glue/webframe.h" using WebKit::WebBindings; @@ -45,7 +44,7 @@ void ExternalHostBindings::postMessage( } std::string origin; - GURL origin_url(frame_->GetURL().GetOrigin()); + GURL origin_url(GURL(frame_->url()).GetOrigin()); if (origin_url.is_empty()) { // If the origin is not a scheme/host/port tuple, then return the literal // string "null". @@ -67,7 +66,7 @@ bool ExternalHostBindings::ForwardMessageFromExternalHost( bool status = false; if (target.compare("*") != 0) { - GURL frame_url(frame_->GetURL()); + GURL frame_url(frame_->url()); GURL frame_origin(frame_url.GetOrigin()); GURL target_origin(GURL(target).GetOrigin()); @@ -141,9 +140,9 @@ bool ExternalHostBindings::CreateMessageEvent(NPObject** message_event) { DCHECK(message_event != NULL); DCHECK(frame_ != NULL); - NPObject* window = frame_->GetWindowNPObject(); + NPObject* window = frame_->windowObject(); if (!window) { - NOTREACHED() << "frame_->GetWindowNPObject"; + NOTREACHED() << "frame_->windowObject"; return false; } diff --git a/chrome/renderer/external_host_bindings.h b/chrome/renderer/external_host_bindings.h index d995975..1e7f6d2 100644 --- a/chrome/renderer/external_host_bindings.h +++ b/chrome/renderer/external_host_bindings.h @@ -29,7 +29,8 @@ class ExternalHostBindings : public DOMBoundBrowserObject { const std::string& target); // Overridden to hold onto a pointer back to the web frame. - void BindToJavascript(WebFrame* frame, const std::wstring& classname) { + void BindToJavascript(WebKit::WebFrame* frame, + const std::wstring& classname) { frame_ = frame; DOMBoundBrowserObject::BindToJavascript(frame, classname); } @@ -42,7 +43,7 @@ class ExternalHostBindings : public DOMBoundBrowserObject { private: CppVariant on_message_handler_; - WebFrame* frame_; + WebKit::WebFrame* frame_; DISALLOW_COPY_AND_ASSIGN(ExternalHostBindings); }; diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc index a8afe17..f98993b 100644 --- a/chrome/renderer/loadtimes_extension_bindings.cc +++ b/chrome/renderer/loadtimes_extension_bindings.cc @@ -8,10 +8,11 @@ #include "base/time.h" #include "chrome/renderer/navigation_state.h" +#include "webkit/api/public/WebFrame.h" #include "v8/include/v8.h" -#include "webkit/glue/webframe.h" using WebKit::WebDataSource; +using WebKit::WebFrame; using WebKit::WebNavigationType; // Values for CSI "tran" property @@ -94,9 +95,9 @@ class LoadTimesExtensionWrapper : public v8::Extension { } static v8::Handle<v8::Value> GetLoadTimes(const v8::Arguments& args) { - WebFrame* frame = WebFrame::RetrieveFrameForEnteredContext(); + WebFrame* frame = WebFrame::frameForEnteredContext(); if (frame) { - WebDataSource* data_source = frame->GetDataSource(); + WebDataSource* data_source = frame->dataSource(); if (data_source) { NavigationState* navigation_state = NavigationState::FromDataSource(data_source); @@ -135,9 +136,9 @@ class LoadTimesExtensionWrapper : public v8::Extension { } static v8::Handle<v8::Value> GetCSI(const v8::Arguments& args) { - WebFrame* frame = WebFrame::RetrieveFrameForEnteredContext(); + WebFrame* frame = WebFrame::frameForEnteredContext(); if (frame) { - WebDataSource* data_source = frame->GetDataSource(); + WebDataSource* data_source = frame->dataSource(); if (data_source) { NavigationState* navigation_state = NavigationState::FromDataSource(data_source); diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index a0803ba..3d4a336 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -10,12 +10,13 @@ #include "chrome/renderer/render_view.h" #include "grit/generated_resources.h" #include "printing/units.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebURLRequest.h" -#include "webkit/glue/webframe.h" +using WebKit::WebFrame; using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebString; @@ -50,11 +51,11 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( web_view->resize(print_layout_size); - expected_pages_count_ = frame->PrintBegin(print_canvas_size_); + expected_pages_count_ = frame->printBegin(print_canvas_size_); } PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { - frame_->PrintEnd(); + frame_->printEnd(); web_view_->resize(prev_view_size_); } @@ -88,7 +89,7 @@ bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, // Create a new WebView with the same settings as the current display one. // Except that we disable javascript (don't want any active content running // on the page). - WebPreferences prefs = web_frame->GetView()->GetPreferences(); + WebPreferences prefs = web_frame->view()->GetPreferences(); prefs.javascript_enabled = false; prefs.java_enabled = false; print_web_view_.reset(WebView::Create(this, prefs)); @@ -96,14 +97,14 @@ bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); print_pages_params_->pages.clear(); // Print all pages of selection. - std::string html = web_frame->GetSelection(true); + std::string html = web_frame->selectionAsMarkup().utf8(); std::string url_str = "data:text/html;charset=utf-8,"; url_str.append(html); GURL url(url_str); // When loading is done this will call DidStopLoading that will do the // actual printing. - print_web_view_->GetMainFrame()->LoadRequest(WebURLRequest(url)); + print_web_view_->GetMainFrame()->loadRequest(WebURLRequest(url)); return true; } @@ -112,7 +113,7 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, WebFrame* frame) { PrepareFrameAndViewForPrint prep_frame_view(params.params, frame, - frame->GetView()); + frame->view()); int page_count = prep_frame_view.GetExpectedPageCount(); Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id(), diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index efa6ee0..0c2f0ff 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -34,7 +34,7 @@ struct ViewMsg_PrintPages_Params; class PrepareFrameAndViewForPrint { public: PrepareFrameAndViewForPrint(const ViewMsg_Print_Params& print_params, - WebFrame* frame, + WebKit::WebFrame* frame, WebView* web_view); ~PrepareFrameAndViewForPrint(); @@ -47,7 +47,7 @@ class PrepareFrameAndViewForPrint { } private: - WebFrame* frame_; + WebKit::WebFrame* frame_; WebView* web_view_; gfx::Size print_canvas_size_; gfx::Size prev_view_size_; @@ -65,7 +65,7 @@ class PrintWebViewHelper : public WebViewDelegate { explicit PrintWebViewHelper(RenderView* render_view); virtual ~PrintWebViewHelper(); - void Print(WebFrame* frame, bool script_initiated); + void Print(WebKit::WebFrame* frame, bool script_initiated); // Is there a background print in progress? bool IsPrinting() { @@ -77,16 +77,17 @@ class PrintWebViewHelper : public WebViewDelegate { protected: bool CopyAndPrint(const ViewMsg_PrintPages_Params& params, - WebFrame* web_frame); + WebKit::WebFrame* web_frame); // Prints the page listed in |params|. void PrintPage(const ViewMsg_PrintPage_Params& params, const gfx::Size& canvas_size, - WebFrame* frame); + WebKit::WebFrame* frame); // Prints all the pages listed in |params|. // It will implicitly revert the document to display CSS media type. - void PrintPages(const ViewMsg_PrintPages_Params& params, WebFrame* frame); + void PrintPages(const ViewMsg_PrintPages_Params& params, + WebKit::WebFrame* frame); // IPC::Message::Sender bool Send(IPC::Message* msg); diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index 52b997d..0fb7ffc 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -7,8 +7,9 @@ #include "base/logging.h" #include "chrome/common/render_messages.h" #include "skia/ext/vector_canvas.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" +using WebKit::WebFrame; void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { // If still not finished with earlier print request simply ignore. @@ -39,7 +40,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { // Calculate the estimated page count. PrepareFrameAndViewForPrint prep_frame_view(default_settings, frame, - frame->GetView()); + frame->view()); int expected_pages_count = prep_frame_view.GetExpectedPageCount(); DCHECK(expected_pages_count); @@ -74,7 +75,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, // each page in printing. We might also need to create a metafile class // on Linux. skia::VectorCanvas canvas(size_x, size_y); - float webkit_shrink = frame->PrintPage(params.page_number, &canvas); + float webkit_shrink = frame->printPage(params.page_number, &canvas); if (shrink <= 0) { NOTREACHED() << "Printing page " << params.page_number << " failed."; } else { diff --git a/chrome/renderer/print_web_view_helper_mac.cc b/chrome/renderer/print_web_view_helper_mac.cc index ce07add..87a5517 100644 --- a/chrome/renderer/print_web_view_helper_mac.cc +++ b/chrome/renderer/print_web_view_helper_mac.cc @@ -6,6 +6,8 @@ #include "base/logging.h" +using WebKit::WebFrame; + void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { // TODO(port): print not implemented NOTIMPLEMENTED(); diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index e4e372a..fe7a8db 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -12,9 +12,10 @@ #include "grit/generated_resources.h" #include "printing/native_metafile.h" #include "webkit/api/public/WebConsoleMessage.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" using WebKit::WebConsoleMessage; +using WebKit::WebFrame; using WebKit::WebString; #include "skia/ext/vector_canvas.h" @@ -42,7 +43,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { if (diff.InSeconds() < min_wait_seconds) { WebString message(WebString::fromUTF8( "Ignoring too frequent calls to print().")); - frame->AddMessageToConsole(WebConsoleMessage( + frame->addMessageToConsole(WebConsoleMessage( WebConsoleMessage::LevelWarning, message)); return; @@ -77,7 +78,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { { PrepareFrameAndViewForPrint prep_frame_view(default_settings, frame, - frame->GetView()); + frame->view()); expected_pages_count = prep_frame_view.GetExpectedPageCount(); DCHECK(expected_pages_count); } @@ -96,7 +97,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { // of this message has to deal with this. params.host_window_id = render_view_->host_window(); params.cookie = default_settings.document_cookie; - params.has_selection = frame->HasSelection(); + params.has_selection = frame->hasSelection(); params.expected_pages_count = expected_pages_count; msg = new ViewHostMsg_ScriptedPrint(params, @@ -195,7 +196,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, #else // 100% GDI based. skia::VectorCanvas canvas(hdc, size_x, size_y); - float webkit_shrink = frame->PrintPage(params.page_number, &canvas); + float webkit_shrink = frame->printPage(params.page_number, &canvas); if (shrink <= 0) { NOTREACHED() << "Printing page " << params.page_number << " failed."; } else { diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index e82f7fc..add2fc1 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -58,6 +58,7 @@ #include "webkit/api/public/WebDataSource.h" #include "webkit/api/public/WebDragData.h" #include "webkit/api/public/WebForm.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebHistoryItem.h" #include "webkit/api/public/WebNode.h" #include "webkit/api/public/WebPoint.h" @@ -82,12 +83,10 @@ #include "webkit/glue/webaccessibilitymanager_impl.h" #include "webkit/glue/webdevtoolsagent_delegate.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webmediaplayer_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin_delegate.h" -#include "webkit/glue/webtextinput.h" #include "webkit/glue/webview.h" #if defined(OS_WIN) @@ -108,6 +107,7 @@ using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; using WebKit::WebForm; +using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebNavigationPolicy; using WebKit::WebNavigationType; @@ -337,7 +337,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd, void RenderView::OnMessageReceived(const IPC::Message& message) { WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; child_process_logging::ScopedActiveURLSetter url_setter( - main_frame ? main_frame->GetURL() : GURL()); + main_frame ? main_frame->url() : WebURL()); // If this is developer tools renderer intercept tools messages first. if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) @@ -441,7 +441,7 @@ void RenderView::SendThumbnail() { return; // get the URL for this page - GURL url(main_frame->GetURL()); + GURL url(main_frame->url()); if (url.is_empty()) return; @@ -463,7 +463,7 @@ void RenderView::OnPrintPages() { if (webview()) { // If the user has selected text in the currently focused frame we print // only that frame (this makes print selection work for multiple frames). - if (webview()->GetFocusedFrame()->HasSelection()) + if (webview()->GetFocusedFrame()->hasSelection()) Print(webview()->GetFocusedFrame(), false); else Print(webview()->GetMainFrame(), false); @@ -493,12 +493,12 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { return; // Don't index/capture pages that are in view source mode. - if (main_frame->GetInViewSourceMode()) + if (main_frame->isViewSourceModeEnabled()) return; // Don't index/capture pages that failed to load. This only checks the top // level frame so the thumbnail may contain a frame that failed to load. - WebDataSource* ds = main_frame->GetDataSource(); + WebDataSource* ds = main_frame->dataSource(); if (ds && ds->hasUnreachableURL()) return; @@ -506,7 +506,7 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { last_indexed_page_id_ = load_id; // get the URL for this page - GURL url(main_frame->GetURL()); + GURL url(main_frame->url()); if (url.is_empty()) return; @@ -539,7 +539,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { // TODO(brettw) we may want to consider more elaborate heuristics such as // the cachability of the page. We may also want to consider subframes (this // test will still index subframes if the subframe is SSL). - if (frame->GetURL().SchemeIsSecure()) + if (GURL(frame->url()).SchemeIsSecure()) return; #ifdef TIME_TEXT_RETRIEVAL @@ -547,7 +547,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { #endif // get the contents of the frame - frame->GetContentAsPlainText(kMaxIndexChars, contents); + *contents = UTF16ToWideHack(frame->contentAsText(kMaxIndexChars)); #ifdef TIME_TEXT_RETRIEVAL double end = time_util::GetHighResolutionTimeNow(); @@ -621,7 +621,7 @@ bool RenderView::CaptureThumbnail(WebView* view, } } - score->at_top = (view->GetMainFrame()->ScrollOffset().height == 0); + score->at_top = (view->GetMainFrame()->scrollOffset().height == 0); SkBitmap subset; device.accessBitmap(false).extractSubset(&subset, src_rect); @@ -664,7 +664,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { bool is_reload = params.reload; WebFrame* main_frame = webview()->GetMainFrame(); - if (is_reload && main_frame->GetCurrentHistoryItem().isNull()) { + if (is_reload && main_frame->currentHistoryItem().isNull()) { // We cannot reload if we do not have any history state. This happens, for // example, when recovering from a crash. Our workaround here is a bit of // a hack since it means that reload after a crashed tab does not cause an @@ -685,11 +685,11 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { // have history state, then we need to navigate to it, which corresponds to a // back/forward navigation event. if (is_reload) { - main_frame->Reload(); + main_frame->reload(); } else if (!params.state.empty()) { // We must know the page ID of the page we are navigating back to. DCHECK_NE(params.page_id, -1); - main_frame->LoadHistoryItem( + main_frame->loadHistoryItem( webkit_glue::HistoryItemFromString(params.state)); } else { // Navigate to the given URL. @@ -698,7 +698,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { // A session history navigation should have been accompanied by state. DCHECK_EQ(params.page_id, -1); - if (main_frame->GetInViewSourceMode()) + if (main_frame->isViewSourceModeEnabled()) request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); if (params.referrer.is_valid()) { @@ -706,7 +706,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { WebString::fromUTF8(params.referrer.spec())); } - main_frame->LoadRequest(request); + main_frame->loadRequest(request); } // In case LoadRequest failed before DidCreateDataSource was called. @@ -730,7 +730,7 @@ void RenderView::OnLoadAlternateHTMLText(const std::string& html, new_navigation ? -1 : page_id_, PageTransition::LINK, Time::Now())); pending_navigation_state_->set_security_info(security_info); - webview()->GetMainFrame()->LoadHTMLString(html, + webview()->GetMainFrame()->loadHTMLString(html, GURL(kUnreachableWebDataURL), display_url, !new_navigation); @@ -747,7 +747,8 @@ void RenderView::OnExecuteEditCommand(const std::string& name, if (!webview() || !webview()->GetFocusedFrame()) return; - webview()->GetFocusedFrame()->ExecuteEditCommandByName(name, value); + webview()->GetFocusedFrame()->executeCommand( + WebString::fromUTF8(name), WebString::fromUTF8(value)); } void RenderView::OnSetupDevToolsClient() { @@ -761,11 +762,11 @@ void RenderView::OnStopFinding(bool clear_selection) { return; if (clear_selection) - view->GetFocusedFrame()->ClearSelection(); + view->GetFocusedFrame()->clearSelection(); WebFrame* frame = view->GetMainFrame(); while (frame) { - frame->StopFinding(clear_selection); + frame->stopFinding(clear_selection); frame = view->GetNextFrameAfter(frame, false); } } @@ -793,63 +794,71 @@ void RenderView::OnUndo() { if (!webview()) return; - webview()->GetFocusedFrame()->Undo(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Undo")); + UserMetricsRecordAction(L"Undo"); } void RenderView::OnRedo() { if (!webview()) return; - webview()->GetFocusedFrame()->Redo(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Redo")); + UserMetricsRecordAction(L"Redo"); } void RenderView::OnCut() { if (!webview()) return; - webview()->GetFocusedFrame()->Cut(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Cut")); + UserMetricsRecordAction(L"Cut"); } void RenderView::OnCopy() { if (!webview()) return; - webview()->GetFocusedFrame()->Copy(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Copy")); + UserMetricsRecordAction(L"Copy"); } void RenderView::OnPaste() { if (!webview()) return; - webview()->GetFocusedFrame()->Paste(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Paste")); + UserMetricsRecordAction(L"Paste"); } void RenderView::OnReplace(const std::wstring& text) { if (!webview()) return; - webview()->GetFocusedFrame()->Replace(text); + webview()->GetFocusedFrame()->replaceSelection(WideToUTF16Hack(text)); } void RenderView::OnToggleSpellCheck() { if (!webview()) return; - webview()->GetFocusedFrame()->ToggleSpellCheck(); + WebFrame* frame = webview()->GetFocusedFrame(); + frame->enableContinuousSpellChecking( + !frame->isContinuousSpellCheckingEnabled()); } void RenderView::OnDelete() { if (!webview()) return; - webview()->GetFocusedFrame()->Delete(); + webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Delete")); + UserMetricsRecordAction(L"DeleteSelection"); } void RenderView::OnSelectAll() { if (!webview()) return; - webview()->GetFocusedFrame()->SelectAll(); + webview()->GetFocusedFrame()->selectAll(); } void RenderView::OnSetInitialFocus(bool reverse) { @@ -862,7 +871,7 @@ void RenderView::OnSetInitialFocus(bool reverse) { // Tell the embedding application that the URL of the active page has changed void RenderView::UpdateURL(WebFrame* frame) { - WebDataSource* ds = frame->GetDataSource(); + WebDataSource* ds = frame->dataSource(); DCHECK(ds); const WebURLRequest& request = ds->request(); @@ -914,7 +923,7 @@ void RenderView::UpdateURL(WebFrame* frame) { params.gesture = navigation_gesture_; navigation_gesture_ = NavigationGestureUnknown; - if (!frame->GetParent()) { + if (!frame->parent()) { // Top-level navigation. // Update contents MIME type for main frame. @@ -1022,7 +1031,7 @@ void RenderView::UpdateSessionHistory(WebFrame* frame) { return; const WebHistoryItem& item = - webview()->GetMainFrame()->GetPreviousHistoryItem(); + webview()->GetMainFrame()->previousHistoryItem(); if (item.isNull()) return; @@ -1064,11 +1073,11 @@ void RenderView::DidStopLoading(WebView* webview) { // displayed when done loading. Ideally we would send notification when // finished parsing the head, but webkit doesn't support that yet. // The feed discovery code would also benefit from access to the head. - GURL favicon_url(webview->GetMainFrame()->GetFavIconURL()); + GURL favicon_url(webview->GetMainFrame()->favIconURL()); if (!favicon_url.is_empty()) Send(new ViewHostMsg_UpdateFavIconURL(routing_id_, page_id_, favicon_url)); - AddGURLSearchProvider(webview->GetMainFrame()->GetOSDDURL(), + AddGURLSearchProvider(webview->GetMainFrame()->openSearchDescriptionURL(), true); // autodetected Send(new ViewHostMsg_DidStopLoading(routing_id_)); @@ -1099,13 +1108,13 @@ void RenderView::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { void RenderView::DidPaint() { WebFrame* main_frame = webview()->GetMainFrame(); - if (main_frame->GetProvisionalDataSource()) { + if (main_frame->provisionalDataSource()) { // If we have a provisional frame we are between the start // and commit stages of loading...ignore this paint. return; } - WebDataSource* ds = main_frame->GetDataSource(); + WebDataSource* ds = main_frame->dataSource(); NavigationState* navigation_state = NavigationState::FromDataSource(ds); DCHECK(navigation_state); @@ -1123,7 +1132,7 @@ void RenderView::DidStartProvisionalLoadForFrame( WebView* webview, WebFrame* frame, NavigationGesture gesture) { - WebDataSource* ds = frame->GetProvisionalDataSource(); + WebDataSource* ds = frame->provisionalDataSource(); NavigationState* navigation_state = NavigationState::FromDataSource(ds); navigation_state->set_start_load_time(Time::Now()); @@ -1135,13 +1144,13 @@ void RenderView::DidStartProvisionalLoadForFrame( navigation_state->set_request_time(Time::FromDoubleT(event_time)); } - bool is_top_most = !frame->GetParent(); + bool is_top_most = !frame->parent(); if (is_top_most) { navigation_gesture_ = gesture; // Make sure redirect tracking state is clear for the new load. completed_client_redirect_src_ = GURL(); - } else if (frame->GetParent()->IsLoading()) { + } else if (frame->parent()->isLoading()) { // Take note of AUTO_SUBFRAME loads here, so that we can know how to // load an error page. See DidFailProvisionalLoadWithError. navigation_state->set_transition_type(PageTransition::AUTO_SUBFRAME); @@ -1157,9 +1166,11 @@ bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, WebFrame* frame) { // Let the browser know we loaded a resource from the memory cache. This // message is needed to display the correct SSL indicators. - Send(new ViewHostMsg_DidLoadResourceFromMemoryCache(routing_id_, - request.url(), frame->GetSecurityOrigin(), - frame->GetTop()->GetSecurityOrigin(), + Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( + routing_id_, + request.url(), + frame->securityOrigin().utf8(), + frame->top()->securityOrigin().utf8(), response.securityInfo())); return false; @@ -1170,7 +1181,7 @@ void RenderView::DidReceiveProvisionalLoadServerRedirect(WebView* webview, if (frame == webview->GetMainFrame()) { // Received a redirect on the main frame. WebDataSource* data_source = - webview->GetMainFrame()->GetProvisionalDataSource(); + webview->GetMainFrame()->provisionalDataSource(); if (!data_source) { // Should only be invoked when we have a data source. NOTREACHED(); @@ -1195,7 +1206,7 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, // SSL manager can react to the provisional load failure before being // notified the load stopped. // - WebDataSource* ds = frame->GetProvisionalDataSource(); + WebDataSource* ds = frame->provisionalDataSource(); DCHECK(ds); const WebURLRequest& failed_request = ds->request(); @@ -1204,8 +1215,7 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, (error.reason == net::ERR_CACHE_MISS && EqualsASCII(failed_request.httpMethod(), "POST")); Send(new ViewHostMsg_DidFailProvisionalLoadWithError( - routing_id_, !frame->GetParent(), - error.reason, error.unreachableURL, + routing_id_, !frame->parent(), error.reason, error.unreachableURL, show_repost_interstitial)); // Don't display an error page if this is simply a cancelled load. Aside @@ -1214,7 +1224,7 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, return; // Make sure we never show errors in view source mode. - frame->SetInViewSourceMode(false); + frame->enableViewSourceMode(false); NavigationState* navigation_state = NavigationState::FromDataSource(ds); @@ -1277,7 +1287,7 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, alt_html = html; } - frame->LoadHTMLString(alt_html, + frame->loadHTMLString(alt_html, GURL(kUnreachableWebDataURL), failed_url, replace); @@ -1286,9 +1296,9 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, void RenderView::DidReceiveDocumentData(WebFrame* frame, const char* data, size_t data_len) { NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetDataSource()); + NavigationState::FromDataSource(frame->dataSource()); if (!navigation_state->postpone_loading_data()) { - frame->CommitDocumentData(data, data_len); + frame->commitDocumentData(data, data_len); return; } @@ -1297,7 +1307,7 @@ void RenderView::DidReceiveDocumentData(WebFrame* frame, const char* data, navigation_state->append_postponed_data(data, data_len); if (navigation_state->postponed_data().size() >= 512) { navigation_state->set_postpone_loading_data(false); - frame->CommitDocumentData(navigation_state->postponed_data().data(), + frame->commitDocumentData(navigation_state->postponed_data().data(), navigation_state->postponed_data().size()); navigation_state->clear_postponed_data(); } @@ -1306,7 +1316,7 @@ void RenderView::DidReceiveDocumentData(WebFrame* frame, const char* data, void RenderView::DidCommitLoadForFrame(WebView *webview, WebFrame* frame, bool is_new_navigation) { NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetDataSource()); + NavigationState::FromDataSource(frame->dataSource()); navigation_state->set_commit_load_time(Time::Now()); if (is_new_navigation) { @@ -1368,7 +1378,7 @@ void RenderView::DidReceiveTitle(WebView* webview, } void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { - WebDataSource* ds = frame->GetDataSource(); + WebDataSource* ds = frame->dataSource(); NavigationState* navigation_state = NavigationState::FromDataSource(ds); DCHECK(navigation_state); navigation_state->set_finish_load_time(Time::Now()); @@ -1384,7 +1394,7 @@ void RenderView::DidFailLoadWithError(WebView* webview, void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, WebFrame* frame) { - WebDataSource* ds = frame->GetDataSource(); + WebDataSource* ds = frame->dataSource(); NavigationState* navigation_state = NavigationState::FromDataSource(ds); DCHECK(navigation_state); navigation_state->set_finish_document_load_time(Time::Now()); @@ -1417,12 +1427,12 @@ void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, // initiate this navigation, then we need to take care to reset any pre- // existing navigation state to a content-initiated navigation state. // DidCreateDataSource conveniently takes care of this for us. - DidCreateDataSource(frame, frame->GetDataSource()); + DidCreateDataSource(frame, frame->dataSource()); DidCommitLoadForFrame(webview, frame, is_new_navigation); const string16& title = - webview->GetMainFrame()->GetDataSource()->pageTitle(); + webview->GetMainFrame()->dataSource()->pageTitle(); UpdateTitle(frame, UTF16ToWideHack(title)); } @@ -1434,8 +1444,8 @@ void RenderView::DidCompleteClientRedirect(WebView* webview, } void RenderView::WillCloseFrame(WebView* webview, WebFrame* frame) { - if (!frame->GetParent()) { - const GURL& url = frame->GetURL(); + if (!frame->parent()) { + const GURL& url = frame->url(); if (url.SchemeIs("http") || url.SchemeIs("https")) DumpLoadHistograms(); } @@ -1444,7 +1454,7 @@ void RenderView::WillCloseFrame(WebView* webview, WebFrame* frame) { void RenderView::WillSubmitForm(WebView* webview, WebFrame* frame, const WebForm& form) { NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetProvisionalDataSource()); + NavigationState::FromDataSource(frame->provisionalDataSource()); if (navigation_state->transition_type() == PageTransition::LINK) navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); @@ -1478,12 +1488,12 @@ void RenderView::DidReceiveResponse(WebFrame* frame, uint32 identifier, // of the top-most frame. If we have a provisional data source, then we // can't have any sub-resources yet, so we know that this response must // correspond to a frame load. - if (!frame->GetProvisionalDataSource() || frame->GetParent()) + if (!frame->provisionalDataSource() || frame->parent()) return; // If we are in view source mode, then just let the user see the source of // the server's 404 error page. - if (frame->GetInViewSourceMode()) + if (frame->isViewSourceModeEnabled()) return; // Can we even load an alternate error page for this URL? @@ -1491,21 +1501,21 @@ void RenderView::DidReceiveResponse(WebFrame* frame, uint32 identifier, return; NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetProvisionalDataSource()); + NavigationState::FromDataSource(frame->provisionalDataSource()); navigation_state->set_postpone_loading_data(true); navigation_state->clear_postponed_data(); } void RenderView::DidFinishLoading(WebFrame* frame, uint32 identifier) { NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetDataSource()); + NavigationState::FromDataSource(frame->dataSource()); if (!navigation_state->postpone_loading_data()) return; // The server returned a 404 and the content was < 512 bytes (which we // suppressed). Go ahead and fetch the alternate page content. - const GURL& frame_url = frame->GetURL(); + const GURL& frame_url = frame->url(); const GURL& error_page_url = GetAlternateErrorPageURL(frame_url, HTTP_404); DCHECK(error_page_url.is_valid()); @@ -1546,9 +1556,9 @@ void RenderView::DocumentElementAvailable(WebFrame* frame) { // HACK. This is a temporary workaround to allow cross-origin XHR for Chrome // extensions. It grants full access to every origin, when we really want // to be able to restrict them more specifically. - GURL url = frame->GetURL(); + GURL url = frame->url(); if (url.SchemeIs(chrome::kExtensionScheme)) - frame->GrantUniversalAccess(); + frame->grantUniversalAccess(); if (RenderThread::current()) // Will be NULL during unit tests. RenderThread::current()->user_script_slave()->InjectScripts( @@ -1593,9 +1603,9 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // Not interested in reloads. type != WebKit::WebNavigationTypeReload && // Must be a top level frame. - frame->GetParent() == NULL) { + frame->parent() == NULL) { // Skip if navigation is on the same page (using '#'). - GURL frame_origin = frame->GetURL().GetOrigin(); + GURL frame_origin = GURL(frame->url()).GetOrigin(); if (url.GetOrigin() != frame_origin || url.ref().empty()) { last_top_level_navigation_page_id_ = page_id_; OpenURL(webview, url, GURL(), default_policy); @@ -1606,7 +1616,7 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // A content initiated navigation may have originated from a link-click, // script, drag-n-drop operation, etc. bool is_content_initiated = - NavigationState::FromDataSource(frame->GetProvisionalDataSource())-> + NavigationState::FromDataSource(frame->provisionalDataSource())-> is_content_initiated(); // We only care about navigations that are within the current tab (as opposed @@ -1614,13 +1624,13 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // But we sometimes navigate to about:blank to clear a tab, and we want to // still allow that. if (default_policy == WebKit::WebNavigationPolicyCurrentTab && - is_content_initiated && frame->GetParent() == NULL && + is_content_initiated && frame->parent() == NULL && !url.SchemeIs(chrome::kAboutScheme)) { // When we received such unsolicited navigations, we sometimes want to // punt them up to the browser to handle. if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) || BindingsPolicy::is_extension_enabled(enabled_bindings_) || - frame->GetInViewSourceMode() || + frame->isViewSourceModeEnabled() || url.SchemeIs(chrome::kViewSourceScheme) || url.SchemeIs(chrome::kPrintScheme)) { OpenURL(webview, url, GURL(), default_policy); @@ -1641,15 +1651,15 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // JavaScript. bool is_fork = // Must start from a tab showing about:blank, which is later redirected. - frame->GetURL() == GURL("about:blank") && + GURL(frame->url()) == GURL("about:blank") && // Must be the first real navigation of the tab. GetHistoryBackListCount() < 1 && GetHistoryForwardListCount() < 1 && // The parent page must have set the child's window.opener to null before // redirecting to the desired URL. - frame->GetOpener() == NULL && + frame->opener() == NULL && // Must be a top-level frame. - frame->GetParent() == NULL && + frame->parent() == NULL && // Must not have issued the request from this page. is_content_initiated && // Must be targeted at the current tab. @@ -1670,7 +1680,7 @@ void RenderView::RunJavaScriptAlert(WebFrame* webframe, RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert, message, std::wstring(), - webframe->GetURL(), + webframe->url(), NULL); } @@ -1679,7 +1689,7 @@ bool RenderView::RunJavaScriptConfirm(WebFrame* webframe, return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptConfirm, message, std::wstring(), - webframe->GetURL(), + webframe->url(), NULL); } @@ -1690,7 +1700,7 @@ bool RenderView::RunJavaScriptPrompt(WebFrame* webframe, return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptPrompt, message, default_value, - webframe->GetURL(), + webframe->url(), result); } @@ -1725,7 +1735,7 @@ bool RenderView::RunBeforeUnloadConfirm(WebFrame* webframe, // response as RunJavaScriptMessage. std::wstring ignored_result; IPC::SyncMessage* msg = new ViewHostMsg_RunBeforeUnloadConfirm( - routing_id_, webframe->GetURL(), message, &success, &ignored_result); + routing_id_, webframe->url(), message, &success, &ignored_result); msg->set_pump_messages_event(modal_dialog_event_.get()); Send(msg); @@ -1903,7 +1913,7 @@ WebPluginDelegate* RenderView::CreatePluginDelegate( GURL policy_url; if (webview->GetMainFrame()) - policy_url = webview->GetMainFrame()->GetURL(); + policy_url = webview->GetMainFrame()->url(); FilePath path; render_thread_->Send( @@ -2022,7 +2032,7 @@ void RenderView::DidContentsSizeChange(WebWidget* webwidget, // WebCore likes to tell us things have changed even when they haven't, so // cache the width and only send the IPC message when we're sure the // width is different. - int width = webview()->GetMainFrame()->GetContentsPreferredWidth(); + int width = webview()->GetMainFrame()->contentsPreferredWidth(); if (width != preferred_width_) { Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width)); preferred_width_ = width; @@ -2072,8 +2082,7 @@ void RenderView::SyncNavigationState() { if (!webview()) return; - const WebHistoryItem& item = - webview()->GetMainFrame()->GetCurrentHistoryItem(); + const WebHistoryItem& item = webview()->GetMainFrame()->currentHistoryItem(); if (item.isNull()) return; @@ -2108,7 +2117,7 @@ void RenderView::ShowContextMenu(WebView* webview, params.selection_text = selection_text; params.misspelled_word = misspelled_word; params.spellcheck_enabled = - webview->GetFocusedFrame()->SpellCheckEnabled(); + webview->GetFocusedFrame()->isContinuousSpellCheckingEnabled(); params.edit_flags = edit_flags; params.security_info = security_info; params.frame_charset = frame_charset; @@ -2255,12 +2264,12 @@ void RenderView::OnFind(int request_id, bool result = false; do { - result = search_frame->Find( + result = search_frame->find( request_id, search_text, options, wrap_within_frame, &selection_rect); if (!result) { // don't leave text selected as you move to the next frame. - search_frame->ClearSelection(); + search_frame->clearSelection(); // Find the next frame, but skip the invisible ones. do { @@ -2269,10 +2278,11 @@ void RenderView::OnFind(int request_id, search_frame = options.forward ? webview()->GetNextFrameAfter(search_frame, true) : webview()->GetPreviousFrameBefore(search_frame, true); - } while (!search_frame->Visible() && search_frame != focused_frame); + } while (!search_frame->hasVisibleContent() && + search_frame != focused_frame); // Make sure selection doesn't affect the search operation in new frame. - search_frame->ClearSelection(); + search_frame->clearSelection(); // If we have multiple frames and we have wrapped back around to the // focused frame, we need to search it once more allowing wrap within @@ -2280,7 +2290,7 @@ void RenderView::OnFind(int request_id, // reported matches, but no frames after the focused_frame contain a // match for the search word(s). if (multi_frame && search_frame == focused_frame) { - result = search_frame->Find( + result = search_frame->find( request_id, search_text, options, true, // Force wrapping. &selection_rect); } @@ -2291,7 +2301,7 @@ void RenderView::OnFind(int request_id, if (options.findNext) { // Force the main_frame to report the actual count. - main_frame->IncreaseMatchCount(0, request_id); + main_frame->increaseMatchCount(0, request_id); } 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 @@ -2314,18 +2324,18 @@ void RenderView::OnFind(int request_id, // Scoping effort begins, starting with the mainframe. search_frame = main_frame; - main_frame->ResetMatchCount(); + main_frame->resetMatchCount(); do { // Cancel all old scoping requests before starting a new one. - search_frame->CancelPendingScopingEffort(); + search_frame->cancelPendingScopingEffort(); // We don't start another scoping effort unless at least one match has // been found. if (result) { // Start new scoping request. If the scoping function determines that it // needs to scope, it will defer until later. - search_frame->ScopeStringMatches(request_id, + search_frame->scopeStringMatches(request_id, search_text, options, true); // reset the tickmarks @@ -2462,9 +2472,7 @@ void RenderView::OnInsertText(const string16& text) { WebFrame* frame = webview()->GetFocusedFrame(); if (!frame) return; - WebTextInput* text_input = frame->GetTextInput(); - if (text_input) - text_input->InsertText(text); + frame->insertText(text); } void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) { @@ -2510,7 +2518,7 @@ void RenderView::DidChangeSelection(bool is_empty_selection) { // the selection hasn't actually changed. We don't want to report these // because it will cause us to continually claim the X clipboard. const std::string& this_selection = - webview()->GetFocusedFrame()->GetSelection(false); + webview()->GetFocusedFrame()->selectionAsText().utf8(); if (this_selection == last_selection_) return; @@ -2539,15 +2547,32 @@ void RenderView::PasteFromSelectionClipboard() { Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_)); } -WebFrame* RenderView::GetChildFrame(const std::wstring& frame_xpath) const { - WebFrame* web_frame; - if (frame_xpath.empty()) { - web_frame = webview()->GetMainFrame(); - } else { - web_frame = webview()->GetMainFrame()->GetChildFrame(frame_xpath); +WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const { + if (xpath.empty()) + return webview()->GetMainFrame(); + + // xpath string can represent a frame deep down the tree (across multiple + // frame DOMs). + // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] + // should break into 2 xpaths + // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] + + WebFrame* frame = webview()->GetMainFrame(); + + std::wstring xpath_remaining = xpath; + while (!xpath_remaining.empty()) { + std::wstring::size_type delim_pos = xpath_remaining.find_first_of(L'\n'); + std::wstring xpath_child; + if (delim_pos != std::wstring::npos) { + xpath_child = xpath_remaining.substr(0, delim_pos); + xpath_remaining.erase(0, delim_pos + 1); + } else { + xpath_remaining.swap(xpath_child); + } + frame = frame->findChildByExpression(WideToUTF16Hack(xpath_child)); } - return web_frame; + return frame; } void RenderView::EvaluateScript(const std::wstring& frame_xpath, @@ -2556,7 +2581,7 @@ void RenderView::EvaluateScript(const std::wstring& frame_xpath, if (!web_frame) return; - web_frame->ExecuteScript(WebScriptSource(WideToUTF16Hack(script))); + web_frame->executeScript(WebScriptSource(WideToUTF16Hack(script))); } void RenderView::InsertCSS(const std::wstring& frame_xpath, @@ -2565,7 +2590,7 @@ void RenderView::InsertCSS(const std::wstring& frame_xpath, if (!web_frame) return; - web_frame->InsertCSSStyles(css); + web_frame->insertStyleText(WebString::fromUTF8(css)); } void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath, @@ -2587,7 +2612,7 @@ void RenderView::OnAddMessageToConsole( const WebConsoleMessage::Level& level) { WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath)); if (web_frame) - web_frame->AddMessageToConsole(WebConsoleMessage(level, message)); + web_frame->addMessageToConsole(WebConsoleMessage(level, message)); } void RenderView::OnAllowBindings(int enabled_bindings_flags) { @@ -2728,7 +2753,7 @@ void RenderView::OnEnableViewSourceMode() { if (!main_frame) return; - main_frame->SetInViewSourceMode(true); + main_frame->enableViewSourceMode(true); } void RenderView::OnEnableIntrinsicWidthChangedMode() { @@ -2851,11 +2876,12 @@ void RenderView::OnClosePage(const ViewMsg_ClosePage_Params& params) { // http://b/issue?id=753080. WebFrame* main_frame = webview()->GetMainFrame(); if (main_frame) { - const GURL& url = main_frame->GetURL(); + const GURL& url = main_frame->url(); // TODO(davemoore) this code should be removed once WillCloseFrame() gets // called when a page is destroyed. DumpLoadHistograms() is safe to call // multiple times for the same frame, but it will simplify things. - if (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme)) + if (url.SchemeIs(chrome::kHttpScheme) || + url.SchemeIs(chrome::kHttpsScheme)) DumpLoadHistograms(); } webview()->ClosePage(); @@ -2881,7 +2907,7 @@ void RenderView::DidAddHistoryItem() { WebFrame* main_frame = webview()->GetMainFrame(); DCHECK(main_frame != NULL); - WebDataSource* ds = main_frame->GetDataSource(); + WebDataSource* ds = main_frame->dataSource(); DCHECK(ds != NULL); NavigationState* navigation_state = NavigationState::FromDataSource(ds); @@ -2918,7 +2944,7 @@ bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, // value in showing them for failed subframes. Ideally, we would be // able to use the TYPED transition type for this, but that flag is // not preserved across page reloads. - if (frame->GetParent()) + if (frame->parent()) return false; // Use the alternate error page service if this is a DNS failure or @@ -2938,7 +2964,7 @@ bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, // Load an empty page first so there is an immediate response to the error, // and then kick off a request for the alternate error page. - frame->LoadHTMLString(std::string(), + frame->loadHTMLString(std::string(), GURL(kUnreachableWebDataURL), error.unreachableURL, replace); @@ -2947,7 +2973,7 @@ bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, // source we just created via the LoadHTMLString call. That way if another // navigation occurs, the fetcher will get destroyed. NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetProvisionalDataSource()); + NavigationState::FromDataSource(frame->provisionalDataSource()); navigation_state->set_alt_error_page_fetcher( new AltErrorPageResourceFetcher( error_page_url, frame, error, @@ -2982,7 +3008,7 @@ void RenderView::AltErrorPageFinished(WebFrame* frame, const std::string* html_to_load = &html; if (html.empty()) { NavigationState* navigation_state = - NavigationState::FromDataSource(frame->GetDataSource()); + NavigationState::FromDataSource(frame->dataSource()); html_to_load = &navigation_state->postponed_data(); } LoadNavigationErrorPage( @@ -3074,7 +3100,7 @@ void RenderView::OnExtensionMessageInvoke(const std::string& function_name, void RenderView::DumpLoadHistograms() const { WebFrame* main_frame = webview()->GetMainFrame(); NavigationState* navigation_state = - NavigationState::FromDataSource(main_frame->GetDataSource()); + NavigationState::FromDataSource(main_frame->dataSource()); Time finish = navigation_state->finish_load_time(); // If we've already dumped or we haven't finished loading, do nothing. @@ -3250,8 +3276,8 @@ void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { } void RenderView::SendPasswordForms(WebFrame* frame) { - std::vector<WebForm> forms; - frame->GetForms(&forms); + WebVector<WebForm> forms; + frame->forms(forms); std::vector<PasswordForm> password_forms; for (size_t i = 0; i < forms.size(); ++i) { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index cc2eb98..3fe509b 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -51,7 +51,6 @@ class GURL; class ListValue; class NavigationState; class PrintWebViewHelper; -class WebFrame; class WebPluginDelegate; class WebPluginDelegateProxy; class WebDevToolsAgentDelegate; @@ -141,15 +140,15 @@ class RenderView : public RenderWidget, virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, const std::string& json_arguments, std::string* json_retval); - virtual void RunJavaScriptAlert(WebFrame* webframe, + virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, const std::wstring& message); - virtual bool RunJavaScriptConfirm(WebFrame* webframe, + virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, const std::wstring& message); - virtual bool RunJavaScriptPrompt(WebFrame* webframe, + virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, const std::wstring& message, const std::wstring& default_value, std::wstring* result); - virtual bool RunBeforeUnloadConfirm(WebFrame* webframe, + virtual bool RunBeforeUnloadConfirm(WebKit::WebFrame* webframe, const std::wstring& message); virtual void QueryFormFieldAutofill(const std::wstring& field_name, const std::wstring& text, @@ -169,73 +168,74 @@ class RenderView : public RenderWidget, virtual void DidStartLoading(WebView* webview); virtual void DidStopLoading(WebView* webview); - virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds); + virtual void DidCreateDataSource(WebKit::WebFrame* frame, + WebKit::WebDataSource* ds); virtual void DidStartProvisionalLoadForFrame( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, NavigationGesture gesture); virtual void DidReceiveProvisionalLoadServerRedirect(WebView* webview, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidFailProvisionalLoadWithError( WebView* webview, const WebKit::WebURLError& error, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void LoadNavigationErrorPage( - WebFrame* frame, + WebKit::WebFrame* frame, const WebKit::WebURLRequest& failed_request, const WebKit::WebURLError& error, const std::string& html, bool replace); - virtual void DidReceiveDocumentData(WebFrame* frame, const char* data, + virtual void DidReceiveDocumentData(WebKit::WebFrame* frame, const char* data, size_t data_len); - virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, + virtual void DidCommitLoadForFrame(WebView* webview, WebKit::WebFrame* frame, bool is_new_navigation); virtual void DidReceiveTitle(WebView* webview, const std::wstring& title, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidFinishLoadForFrame(WebView* webview, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidFailLoadWithError(WebView* webview, const WebKit::WebURLError& error, - WebFrame* forFrame); - virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebFrame* frame); + WebKit::WebFrame* forFrame); + virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebKit::WebFrame* frame); virtual bool DidLoadResourceFromMemoryCache( WebView* webview, const WebKit::WebURLRequest& request, const WebKit::WebURLResponse& response, - WebFrame* frame); - virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebFrame* frame); + WebKit::WebFrame* frame); + virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebKit::WebFrame* frame); virtual void DidChangeLocationWithinPageForFrame(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, bool is_new_navigation); virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget, int new_width, int new_height); virtual void DidCompleteClientRedirect(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const GURL& source); - virtual void WillCloseFrame(WebView* webview, WebFrame* frame); - virtual void WillSubmitForm(WebView* webview, WebFrame* frame, + virtual void WillCloseFrame(WebView* webview, WebKit::WebFrame* frame); + virtual void WillSubmitForm(WebView* webview, WebKit::WebFrame* frame, const WebKit::WebForm& form); - virtual void WillSendRequest(WebFrame* webframe, + virtual void WillSendRequest(WebKit::WebFrame* webframe, uint32 identifier, WebKit::WebURLRequest* request, const WebKit::WebURLResponse& redirect_response); - virtual void DidReceiveResponse(WebFrame* webframe, + virtual void DidReceiveResponse(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLResponse& response); - virtual void DidFinishLoading(WebFrame* webframe, uint32 identifier); + virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier); - virtual void WindowObjectCleared(WebFrame* webframe); - virtual void DocumentElementAvailable(WebFrame* webframe); - virtual void DidCreateScriptContextForFrame(WebFrame* webframe); - virtual void DidDestroyScriptContextForFrame(WebFrame* webframe); - virtual void DidCreateIsolatedScriptContext(WebFrame* webframe); + virtual void WindowObjectCleared(WebKit::WebFrame* webframe); + virtual void DocumentElementAvailable(WebKit::WebFrame* webframe); + virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe); + virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe); + virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe); virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, WebKit::WebNavigationPolicy default_policy, @@ -320,7 +320,7 @@ class RenderView : public RenderWidget, int* misspell_length); virtual std::wstring GetAutoCorrectWord(const std::wstring& word); virtual void SetInputMethodState(bool enabled); - virtual void ScriptedPrint(WebFrame* frame); + virtual void ScriptedPrint(WebKit::WebFrame* frame); virtual void UserMetricsRecordAction(const std::wstring& action); virtual void DnsPrefetch(const std::vector<std::string>& host_names); @@ -413,9 +413,9 @@ class RenderView : public RenderWidget, SharedRenderViewCounter* counter, int32 routing_id); - void UpdateURL(WebFrame* frame); - void UpdateTitle(WebFrame* frame, const std::wstring& title); - void UpdateSessionHistory(WebFrame* frame); + void UpdateURL(WebKit::WebFrame* frame); + void UpdateTitle(WebKit::WebFrame* frame, const std::wstring& title); + void UpdateSessionHistory(WebKit::WebFrame* frame); // Update current main frame's encoding and send it to browser window. // Since we want to let users see the right encoding info from menu @@ -430,7 +430,7 @@ class RenderView : public RenderWidget, // c) function:DidFinishDocumentLoadForFrame. When this function is // called, that means we have got whole html page. In here we should // finally get right encoding of page. - void UpdateEncoding(WebFrame* frame, const std::wstring& encoding_name); + void UpdateEncoding(WebKit::WebFrame* frame, const std::wstring& encoding_name); // Captures the thumbnail and text contents for indexing for the given load // ID. If the view's load ID is different than the parameter, this call is @@ -440,7 +440,7 @@ class RenderView : public RenderWidget, // Called to retrieve the text from the given frame contents, the page text // up to the maximum amount will be placed into the given buffer - void CaptureText(WebFrame* frame, std::wstring* contents); + void CaptureText(WebKit::WebFrame* frame, std::wstring* contents); // Creates a thumbnail of |frame|'s contents resized to (|w|, |h|) // and puts that in |thumbnail|. Thumbnail metadata goes in |score|. @@ -606,14 +606,14 @@ class RenderView : public RenderWidget, // Exposes the DOMAutomationController object that allows JS to send // information to the browser process. - void BindDOMAutomationController(WebFrame* webframe); + void BindDOMAutomationController(WebKit::WebFrame* webframe); // Creates DevToolsClient and sets up JavaScript bindings for developer tools // UI that is going to be hosted by this RenderView. void CreateDevToolsClient(); // Locates a sub frame with given xpath - WebFrame* GetChildFrame(const std::wstring& frame_xpath) const; + WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const; enum ErrorPageType { DNS_ERROR, @@ -625,11 +625,11 @@ class RenderView : public RenderWidget, GURL GetAlternateErrorPageURL( const GURL& failed_url, ErrorPageType error_type); bool MaybeLoadAlternateErrorPage( - WebFrame* frame, const WebKit::WebURLError& error, bool replace); + WebKit::WebFrame* frame, const WebKit::WebURLError& error, bool replace); std::string GetAltHTMLForTemplate( const DictionaryValue& error_strings, int template_resource_id) const; void AltErrorPageFinished( - WebFrame* frame, const WebKit::WebURLError& original_error, + WebKit::WebFrame* frame, const WebKit::WebURLError& original_error, const std::string& html); virtual void DidAddHistoryItem(); @@ -640,9 +640,9 @@ class RenderView : public RenderWidget, void DumpLoadHistograms() const; // Scan the given frame for password forms and send them up to the browser. - void SendPasswordForms(WebFrame* frame); + void SendPasswordForms(WebKit::WebFrame* frame); - void Print(WebFrame* frame, bool script_initiated); + void Print(WebKit::WebFrame* frame, bool script_initiated); #if defined(OS_LINUX) void UpdateFontRenderingFromRendererPrefs(); diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index 135c78d..24bfe2d 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -14,6 +14,7 @@ #include "webkit/api/public/WebURLError.h" using WebKit::WebCompositionCommand; +using WebKit::WebFrame; using WebKit::WebTextDirection; using WebKit::WebURLError; @@ -247,8 +248,8 @@ TEST_F(RenderViewTest, ImeComposition) { // Retrieve the content of this page and compare it with the expected // result. const int kMaxOutputCharacters = 128; - std::wstring output; - GetMainFrame()->GetContentAsPlainText(kMaxOutputCharacters, &output); + std::wstring output = UTF16ToWideHack( + GetMainFrame()->contentAsText(kMaxOutputCharacters)); EXPECT_EQ(output, ime_message->result); } } @@ -296,8 +297,8 @@ TEST_F(RenderViewTest, OnSetTextDirection) { // Copy the document content to std::wstring and compare with the // expected result. const int kMaxOutputCharacters = 16; - std::wstring output; - GetMainFrame()->GetContentAsPlainText(kMaxOutputCharacters, &output); + std::wstring output = UTF16ToWideHack( + GetMainFrame()->contentAsText(kMaxOutputCharacters)); EXPECT_EQ(output, kTextDirection[i].expected_result); } } @@ -612,9 +613,8 @@ TEST_F(RenderViewTest, OnHandleKeyboardEvent) { // text created from a virtual-key code, a character code, and the // modifier-key status. const int kMaxOutputCharacters = 1024; - std::wstring output; - GetMainFrame()->GetContentAsPlainText(kMaxOutputCharacters, &output); - + std::wstring output = UTF16ToWideHack( + GetMainFrame()->contentAsText(kMaxOutputCharacters)); EXPECT_EQ(expected_result, output); } } @@ -825,8 +825,8 @@ TEST_F(RenderViewTest, InsertCharacters) { // text created from a virtual-key code, a character code, and the // modifier-key status. const int kMaxOutputCharacters = 4096; - std::wstring output; - GetMainFrame()->GetContentAsPlainText(kMaxOutputCharacters, &output); + std::wstring output = UTF16ToWideHack( + GetMainFrame()->contentAsText(kMaxOutputCharacters)); EXPECT_EQ(kLayouts[i].expected_result, output); } #else @@ -852,15 +852,15 @@ TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForError) { #endif TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForCancellation) { - GetMainFrame()->SetInViewSourceMode(true); + GetMainFrame()->enableViewSourceMode(true); WebURLError error; error.domain.fromUTF8("test_domain"); error.reason = net::ERR_ABORTED; error.unreachableURL = GURL("http://foo"); WebFrame* web_frame = GetMainFrame(); - WebView* web_view = web_frame->GetView(); + WebView* web_view = web_frame->view(); // A cancellation occurred. view_->DidFailProvisionalLoadWithError(web_view, error, web_frame); // Frame should stay in view-source mode. - EXPECT_TRUE(web_frame->GetInViewSourceMode()); + EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); } diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 5f31444..12ec6fa 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -30,10 +30,8 @@ #include "webkit/api/public/WebKitClient.h" #include "webkit/api/public/WebString.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" - #if defined(OS_WIN) #include <strsafe.h> // note: per msdn docs, this must *follow* other includes #endif diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index f6a8f13..4b2eb2f 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -13,11 +13,12 @@ #include "base/string_util.h" #include "chrome/renderer/extension_groups.h" #include "googleurl/src/gurl.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebScriptSource.h" -#include "webkit/glue/webframe.h" #include "grit/renderer_resources.h" +using WebKit::WebFrame; using WebKit::WebScriptSource; using WebKit::WebString; @@ -111,7 +112,7 @@ bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) { bool UserScriptSlave::InjectScripts(WebFrame* frame, UserScript::RunLocation location) { // Don't bother if this is not a URL we inject script into. - if (!URLPattern::IsValidScheme(frame->GetURL().scheme())) + if (!URLPattern::IsValidScheme(GURL(frame->url()).scheme())) return true; PerfTimer timer; @@ -120,7 +121,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, for (size_t i = 0; i < scripts_.size(); ++i) { std::vector<WebScriptSource> sources; UserScript* script = scripts_[i]; - if (!script->MatchesUrl(frame->GetURL())) + if (!script->MatchesUrl(frame->url())) continue; // This frame doesn't match the script url pattern, skip it. ++num_matched; @@ -128,7 +129,8 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (location == UserScript::DOCUMENT_START) { for (size_t j = 0; j < script->css_scripts().size(); ++j) { UserScript::File& file = script->css_scripts()[j]; - frame->InsertCSSStyles(file.GetContent().as_string()); + frame->insertStyleText( + WebString::fromUTF8(file.GetContent().as_string())); } } if (script->run_location() == location) { @@ -161,7 +163,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, StringPrintf(kInitExtension, script->extension_id().c_str())))); } - frame->ExecuteScriptInNewWorld(&sources.front(), sources.size(), + frame->executeScriptInNewWorld(&sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS); } } @@ -176,6 +178,6 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, } LOG(INFO) << "Injected " << num_matched << " user scripts into " << - frame->GetURL().spec(); + frame->url().spec().data(); return true; } diff --git a/chrome/renderer/user_script_slave.h b/chrome/renderer/user_script_slave.h index dcc1c7d..8f1fc9b 100644 --- a/chrome/renderer/user_script_slave.h +++ b/chrome/renderer/user_script_slave.h @@ -14,7 +14,9 @@ #include "base/string_piece.h" #include "chrome/common/extensions/user_script.h" +namespace WebKit { class WebFrame; +} // Manages installed UserScripts for a render process. class UserScriptSlave { @@ -27,7 +29,7 @@ class UserScriptSlave { // Inject the appropriate scripts into a frame based on its URL. // TODO(aa): Extract a UserScriptFrame interface out of this to improve // testability. - bool InjectScripts(WebFrame* frame, UserScript::RunLocation location); + bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); private: // Shared memory containing raw script data. diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 283c405..e36126d 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -35,9 +35,9 @@ #include "webkit/api/public/WebBindings.h" #include "webkit/api/public/WebCursorInfo.h" #include "webkit/api/public/WebDragData.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebVector.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webview.h" @@ -180,7 +180,7 @@ WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, sad_plugin_(NULL), invalidate_pending_(false), transparent_(false), - page_url_(render_view_->webview()->GetMainFrame()->GetURL()) { + page_url_(render_view_->webview()->GetMainFrame()->url()) { } WebPluginDelegateProxy::~WebPluginDelegateProxy() { diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index dbc61a7..2530dbe 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -14,22 +14,22 @@ #include "chrome/renderer/extensions/renderer_extension_bindings.h" #include "chrome/renderer/js_only_v8_extensions.h" #include "chrome/renderer/renderer_main_platform_delegate.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptSource.h" #include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/webview.h" +using WebKit::WebFrame; using WebKit::WebScriptSource; using WebKit::WebString; using WebKit::WebURLRequest; namespace { - const int32 kRouteId = 5; const int32 kOpenerId = 7; - -}; +} void RenderViewTest::ProcessPendingMessages() { msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); @@ -41,7 +41,7 @@ WebFrame* RenderViewTest::GetMainFrame() { } void RenderViewTest::ExecuteJavaScript(const char* js) { - GetMainFrame()->ExecuteScript(WebScriptSource(WebString::fromUTF8(js))); + GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); } void RenderViewTest::LoadHTML(const char* html) { @@ -49,7 +49,7 @@ void RenderViewTest::LoadHTML(const char* html) { url_str.append(html); GURL url(url_str); - GetMainFrame()->LoadRequest(WebURLRequest(url)); + GetMainFrame()->loadRequest(WebURLRequest(url)); // The load actually happens asynchronously, so we pump messages to process // the pending continuation. diff --git a/chrome/test/render_view_test.h b/chrome/test/render_view_test.h index 40e6256..5a9a78a 100644 --- a/chrome/test/render_view_test.h +++ b/chrome/test/render_view_test.h @@ -18,7 +18,7 @@ #include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/renderer_webkitclient_impl.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" class RenderViewTest : public testing::Test { public: @@ -30,7 +30,7 @@ class RenderViewTest : public testing::Test { void ProcessPendingMessages(); // Returns a pointer to the main frame. - WebFrame* GetMainFrame(); + WebKit::WebFrame* GetMainFrame(); // Executes the given JavaScript in the context of the main frame. The input // is a NULL-terminated UTF-8 string. diff --git a/webkit/api/public/WebFrame.h b/webkit/api/public/WebFrame.h index acb8dff..954c379 100644 --- a/webkit/api/public/WebFrame.h +++ b/webkit/api/public/WebFrame.h @@ -31,47 +31,73 @@ #ifndef WebFrame_h #define WebFrame_h -#error "This header file is still a work in progress; do not include!" - -#include "WebCommon.h" +#include "WebCanvas.h" +#include "WebURL.h" +class WebView; // FIXME: Move into the WebKit namespace. struct NPObject; +#if WEBKIT_USING_V8 +namespace v8 { + class Context; + template <class T> class Local; +} +#endif + namespace WebKit { class WebData; class WebDataSource; + class WebForm; class WebHistoryItem; + class WebRange; class WebString; class WebURL; class WebURLRequest; - class WebView; + struct WebConsoleMessage; + struct WebFindOptions; + struct WebRect; + struct WebScriptSource; + struct WebSize; + template <typename T> class WebVector; class WebFrame { public: - // Returns the frame that is currently executing script or 0 if there - // is none. - WEBKIT_API static WebFrame* activeFrame(); + // The two functions below retrieve the WebFrame instances relating the + // currently executing JavaScript. Since JavaScript can make function + // calls across frames, though, we need to be more precise. + // + // For example, imagine that a JS function in frame A calls a function + // in frame B, which calls native code, which wants to know what the + // 'active' frame is. + // + // The 'entered context' is the context where execution first entered + // the script engine; the context that is at the bottom of the JS + // function stack. frameForEnteredContext() would return frame A in + // our example. + // + // The 'current context' is the context the JS engine is currently + // inside of; the context that is at the top of the JS function stack. + // frameForCurrentContext() would return frame B in our example. + WEBKIT_API static WebFrame* frameForEnteredContext(); + WEBKIT_API static WebFrame* frameForCurrentContext(); // Basic properties --------------------------------------------------- // The name of this frame. - virtual WebString name() = 0; + virtual WebString name() const = 0; // The url of the document loaded in this frame. This is equivalent to // dataSource()->request().url(). - virtual WebURL url() = 0; + virtual WebURL url() const = 0; // The url of the favicon (if any) specified by the document loaded in // this frame. - virtual WebURL favIconURL() = 0; + virtual WebURL favIconURL() const = 0; // The url of the OpenSearch Desription Document (if any) specified by // the document loaded in this frame. - virtual WebURL openSearchDescriptionURL() = 0; - - // Returns the security origin of the current document. - virtual WebString securityOrigin() = 0; + virtual WebURL openSearchDescriptionURL() const = 0; // Geometry ----------------------------------------------------------- @@ -80,57 +106,70 @@ namespace WebKit { // not be accurate if the page layout is out-of-date. // The scroll offset from the top-left corner of the frame in pixels. - virtual WebSize scrollOffset() = 0; + virtual WebSize scrollOffset() const = 0; // The size of the contents area. - virtual WebSize contentsSize() = 0; + virtual WebSize contentsSize() const = 0; // Returns the minimum preferred width of the content contained in the // current document. - virtual int contentsPreferredWidth() = 0; + virtual int contentsPreferredWidth() const = 0; // Returns true if the contents (minus scrollbars) has non-zero area. - virtual bool hasVisibleContent() = 0; + virtual bool hasVisibleContent() const = 0; // Hierarchy ---------------------------------------------------------- // Returns the containing view. - virtual WebView* view() = 0; + virtual WebView* view() const = 0; + + // Returns the frame that opened this frame or 0 if there is none. + virtual WebFrame* opener() const = 0; - // Returns the parent frame. - virtual WebFrame* parent() = 0; + // Returns the parent frame or 0 if this is a top-most frame. + virtual WebFrame* parent() const = 0; // Returns the top-most frame in the hierarchy containing this frame. - virtual WebFrame* top() = 0; + virtual WebFrame* top() const = 0; // Returns the first/last child frame. - virtual WebFrame* firstChild() = 0; - virtual WebFrame* lastChild() = 0; + virtual WebFrame* firstChild() const = 0; + virtual WebFrame* lastChild() const = 0; // Returns the next/previous sibling frame. - virtual WebFrame* nextSibling() = 0; - virtual WebFrame* previousSibling() = 0; + virtual WebFrame* nextSibling() const = 0; + virtual WebFrame* previousSibling() const = 0; // Returns the next/previous frame in "frame traversal order" // optionally wrapping around. - virtual WebFrame* traverseNext(bool wrap) = 0; - virtual WebFrame* traversePrevious(bool wrap) = 0; + virtual WebFrame* traverseNext(bool wrap) const = 0; + virtual WebFrame* traversePrevious(bool wrap) const = 0; // Returns the child frame identified by the given name. - virtual WebFrame* findChildByName(const WebString& name) = 0; + virtual WebFrame* findChildByName(const WebString& name) const = 0; // Returns the child frame identified by the given xpath expression. - virtual WebFrame* findChildByExpression(const WebString& xpath) = 0; + virtual WebFrame* findChildByExpression(const WebString& xpath) const = 0; + + + // Content ------------------------------------------------------------ + + virtual void forms(WebVector<WebForm>&) const = 0; // Scripting ---------------------------------------------------------- - // Calls window.gc() if it is defined. - virtual void collectGarbage() = 0; + // Returns the security origin of the current document. + virtual WebString securityOrigin() const = 0; + + // This grants the currently loaded document access to all security + // origins (including file URLs). Use with care. The access is + // revoked when a new document is loaded into this frame. + virtual void grantUniversalAccess() = 0; // Returns a NPObject corresponding to this frame's DOMWindow. - virtual NPObject* windowObject() = 0; + virtual NPObject* windowObject() const = 0; // Binds a NPObject as a property of this frame's DOMWindow. virtual void bindToWindowObject(const WebString& name, NPObject*) = 0; @@ -141,20 +180,37 @@ namespace WebKit { // Executes script in a new context associated with the frame. The // script gets its own global scope and its own prototypes for // intrinsic JS objects (String, Array, and so-on). It shares the - // wrappers for all DOM nodes and DOM constructors. + // wrappers for all DOM nodes and DOM constructors. extensionGroup is + // an embedder-provided specifier that controls which v8 extensions are + // loaded into the new context - see WebKit::registerExtension for the + // corresponding specifier. virtual void executeScriptInNewContext(const WebScriptSource* sources, - unsigned numSources) = 0; + unsigned numSources, + int extensionGroup) = 0; // Executes JavaScript in a new world 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 also // gets its own wrappers for all DOM nodes and DOM constructors. + // extensionGroup is an embedder-provided specifier that controls which + // v8 extensions are loaded into the new context - see + // WebKit::registerExtension for the corresponding specifier. virtual void executeScriptInNewWorld(const WebScriptSource* sources, - unsigned numSources) = 0; + unsigned numSources, + int extensionGroup) = 0; // Logs to the console associated with this frame. virtual void addMessageToConsole(const WebConsoleMessage&) = 0; + // Calls window.gc() if it is defined. + virtual void collectGarbage() = 0; + +#if WEBKIT_USING_V8 + // Returns the V8 context for this frame, or an empty handle if there + // is none. + virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0; +#endif + // Styling ------------------------------------------------------------- @@ -165,12 +221,22 @@ namespace WebKit { // Navigation ---------------------------------------------------------- + // Reload the current document. virtual void reload() = 0; + // Load the given URL. virtual void loadRequest(const WebURLRequest&) = 0; + // Load the given history state, corresponding to a back/forward + // navigation. virtual void loadHistoryItem(const WebHistoryItem&) = 0; + // Loads the given data with specific mime type and optional text + // encoding. For HTML data, baseURL indicates the security origin of + // the document and is used to resolve links. If specified, + // unreachableURL is reported via WebDataSource::unreachableURL. If + // replace is false, then this data will be loaded as a normal + // navigation. Otherwise, the current history item will be replaced. virtual void loadData(const WebData& data, const WebString& mimeType, const WebString& textEncoding, @@ -178,43 +244,50 @@ namespace WebKit { const WebURL& unreachableURL = WebURL(), bool replace = false) = 0; + // This method is short-hand for calling LoadData, where mime_type is + // "text/html" and text_encoding is "UTF-8". virtual void loadHTMLString(const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL = WebURL(), bool replace = false) = 0; - virtual bool isLoading() = 0; + // Returns true if the current frame is busy loading content. + virtual bool isLoading() const = 0; // Stops any pending loads on the frame and its children. virtual void stopLoading() = 0; // Returns the data source that is currently loading. May be null. - virtual WebDataSource* provisionalDataSource() = 0; + virtual WebDataSource* provisionalDataSource() const = 0; // Returns the data source that is currently loaded. - virtual WebDataSource* dataSource() = 0; + virtual WebDataSource* dataSource() const = 0; // Returns the previous history item. Check WebHistoryItem::isNull() // before using. - virtual WebHistoryItem previousHistoryItem() = 0; + virtual WebHistoryItem previousHistoryItem() const = 0; // Returns the current history item. Check WebHistoryItem::isNull() // before using. - virtual WebHistoryItem currentHistoryItem() = 0; + virtual WebHistoryItem currentHistoryItem() const = 0; // View-source rendering mode. Set this before loading an URL to cause // it to be rendered in view-source mode. virtual void enableViewSourceMode(bool) = 0; - virtual bool isViewSourceModeEnabled() = 0; + virtual bool isViewSourceModeEnabled() const = 0; + // Called to associate the WebURLRequest with this frame. The request + // will be modified to inherit parameters that allow it to be loaded. + // This method ends up triggering WebFrameClient::willSendRequest. + virtual void dispatchWillSendRequest(WebURLRequest&) = 0; - // App-cache ----------------------------------------------------------- - - virtual void selectAppCacheWithoutManifest() = 0; - virtual void selectAppCacheWithManifest(const WebURL& manifest) = 0; + // Called from within WebFrameClient::didReceiveDocumentData to commit + // data for the frame that will be used to construct the frame's + // document. + virtual void commitDocumentData(const char* data, size_t length) = 0; - // Will be null if an app cache has not been selected. - virtual WebAppCacheContext* appCacheContext() = 0; + // Returns the number of registered unload listeners. + virtual unsigned unloadListenerCount() const = 0; // Editing ------------------------------------------------------------- @@ -222,23 +295,34 @@ namespace WebKit { // Replaces the selection with the given text. virtual void replaceSelection(const WebString& text) = 0; + virtual void insertText(const WebString& text) = 0; + + virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0; + virtual void unmarkText() = 0; + virtual bool hasMarkedText() const = 0; + + virtual WebRange markedRange() const = 0; + // See EditorCommand.cpp for the list of supported commands. - virtual void executeCommand(const WebString&) = 0; - virtual void executeCommand(const WebString&, const WebString& value) = 0; - virtual bool isCommandEnabled(const WebString&); + virtual bool executeCommand(const WebString&) = 0; + virtual bool executeCommand(const WebString&, const WebString& value) = 0; + virtual bool isCommandEnabled(const WebString&) const = 0; // Spell-checking support. virtual void enableContinuousSpellChecking(bool) = 0; - virtual bool isContinuousSpellCheckingEnabled() = 0; + virtual bool isContinuousSpellCheckingEnabled() const = 0; // Selection ----------------------------------------------------------- virtual void selectAll() = 0; - virtual void selectNone() = 0; + virtual void clearSelection() = 0; + virtual bool hasSelection() const = 0; + + virtual WebRange selectionRange() const = 0; - virtual WebString selectionAsText() = 0; - virtual WebString selectionAsHTML() = 0; + virtual WebString selectionAsText() const = 0; + virtual WebString selectionAsMarkup() const = 0; // Printing ------------------------------------------------------------ @@ -246,20 +330,96 @@ namespace WebKit { // Reformats the WebFrame for printing. pageSize is the page size in // pixels. Returns the number of pages that can be printed at the // given page size. - virtual int printBegin(const WebSize& pageSize); + virtual int printBegin(const WebSize& pageSize) = 0; // Prints one page, and returns the calculated page shrinking factor // (usually between 1/1.25 and 1/2). Returns 0 if the page number is // invalid or not in printing mode. - virtual float printPage(int pageToPrint, const WebCanvas&); + virtual float printPage(int pageToPrint, WebCanvas*) = 0; // Reformats the WebFrame for screen display. - virtual void printEnd(); + virtual void printEnd() = 0; // Find-in-page -------------------------------------------------------- - // FIXME + // Searches a frame for a given string. + // + // If a match is found, this function will select it (scrolling down to + // make it visible if needed) and fill in selectionRect with the + // location of where the match was found (in window coordinates). + // + // 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(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool wrapWithinFrame, + WebRect* selectionRect) = 0; + + // Notifies the frame that we are no longer interested in searching. + // This will abort any asynchronous scoping effort already under way + // (see the function scopeStringMatches for details) and erase all + // tick-marks and highlighting from the previous search. If + // clearSelection is true, it will also make sure the end state for the + // find operation does not leave a selection. This can occur when the + // user clears the search string but does not close the find box. + virtual void stopFinding(bool clearSelection) = 0; + + // Counts how many times a particular string occurs within the frame. + // It also retrieves the location of the string and updates a vector in + // the frame so that tick-marks and highlighting can be drawn. This + // function does its work asynchronously, by running for a certain + // time-slice and then scheduling itself (co-operative multitasking) to + // be invoked later (repeating the process until all matches have been + // found). This allows multiple frames to be searched at the same time + // and provides a way to cancel at any time (see + // cancelPendingScopingEffort). The parameter searchText 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(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool reset) = 0; + + // Cancels any outstanding requests for scoping string matches on a frame. + virtual void cancelPendingScopingEffort() = 0; + + // This function is called on the main frame during the scoping effort + // to keep a running tally of the accumulated total match-count for all + // frames. After updating the count it will notify the WebViewClient + // about the new count. + virtual void increaseMatchCount(int count, int identifier) = 0; + + // Notifies the WebViewClient about a new selection rect. This will + // result in the browser getting notified. For more information see + // WebViewClient. + virtual void reportFindInPageSelection(const WebRect& selectionRect, + int activeMatchOrdinal, + int identifier) = 0; + + // This function is called on the main frame to reset the total number + // of matches found during the scoping effort. + virtual void resetMatchCount() = 0; + + + // Utility ------------------------------------------------------------- + + // Returns the contents of this frame as a string. If the text is + // longer than maxChars, it will be clipped to that length. WARNING: + // This function may be slow depending on the number of characters + // retrieved and page complexity. For a typically sized page, expect + // it to take on the order of milliseconds. + // + // If there is room, subframe text will be recursively appended. Each + // frame will be separated by an empty line. + virtual WebString contentAsText(size_t maxChars) const = 0; + + // Returns HTML text for the contents of this frame. This is generated + // from the DOM. + virtual WebString contentAsMarkup() const = 0; }; } // namespace WebKit diff --git a/webkit/api/public/WebRange.h b/webkit/api/public/WebRange.h index bd6924c..e504524 100644 --- a/webkit/api/public/WebRange.h +++ b/webkit/api/public/WebRange.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -33,6 +33,11 @@ #include "WebCommon.h" +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Range; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + namespace WebKit { class WebNode; class WebRangePrivate; @@ -56,7 +61,14 @@ namespace WebKit { WEBKIT_API WebNode startContainer(int& exceptionCode) const; WEBKIT_API WebNode endContainer(int& exceptionCode) const; +#if WEBKIT_IMPLEMENTATION + WebRange(const WTF::PassRefPtr<WebCore::Range>&); + WebRange& operator=(const WTF::PassRefPtr<WebCore::Range>&); + operator WTF::PassRefPtr<WebCore::Range>() const; +#endif + private: + void assign(WebRangePrivate*); WebRangePrivate* m_private; }; diff --git a/webkit/api/public/WebString.h b/webkit/api/public/WebString.h index 8eee441..bf59854 100644 --- a/webkit/api/public/WebString.h +++ b/webkit/api/public/WebString.h @@ -40,7 +40,7 @@ namespace WebCore { class String; class AtomicString; } #endif namespace WebKit { - + class WebCString; class WebStringPrivate; // A UTF-16 string container. It is inexpensive to copy a WebString @@ -77,6 +77,8 @@ namespace WebKit { bool isEmpty() const { return length() == 0; } bool isNull() const { return m_private == 0; } + WEBKIT_API WebCString utf8() const; + WEBKIT_API static WebString fromUTF8(const char* data, size_t length); WEBKIT_API static WebString fromUTF8(const char* data); diff --git a/webkit/api/src/WebRange.cpp b/webkit/api/src/WebRange.cpp new file mode 100644 index 0000000..aa101c90 --- /dev/null +++ b/webkit/api/src/WebRange.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebRange.h" + +#include "WebNode.h" + +#include "Range.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebRangePrivate : public Range { +}; + +void WebRange::reset() +{ + assign(0); +} + +void WebRange::assign(const WebRange& other) +{ + WebRangePrivate* p = const_cast<WebRangePrivate*>(other.m_private); + p->ref(); + assign(p); +} + +int WebRange::startOffset() const +{ + return m_private->startOffset(); +} + +int WebRange::endOffset() const +{ + return m_private->endOffset(); +} + +WebNode WebRange::startContainer(int& exceptionCode) const +{ + return PassRefPtr<Node>(m_private->startContainer(exceptionCode)); +} + +WebNode WebRange::endContainer(int& exceptionCode) const +{ + return PassRefPtr<Node>(m_private->endContainer(exceptionCode)); +} + +WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range) + : m_private(static_cast<WebRangePrivate*>(range.releaseRef())) +{ +} + +WebRange& WebRange::operator=(const WTF::PassRefPtr<WebCore::Range>& range) +{ + assign(static_cast<WebRangePrivate*>(range.releaseRef())); + return *this; +} + +WebRange::operator WTF::PassRefPtr<WebCore::Range>() const +{ + return PassRefPtr<Range>(const_cast<WebRangePrivate*>(m_private)); +} + +void WebRange::assign(WebRangePrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/webkit/api/src/WebString.cpp b/webkit/api/src/WebString.cpp index 9d1b2d6..cc6112a 100644 --- a/webkit/api/src/WebString.cpp +++ b/webkit/api/src/WebString.cpp @@ -31,6 +31,9 @@ #include "config.h" #include "WebString.h" +#include "WebCString.h" + +#include "CString.h" #include "PlatformString.h" #include "AtomicString.h" @@ -68,6 +71,11 @@ const WebUChar* WebString::data() const return m_private ? const_cast<WebStringPrivate*>(m_private)->characters() : 0; } +WebCString WebString::utf8() const +{ + return WebCore::String(m_private).utf8(); +} + WebString WebString::fromUTF8(const char* data, size_t length) { return WebCore::String::fromUTF8(data, length); diff --git a/webkit/glue/alt_error_page_resource_fetcher.cc b/webkit/glue/alt_error_page_resource_fetcher.cc index 6c8bad9..341d752 100644 --- a/webkit/glue/alt_error_page_resource_fetcher.cc +++ b/webkit/glue/alt_error_page_resource_fetcher.cc @@ -6,6 +6,7 @@ #include "webkit/glue/resource_fetcher.h" +using WebKit::WebFrame; using WebKit::WebURLError; using WebKit::WebURLResponse; diff --git a/webkit/glue/alt_error_page_resource_fetcher.h b/webkit/glue/alt_error_page_resource_fetcher.h index d591e02..b9b47ba 100644 --- a/webkit/glue/alt_error_page_resource_fetcher.h +++ b/webkit/glue/alt_error_page_resource_fetcher.h @@ -10,9 +10,8 @@ #include "googleurl/src/gurl.h" #include "webkit/api/public/WebURLError.h" -class WebFrame; - namespace WebKit { +class WebFrame; class WebURLResponse; } @@ -26,11 +25,11 @@ class AltErrorPageResourceFetcher { // This will be called when the alternative error page has been fetched, // successfully or not. If there is a failure, the third parameter (the // data) will be empty. - typedef Callback3< - WebFrame*, const WebKit::WebURLError&, const std::string&>::Type Callback; + typedef Callback3<WebKit::WebFrame*, const WebKit::WebURLError&, + const std::string&>::Type Callback; AltErrorPageResourceFetcher(const GURL& url, - WebFrame* frame, + WebKit::WebFrame* frame, const WebKit::WebURLError& original_error, Callback* callback); ~AltErrorPageResourceFetcher(); @@ -45,7 +44,7 @@ class AltErrorPageResourceFetcher { // Does the actual fetching. scoped_ptr<ResourceFetcherWithTimeout> fetcher_; - WebFrame* frame_; + WebKit::WebFrame* frame_; scoped_ptr<Callback> callback_; // The error associated with this load. If there's an error talking with the diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 612d0ad..451c9d6 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -228,7 +228,7 @@ WebCore::Page* ChromeClientImpl::createWindow( // This corresponds to window.open(""), for example. if (!r.resourceRequest().isEmpty()) { WrappedResourceRequest request(r.resourceRequest()); - new_view->main_frame()->LoadRequest(request); + new_view->main_frame()->loadRequest(request); } WebViewImpl* new_view_impl = static_cast<WebViewImpl*>(new_view); diff --git a/webkit/glue/context_menu_unittest.cc b/webkit/glue/context_menu_unittest.cc index 0905a97..8fc009f 100644 --- a/webkit/glue/context_menu_unittest.cc +++ b/webkit/glue/context_menu_unittest.cc @@ -10,7 +10,6 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" diff --git a/webkit/glue/cpp_bound_class.cc b/webkit/glue/cpp_bound_class.cc index ef0a72d6..3e5c1e7 100644 --- a/webkit/glue/cpp_bound_class.cc +++ b/webkit/glue/cpp_bound_class.cc @@ -14,11 +14,14 @@ #include "base/compiler_specific.h" #include "base/logging.h" +#include "base/string_util.h" #include "webkit/api/public/WebBindings.h" +#include "webkit/api/public/WebFrame.h" +#include "webkit/api/public/WebString.h" #include "webkit/glue/cpp_bound_class.h" -#include "webkit/glue/webframe.h" using WebKit::WebBindings; +using WebKit::WebFrame; // Our special NPObject type. We extend an NPObject with a pointer to a // CppBoundClass, which is just a C++ interface that we forward all NPObject @@ -246,6 +249,7 @@ void CppBoundClass::BindToJavascript(WebFrame* frame, // BindToWindowObject will take its own reference to the NPObject, and clean // up after itself. It will also (indirectly) register the object with V8, // so we must remember this so we can unregister it when we're destroyed. - frame->BindToWindowObject(classname, NPVARIANT_TO_OBJECT(*GetAsCppVariant())); + frame->bindToWindowObject(WideToUTF16Hack(classname), + NPVARIANT_TO_OBJECT(*GetAsCppVariant())); bound_to_frame_ = true; } diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h index 7b1b9b8..7db5f3b 100644 --- a/webkit/glue/cpp_bound_class.h +++ b/webkit/glue/cpp_bound_class.h @@ -26,7 +26,9 @@ #include "base/scoped_ptr.h" #include "base/task.h" +namespace WebKit { class WebFrame; +} typedef std::vector<CppVariant> CppArgumentList; @@ -51,7 +53,8 @@ class CppBoundClass { // as window.<classname>. The owner of the CppBoundObject is responsible for // keeping the object around while the frame is alive, and for destroying it // afterwards. - void BindToJavascript(WebFrame* frame, const std::wstring& classname); + void BindToJavascript( + WebKit::WebFrame* frame, const std::wstring& classname); // The type of callbacks. typedef Callback2<const CppArgumentList&, CppVariant*>::Type Callback; diff --git a/webkit/glue/cpp_bound_class_unittest.cc b/webkit/glue/cpp_bound_class_unittest.cc index 38aefa3..7bfd8a5 100644 --- a/webkit/glue/cpp_bound_class_unittest.cc +++ b/webkit/glue/cpp_bound_class_unittest.cc @@ -10,13 +10,15 @@ #include "base/message_loop.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebURL.h" #include "webkit/glue/cpp_binding_example.h" #include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebFrame; + namespace { class CppBindingExampleSubObject : public CppBindingExample { @@ -102,7 +104,7 @@ class CppBoundClassTest : public TestShellTest { html.append(javascript); html.append("</script></body></html>"); // The base URL doesn't matter. - webframe_->LoadHTMLString(html, GURL("about:blank")); + webframe_->loadHTMLString(html, GURL("about:blank")); test_shell_->WaitTestFinished(); } diff --git a/webkit/glue/devtools/devtools_rpc_js.h b/webkit/glue/devtools/devtools_rpc_js.h index 7f9f856..4e82273 100644 --- a/webkit/glue/devtools/devtools_rpc_js.h +++ b/webkit/glue/devtools/devtools_rpc_js.h @@ -14,10 +14,10 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/values.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/glue/cpp_bound_class.h" #include "webkit/glue/devtools/devtools_rpc.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webframe.h" /////////////////////////////////////////////////////// // JS RPC binds and stubs diff --git a/webkit/glue/devtools/dom_agent_unittest.cc b/webkit/glue/devtools/dom_agent_unittest.cc index 3c693b2..ce01a50 100644 --- a/webkit/glue/devtools/dom_agent_unittest.cc +++ b/webkit/glue/devtools/dom_agent_unittest.cc @@ -20,13 +20,13 @@ #include "net/base/net_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebURL.h" #include "webkit/glue/devtools/devtools_mock_rpc.h" #include "webkit/glue/devtools/devtools_rpc.h" #include "webkit/glue/devtools/dom_agent_impl.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" @@ -38,6 +38,7 @@ using WebCore::HTMLFrameOwnerElement; using WebCore::Node; using WebCore::String; using WebCore::Text; +using WebKit::WebFrame; namespace { @@ -61,7 +62,7 @@ class DomAgentTests : public TestShellTest { test_shell_->ResetTestController(); GURL file_url = net::FilePathToFileURL(data_dir_); WebFrame* main_frame = test_shell_->webView()->GetMainFrame(); - main_frame->LoadHTMLString("<html> <head> </head> <body> </body> </html>", + main_frame->loadHTMLString("<html> <head> </head> <body> </body> </html>", file_url); WebFrameImpl* main_frame_impl = static_cast<WebFrameImpl*>(main_frame); diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 16f364a..c05cdf7 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -38,6 +38,7 @@ MSVC_POP_WARNING(); #include "webkit/glue/webview_impl.h" using WebCore::String; +using WebKit::WebFrame; namespace { @@ -780,7 +781,7 @@ void GetApplicationInfo(WebView* view, WebApplicationInfo* app_info) { webkit_glue::StringToStdWString(meta->content()); } else if (meta->name() == String("application-url")) { std::string url = webkit_glue::StringToStdString(meta->content()); - GURL main_url = main_frame->GetURL(); + GURL main_url = main_frame->url(); app_info->app_url = main_url.is_valid() ? main_url.Resolve(url) : GURL(url); if (!app_info->app_url.is_valid()) diff --git a/webkit/glue/dom_operations_unittest.cc b/webkit/glue/dom_operations_unittest.cc index 0ebf1b4..4d6fb86 100644 --- a/webkit/glue/dom_operations_unittest.cc +++ b/webkit/glue/dom_operations_unittest.cc @@ -9,7 +9,6 @@ #include "net/url_request/url_request_context.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/webview.h" -#include "webkit/glue/webframe.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_shell_test.h" diff --git a/webkit/glue/dom_serializer.cc b/webkit/glue/dom_serializer.cc index 631c210..f71a928 100644 --- a/webkit/glue/dom_serializer.cc +++ b/webkit/glue/dom_serializer.cc @@ -80,6 +80,8 @@ MSVC_POP_WARNING(); #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" +using WebKit::WebFrame; + namespace { // Default "mark of the web" declaration diff --git a/webkit/glue/dom_serializer.h b/webkit/glue/dom_serializer.h index fc6d0ef..3c59760 100644 --- a/webkit/glue/dom_serializer.h +++ b/webkit/glue/dom_serializer.h @@ -11,7 +11,6 @@ #include "base/hash_tables.h" #include "googleurl/src/gurl.h" -class WebFrame; class WebFrameImpl; namespace WebCore { @@ -22,6 +21,10 @@ class String; class TextEncoding; } +namespace WebKit { +class WebFrame; +} + namespace webkit_glue { class DomSerializerDelegate; @@ -50,7 +53,7 @@ class DomSerializer { // saved links, which matched with vector:links one by one. // The parameter local_directory_name is relative path of directory which // contain all saved auxiliary files included all sub frames and resources. - DomSerializer(WebFrame* webframe, + DomSerializer(WebKit::WebFrame* webframe, bool recursive_serialization, DomSerializerDelegate* delegate, const std::vector<GURL>& links, diff --git a/webkit/glue/dom_serializer_unittest.cc b/webkit/glue/dom_serializer_unittest.cc index d3f7e8e..de8d7e1 100644 --- a/webkit/glue/dom_serializer_unittest.cc +++ b/webkit/glue/dom_serializer_unittest.cc @@ -36,7 +36,6 @@ MSVC_POP_WARNING(); #include "webkit/glue/dom_serializer.h" #include "webkit/glue/dom_serializer_delegate.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" @@ -109,11 +108,12 @@ class DomSerializerTests : public TestShellTest, test_shell_->ResetTestController(); // If input encoding is empty, use UTF-8 as default encoding. if (encoding_info.isEmpty()) { - test_shell_->webView()->GetMainFrame()->LoadHTMLString(contents, + test_shell_->webView()->GetMainFrame()->loadHTMLString(contents, base_url); } else { // Do not use WebFrame.LoadHTMLString because it assumes that input // html contents use UTF-8 encoding. + // TODO(darin): This should use WebFrame::loadData. WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(test_shell_->webView()->GetMainFrame()); ASSERT_TRUE(web_frame != NULL); diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index c4de103..a000f2e 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -703,7 +703,7 @@ void EditorClientImpl::textFieldDidEndEditing(WebCore::Element* element) { WebFrameImpl* webframe = WebFrameImpl::FromFrame(input_element->document()->frame()); - if (webframe->GetView() && !webframe->GetView()->GetDelegate()) + if (webframe->GetWebViewImpl() && !webframe->GetWebViewImpl()->GetDelegate()) return; // The page is getting closed, don't fill the password. webkit_glue::PasswordAutocompleteListener* listener = diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc index 8b9f1fa..306aaa0 100644 --- a/webkit/glue/glue_util.cc +++ b/webkit/glue/glue_util.cc @@ -24,6 +24,7 @@ #include "KURL.h" #include "Node.h" #include "PlatformString.h" +#include "Range.h" #include "ResourceError.h" #undef LOG @@ -39,6 +40,7 @@ #include "webkit/api/public/WebHistoryItem.h" #include "webkit/api/public/WebNode.h" #include "webkit/api/public/WebPoint.h" +#include "webkit/api/public/WebRange.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebString.h" @@ -264,9 +266,11 @@ WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement( } // WebNode conversions --------------------------------------------------------- + WebKit::WebNode NodeToWebNode(const WTF::PassRefPtr<WebCore::Node>& node) { return node; } + WTF::PassRefPtr<WebCore::Node> WebNodeToNode(const WebKit::WebNode& node) { return node; } @@ -283,6 +287,16 @@ WTF::PassRefPtr<WebCore::HistoryItem> WebHistoryItemToHistoryItem( return item; } +// WebRange conversions -------------------------------------------------------- + +WebKit::WebRange RangeToWebRange(const WTF::PassRefPtr<WebCore::Range>& range) { + return range; +} + +WTF::PassRefPtr<WebCore::Range> WebRangeToRange(const WebKit::WebRange& range) { + return range; +} + // WebURLError conversions ----------------------------------------------------- WebKit::WebURLError ResourceErrorToWebURLError( diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h index 4163f29..8842d0e 100644 --- a/webkit/glue/glue_util.h +++ b/webkit/glue/glue_util.h @@ -21,6 +21,7 @@ class IntRect; class IntSize; class KURL; class Node; +class Range; class ResourceError; class ResourceResponse; class SharedBuffer; @@ -35,6 +36,7 @@ class WebDragData; class WebForm; class WebHistoryItem; class WebNode; +class WebRange; class WebString; class WebURL; class WebURLRequest; @@ -144,6 +146,12 @@ WebKit::WebHistoryItem HistoryItemToWebHistoryItem( WTF::PassRefPtr<WebCore::HistoryItem> WebHistoryItemToHistoryItem( const WebKit::WebHistoryItem&); +// WebRange <-> Range +WebKit::WebRange RangeToWebRange( + const WTF::PassRefPtr<WebCore::Range>&); +WTF::PassRefPtr<WebCore::Range> WebRangeToRange( + const WebKit::WebRange&); + // WebURLError <-> ResourceError WebKit::WebURLError ResourceErrorToWebURLError( const WebCore::ResourceError& error); diff --git a/webkit/glue/iframe_redirect_unittest.cc b/webkit/glue/iframe_redirect_unittest.cc index dfa6e08..1a4fa03 100644 --- a/webkit/glue/iframe_redirect_unittest.cc +++ b/webkit/glue/iframe_redirect_unittest.cc @@ -11,14 +11,15 @@ #include "base/file_util.h" #include "base/string_util.h" #include "webkit/api/public/WebDataSource.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebVector.h" #include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" using WebKit::WebDataSource; +using WebKit::WebFrame; using WebKit::WebURL; using WebKit::WebVector; @@ -39,7 +40,7 @@ TEST_F(IFrameRedirectTest, Test) { WebFrame* iframe = test_shell_->webView()->GetFrameWithName(L"ifr"); ASSERT_TRUE(iframe != NULL); - WebDataSource* iframe_ds = iframe->GetDataSource(); + WebDataSource* iframe_ds = iframe->dataSource(); ASSERT_TRUE(iframe_ds != NULL); WebVector<WebURL> redirects; iframe_ds->redirectChain(redirects); diff --git a/webkit/glue/image_resource_fetcher.cc b/webkit/glue/image_resource_fetcher.cc index dc90744..0a30f53 100644 --- a/webkit/glue/image_resource_fetcher.cc +++ b/webkit/glue/image_resource_fetcher.cc @@ -5,10 +5,12 @@ #include "webkit/glue/image_resource_fetcher.h" #include "base/gfx/size.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/glue/image_decoder.h" -#include "webkit/glue/webframe.h" #include "third_party/skia/include/core/SkBitmap.h" +using WebKit::WebFrame; + namespace webkit_glue { ImageResourceFetcher::ImageResourceFetcher( diff --git a/webkit/glue/image_resource_fetcher.h b/webkit/glue/image_resource_fetcher.h index af542dd..ef2f857 100644 --- a/webkit/glue/image_resource_fetcher.h +++ b/webkit/glue/image_resource_fetcher.h @@ -21,7 +21,7 @@ class ImageResourceFetcher { typedef Callback2<ImageResourceFetcher*, const SkBitmap&>::Type Callback; ImageResourceFetcher(const GURL& image_url, - WebFrame* frame, + WebKit::WebFrame* frame, int id, int image_size, Callback* callback); diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index 6fb6579..377798a 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -75,7 +75,7 @@ Page* WebInspectorClient::createPage() { if (!inspector_web_view_) return NULL; - inspector_web_view_->main_frame()->LoadRequest( + inspector_web_view_->main_frame()->loadRequest( WebURLRequest(webkit_glue::GetInspectorURL())); page = inspector_web_view_->page(); diff --git a/webkit/glue/mimetype_unittest.cc b/webkit/glue/mimetype_unittest.cc index 427c0b1..7dd52f4 100644 --- a/webkit/glue/mimetype_unittest.cc +++ b/webkit/glue/mimetype_unittest.cc @@ -15,6 +15,8 @@ #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebFrame; + namespace { class MimeTypeTests : public TestShellTest { diff --git a/webkit/glue/resource_fetcher.cc b/webkit/glue/resource_fetcher.cc index e7e6978..06bfd09 100644 --- a/webkit/glue/resource_fetcher.cc +++ b/webkit/glue/resource_fetcher.cc @@ -5,15 +5,16 @@ #include "webkit/glue/resource_fetcher.h" #include "base/logging.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebKitClient.h" #include "webkit/api/public/WebURLError.h" #include "webkit/api/public/WebURLLoader.h" #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/public/WebURL.h" -#include "webkit/glue/webframe.h" using base::TimeDelta; +using WebKit::WebFrame; using WebKit::WebURLError; using WebKit::WebURLLoader; using WebKit::WebURLRequest; @@ -46,7 +47,7 @@ void ResourceFetcher::Cancel() { void ResourceFetcher::Start(WebFrame* frame) { WebURLRequest request(url_); - frame->DispatchWillSendRequest(&request); + frame->dispatchWillSendRequest(request); loader_.reset(WebKit::webKitClient()->createURLLoader()); loader_->loadAsynchronously(request, this); diff --git a/webkit/glue/resource_fetcher.h b/webkit/glue/resource_fetcher.h index b146e61..62c5bc5 100644 --- a/webkit/glue/resource_fetcher.h +++ b/webkit/glue/resource_fetcher.h @@ -22,9 +22,9 @@ #include "webkit/api/public/WebURLResponse.h" class GURL; -class WebFrame; namespace WebKit { +class WebFrame; class WebURLLoader; class WebURLRequest; struct WebURLError; @@ -41,7 +41,8 @@ class ResourceFetcher : public WebKit::WebURLLoaderClient { const std::string&>::Type Callback; // We need a frame to make requests. - ResourceFetcher(const GURL& url, WebFrame* frame, Callback* callback); + ResourceFetcher( + const GURL& url, WebKit::WebFrame* frame, Callback* callback); ~ResourceFetcher(); // Stop the request and don't call the callback. @@ -82,7 +83,7 @@ class ResourceFetcher : public WebKit::WebURLLoaderClient { private: // Start the actual download. - void Start(WebFrame* frame); + void Start(WebKit::WebFrame* frame); // Buffer to hold the content from the server. std::string data_; @@ -92,7 +93,7 @@ class ResourceFetcher : public WebKit::WebURLLoaderClient { // A resource fetcher with a timeout class ResourceFetcherWithTimeout : public ResourceFetcher { public: - ResourceFetcherWithTimeout(const GURL& url, WebFrame* frame, + ResourceFetcherWithTimeout(const GURL& url, WebKit::WebFrame* frame, int timeout_secs, Callback* c); virtual ~ResourceFetcherWithTimeout() {} diff --git a/webkit/glue/resource_fetcher_unittest.cc b/webkit/glue/resource_fetcher_unittest.cc index a5e7022..b61765f 100644 --- a/webkit/glue/resource_fetcher_unittest.cc +++ b/webkit/glue/resource_fetcher_unittest.cc @@ -6,14 +6,15 @@ #include <gtk/gtk.h> #endif +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebURLResponse.h" #include "webkit/glue/unittest_test_server.h" #include "webkit/glue/webview.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/resource_fetcher.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebFrame; using WebKit::WebURLResponse; using webkit_glue::ResourceFetcher; using webkit_glue::ResourceFetcherWithTimeout; diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index b76fd56..07245fd 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -28,8 +28,6 @@ #include "net/url_request/url_request_status.h" #include "webkit/glue/resource_type.h" -class WebFrame; - namespace net { class HttpResponseHeaders; } diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index b6ca3ca..664aac0 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -49,6 +49,7 @@ using WebCore::V8ClassIndex; using WebCore::V8DOMWrapper; using WebCore::V8Proxy; using WebKit::WebDataSource; +using WebKit::WebFrame; using WebKit::WebURLRequest; WebDevToolsAgentImpl::WebDevToolsAgentImpl( @@ -158,7 +159,7 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame( DisposeUtilityContext(); return; } - WebDataSource* ds = frame->GetDataSource(); + WebDataSource* ds = frame->dataSource(); const WebURLRequest& request = ds->request(); GURL url = ds->hasUnreachableURL() ? ds->unreachableURL() : diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h index d06705e..a756ce0 100644 --- a/webkit/glue/webdevtoolsagent_impl.h +++ b/webkit/glue/webdevtoolsagent_impl.h @@ -21,6 +21,10 @@ class Node; class String; } +namespace WebKit { +class WebFrame; +} + class BoundObject; class DebuggerAgentDelegateStub; class DebuggerAgentImpl; @@ -28,7 +32,6 @@ class DomAgentImpl; class NetAgentImpl; class Value; class WebDevToolsAgentDelegate; -class WebFrame; class WebFrameImpl; class WebViewImpl; @@ -74,7 +77,7 @@ class WebDevToolsAgentImpl // Methods called by the glue. void SetMainFrameDocumentReady(bool ready); void DidCommitLoadForFrame(WebViewImpl* webview, - WebFrame* frame, + WebKit::WebFrame* frame, bool is_new_navigation); void WindowObjectCleared(WebFrameImpl* webframe); diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index 6095e61..0a85288 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -25,6 +25,7 @@ #include "base/string_util.h" #include "base/values.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebScriptSource.h" #include "webkit/glue/devtools/bound_object.h" #include "webkit/glue/devtools/debugger_agent.h" @@ -34,10 +35,10 @@ #include "webkit/glue/glue_util.h" #include "webkit/glue/webdevtoolsclient_delegate.h" #include "webkit/glue/webdevtoolsclient_impl.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webview_impl.h" using namespace WebCore; +using WebKit::WebFrame; using WebKit::WebScriptSource; using WebKit::WebString; @@ -229,7 +230,7 @@ void WebDevToolsClientImpl::AddResourceSourceToFrame(int resource_id, } void WebDevToolsClientImpl::ExecuteScript(const std::string& expr) { - web_view_impl_->GetMainFrame()->ExecuteScript( + web_view_impl_->GetMainFrame()->executeScript( WebScriptSource(WebString::fromUTF8(expr))); } diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h deleted file mode 100644 index ca3d063..0000000 --- a/webkit/glue/webframe.h +++ /dev/null @@ -1,423 +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_WEBFRAME_H_ -#define WEBKIT_GLUE_WEBFRAME_H_ - -#include <vector> - -#include "base/scoped_ptr.h" -#include "base/string16.h" -#include "skia/ext/bitmap_platform_device.h" -#include "skia/ext/platform_canvas.h" -#include "webkit/api/public/WebCanvas.h" -#include "webkit/api/public/WebURL.h" - -class GURL; -class WebView; -class WebTextInput; -struct NPObject; - -namespace WebKit { -class WebData; -class WebDataSource; -class WebForm; -class WebHistoryItem; -class WebString; -class WebURLRequest; -struct WebConsoleMessage; -struct WebFindOptions; -struct WebRect; -struct WebScriptSource; -struct WebSize; -struct WebURLError; -} - -#if WEBKIT_USING_V8 -namespace v8 { - template <class T> class Local; - class Context; -} -#endif - -// Every frame in a web page is represented by one WebFrame, including the -// outermost frame. -class WebFrame { - public: - WebFrame() {} - - // The two functions below retrieve WebFrame instances relating the currently - // executing JavaScript. Since JavaScript can make function calls across - // frames, though, we need to be more precise. - // - // For example, imagine that a JS function in frame A calls a function in - // frame B, which calls native code, which wants to know what the 'active' - // frame is. - // - // The 'entered context' is the context where execution first entered the - // script engine; the context that is at the bottom of the JS function stack. - // RetrieveFrameForEnteredContext() would return Frame A in our example. - // - // The 'current context' is the context the JS engine is currently inside of; - // the context that is at the top of the JS function stack. - // RetrieveFrameForCurrentContext() would return Frame B in our example. - static WebFrame* RetrieveFrameForEnteredContext(); - static WebFrame* RetrieveFrameForCurrentContext(); - - // Binds a C++ class to a JavaScript property of the window object. This - // should generally be used via CppBoundClass::BindToJavascript() instead of - // calling it directly. - virtual void BindToWindowObject(const std::wstring& name, - NPObject* object) = 0; - - virtual void CallJSGC() = 0; - - // This grants the currently loaded Document access to all security origins - // (including file URLs). Use with care. The access is revoked when a new - // document is loaded into this frame. - virtual void GrantUniversalAccess() = 0; - - virtual NPObject* GetWindowNPObject() = 0; - -#if WEBKIT_USING_V8 - // Returns the V8 context for this frame, or an empty handle if there is - // none. - virtual v8::Local<v8::Context> GetMainWorldScriptContext() = 0; -#endif - - // Reload the current document. - virtual void Reload() = 0; - - // Loads the given WebURLRequest. - virtual void LoadRequest(const WebKit::WebURLRequest& request) = 0; - - // Loads the given WebHistoryItem. This corresponds to a back/forward - // navigation. - virtual void LoadHistoryItem(const WebKit::WebHistoryItem& item) = 0; - - // Loads the given data with specific mime type and optional text encoding. - // For HTML data, base_url indicates the security origin of the document and - // is used to resolve links. If specified, unreachable_url is reported via - // WebDataSource::unreachableURL. If replace is false, then this data will - // be loaded as a normal navigation. Otherwise, the current history item - // will be replaced. - virtual void LoadData( - const WebKit::WebData& data, - const WebKit::WebString& mime_type, - const WebKit::WebString& text_encoding, - const WebKit::WebURL& base_url, - const WebKit::WebURL& unreachable_url = WebKit::WebURL(), - bool replace = false) = 0; - - // This method is short-hand for calling LoadData, where mime_type is - // "text/html" and text_encoding is "UTF-8". - virtual void LoadHTMLString( - const WebKit::WebData& html, - const WebKit::WebURL& base_url, - const WebKit::WebURL& unreachable_url = WebKit::WebURL(), - bool replace = false) = 0; - - // Called to associate the WebURLRequest with this frame. The request will - // be modified to inherit parameters that allow it to be loaded. This method - // ends up triggering WebViewDelegate::WillSendRequest. - virtual void DispatchWillSendRequest(WebKit::WebURLRequest* request) = 0; - - // Called from within WebViewDelegate::DidReceiveDocumentData to commit data - // for the frame that will be used to construct the frame's document. - virtual void CommitDocumentData(const char* data, size_t data_len) = 0; - - // Executes JavaScript in the web frame. - 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. extension_group is an - // embedder-provided specifier that controls which v8 extensions are loaded - // into the new context - see WebKit::registerExtension for the corresponding - // specifier. - virtual void ExecuteScriptInNewContext( - const WebKit::WebScriptSource* sources, int num_sources, - int extension_group) = 0; - - // Executes JavaScript in a new world 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 also gets its own - // wrappers for all DOM nodes and DOM constructors. extension_group is an - // embedder-provided specifier that controls which v8 extensions are loaded - // into the new context - see WebKit::registerExtension for the corresponding - // specifier. - virtual void ExecuteScriptInNewWorld( - const WebKit::WebScriptSource* sources, int num_sources, - int extension_group) = 0; - - // Inserts the given CSS styles at the beginning of the document. - virtual bool InsertCSSStyles(const std::string& css) = 0; - - // Returns the WebHistoryItem representing the state of the previous page - // load for later use when loading. The previous page is the page that was - // loaded before DidCommitLoadForFrame was received. - // - // Returns a null item if there is no valid state to return (for example, - // there is no previous item). Returns true if the previous item's state was - // retrieved, even if that state may be empty. - virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const = 0; - - // Returns the WebHistoryItem representing the state of the current page load - // for later use when loading. - // - // Returns a null item if there is no valid state to return (for example, - // there is no previous item). Returns true if the current item's state was - // retrieved, even if that state may be empty. - virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const = 0; - - // Returns the current URL of the frame, or an empty GURL if there is no - // URL to retrieve (for example, the frame may never have had any content). - virtual GURL GetURL() const = 0; - - // Returns the URL to the favorite icon for the frame. An empty GURL is - // returned if the frame has not finished loading, or the frame's URL - // protocol is not http or https. - virtual GURL GetFavIconURL() const = 0; - - // Returns the URL to the OpenSearch description document for the frame. If - // the page does not have a valid document, an empty GURL is returned. - virtual GURL GetOSDDURL() const = 0; - - // Return the minPrefWidth of the content contained in the current Document - virtual int GetContentsPreferredWidth() const = 0; - - // Returns the committed data source, which is the last data source that has - // successfully started loading. Will return NULL if no provisional data - // has been committed. - virtual WebKit::WebDataSource* GetDataSource() const = 0; - - // Returns the provisional data source, which is a data source where a - // request has been made, but we are not sure if we will use data from it - // (for example, it may be an invalid URL). When the provisional load is - // "committed," it will become the "real" data source (see GetDataSource - // above) and the provisional data source will be NULL. - virtual WebKit::WebDataSource* GetProvisionalDataSource() const = 0; - - // - // @method stopLoading - // @discussion Stop any pending loads on the frame's data source, - // and its children. - // - (void)stopLoading; - virtual void StopLoading() = 0; - - // Returns true if this frame is loading its main resource or a subresource. - virtual bool IsLoading() const = 0; - - // Returns the frame that opened this frame, or NULL if this window has no - // opener. - virtual WebFrame* GetOpener() const = 0; - - // Returns the frame containing this frame, or NULL of this is a top level - // frame with no parent. - virtual WebFrame* GetParent() const = 0; - - // Returns the top-most frame in the frame hierarchy containing this frame. - virtual WebFrame* GetTop() const = 0; - - // Returns the child frame with the given xpath. - // The document of this frame is used as the context node. - // The xpath may need a recursive traversal if non-trivial - // A non-trivial xpath will contain a combination of xpaths - // (delimited by '\n') leading to an inner subframe. - // - // Example: /html/body/iframe/\n/html/body/div/iframe/\n/frameset/frame[0] - // can be broken into 3 xpaths - // /html/body/iframe evaluates to an iframe within the root frame - // /html/body/div/iframe evaluates to an iframe within the level-1 iframe - // /frameset/frame[0] evaluates to first frame within the level-2 iframe - virtual WebFrame* GetChildFrame(const std::wstring& xpath) const = 0; - - // Returns a pointer to the WebView that contains this WebFrame. This - // pointer is not AddRef'd and is only valid for the lifetime of the WebFrame - // unless it is AddRef'd separately by the caller. - virtual WebView* GetView() const = 0; - - // Returns a vector of WebForms (corresponds to document.forms). - virtual void GetForms(std::vector<WebKit::WebForm>* forms) const = 0; - - // Returns the serialization of the frame's security origin. - virtual std::string GetSecurityOrigin() const = 0; - - // Fills the contents of this frame into the given string. If the text is - // longer than max_chars, it will be clipped to that length. Warning: this - // function may be slow depending on the number of characters retrieved and - // page complexity. For a typically sized page, expect it to take on the - // order of milliseconds. - // - // If there is room, subframe text will be recursively appended. Each frame - // will be separated by an empty line. - virtual void GetContentAsPlainText(int max_chars, - std::wstring* text) const = 0; - - // Searches a frame for a given string. - // - // If a match is found, this function will select it (scrolling down to make - // it visible if needed) and fill in the IntRect (selection_rect) with the - // location of where the match was found (in screen coordinates). - // - // 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(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - bool wrap_within_frame, - WebKit::WebRect* selection_rect) = 0; - - // Notifies the frame that we are no longer interested in searching. This will - // abort any asynchronous scoping effort already under way (see the function - // ScopeStringMatches for details) and erase all tick-marks and highlighting - // from the previous search. If |clear_selection| is true, it will also make - // sure the end state for the Find operation does not leave a selection. - // This can occur when the user clears the search string but does not close - // the find box. - virtual void StopFinding(bool clear_selection) = 0; - - // Counts how many times a particular string occurs within the frame. It - // also retrieves the location of the string and updates a vector in the frame - // so that tick-marks and highlighting can be drawn. This function does its - // work asynchronously, by running for a certain time-slice and then - // scheduling itself (co-operative multitasking) to be invoked later - // (repeating the process until all matches have been found). This allows - // multiple frames to be searched at the same time and provides a way to - // 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(int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - bool reset) = 0; - - // Cancels any outstanding requests for scoping string matches on a frame. - virtual void CancelPendingScopingEffort() = 0; - - // This function is called on the mainframe during the scoping effort to keep - // a running tally of the accumulated total match-count for all frames. After - // updating the count it will notify the render-view about the new count. - virtual void IncreaseMatchCount(int count, int request_id) = 0; - - // Notifies the webview-delegate about a new selection rect. This will result - // in the browser getting notified. For more information see WebViewDelegate. - virtual void ReportFindInPageSelection(const WebKit::WebRect& selection_rect, - int active_match_ordinal, - int request_id) = 0; - - // This function is called on the mainframe to reset the total number of - // matches found during the scoping effort. - virtual void ResetMatchCount() = 0; - - // Returns true if the frame is visible (defined as width > 0 and height > 0). - virtual bool Visible() = 0; - - // Selects all the text in the frame. - virtual void SelectAll() = 0; - - // - // - (void)copy:(id)sender; - virtual void Copy() = 0; - - // - // - (void)cut:(id)sender; - virtual void Cut() = 0; - - // - // - (void)paste:(id)sender; - virtual void Paste() = 0; - - // Replace the selection text by a given text. - virtual void Replace(const std::wstring& text) = 0; - - // Toggle spell check on and off. - virtual void ToggleSpellCheck() = 0; - - // Return whether spell check is enabled or not in this frame. - virtual bool SpellCheckEnabled() = 0; - - // - // - (void)delete:(id)sender; - // Delete as in similar to Cut, not as in teardown - virtual void Delete() = 0; - - // Undo the last text editing command. - virtual void Undo() = 0; - - // Redo the last undone text editing command. - virtual void Redo() = 0; - - // Clear any text selection in the frame. - virtual void ClearSelection() = 0; - - // Checks if there is currently a selected area (indicates that GetSelection - // would return a non-empty string). - virtual bool HasSelection() = 0; - - // Returns the selected text if there is any. If |as_html| is true, returns - // the selection as HTML. The return value is encoded in utf-8. - virtual std::string GetSelection(bool as_html) = 0; - - // Returns the full HTML of the page. - virtual std::string GetFullPageHtml() = 0; - - // This function sets a flag within WebKit to instruct it to render the page - // as View-Source (showing the HTML source for the page). - virtual void SetInViewSourceMode(bool enable) = 0; - - // This function returns whether this frame is in "view-source" mode. - virtual bool GetInViewSourceMode() const = 0; - - // Returns the frame name. - virtual std::wstring GetName() = 0; - - // Returns a pointer to the WebTextInput object associated with the frame. - // The caller does not own the object returned. - virtual WebTextInput* GetTextInput() = 0; - - // Executes a webkit editor command. The supported commands are a - // superset of those accepted by javascript:document.execCommand(). - // This method is exposed in order to implement - // javascript:layoutTestController.execCommand() - virtual bool ExecuteEditCommandByName(const std::string& name, - const std::string& value) = 0; - - // Checks whether a webkit editor command is currently enabled. This - // method is exposed in order to implement - // javascript:layoutTestController.isCommandEnabled() - virtual bool IsEditCommandEnabled(const std::string& name) = 0; - - // Adds a message to the frame's console. - virtual void AddMessageToConsole(const WebKit::WebConsoleMessage&) = 0; - - // The current scroll offset from the top of frame in pixels. - virtual WebKit::WebSize ScrollOffset() const = 0; - - // Reformats the WebFrame for printing. page_size is the page size in - // pixels. Returns the number of pages that can be printed at the given page - // size. - virtual int PrintBegin(const WebKit::WebSize& page_size) = 0; - - // Prints one page, and returns the calculated page shrinking factor (usually - // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or not - // in printing mode. - virtual float PrintPage(int page_to_print, WebKit::WebCanvas* canvas) = 0; - - // Reformats the WebFrame for screen display. - virtual void PrintEnd() = 0; - - // Only for test_shell - virtual int PendingFrameUnloadEventCount() const = 0; - - protected: - virtual ~WebFrame() {} - - private: - DISALLOW_COPY_AND_ASSIGN(WebFrame); -}; - -#endif // WEBKIT_GLUE_WEBFRAME_H_ diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 2dad34d..4f784f2 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -148,17 +148,18 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebFindOptions.h" #include "webkit/api/public/WebForm.h" #include "webkit/api/public/WebHistoryItem.h" +#include "webkit/api/public/WebRange.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebScriptSource.h" #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebURLError.h" +#include "webkit/api/public/WebVector.h" #include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dom_operations_private.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webframe_impl.h" -#include "webkit/glue/webtextinput_impl.h" #include "webkit/glue/webview_impl.h" #if defined(OS_LINUX) @@ -172,6 +173,7 @@ MSVC_POP_WARNING(); using base::Time; +using WebCore::AtomicString; using WebCore::ChromeClientChromium; using WebCore::Color; using WebCore::Document; @@ -213,8 +215,10 @@ using WebKit::WebConsoleMessage; using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebFindOptions; +using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebForm; +using WebKit::WebRange; using WebKit::WebRect; using WebKit::WebScriptSource; using WebKit::WebSize; @@ -223,6 +227,7 @@ using WebKit::WebURL; using WebKit::WebURLError; using WebKit::WebURLRequest; using WebKit::WebURLResponse; +using WebKit::WebVector; // Key for a StatsCounter tracking how many WebFrames are active. static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; @@ -232,14 +237,14 @@ static const char* const kOSDRel = "search"; // The separator between frames when the frames are converted to plain text. static const wchar_t kFrameSeparator[] = L"\n\n"; -static const int kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; +static const size_t kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; -// Backend for GetContentAsPlainText, this is a recursive function that gets +// Backend for contentAsPlainText, this is a recursive function that gets // the text for the current frame and all of its subframes. It will append // the text of each frame in turn to the |output| up to |max_chars| length. // // The |frame| must be non-NULL. -static void FrameContentAsPlainText(int max_chars, Frame* frame, +static void FrameContentAsPlainText(size_t max_chars, Frame* frame, std::wstring* output) { Document* doc = frame->document(); if (!doc) @@ -285,12 +290,12 @@ static void FrameContentAsPlainText(int max_chars, Frame* frame, // Just got a NULL node, we can forge ahead! continue; } - int to_append = std::min(it.length(), - max_chars - static_cast<int>(output->size())); + size_t to_append = std::min(static_cast<size_t>(it.length()), + max_chars - output->size()); std::wstring wstr; UTF16ToWide(reinterpret_cast<const char16*>(chars), to_append, &wstr); output->append(wstr.c_str(), to_append); - if (output->size() >= static_cast<size_t>(max_chars)) + if (output->size() >= max_chars) return; // Filled up the buffer. } } @@ -304,12 +309,12 @@ static void FrameContentAsPlainText(int max_chars, Frame* frame, // max_chars. This will cause the computation above: // max_chars - output->size() // to be a negative number which will crash when the subframe is added. - if (static_cast<int>(output->size()) >= max_chars - kFrameSeparatorLen) + if (output->size() >= max_chars - kFrameSeparatorLen) return; output->append(kFrameSeparator, kFrameSeparatorLen); FrameContentAsPlainText(max_chars, cur_child, output); - if (output->size() >= static_cast<size_t>(max_chars)) + if (output->size() >= max_chars) return; // Filled up the buffer. } } @@ -359,8 +364,8 @@ class ChromePrintContext : public WebCore::PrintContext { int WebFrameImpl::live_object_count_ = 0; // static -WebFrame* WebFrame::RetrieveFrameForEnteredContext() { - WebCore::Frame* frame = +WebFrame* WebFrame::frameForEnteredContext() { + Frame* frame = WebCore::ScriptController::retrieveFrameForEnteredContext(); if (frame) return WebFrameImpl::FromFrame(frame); @@ -369,8 +374,8 @@ WebFrame* WebFrame::RetrieveFrameForEnteredContext() { } // static -WebFrame* WebFrame::RetrieveFrameForCurrentContext() { - WebCore::Frame* frame = +WebFrame* WebFrame::frameForCurrentContext() { + Frame* frame = WebCore::ScriptController::retrieveFrameForCurrentContext(); if (frame) return WebFrameImpl::FromFrame(frame); @@ -399,7 +404,7 @@ WebFrameImpl::~WebFrameImpl() { StatsCounter(kWebFrameActiveCount).Decrement(); live_object_count_--; - CancelPendingScopingEffort(); + cancelPendingScopingEffort(); ClearPasswordListeners(); } @@ -419,14 +424,14 @@ void WebFrameImpl::InitMainFrame(WebViewImpl* webview_impl) { frame_->init(); } -void WebFrameImpl::Reload() { +void WebFrameImpl::reload() { frame_->loader()->saveDocumentAndScrollState(); - StopLoading(); // Make sure existing activity stops. + stopLoading(); // Make sure existing activity stops. frame_->loader()->reload(); } -void WebFrameImpl::LoadRequest(const WebURLRequest& request) { +void WebFrameImpl::loadRequest(const WebURLRequest& request) { const ResourceRequest* resource_request = webkit_glue::WebURLRequestToResourceRequest(&request); DCHECK(resource_request); @@ -436,16 +441,16 @@ void WebFrameImpl::LoadRequest(const WebURLRequest& request) { return; } - StopLoading(); // Make sure existing activity stops. + stopLoading(); // Make sure existing activity stops. frame_->loader()->load(*resource_request, false); } -void WebFrameImpl::LoadHistoryItem(const WebHistoryItem& item) { +void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) { RefPtr<HistoryItem> history_item = webkit_glue::WebHistoryItemToHistoryItem(item); DCHECK(history_item.get()); - StopLoading(); // Make sure existing activity stops. + stopLoading(); // Make sure existing activity stops. // If there is no current_item, which happens when we are navigating in // session history after a crash, we need to manufacture one otherwise WebKit @@ -462,7 +467,7 @@ void WebFrameImpl::LoadHistoryItem(const WebHistoryItem& item) { WebCore::FrameLoadTypeIndexedBackForward); } -void WebFrameImpl::LoadData(const WebData& data, +void WebFrameImpl::loadData(const WebData& data, const WebString& mime_type, const WebString& text_encoding, const WebURL& base_url, @@ -475,7 +480,7 @@ void WebFrameImpl::LoadData(const WebData& data, webkit_glue::WebURLToKURL(unreachable_url)); DCHECK(subst_data.isValid()); - StopLoading(); // Make sure existing activity stops. + stopLoading(); // Make sure existing activity stops. frame_->loader()->load(ResourceRequest(webkit_glue::WebURLToKURL(base_url)), subst_data, false); if (replace) { @@ -485,11 +490,11 @@ void WebFrameImpl::LoadData(const WebData& data, } } -void WebFrameImpl::LoadHTMLString(const WebData& data, +void WebFrameImpl::loadHTMLString(const WebData& data, const WebURL& base_url, const WebURL& unreachable_url, bool replace) { - LoadData(data, + loadData(data, WebString::fromUTF8("text/html"), WebString::fromUTF8("UTF-8"), base_url, @@ -497,27 +502,27 @@ void WebFrameImpl::LoadHTMLString(const WebData& data, replace); } -GURL WebFrameImpl::GetURL() const { - const WebDataSource* ds = GetDataSource(); +WebURL WebFrameImpl::url() const { + const WebDataSource* ds = dataSource(); if (!ds) - return GURL(); + return WebURL(); return ds->request().url(); } -GURL WebFrameImpl::GetFavIconURL() const { +WebURL WebFrameImpl::favIconURL() const { WebCore::FrameLoader* frame_loader = frame_->loader(); // The URL to the favicon may be in the header. As such, only // ask the loader for the favicon if it's finished loading. if (frame_loader->state() == WebCore::FrameStateComplete) { const KURL& url = frame_loader->iconURL(); if (!url.isEmpty()) { - return webkit_glue::KURLToGURL(url); + return webkit_glue::KURLToWebURL(url); } } - return GURL(); + return WebURL(); } -GURL WebFrameImpl::GetOSDDURL() const { +WebURL WebFrameImpl::openSearchDescriptionURL() const { WebCore::FrameLoader* frame_loader = frame_->loader(); if (frame_loader->state() == WebCore::FrameStateComplete && frame_->document() && frame_->document()->head() && @@ -531,15 +536,15 @@ GURL WebFrameImpl::GetOSDDURL() const { webkit_glue::CastToHTMLLinkElement(child); if (link_element && link_element->type() == kOSDType && link_element->rel() == kOSDRel && !link_element->href().isEmpty()) { - return webkit_glue::KURLToGURL(link_element->href()); + return webkit_glue::KURLToWebURL(link_element->href()); } } } } - return GURL(); + return WebURL(); } -int WebFrameImpl::GetContentsPreferredWidth() const { +int WebFrameImpl::contentsPreferredWidth() const { if ((frame_->document() != NULL) && (frame_->document()->renderView() != NULL)) { return frame_->document()->renderView()->minPrefWidth(); @@ -548,7 +553,7 @@ int WebFrameImpl::GetContentsPreferredWidth() const { } } -WebHistoryItem WebFrameImpl::GetPreviousHistoryItem() const { +WebHistoryItem WebFrameImpl::previousHistoryItem() const { // We use the previous item here because documentState (filled-out forms) // only get saved to history when it becomes the previous item. The caller // is expected to query the history item after a navigation occurs, after @@ -557,7 +562,7 @@ WebHistoryItem WebFrameImpl::GetPreviousHistoryItem() const { GetWebViewImpl()->GetPreviousHistoryItem()); } -WebHistoryItem WebFrameImpl::GetCurrentHistoryItem() const { +WebHistoryItem WebFrameImpl::currentHistoryItem() const { frame_->loader()->saveDocumentAndScrollState(); return webkit_glue::HistoryItemToWebHistoryItem( @@ -568,15 +573,15 @@ static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) { return loader ? WebDataSourceImpl::FromLoader(loader) : NULL; } -WebDataSource* WebFrameImpl::GetDataSource() const { +WebDataSource* WebFrameImpl::dataSource() const { return DataSourceForDocLoader(frame_->loader()->documentLoader()); } WebDataSourceImpl* WebFrameImpl::GetDataSourceImpl() const { - return static_cast<WebDataSourceImpl*>(GetDataSource()); + return static_cast<WebDataSourceImpl*>(dataSource()); } -WebDataSource* WebFrameImpl::GetProvisionalDataSource() const { +WebDataSource* WebFrameImpl::provisionalDataSource() const { FrameLoader* frame_loader = frame_->loader(); // We regard the policy document loader as still provisional. @@ -588,10 +593,10 @@ WebDataSource* WebFrameImpl::GetProvisionalDataSource() const { } WebDataSourceImpl* WebFrameImpl::GetProvisionalDataSourceImpl() const { - return static_cast<WebDataSourceImpl*>(GetProvisionalDataSource()); + return static_cast<WebDataSourceImpl*>(provisionalDataSource()); } -void WebFrameImpl::StopLoading() { +void WebFrameImpl::stopLoading() { if (!frame_) return; @@ -601,13 +606,13 @@ void WebFrameImpl::StopLoading() { frame_->loader()->stopLoading(false); } -bool WebFrameImpl::IsLoading() const { +bool WebFrameImpl::isLoading() const { if (!frame_) return false; return frame_->loader()->isLoading(); } -WebFrame* WebFrameImpl::GetOpener() const { +WebFrame* WebFrameImpl::opener() const { if (frame_) { Frame* opener = frame_->loader()->opener(); if (opener) @@ -616,7 +621,7 @@ WebFrame* WebFrameImpl::GetOpener() const { return NULL; } -WebFrame* WebFrameImpl::GetParent() const { +WebFrame* WebFrameImpl::parent() const { if (frame_) { Frame *parent = frame_->tree()->parent(); if (parent) @@ -625,113 +630,66 @@ WebFrame* WebFrameImpl::GetParent() const { return NULL; } -WebFrame* WebFrameImpl::GetTop() const { +WebFrame* WebFrameImpl::top() const { if (frame_) return FromFrame(frame_->tree()->top()); return NULL; } -WebFrame* WebFrameImpl::GetChildFrame(const std::wstring& xpath) const { - // xpath string can represent a frame deep down the tree (across multiple - // frame DOMs). - // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] - // should break into 2 xpaths - // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] - - if (xpath.empty()) - return NULL; - - std::wstring secondary; - String xpath_str; - - std::wstring::size_type delim_pos = xpath.find_first_of(L'\n'); - if (delim_pos != std::wstring::npos) { - std::wstring primary = xpath.substr(0, delim_pos); - secondary = xpath.substr(delim_pos + 1); - xpath_str = webkit_glue::StdWStringToString(primary); - } else { - xpath_str = webkit_glue::StdWStringToString(xpath); - } - - Document* document = frame_->document(); - - ExceptionCode ec = 0; - PassRefPtr<XPathResult> xpath_result = - document->evaluate(xpath_str, - document, - NULL, /* namespace */ - XPathResult::ORDERED_NODE_ITERATOR_TYPE, - NULL, /* XPathResult object */ - ec); - - if (!xpath_result.get()) - return NULL; - - Node* node = xpath_result->iterateNext(ec); - - if (!node || !node->isFrameOwnerElement()) - return NULL; - HTMLFrameOwnerElement* frame_element = - static_cast<HTMLFrameOwnerElement*>(node); - WebFrame* web_frame = FromFrame(frame_element->contentFrame()); - - if (secondary.empty()) - return web_frame; - else - return web_frame->GetChildFrame(secondary); -} - -void WebFrameImpl::SetInViewSourceMode(bool enable) { +void WebFrameImpl::enableViewSourceMode(bool enable) { if (frame_) frame_->setInViewSourceMode(enable); } -bool WebFrameImpl::GetInViewSourceMode() const { +bool WebFrameImpl::isViewSourceModeEnabled() const { if (frame_) return frame_->inViewSourceMode(); return false; } -WebView* WebFrameImpl::GetView() const { +WebView* WebFrameImpl::view() const { return GetWebViewImpl(); } -void WebFrameImpl::GetForms(std::vector<WebForm>* results) const { - results->clear(); +void WebFrameImpl::forms(WebVector<WebForm>& results) const { if (!frame_) return; + RefPtr<WebCore::HTMLCollection> forms = frame_->document()->forms(); - unsigned int form_count = forms->length(); - for (unsigned int i = 0; i < form_count; ++i) { + size_t form_count = forms->length(); + + WebVector<WebForm> temp(form_count); + for (size_t i = 0; i < form_count; ++i) { Node* node = forms->item(i); // Strange but true, sometimes item can be NULL. if (node) { - results->push_back(webkit_glue::HTMLFormElementToWebForm( - static_cast<HTMLFormElement*>(node))); + temp[i] = webkit_glue::HTMLFormElementToWebForm( + static_cast<HTMLFormElement*>(node)); } } + results.swap(temp); } -std::string WebFrameImpl::GetSecurityOrigin() const { +WebString WebFrameImpl::securityOrigin() const { if (frame_) { if (frame_->document()) - return webkit_glue::StringToStdString( + return webkit_glue::StringToWebString( frame_->document()->securityOrigin()->toString()); } - return "null"; + return WebString::fromUTF8("null"); } -void WebFrameImpl::BindToWindowObject(const std::wstring& name, +void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) { - assert(frame_); + DCHECK(frame_); if (!frame_ || !frame_->script()->isEnabled()) return; // TODO(mbelshe): Move this to the ScriptController and make it JS neutral. - String key = webkit_glue::StdWStringToString(name); + String key = webkit_glue::WebStringToString(name); #if USE(V8) frame_->script()->bindToWindowObject(frame_, key, object); #endif @@ -751,7 +709,7 @@ void WebFrameImpl::BindToWindowObject(const std::wstring& name, // Call JavaScript garbage collection. -void WebFrameImpl::CallJSGC() { +void WebFrameImpl::collectGarbage() { if (!frame_) return; if (!frame_->settings()->isJavaScriptEnabled()) @@ -762,23 +720,24 @@ void WebFrameImpl::CallJSGC() { #endif } -void WebFrameImpl::GrantUniversalAccess() { +void WebFrameImpl::grantUniversalAccess() { DCHECK(frame_ && frame_->document()); if (frame_ && frame_->document()) { frame_->document()->securityOrigin()->grantUniversalAccess(); } } -void WebFrameImpl::GetContentAsPlainText(int max_chars, - std::wstring* text) const { - text->clear(); +WebString WebFrameImpl::contentAsText(size_t max_chars) const { if (!frame_) - return; + return WebString(); - FrameContentAsPlainText(max_chars, frame_, text); + std::wstring text; + FrameContentAsPlainText(max_chars, frame_, &text); + // TODO(darin): Too many string copies!!! + return WideToUTF16Hack(text); } -NPObject* WebFrameImpl::GetWindowNPObject() { +NPObject* WebFrameImpl::windowObject() const { if (!frame_) return NULL; @@ -788,7 +747,7 @@ NPObject* WebFrameImpl::GetWindowNPObject() { #if USE(V8) // Returns the V8 context for this frame, or an empty handle if there is // none. -v8::Local<v8::Context> WebFrameImpl::GetMainWorldScriptContext() { +v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const { if (!frame_) return v8::Local<v8::Context>(); @@ -820,25 +779,25 @@ void WebFrameImpl::InvalidateArea(AreaToInvalidate area) { } } -void WebFrameImpl::IncreaseMatchCount(int count, int request_id) { +void WebFrameImpl::increaseMatchCount(int count, int request_id) { // This function should only be called on the mainframe. - DCHECK(this == static_cast<WebFrameImpl*>(GetView()->GetMainFrame())); + DCHECK(!parent()); total_matchcount_ += count; // Update the UI with the latest findings. - WebViewDelegate* webview_delegate = GetView()->GetDelegate(); + WebViewDelegate* webview_delegate = GetWebViewImpl()->GetDelegate(); DCHECK(webview_delegate); if (webview_delegate) webview_delegate->ReportFindInPageMatchCount(total_matchcount_, request_id, frames_scoping_count_ == 0); } -void WebFrameImpl::ReportFindInPageSelection(const WebRect& selection_rect, +void WebFrameImpl::reportFindInPageSelection(const WebRect& selection_rect, int active_match_ordinal, int request_id) { // Update the UI with the latest selection rect. - WebViewDelegate* webview_delegate = GetView()->GetDelegate(); + WebViewDelegate* webview_delegate = GetWebViewImpl()->GetDelegate(); DCHECK(webview_delegate); if (webview_delegate) { webview_delegate->ReportFindInPageSelection( @@ -848,20 +807,19 @@ void WebFrameImpl::ReportFindInPageSelection(const WebRect& selection_rect, } } -void WebFrameImpl::ResetMatchCount() { +void WebFrameImpl::resetMatchCount() { total_matchcount_ = 0; frames_scoping_count_ = 0; } -bool WebFrameImpl::Find(int request_id, - const string16& search_text, +bool WebFrameImpl::find(int request_id, + const WebString& search_text, const WebFindOptions& options, bool wrap_within_frame, WebRect* selection_rect) { - WebCore::String webcore_string = webkit_glue::String16ToString(search_text); + WebCore::String webcore_string = webkit_glue::WebStringToString(search_text); - WebFrameImpl* const main_frame_impl = - static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); + WebFrameImpl* const main_frame_impl = GetWebViewImpl()->main_frame(); if (!options.findNext) frame()->page()->unmarkAllTextMatches(); @@ -907,7 +865,7 @@ bool WebFrameImpl::Find(int request_id, active_match_ = new_selection.toNormalizedRange(); curr_selection_rect = active_match_->boundingBox(); SetMarkerActive(active_match_.get(), true); // Active. - ClearSelection(); // WebKit draws the highlighting for all matches. + clearSelection(); // WebKit draws the highlighting for all matches. } if (!options.findNext) { @@ -939,7 +897,7 @@ bool WebFrameImpl::Find(int request_id, rect.y -= frameview()->scrollOffset().height(); *selection_rect = rect; - ReportFindInPageSelection(rect, + reportFindInPageSelection(rect, active_match_index_ + 1, request_id); } @@ -958,8 +916,7 @@ bool WebFrameImpl::Find(int request_id, int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const { int ordinal = 0; WebViewImpl* web_view = GetWebViewImpl(); - WebFrameImpl* const main_frame_impl = - static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); + WebFrameImpl* const main_frame_impl = GetWebViewImpl()->main_frame(); // Iterate from the main frame up to (but not including) |frame| and // add up the number of matches found so far. for (WebFrameImpl* it = main_frame_impl; @@ -976,7 +933,7 @@ int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const { bool WebFrameImpl::ShouldScopeMatches(const string16& search_text) { // 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()) + if (!frame() || !hasVisibleContent()) return false; DCHECK(frame()->document() && frame()->view()); @@ -1057,15 +1014,14 @@ void WebFrameImpl::SetMarkerActive(WebCore::Range* range, bool active) { frame()->document()->setMarkersActive(range, active); } -void WebFrameImpl::ScopeStringMatches(int request_id, - const string16& search_text, +void WebFrameImpl::scopeStringMatches(int request_id, + const WebString& search_text, const WebFindOptions& options, bool reset) { if (!ShouldScopeMatches(search_text)) return; - WebFrameImpl* main_frame_impl = - static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); + WebFrameImpl* main_frame_impl = GetWebViewImpl()->main_frame(); if (reset) { // This is a brand new search, so we need to reset everything. @@ -1085,7 +1041,7 @@ void WebFrameImpl::ScopeStringMatches(int request_id, // Now, defer scoping until later to allow find operation to finish quickly. MessageLoop::current()->PostTask(FROM_HERE, scope_matches_factory_.NewRunnableMethod( - &WebFrameImpl::ScopeStringMatches, + &WebFrameImpl::scopeStringMatches, request_id, search_text, options, @@ -1186,7 +1142,7 @@ void WebFrameImpl::ScopeStringMatches(int request_id, // Notify browser of new location for the selected rectangle. result_bounds.move(-frameview()->scrollOffset().width(), -frameview()->scrollOffset().height()); - ReportFindInPageSelection( + reportFindInPageSelection( webkit_glue::IntRectToWebRect( frame()->view()->convertToContainingWindow(result_bounds)), active_match_index_ + 1, @@ -1210,7 +1166,7 @@ void WebFrameImpl::ScopeStringMatches(int request_id, last_match_count_ += match_count; // Let the mainframe know how much we found during this pass. - main_frame_impl->IncreaseMatchCount(match_count, request_id); + main_frame_impl->increaseMatchCount(match_count, request_id); } if (timeout) { @@ -1223,7 +1179,7 @@ void WebFrameImpl::ScopeStringMatches(int request_id, // Scoping effort ran out of time, lets ask for another time-slice. MessageLoop::current()->PostTask(FROM_HERE, scope_matches_factory_.NewRunnableMethod( - &WebFrameImpl::ScopeStringMatches, + &WebFrameImpl::scopeStringMatches, request_id, search_text, options, @@ -1240,20 +1196,19 @@ void WebFrameImpl::ScopeStringMatches(int request_id, // 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_id); + main_frame_impl->increaseMatchCount(0, request_id); // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. InvalidateArea(INVALIDATE_SCROLLBAR); } -void WebFrameImpl::CancelPendingScopingEffort() { +void WebFrameImpl::cancelPendingScopingEffort() { scope_matches_factory_.RevokeAll(); active_match_index_ = -1; } void WebFrameImpl::SetFindEndstateFocusAndSelection() { - WebFrameImpl* main_frame_impl = - static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); + WebFrameImpl* main_frame_impl = GetWebViewImpl()->main_frame(); if (this == main_frame_impl->active_match_frame() && active_match_.get()) { @@ -1288,13 +1243,13 @@ void WebFrameImpl::SetFindEndstateFocusAndSelection() { } } -void WebFrameImpl::StopFinding(bool clear_selection) { +void WebFrameImpl::stopFinding(bool clear_selection) { if (!clear_selection) SetFindEndstateFocusAndSelection(); - CancelPendingScopingEffort(); + cancelPendingScopingEffort(); // Remove all markers for matches found and turn off the highlighting. - if (this == static_cast<WebFrameImpl*>(GetView()->GetMainFrame())) + if (!parent()) frame()->document()->removeMarkers(WebCore::DocumentMarker::TextMatch); frame()->setMarkedTextMatchesAreHighlighted(false); @@ -1302,108 +1257,97 @@ void WebFrameImpl::StopFinding(bool clear_selection) { InvalidateArea(INVALIDATE_ALL); } -void WebFrameImpl::SelectAll() { +void WebFrameImpl::selectAll() { frame()->selection()->selectAll(); - WebViewDelegate* d = GetView()->GetDelegate(); + WebViewDelegate* d = GetWebViewImpl()->GetDelegate(); if (d) d->UserMetricsRecordAction(L"SelectAll"); } -void WebFrameImpl::Copy() { - frame()->editor()->copy(); - - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"Copy"); +WebRange WebFrameImpl::selectionRange() const { + return webkit_glue::RangeToWebRange( + frame()->selection()->toNormalizedRange()); } -void WebFrameImpl::Cut() { - frame()->editor()->cut(); +WebString WebFrameImpl::selectionAsText() const { + RefPtr<Range> range = frame()->selection()->toNormalizedRange(); + if (!range.get()) + return WebString(); - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"Cut"); + String text = range->text(); +#if defined(OS_WIN) + WebCore::replaceNewlinesWithWindowsStyleNewlines(text); +#endif + WebCore::replaceNBSPWithSpace(text); + return webkit_glue::StringToWebString(text); } -void WebFrameImpl::Paste() { - frame()->editor()->paste(); +WebString WebFrameImpl::selectionAsMarkup() const { + RefPtr<Range> range = frame()->selection()->toNormalizedRange(); + if (!range.get()) + return WebString(); - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"Paste"); + String markup = WebCore::createMarkup(range.get(), 0); + return webkit_glue::StringToWebString(markup); } -void WebFrameImpl::Replace(const std::wstring& wtext) { - String text = webkit_glue::StdWStringToString(wtext); +void WebFrameImpl::replaceSelection(const WebString& wtext) { + String text = webkit_glue::WebStringToString(wtext); RefPtr<DocumentFragment> fragment = createFragmentFromText( frame()->selection()->toNormalizedRange().get(), text); WebCore::applyCommand(WebCore::ReplaceSelectionCommand::create( frame()->document(), fragment.get(), false, true, true)); } -void WebFrameImpl::ToggleSpellCheck() { - frame()->editor()->toggleContinuousSpellChecking(); +void WebFrameImpl::insertText(const WebString& text) { + frame()->editor()->insertText(webkit_glue::WebStringToString(text), NULL); } -bool WebFrameImpl::SpellCheckEnabled() { - return frame()->editor()->isContinuousSpellCheckingEnabled(); -} +void WebFrameImpl::setMarkedText( + const WebString& text, unsigned location, unsigned length) { + WebCore::Editor* editor = frame()->editor(); + WebCore::String str = webkit_glue::WebStringToString(text); -void WebFrameImpl::Delete() { - frame()->editor()->command("Delete").execute(); + editor->confirmComposition(str); - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"DeleteSelection"); + WTF::Vector<WebCore::CompositionUnderline> decorations; + editor->setComposition(str, decorations, location, length); } -void WebFrameImpl::Undo() { - frame()->editor()->undo(); - - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"Undo"); +void WebFrameImpl::unmarkText() { + frame()->editor()->confirmCompositionWithoutDisturbingSelection(); } -void WebFrameImpl::Redo() { - frame()->editor()->redo(); +bool WebFrameImpl::hasMarkedText() const { + return frame()->editor()->hasComposition(); +} - WebViewDelegate* d = GetView()->GetDelegate(); - if (d) - d->UserMetricsRecordAction(L"Redo"); +WebRange WebFrameImpl::markedRange() const { + return webkit_glue::RangeToWebRange(frame()->editor()->compositionRange()); } -void WebFrameImpl::ClearSelection() { - frame()->selection()->clear(); +void WebFrameImpl::enableContinuousSpellChecking(bool enable) { + if (enable == isContinuousSpellCheckingEnabled()) + return; + frame()->editor()->toggleContinuousSpellChecking(); } -bool WebFrameImpl::HasSelection() { - // frame()->selection()->isNone() never returns true. - return (frame()->selection()->start() != - frame()->selection()->end()); +bool WebFrameImpl::isContinuousSpellCheckingEnabled() const { + return frame()->editor()->isContinuousSpellCheckingEnabled(); } -std::string WebFrameImpl::GetSelection(bool as_html) { - RefPtr<Range> range = frame()->selection()->toNormalizedRange(); - if (!range.get()) - return std::string(); +void WebFrameImpl::clearSelection() { + frame()->selection()->clear(); +} - if (as_html) { - String markup = WebCore::createMarkup(range.get(), 0); - return webkit_glue::StringToStdString(markup); - } else { - String text = range->text(); -#if defined(OS_WIN) - WebCore::replaceNewlinesWithWindowsStyleNewlines(text); -#endif - WebCore::replaceNBSPWithSpace(text); - return webkit_glue::StringToStdString(text); - } +bool WebFrameImpl::hasSelection() const { + // frame()->selection()->isNone() never returns true. + return (frame()->selection()->start() != frame()->selection()->end()); } -std::string WebFrameImpl::GetFullPageHtml() { - return webkit_glue::StringToStdString(createFullMarkup(frame_->document())); +WebString WebFrameImpl::contentAsMarkup() const { + return webkit_glue::StringToWebString(createFullMarkup(frame_->document())); } void WebFrameImpl::CreateFrameView() { @@ -1525,14 +1469,14 @@ void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { } } -void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) { +void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request) { ResourceResponse response; frame_->loader()->client()->dispatchWillSendRequest(NULL, 0, - *webkit_glue::WebURLRequestToMutableResourceRequest(request), + *webkit_glue::WebURLRequestToMutableResourceRequest(&request), response); } -void WebFrameImpl::CommitDocumentData(const char* data, size_t data_len) { +void WebFrameImpl::commitDocumentData(const char* data, size_t data_len) { DocumentLoader* document_loader = frame_->loader()->documentLoader(); // Set the text encoding. This calls begin() for us. It is safe to call @@ -1549,7 +1493,7 @@ void WebFrameImpl::CommitDocumentData(const char* data, size_t data_len) { frame_->loader()->addData(data, data_len); } -void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { +void WebFrameImpl::executeScript(const WebScriptSource& source) { frame_->loader()->executeScript( WebCore::ScriptSourceCode( webkit_glue::WebStringToString(source.code), @@ -1557,7 +1501,7 @@ void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { source.startLine)); } -bool WebFrameImpl::InsertCSSStyles(const std::string& css) { +bool WebFrameImpl::insertStyleText(const WebString& css) { Document* document = frame()->document(); if (!document) return false; @@ -1568,7 +1512,7 @@ bool WebFrameImpl::InsertCSSStyles(const std::string& css) { RefPtr<WebCore::Element> stylesheet = document->createElement( WebCore::HTMLNames::styleTag, false); ExceptionCode err = 0; - stylesheet->setTextContent(webkit_glue::StdStringToString(css), err); + stylesheet->setTextContent(webkit_glue::WebStringToString(css), err); DCHECK(!err) << "Failed to set style element content"; WebCore::Node* first = document_element->firstChild(); bool success = document_element->insertBefore(stylesheet, first, err); @@ -1576,12 +1520,12 @@ bool WebFrameImpl::InsertCSSStyles(const std::string& css) { return success; } -void WebFrameImpl::ExecuteScriptInNewContext( - const WebScriptSource* sources_in, int num_sources, - int extension_group) { +void WebFrameImpl::executeScriptInNewContext( + const WebScriptSource* sources_in, unsigned num_sources, + int extension_group) { Vector<WebCore::ScriptSourceCode> sources; - for (int i = 0; i < num_sources; ++i) { + for (unsigned i = 0; i < num_sources; ++i) { sources.append(WebCore::ScriptSourceCode( webkit_glue::WebStringToString(sources_in[i].code), webkit_glue::WebURLToKURL(sources_in[i].url), @@ -1591,12 +1535,12 @@ void WebFrameImpl::ExecuteScriptInNewContext( frame_->script()->evaluateInNewContext(sources, extension_group); } -void WebFrameImpl::ExecuteScriptInNewWorld( - const WebScriptSource* sources_in, int num_sources, - int extension_group) { +void WebFrameImpl::executeScriptInNewWorld( + const WebScriptSource* sources_in, unsigned num_sources, + int extension_group) { Vector<WebCore::ScriptSourceCode> sources; - for (int i = 0; i < num_sources; ++i) { + for (unsigned i = 0; i < num_sources; ++i) { sources.append(WebCore::ScriptSourceCode( webkit_glue::WebStringToString(sources_in[i].code), webkit_glue::WebURLToKURL(sources_in[i].url), @@ -1606,18 +1550,11 @@ void WebFrameImpl::ExecuteScriptInNewWorld( frame_->script()->evaluateInNewWorld(sources, extension_group); } -std::wstring WebFrameImpl::GetName() { - return webkit_glue::StringToStdWString(frame_->tree()->name()); -} - -WebTextInput* WebFrameImpl::GetTextInput() { - if (!webtextinput_impl_.get()) { - webtextinput_impl_.reset(new WebTextInputImpl(this)); - } - return webtextinput_impl_.get(); +WebString WebFrameImpl::name() const { + return webkit_glue::StringToWebString(frame_->tree()->name()); } -bool WebFrameImpl::Visible() { +bool WebFrameImpl::hasVisibleContent() const { return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight() > 0; } @@ -1668,20 +1605,66 @@ PassRefPtr<Frame> WebFrameImpl::CreateChildFrame( return child_frame.release(); } -bool WebFrameImpl::ExecuteEditCommandByName(const std::string& name, - const std::string& value) { +bool WebFrameImpl::executeCommand(const WebString& name) { ASSERT(frame()); - return frame()->editor()->command(webkit_glue::StdStringToString(name)) - .execute(webkit_glue::StdStringToString(value)); + + if (name.length() <= 2) + return false; + + // Since we don't have NSControl, we will convert the format of command + // string and call the function on Editor directly. + string16 command = name; + + // Make sure the first letter is upper case. + command.replace(0, 1, 1, toupper(command.at(0))); + + // Remove the trailing ':' if existing. + if (command.at(command.length() - 1) == ':') + command.erase(command.length() - 1, 1); + + bool rv = true; + + // Specially handling commands that Editor::execCommand does not directly + // support. + if (EqualsASCII(command, "DeleteToEndOfParagraph")) { + WebCore::Editor* editor = frame()->editor(); + if (!editor->deleteWithDirection(WebCore::SelectionController::FORWARD, + WebCore::ParagraphBoundary, + true, + false)) { + editor->deleteWithDirection(WebCore::SelectionController::FORWARD, + WebCore::CharacterGranularity, + true, + false); + } + } else if (EqualsASCII(command, "Indent")) { + frame()->editor()->indent(); + } else if (EqualsASCII(command, "Outdent")) { + frame()->editor()->outdent(); + } else if (EqualsASCII(command, "DeleteBackward")) { + rv = frame()->editor()->command(AtomicString("BackwardDelete")).execute(); + } else if (EqualsASCII(command, "DeleteForward")) { + rv = frame()->editor()->command(AtomicString("ForwardDelete")).execute(); + } else { + rv = frame()->editor()->command(AtomicString(command.c_str())).execute(); + } + return rv; } -bool WebFrameImpl::IsEditCommandEnabled(const std::string& name) { +bool WebFrameImpl::executeCommand(const WebString& name, + const WebString& value) { ASSERT(frame()); - return frame()->editor()->command(webkit_glue::StdStringToString(name)) - .isEnabled(); + return frame()->editor()->command(webkit_glue::WebStringToString(name)). + execute(webkit_glue::WebStringToString(value)); } -void WebFrameImpl::AddMessageToConsole(const WebConsoleMessage& message) { +bool WebFrameImpl::isCommandEnabled(const WebString& name) const { + ASSERT(frame()); + return frame()->editor()->command(webkit_glue::WebStringToString(name)). + isEnabled(); +} + +void WebFrameImpl::addMessageToConsole(const WebConsoleMessage& message) { ASSERT(frame()); WebCore::MessageLevel webcore_message_level; @@ -1709,7 +1692,7 @@ void WebFrameImpl::AddMessageToConsole(const WebConsoleMessage& message) { 1, String()); } -WebSize WebFrameImpl::ScrollOffset() const { +WebSize WebFrameImpl::scrollOffset() const { WebCore::FrameView* view = frameview(); if (view) return webkit_glue::IntSizeToWebSize(view->scrollOffset()); @@ -1717,11 +1700,71 @@ WebSize WebFrameImpl::ScrollOffset() const { return WebSize(); } +WebSize WebFrameImpl::contentsSize() const { + return webkit_glue::IntSizeToWebSize(frame()->view()->contentsSize()); +} + +WebFrame* WebFrameImpl::firstChild() const { + return FromFrame(frame()->tree()->firstChild()); +} + +WebFrame* WebFrameImpl::lastChild() const { + return FromFrame(frame()->tree()->lastChild()); +} + +WebFrame* WebFrameImpl::nextSibling() const { + return FromFrame(frame()->tree()->nextSibling()); +} + +WebFrame* WebFrameImpl::previousSibling() const { + return FromFrame(frame()->tree()->previousSibling()); +} + +WebFrame* WebFrameImpl::traverseNext(bool wrap) const { + return FromFrame(frame()->tree()->traverseNextWithWrap(wrap)); +} + +WebFrame* WebFrameImpl::traversePrevious(bool wrap) const { + return FromFrame(frame()->tree()->traversePreviousWithWrap(wrap)); +} + +WebFrame* WebFrameImpl::findChildByName(const WebKit::WebString& name) const { + return FromFrame(frame()->tree()->child( + webkit_glue::WebStringToString(name))); +} + +WebFrame* WebFrameImpl::findChildByExpression( + const WebKit::WebString& xpath) const { + if (xpath.isEmpty()) + return NULL; + + Document* document = frame_->document(); + + ExceptionCode ec = 0; + PassRefPtr<XPathResult> xpath_result = + document->evaluate(webkit_glue::WebStringToString(xpath), + document, + NULL, /* namespace */ + XPathResult::ORDERED_NODE_ITERATOR_TYPE, + NULL, /* XPathResult object */ + ec); + if (!xpath_result.get()) + return NULL; + + Node* node = xpath_result->iterateNext(ec); + + if (!node || !node->isFrameOwnerElement()) + return NULL; + HTMLFrameOwnerElement* frame_element = + static_cast<HTMLFrameOwnerElement*>(node); + return FromFrame(frame_element->contentFrame()); +} + void WebFrameImpl::SetAllowsScrolling(bool flag) { frame_->view()->setCanHaveScrollbars(flag); } -int WebFrameImpl::PrintBegin(const WebSize& page_size) { +int WebFrameImpl::printBegin(const WebSize& page_size) { DCHECK_EQ(frame()->document()->isFrameSet(), false); print_context_.reset(new ChromePrintContext(frame())); @@ -1736,7 +1779,7 @@ int WebFrameImpl::PrintBegin(const WebSize& page_size) { return print_context_->pageCount(); } -float WebFrameImpl::PrintPage(int page, WebCanvas* canvas) { +float WebFrameImpl::printPage(int page, WebCanvas* canvas) { // Ensure correct state. if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { NOTREACHED(); @@ -1755,14 +1798,14 @@ float WebFrameImpl::PrintPage(int page, WebCanvas* canvas) { return print_context_->spoolPage(spool, page); } -void WebFrameImpl::PrintEnd() { +void WebFrameImpl::printEnd() { DCHECK(print_context_.get()); if (print_context_.get()) print_context_->end(); print_context_.reset(NULL); } -int WebFrameImpl::PendingFrameUnloadEventCount() const { +unsigned WebFrameImpl::unloadListenerCount() const { return frame()->domWindow()->pendingUnloadEventListeners(); } diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index bdfac0c..0749a61 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -29,8 +29,8 @@ #include "base/scoped_ptr.h" #include "base/task.h" #include "skia/ext/platform_canvas.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/glue/password_autocomplete_listener.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webframeloaderclient_impl.h" MSVC_PUSH_WARNING_LEVEL(0); @@ -44,8 +44,6 @@ class WebDataSourceImpl; class WebPluginDelegate; class WebView; class WebViewImpl; -class WebTextInput; -class WebTextInputImpl; namespace gfx { class BitmapPlatformDevice; @@ -63,7 +61,8 @@ struct WindowFeatures; } // Implementation of WebFrame, note that this is a reference counted object. -class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { +class WebFrameImpl : public WebKit::WebFrame, + public base::RefCounted<WebFrameImpl> { public: WebFrameImpl(); ~WebFrameImpl(); @@ -75,117 +74,106 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // Called by the WebViewImpl to initialize its main frame: void InitMainFrame(WebViewImpl* webview_impl); - // WebFrame - virtual void Reload(); - virtual void LoadRequest(const WebKit::WebURLRequest& request); - virtual void LoadHistoryItem(const WebKit::WebHistoryItem& item); - virtual void LoadData( - const WebKit::WebData& data, - const WebKit::WebString& mime_type, - const WebKit::WebString& text_encoding, - const WebKit::WebURL& base_url, - const WebKit::WebURL& unreachable_url = WebKit::WebURL(), - bool replace = false); - virtual void LoadHTMLString( - const WebKit::WebData& data, - const WebKit::WebURL& base_url, - const WebKit::WebURL& unreachable_url = WebKit::WebURL(), - bool replace = false); - virtual void DispatchWillSendRequest(WebKit::WebURLRequest* request); - virtual void CommitDocumentData(const char* data, size_t data_len); - virtual void ExecuteScript(const WebKit::WebScriptSource& source); - virtual void ExecuteScriptInNewContext( - const WebKit::WebScriptSource* sources, int num_sources, + // WebFrame methods: + virtual WebKit::WebString name() const; + virtual WebKit::WebURL url() const; + virtual WebKit::WebURL favIconURL() const; + virtual WebKit::WebURL openSearchDescriptionURL() const; + virtual WebKit::WebSize scrollOffset() const; + virtual WebKit::WebSize contentsSize() const; + virtual int contentsPreferredWidth() const; + virtual bool hasVisibleContent() const; + virtual WebView* view() const; + virtual WebKit::WebFrame* opener() const; + virtual WebKit::WebFrame* parent() const; + virtual WebKit::WebFrame* top() const; + virtual WebKit::WebFrame* firstChild() const; + virtual WebKit::WebFrame* lastChild() const; + virtual WebKit::WebFrame* nextSibling() const; + virtual WebKit::WebFrame* previousSibling() const; + virtual WebKit::WebFrame* traverseNext(bool wrap) const; + virtual WebKit::WebFrame* traversePrevious(bool wrap) const; + virtual WebKit::WebFrame* findChildByName(const WebKit::WebString& name) const; + virtual WebKit::WebFrame* findChildByExpression( + const WebKit::WebString& xpath) const; + virtual void forms(WebKit::WebVector<WebKit::WebForm>&) const; + virtual WebKit::WebString securityOrigin() const; + virtual void grantUniversalAccess(); + virtual NPObject* windowObject() const; + virtual void bindToWindowObject( + const WebKit::WebString& name, NPObject* object); + virtual void executeScript(const WebKit::WebScriptSource&); + virtual void executeScriptInNewContext( + const WebKit::WebScriptSource* sources, unsigned num_sources, int extension_group); - virtual void ExecuteScriptInNewWorld( - const WebKit::WebScriptSource* sources, int num_sources, + virtual void executeScriptInNewWorld( + const WebKit::WebScriptSource* sources, unsigned num_sources, int extension_group); - virtual bool InsertCSSStyles(const std::string& css); - virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const; - virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const; - virtual GURL GetURL() const; - virtual GURL GetFavIconURL() const; - virtual GURL GetOSDDURL() const; - virtual int GetContentsPreferredWidth() const; - virtual WebKit::WebDataSource* GetDataSource() const; - virtual WebKit::WebDataSource* GetProvisionalDataSource() const; - virtual void StopLoading(); - virtual bool IsLoading() const; - virtual WebFrame* GetOpener() const; - virtual WebFrame* GetParent() const; - virtual WebFrame* GetTop() const; - virtual WebFrame* GetChildFrame(const std::wstring& xpath) const; - virtual WebView* GetView() const; - virtual void GetForms(std::vector<WebKit::WebForm>* forms) const; - virtual std::string GetSecurityOrigin() const; - - // This method calls createRuntimeObject (in KJS::Bindings::Instance), which - // increments the refcount of the NPObject passed in. - virtual void BindToWindowObject(const std::wstring& name, NPObject* object); - virtual void CallJSGC(); - - virtual void GrantUniversalAccess(); - - virtual NPObject* GetWindowNPObject(); - -#if USE(V8) - // Returns the V8 context for this frame, or an empty handle if there is - // none. - virtual v8::Local<v8::Context> GetMainWorldScriptContext(); + virtual void addMessageToConsole(const WebKit::WebConsoleMessage&); + virtual void collectGarbage(); +#if WEBKIT_USING_V8 + virtual v8::Local<v8::Context> mainWorldScriptContext() const; #endif - - virtual void GetContentAsPlainText(int max_chars, std::wstring* text) const; - virtual bool Find( - int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - bool wrap_within_frame, + virtual bool insertStyleText(const WebKit::WebString& style_text); + virtual void reload(); + virtual void loadRequest(const WebKit::WebURLRequest& request); + virtual void loadHistoryItem(const WebKit::WebHistoryItem& history_item); + virtual void loadData( + const WebKit::WebData& data, const WebKit::WebString& mime_type, + const WebKit::WebString& text_encoding, const WebKit::WebURL& base_url, + const WebKit::WebURL& unreachable_url, bool replace); + virtual void loadHTMLString( + const WebKit::WebData& html, const WebKit::WebURL& base_url, + const WebKit::WebURL& unreachable_url, bool replace); + virtual bool isLoading() const; + virtual void stopLoading(); + virtual WebKit::WebDataSource* provisionalDataSource() const; + virtual WebKit::WebDataSource* dataSource() const; + virtual WebKit::WebHistoryItem previousHistoryItem() const; + virtual WebKit::WebHistoryItem currentHistoryItem() const; + virtual void enableViewSourceMode(bool enable); + virtual bool isViewSourceModeEnabled() const; + virtual void dispatchWillSendRequest(WebKit::WebURLRequest& request); + virtual void commitDocumentData(const char* data, size_t length); + virtual unsigned unloadListenerCount() const; + virtual void replaceSelection(const WebKit::WebString& text); + virtual void insertText(const WebKit::WebString& text); + virtual void setMarkedText( + const WebKit::WebString& text, unsigned location, unsigned length); + virtual void unmarkText(); + virtual bool hasMarkedText() const; + virtual WebKit::WebRange markedRange() const; + virtual bool executeCommand(const WebKit::WebString& command); + virtual bool executeCommand( + const WebKit::WebString& command, const WebKit::WebString& value); + virtual bool isCommandEnabled(const WebKit::WebString& command) const; + virtual void enableContinuousSpellChecking(bool enable); + virtual bool isContinuousSpellCheckingEnabled() const; + virtual void selectAll(); + virtual void clearSelection(); + virtual bool hasSelection() const; + virtual WebKit::WebRange selectionRange() const; + virtual WebKit::WebString selectionAsText() const; + virtual WebKit::WebString selectionAsMarkup() const; + virtual int printBegin(const WebKit::WebSize& page_size); + virtual float printPage(int page_to_print, WebKit::WebCanvas* canvas); + virtual void printEnd(); + virtual bool find( + int identifier, const WebKit::WebString& search_text, + const WebKit::WebFindOptions& options, bool wrap_within_frame, WebKit::WebRect* selection_rect); - virtual void StopFinding(bool clear_selection); - virtual void ScopeStringMatches( - int request_id, - const string16& search_text, - const WebKit::WebFindOptions& options, - bool reset); - virtual void CancelPendingScopingEffort(); - virtual void ResetMatchCount(); - virtual bool Visible(); - virtual void SelectAll(); - virtual void Copy(); - virtual void Cut(); - virtual void Paste(); - virtual void Replace(const std::wstring& text); - virtual void ToggleSpellCheck(); - virtual bool SpellCheckEnabled(); - virtual void Delete(); - virtual void Undo(); - virtual void Redo(); - virtual void ClearSelection(); - virtual bool HasSelection(); - virtual std::string GetSelection(bool as_html); - virtual std::string GetFullPageHtml(); - - virtual void SetInViewSourceMode(bool enable); - - virtual bool GetInViewSourceMode() const; - - virtual void DidFail(const WebCore::ResourceError&, bool was_provisional); - - virtual std::wstring GetName(); - - virtual WebTextInput* GetTextInput(); - - virtual bool ExecuteEditCommandByName(const std::string& name, - const std::string& value); - virtual bool IsEditCommandEnabled(const std::string& name); - - virtual void AddMessageToConsole(const WebKit::WebConsoleMessage&); - - virtual WebKit::WebSize ScrollOffset() const; - - virtual int PrintBegin(const WebKit::WebSize& page_size); - virtual float PrintPage(int page, WebKit::WebCanvas* canvas); - virtual void PrintEnd(); + virtual void stopFinding(bool clear_selection); + virtual void scopeStringMatches( + int identifier, const WebKit::WebString& search_text, + const WebKit::WebFindOptions& options, bool reset); + virtual void cancelPendingScopingEffort(); + virtual void increaseMatchCount(int count, int identifier); + virtual void reportFindInPageSelection( + const WebKit::WebRect& selection_rect, int active_match_ordinal, + int identifier); + virtual void resetMatchCount(); + virtual WebKit::WebString contentAsText(size_t max_chars) const; + virtual WebKit::WebString contentAsMarkup() const; PassRefPtr<WebCore::Frame> CreateChildFrame( const WebCore::FrameLoadRequest&, @@ -239,6 +227,8 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // allows us to navigate by pressing Enter after closing the Find box. void SetFindEndstateFocusAndSelection(); + void DidFail(const WebCore::ResourceError& error, bool was_provisional); + // Sets whether the WebFrameImpl allows its document to be scrolled. // If the parameter is true, allow the document to be scrolled. // Otherwise, disallow scrolling. @@ -266,12 +256,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // WebFrameLoaderClient void Closing(); - // See WebFrame.h for details. - virtual void IncreaseMatchCount(int count, int request_id); - virtual void ReportFindInPageSelection(const WebKit::WebRect& selection_rect, - int active_match_ordinal, - int request_id); - // Used to check for leaks of this object. static int live_object_count_; @@ -289,9 +273,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // a pointer back to the appropriate plugin. WebPluginDelegate* plugin_delegate_; - // Handling requests from TextInputController on this frame. - scoped_ptr<WebTextInputImpl> webtextinput_impl_; - // A way for the main frame to keep track of which frame has an active // match. Should be NULL for all other frames. WebFrameImpl* active_match_frame_; diff --git a/webkit/glue/webframe_unittest.cc b/webkit/glue/webframe_unittest.cc index 833d03b1..fc5746e 100644 --- a/webkit/glue/webframe_unittest.cc +++ b/webkit/glue/webframe_unittest.cc @@ -5,11 +5,15 @@ #include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebFrame.h" +#include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebFrame; +using WebKit::WebString; + class WebFrameTest : public TestShellTest { public: }; @@ -21,38 +25,38 @@ TEST_F(WebFrameTest, GetContentAsPlainText) { // Generate a simple test case. const char simple_source[] = "<div>Foo bar</div><div></div>baz"; GURL test_url("http://foo/"); - frame->LoadHTMLString(simple_source, test_url); + frame->loadHTMLString(simple_source, test_url); test_shell_->WaitTestFinished(); // Make sure it comes out OK. - const std::wstring expected(ASCIIToWide("Foo bar\nbaz")); - std::wstring text; - frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); + const string16 expected(ASCIIToUTF16("Foo bar\nbaz")); + string16 text = frame->contentAsText(std::numeric_limits<size_t>::max()); EXPECT_EQ(expected, text); // Try reading the same one with clipping of the text. const int len = 5; - frame->GetContentAsPlainText(len, &text); + text = frame->contentAsText(len); EXPECT_EQ(expected.substr(0, len), text); // Now do a new test with a subframe. const char outer_frame_source[] = "Hello<iframe></iframe> world"; - frame->LoadHTMLString(outer_frame_source, test_url); + frame->loadHTMLString(outer_frame_source, test_url); test_shell_->WaitTestFinished(); // Load something into the subframe. - WebFrame* subframe = frame->GetChildFrame(L"/html/body/iframe"); + WebFrame* subframe = frame->findChildByExpression( + WebString::fromUTF8("/html/body/iframe")); ASSERT_TRUE(subframe); - subframe->LoadHTMLString("sub<p>text", test_url); + subframe->loadHTMLString("sub<p>text", test_url); test_shell_->WaitTestFinished(); - frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); - EXPECT_EQ("Hello world\n\nsub\ntext", WideToUTF8(text)); + text = frame->contentAsText(std::numeric_limits<size_t>::max()); + EXPECT_EQ("Hello world\n\nsub\ntext", UTF16ToUTF8(text)); // Get the frame text where the subframe separator falls on the boundary of // what we'll take. There used to be a crash in this case. - frame->GetContentAsPlainText(12, &text); - EXPECT_EQ("Hello world", WideToUTF8(text)); + text = frame->contentAsText(12); + EXPECT_EQ("Hello world", UTF16ToUTF8(text)); } TEST_F(WebFrameTest, GetFullHtmlOfPage) { @@ -62,33 +66,29 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage) { // Generate a simple test case. const char simple_source[] = "<p>Hello</p><p>World</p>"; GURL test_url("http://hello/"); - frame->LoadHTMLString(simple_source, test_url); + frame->loadHTMLString(simple_source, test_url); test_shell_->WaitTestFinished(); - std::wstring text; - frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); - EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text)); + string16 text = frame->contentAsText(std::numeric_limits<size_t>::max()); + EXPECT_EQ("Hello\n\nWorld", UTF16ToUTF8(text)); - const std::string html = frame->GetFullPageHtml(); + const std::string html = frame->contentAsMarkup().utf8(); // Load again with the output html. - frame->LoadHTMLString(html, test_url); + frame->loadHTMLString(html, test_url); test_shell_->WaitTestFinished(); - EXPECT_EQ(html, frame->GetFullPageHtml()); + EXPECT_EQ(html, UTF16ToUTF8(frame->contentAsMarkup())); - text = L""; - frame->GetContentAsPlainText(std::numeric_limits<int>::max(), &text); - EXPECT_EQ("Hello\n\nWorld", WideToUTF8(text)); + text = frame->contentAsText(std::numeric_limits<size_t>::max()); + EXPECT_EQ("Hello\n\nWorld", UTF16ToUTF8(text)); // Test selection check - EXPECT_FALSE(frame->HasSelection()); - frame->SelectAll(); - EXPECT_TRUE(frame->HasSelection()); - frame->ClearSelection(); - EXPECT_FALSE(frame->HasSelection()); - std::string selection_html = frame->GetSelection(true); - EXPECT_TRUE(selection_html.empty()); - + EXPECT_FALSE(frame->hasSelection()); + frame->selectAll(); + EXPECT_TRUE(frame->hasSelection()); + frame->clearSelection(); + EXPECT_FALSE(frame->hasSelection()); + WebString selection_html = frame->selectionAsMarkup(); + EXPECT_TRUE(selection_html.isEmpty()); } - diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 7455107..9f941b13 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -44,6 +44,7 @@ #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webdevtoolsagent_impl.h" +#include "webkit/glue/webframe_impl.h" #include "webkit/glue/webframeloaderclient_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin_delegate.h" @@ -488,7 +489,7 @@ void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview ? webview->delegate() : NULL; if (d) { - expected_client_redirect_src_ = webframe_->GetURL(); + expected_client_redirect_src_ = webframe_->url(); expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url); // TODO(timsteele): bug 1135512. Webkit does not properly notify us of @@ -1253,7 +1254,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, // TO #if defined(OS_WIN) std::string clsid, version; if (activex_shim::IsMimeTypeActiveX(my_mime_type)) { - GURL url = webframe_->GetURL(); + GURL url = webframe_->url(); for (unsigned int i = 0; i < param_names.size(); i++) { String lowercase_param_name = param_names[i].lower(); if (lowercase_param_name == "classid") { diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index 2c8d032..d8b5cf6 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -49,6 +49,7 @@ #include "webkit_version.h" // Generated +using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebString; using WebKit::WebVector; @@ -90,10 +91,10 @@ std::wstring DumpFramesAsText(WebFrame* web_frame, bool recursive) { std::wstring result; // Add header for all but the main frame. Skip empty frames. - if (webFrameImpl->GetParent() && + if (webFrameImpl->parent() && webFrameImpl->frame()->document()->documentElement()) { result.append(L"\n--------\nFrame: '"); - result.append(webFrameImpl->GetName()); + result.append(UTF16ToWideHack(webFrameImpl->name())); result.append(L"'\n--------\n"); } @@ -126,7 +127,7 @@ std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive) { std::wstring result; if (offset.width() > 0 || offset.height() > 0) { - if (webFrameImpl->GetParent()) { + if (webFrameImpl->parent()) { StringAppendF(&result, L"frame '%ls' ", StringToStdWString( webFrameImpl->frame()->tree()->name()).c_str()); } diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 2276038..998fbce 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -22,10 +22,10 @@ class GURL; class SkBitmap; class StringPiece; class WebView; -class WebFrame; struct WebPluginInfo; namespace WebKit { +class WebFrame; class WebString; } @@ -40,18 +40,18 @@ void SetJavaScriptFlags(const std::wstring& flags); void EnableWebCoreNotImplementedLogging(); // Returns the text of the document element. -std::wstring DumpDocumentText(WebFrame* web_frame); +std::wstring DumpDocumentText(WebKit::WebFrame* web_frame); // Returns the text of the document element and optionally its child frames. // If recursive is false, this is equivalent to DumpDocumentText followed by // a newline. If recursive is true, it recursively dumps all frames as text. -std::wstring DumpFramesAsText(WebFrame* web_frame, bool recursive); +std::wstring DumpFramesAsText(WebKit::WebFrame* web_frame, bool recursive); // Returns the renderer's description of its tree (its externalRepresentation). -std::wstring DumpRenderer(WebFrame* web_frame); +std::wstring DumpRenderer(WebKit::WebFrame* web_frame); // Returns a dump of the scroll position of the webframe. -std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive); +std::wstring DumpFrameScrollPosition(WebKit::WebFrame* web_frame, bool recursive); // Returns a dump of the given history state suitable for implementing the // dumpBackForwardList command of the layoutTestController. diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index 074549a..d5f0cf6 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -18,7 +18,6 @@ typedef void* HANDLE; class GURL; -class WebFrame; class WebPluginResourceClient; struct NPObject; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index a04be97..b4e78d0 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -639,9 +639,10 @@ std::string WebPluginImpl::GetCookies(const GURL& url, const GURL& policy_url) { void WebPluginImpl::ShowModalHTMLDialog(const GURL& url, int width, int height, const std::string& json_arguments, std::string* json_retval) { - if (webframe_ && webframe_->GetView() && - webframe_->GetView()->GetDelegate()) { - webframe_->GetView()->GetDelegate()->ShowModalHTMLDialog( + if (webframe_ && + webframe_->GetWebViewImpl() && + webframe_->GetWebViewImpl()->GetDelegate()) { + webframe_->GetWebViewImpl()->GetDelegate()->ShowModalHTMLDialog( url, width, height, json_arguments, json_retval); } } @@ -1071,7 +1072,7 @@ void WebPluginImpl::didFinishLoading(WebURLLoader* loader) { delete (*index).second; multi_part_response_map_.erase(index); - WebView* web_view = webframe_->GetView(); + WebView* web_view = webframe_->GetWebViewImpl(); web_view->GetDelegate()->DidStopLoading(web_view); } loader->setDefersLoading(true); @@ -1333,7 +1334,7 @@ void WebPluginImpl::HandleHttpMultipartResponse( return; } - WebView* web_view = webframe_->GetView(); + WebView* web_view = webframe_->GetWebViewImpl(); web_view->GetDelegate()->DidStartLoading(web_view); MultiPartResponseClient* multi_part_response_client = diff --git a/webkit/glue/webtextinput.h b/webkit/glue/webtextinput.h deleted file mode 100644 index 2e69874..0000000 --- a/webkit/glue/webtextinput.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 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_WEBTEXTINPUT_H_ -#define WEBKIT_GLUE_WEBTEXTINPUT_H_ - -#include <string> -#include "base/basictypes.h" -#include "base/string16.h" - -class WebTextInput { - public: - WebTextInput() {} - virtual ~WebTextInput() {} - - // Inserts text to the associated frame. - virtual void InsertText(const string16& text) = 0; - - // Executes the given editing command on the frame. - virtual void DoCommand(const string16& command) = 0; - - // Sets marked text region on the frame. - virtual void SetMarkedText(const string16& text, - int32_t location, int32_t length) = 0; - - // Clears the marked text region on the frame. - virtual void UnMarkText() = 0; - - // Returns true if there are marked texts on the frame, returns false - // otherwise. - virtual bool HasMarkedText() = 0; - - // Writes the textual representation of the marked range on the frame to - // range_str. - virtual void MarkedRange(std::string* range_str) = 0; - - // Writes the textual representation of the selected range on the frame to - // range_str. - virtual void SelectedRange(std::string* range_str) = 0; - - // Writes the textual representation of the attributes of marked text range - // on the frame to attributes. - virtual void ValidAttributesForMarkedText(std::string* attributes) = 0; - - virtual void ConversationIdentifier() = 0; - virtual void SubstringFromRange(int32_t location, int32_t length) = 0; - virtual void AttributedSubstringFromRange(int32_t location, - int32_t length) = 0; - virtual void FirstRectForCharacterRange(int32_t location, - int32_t length) = 0; - virtual void CharacterIndexForPoint(double x, double y) = 0; - virtual void MakeAttributedString(const std::string& str) = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(WebTextInput); -}; - -#endif // #ifndef WEBKIT_GLUE_WEBTEXTINPUT_H_ diff --git a/webkit/glue/webtextinput_impl.cc b/webkit/glue/webtextinput_impl.cc deleted file mode 100644 index 84dcb9b..0000000 --- a/webkit/glue/webtextinput_impl.cc +++ /dev/null @@ -1,157 +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. - -#include <ctype.h> -#include "config.h" - -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); -#include "Frame.h" -#include "Editor.h" -MSVC_POP_WARNING(); - -#undef LOG - -#include "base/string16.h" -#include "base/string_util.h" -#include "webkit/glue/glue_util.h" -#include "webkit/glue/webframe_impl.h" -#include "webkit/glue/webtextinput_impl.h" - -WebTextInputImpl::WebTextInputImpl(WebFrameImpl* web_frame_impl) - : WebTextInput(), - web_frame_impl_(web_frame_impl) { -} - -WebTextInputImpl::~WebTextInputImpl() { -} - -WebCore::Frame* WebTextInputImpl::GetFrame() { - return web_frame_impl_->frame(); -} - -WebCore::Editor* WebTextInputImpl::GetEditor() { - return web_frame_impl_->frame()->editor(); -} - -void WebTextInputImpl::InsertText(const string16& text) { - WebCore::String str = webkit_glue::String16ToString(text); - GetEditor()->insertText(str, NULL); -} - -void WebTextInputImpl::DoCommand(const string16& com) { - if (com.length() <= 2) - return; - - // Since we don't have NSControl, we will convert the format of command - // string and call the function on Editor directly. - string16 command = com; - - // Make sure the first letter is upper case. - command.replace(0, 1, 1, toupper(command.at(0))); - - // Remove the trailing ':' if existing. - if (command.at(command.length() - 1) == ':') - command.erase(command.length() - 1, 1); - - // Specially handling commands that Editor::execCommand does not directly - // support. - if (EqualsASCII(command, "DeleteToEndOfParagraph")) { - DeleteToEndOfParagraph(); - } else if(EqualsASCII(command, "Indent")) { - GetEditor()->indent(); - } else if(EqualsASCII(command, "Outdent")) { - GetEditor()->outdent(); - } else if(EqualsASCII(command, "DeleteBackward")) { - WebCore::AtomicString editor_command("BackwardDelete"); - GetEditor()->command(editor_command).execute(); - } else if(EqualsASCII(command, "DeleteForward")) { - WebCore::AtomicString editor_command("ForwardDelete"); - GetEditor()->command(editor_command).execute(); - } else { - WebCore::AtomicString editor_command(command.c_str()); - GetEditor()->command(editor_command).execute(); - } - - return; -} - -void WebTextInputImpl::SetMarkedText(const string16& text, - int32_t location, - int32_t length) { - WebCore::Editor* editor = GetEditor(); - WebCore::String str = webkit_glue::String16ToString(text); - - editor->confirmComposition(str); - - WTF::Vector<WebCore::CompositionUnderline> decorations; - - editor->setComposition(str, decorations, location, length); -} - -void WebTextInputImpl::UnMarkText() { - GetEditor()->confirmCompositionWithoutDisturbingSelection();; -} - -bool WebTextInputImpl::HasMarkedText() { - return GetEditor()->hasComposition(); -} - -void WebTextInputImpl::ConversationIdentifier() { -} - -void WebTextInputImpl::SubstringFromRange(int32_t location, int32_t length) { -} - -void WebTextInputImpl::AttributedSubstringFromRange(int32_t location, - int32_t length) { -} - -void WebTextInputImpl::MarkedRange(std::string* range_str) { - RefPtr<WebCore::Range> range = GetEditor()->compositionRange(); - - // Range::toString() returns a string different from what test expects. - // So we need to construct the string ourselves. - SStringPrintf(range_str, "%d,%d", range->startPosition().deprecatedEditingOffset(), - range->endPosition().deprecatedEditingOffset()); -} - -void WebTextInputImpl::SelectedRange(std::string* range_str) { - WTF::RefPtr<WebCore::Range> range - = GetFrame()->selection()->toNormalizedRange(); - - // Range::toString() returns a string different from what test expects. - // So we need to construct the string ourselves. - SStringPrintf(range_str, "%d,%d", range.get()->startPosition().deprecatedEditingOffset(), - range.get()->endPosition().deprecatedEditingOffset()); -} - -void WebTextInputImpl::FirstRectForCharacterRange(int32_t location, - int32_t length) { -} - -void WebTextInputImpl::CharacterIndexForPoint(double x, double y) { -} - -void WebTextInputImpl::ValidAttributesForMarkedText(std::string* attributes) { - // We simply return a string with relevant keywords. - attributes->assign("NSUnderline,NSUnderlineColor,NSMarkedClauseSegment,NSTextInputReplacementRangeAttributeName"); -} - -void WebTextInputImpl::MakeAttributedString(const std::string& str) { -} - -void WebTextInputImpl::DeleteToEndOfParagraph() { - WebCore::Editor* editor = GetEditor(); - if (!editor->deleteWithDirection(WebCore::SelectionController::FORWARD, - WebCore::ParagraphBoundary, - true, - false)) { - editor->deleteWithDirection(WebCore::SelectionController::FORWARD, - WebCore::CharacterGranularity, - true, - false); - } -} diff --git a/webkit/glue/webtextinput_impl.h b/webkit/glue/webtextinput_impl.h deleted file mode 100644 index 8344f7e..0000000 --- a/webkit/glue/webtextinput_impl.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 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. -// -// Class WebTextInputImpl provides implementation of WebTextInput which is -// used by TextInputController in test_shell. It only facilitates layout tests -// and should not be used by renderers. - -#ifndef WEBKIT_GLUE_WEBTEXTINPUT_IMPL_H_ -#define WEBKIT_GLUE_WEBTEXTINPUT_IMPL_H_ - -#include "webkit/glue/webtextinput.h" - -class WebFrameImpl; - -class WebTextInputImpl : public WebTextInput { - public: - WebTextInputImpl(WebFrameImpl* web_frame_impl); - virtual ~WebTextInputImpl(); - - // WebTextInput methods - virtual void InsertText(const string16& text); - virtual void DoCommand(const string16& command); - virtual void SetMarkedText(const string16& text, - int32_t location, int32_t length); - virtual void UnMarkText(); - virtual bool HasMarkedText(); - virtual void MarkedRange(std::string* range_str); - virtual void SelectedRange(std::string* range_str); - virtual void ValidAttributesForMarkedText(std::string* attributes); - - // TODO(huanr): examine all layout tests involving TextInputController - // and implement these functions if necessary. - virtual void ConversationIdentifier(); - virtual void SubstringFromRange(int32_t location, int32_t length); - virtual void AttributedSubstringFromRange(int32_t location, - int32_t length); - virtual void FirstRectForCharacterRange(int32_t location, - int32_t length); - virtual void CharacterIndexForPoint(double x, double y); - virtual void MakeAttributedString(const std::string& str); - - private: - WebCore::Frame* GetFrame(); - WebCore::Editor* GetEditor(); - - void DeleteToEndOfParagraph(); - - // Holding a non-owning pointer to the web frame we are associated with. - WebFrameImpl* web_frame_impl_; - - DISALLOW_COPY_AND_ASSIGN(WebTextInputImpl); -}; - -#endif // #ifndef WEBKIT_GLUE_WEBTEXTINPUT_IMPL_H_ diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index 08bec75..6e2c794 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -13,6 +13,7 @@ namespace WebKit { class WebDragData; +class WebFrame; class WebSettings; struct WebPoint; } @@ -21,7 +22,6 @@ struct MediaPlayerAction; struct WebPreferences; class GURL; class WebDevToolsAgent; -class WebFrame; class WebViewDelegate; // @@ -99,24 +99,24 @@ class WebView : public WebKit::WebWidget { // mainFrame. // @result The main frame. // - (WebFrame *)mainFrame; - virtual WebFrame* GetMainFrame() = 0; + virtual WebKit::WebFrame* GetMainFrame() = 0; // Returns the currently focused frame. - virtual WebFrame* GetFocusedFrame() = 0; + virtual WebKit::WebFrame* GetFocusedFrame() = 0; // Sets focus to the frame passed in. - virtual void SetFocusedFrame(WebFrame* frame) = 0; + virtual void SetFocusedFrame(WebKit::WebFrame* frame) = 0; // Returns the frame with the given name, or NULL if not found. - virtual WebFrame* GetFrameWithName(const std::wstring& name) = 0; + virtual WebKit::WebFrame* GetFrameWithName(const std::wstring& name) = 0; // Returns the frame previous to the specified frame, by traversing the frame // tree, wrapping around if necessary. - virtual WebFrame* GetPreviousFrameBefore(WebFrame* frame, bool wrap) = 0; + virtual WebKit::WebFrame* GetPreviousFrameBefore(WebKit::WebFrame* frame, bool wrap) = 0; // Returns the frame after to the specified frame, by traversing the frame // tree, wrapping around if necessary. - virtual WebFrame* GetNextFrameAfter(WebFrame* frame, bool wrap) = 0; + virtual WebKit::WebFrame* GetNextFrameAfter(WebKit::WebFrame* frame, bool wrap) = 0; // ---- TODO(darin): remove from here ---- diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 593bfea..7d421af 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -29,12 +29,12 @@ #include <vector> #include "base/gfx/native_widget_types.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebNavigationPolicy.h" #include "webkit/api/public/WebNavigationType.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/api/public/WebWidgetClient.h" #include "webkit/glue/context_menu.h" -#include "webkit/glue/webframe.h" namespace webkit_glue { class WebMediaPlayerDelegate; @@ -65,7 +65,6 @@ struct WebURLError; class FilePath; class SkBitmap; class WebDevToolsAgentDelegate; -class WebFrame; class WebMediaPlayerDelegate; class WebPluginDelegate; class WebView; @@ -233,27 +232,27 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // implementation binds native objects to the window via the webframe instead. // TODO(pamg): If we do implement WebScriptObject, we may wish to switch to // using the original version of this function. - virtual void WindowObjectCleared(WebFrame* webframe) { + virtual void WindowObjectCleared(WebKit::WebFrame* webframe) { } // Notifies that the documentElement for the document in a webframe has been // created. This is called before anything else is parsed or executed for the // document. - virtual void DocumentElementAvailable(WebFrame* webframe) { + virtual void DocumentElementAvailable(WebKit::WebFrame* webframe) { } // Notifies that a new script context has been created for this frame. // This is similar to WindowObjectCleared but only called once per frame // context. - virtual void DidCreateScriptContextForFrame(WebFrame* webframe) { + virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe) { } // Notifies that this frame's script context has been destroyed. - virtual void DidDestroyScriptContextForFrame(WebFrame* webframe) { + virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe) { } // Notifies that a garbage-collected context was created - content scripts. - virtual void DidCreateIsolatedScriptContext(WebFrame* webframe) { + virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe) { } // PolicyDelegate ---------------------------------------------------------- @@ -270,7 +269,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // is_redirect is true if this is a redirect rather than user action. virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, WebKit::WebNavigationPolicy default_policy, @@ -282,7 +281,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // A datasource has been created for a new navigation. The given datasource // will become the provisional datasource for the frame. - virtual void DidCreateDataSource(WebFrame* frame, + virtual void DidCreateDataSource(WebKit::WebFrame* frame, WebKit::WebDataSource* ds) { } @@ -294,7 +293,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // an empty invalid GURL in other cases. virtual void DidStartProvisionalLoadForFrame( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, NavigationGesture gesture) { } @@ -308,7 +307,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // same as the provisional data source's current URL), and the next-to-last // element will be the referring URL. virtual void DidReceiveProvisionalLoadServerRedirect(WebView* webview, - WebFrame* frame) { + WebKit::WebFrame* frame) { } // @method webView:didFailProvisionalLoadWithError:forFrame: @@ -322,17 +321,17 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // This notification is only received for errors like network errors. virtual void DidFailProvisionalLoadWithError(WebView* webview, const WebKit::WebURLError& error, - WebFrame* frame) { + WebKit::WebFrame* frame) { } // Notifies the delegate to commit data for the given frame. The delegate // may optionally convert the data before calling CommitDocumentData or // suppress a call to CommitDocumentData. For example, if CommitDocumentData // is never called, then an empty document will be created. - virtual void DidReceiveDocumentData(WebFrame* frame, + virtual void DidReceiveDocumentData(WebKit::WebFrame* frame, const char* data, size_t data_len) { - frame->CommitDocumentData(data, data_len); + frame->commitDocumentData(data, data_len); } // Notifies the delegate that the load has changed from provisional to @@ -348,7 +347,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // The "is_new_navigation" flag will be true when a new session history entry // was created for the load. The frame's GetHistoryState method can be used // to get the corresponding session history state. - virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, + virtual void DidCommitLoadForFrame(WebView* webview, WebKit::WebFrame* frame, bool is_new_navigation) { } @@ -362,7 +361,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame; virtual void DidReceiveTitle(WebView* webview, const std::wstring& title, - WebFrame* frame) { + WebKit::WebFrame* frame) { } // @@ -375,7 +374,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Plug-In content and JavaScript-requested loads may occur after this method is called. // - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame; virtual void DidFinishLoadForFrame(WebView* webview, - WebFrame* frame) { + WebKit::WebFrame* frame) { } // @@ -388,14 +387,14 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; virtual void DidFailLoadWithError(WebView* webview, const WebKit::WebURLError& error, - WebFrame* forFrame) { + WebKit::WebFrame* forFrame) { } // Notifies the delegate of a DOMContentLoaded event. // This is called when the html resource has been loaded, but // not necessarily all subresources (images, stylesheets). So, this is called // before DidFinishLoadForFrame. - virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebFrame* frame) { + virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebKit::WebFrame* frame) { } // This method is called when we load a resource from an in-memory cache. @@ -405,23 +404,23 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { WebView* webview, const WebKit::WebURLRequest& request, const WebKit::WebURLResponse& response, - WebFrame* frame) { + WebKit::WebFrame* frame) { return false; } // This is called after javascript onload handlers have been fired. - virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebFrame* frame) { + virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebKit::WebFrame* frame) { } // This method is called when anchors within a page have been clicked. // It is very similar to DidCommitLoadForFrame. virtual void DidChangeLocationWithinPageForFrame(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, bool is_new_navigation) { } // This is called when the favicon for a frame has been received. - virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame) { + virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame) { } // Notifies the delegate that a frame will start a client-side redirect. When @@ -437,7 +436,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // client-side redirect is pending. Watch out: WebKit seems to call us twice // for client redirects, resulting in two calls of this function. virtual void WillPerformClientRedirect(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const GURL& src_url, const GURL& dest_url, unsigned int delay_seconds, @@ -455,7 +454,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // // See the implementation of FrameLoader::clientRedirectCancelledOrFinished. virtual void DidCancelClientRedirect(WebView* webview, - WebFrame* frame) { + WebKit::WebFrame* frame) { } // Notifies the delegate that the load about to be committed for the specified @@ -463,12 +462,12 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // The information/notification obtained from this method is relevant until // the next provisional load is started, at which point it becomes obsolete. virtual void DidCompleteClientRedirect(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const GURL& source) { } // Notifies the delegate that a form is about to be submitted. - virtual void WillSubmitForm(WebView* webview, WebFrame* frame, + virtual void WillSubmitForm(WebView* webview, WebKit::WebFrame* frame, const WebKit::WebForm& form) { } @@ -480,7 +479,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // @discussion This method is called right before WebKit is done with the frame // and the objects that it contains. // - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame; - virtual void WillCloseFrame(WebView* webview, WebFrame* frame) { + virtual void WillCloseFrame(WebView* webview, WebKit::WebFrame* frame) { } // ResourceLoadDelegate ---------------------------------------------------- @@ -489,7 +488,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Resource load callbacks will use the identifier throughout the life of the // request. virtual void AssignIdentifierToRequest( - WebFrame* webframe, + WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLRequest& request) { } @@ -500,23 +499,23 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // made. If this request is the result of a redirect, then redirect_response // will be non-null and contain the response that triggered the redirect. virtual void WillSendRequest( - WebFrame* webframe, + WebKit::WebFrame* webframe, uint32 identifier, WebKit::WebURLRequest* request, const WebKit::WebURLResponse& redirect_response) { } - virtual void DidReceiveResponse(WebFrame* webframe, + virtual void DidReceiveResponse(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLResponse& response) { } // Notifies the delegate that a subresource load has succeeded. - virtual void DidFinishLoading(WebFrame* webframe, uint32 identifier) { + virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier) { } // Notifies the delegate that a subresource load has failed, and why. - virtual void DidFailLoadingWithError(WebFrame* webframe, + virtual void DidFailLoadingWithError(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLError& error) { } @@ -564,7 +563,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // should visually indicate that this panel comes from JavaScript and some // information about the originating frame (at least the domain). The panel // should have a single OK button. - virtual void RunJavaScriptAlert(WebFrame* webframe, + virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, const std::wstring& message) { } @@ -572,7 +571,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Clients should visually indicate that this panel comes // from JavaScript. The panel should have two buttons, e.g. "OK" and // "Cancel". Returns true if the user hit OK, or false if the user hit Cancel. - virtual bool RunJavaScriptConfirm(WebFrame* webframe, + virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, const std::wstring& message) { return false; } @@ -584,7 +583,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // panel when it is shown. If the user hit OK, returns true and fills result // with the text in the box. The value of result is undefined if the user // hit Cancel. - virtual bool RunJavaScriptPrompt(WebFrame* webframe, + virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, const std::wstring& message, const std::wstring& default_value, std::wstring* result) { @@ -600,7 +599,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // that the navigation should continue, and Cancel means that the navigation // should be cancelled, leaving the user on the current page. Returns true // if the user hit OK, or false if the user hit Cancel. - virtual bool RunBeforeUnloadConfirm(WebFrame* webframe, + virtual bool RunBeforeUnloadConfirm(WebKit::WebFrame* webframe, const std::wstring& message) { return true; // OK, continue to navigate away } @@ -840,7 +839,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Asks the user to print the page or a specific frame. Called in response to // a window.print() call. - virtual void ScriptedPrint(WebFrame* frame) { } + virtual void ScriptedPrint(WebKit::WebFrame* frame) { } // Called when an item was added to the history virtual void DidAddHistoryItem() { } diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index f18c6b97..03fde26 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -100,6 +100,7 @@ using WebKit::WebCompositionCommand; using WebKit::WebCompositionCommandConfirm; using WebKit::WebCompositionCommandDiscard; using WebKit::WebDragData; +using WebKit::WebFrame; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; @@ -815,11 +816,11 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { if (event.modifiers == WebInputEvent::ControlKey) { switch (event.windowsKeyCode) { case 'A': - GetFocusedFrame()->SelectAll(); + GetFocusedFrame()->selectAll(); return true; case VKEY_INSERT: case 'C': - GetFocusedFrame()->Copy(); + GetFocusedFrame()->executeCommand(WebString::fromUTF8("Copy")); return true; // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl // key combinations which affect scrolling. Safari is buggy in the @@ -1294,7 +1295,7 @@ WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { // TODO(darin): these navigation methods should be killed void WebViewImpl::StopLoading() { - main_frame()->StopLoading(); + main_frame()->stopLoading(); } void WebViewImpl::SetBackForwardListSize(int size) { diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 5d6becb..f2ea84b 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -15,7 +15,6 @@ #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebSize.h" #include "webkit/glue/back_forward_list_client_impl.h" -#include "webkit/glue/image_resource_fetcher.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" @@ -41,6 +40,10 @@ class WebMouseWheelEvent; class WebSettingsImpl; } +namespace webkit_glue { +class ImageResourceFetcher; +} + class AutocompletePopupMenuClient; class SearchableFormData; class WebHistoryItemImpl; @@ -76,12 +79,12 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual void SetDelegate(WebViewDelegate*); virtual void SetUseEditorDelegate(bool value); virtual void SetTabKeyCyclesThroughElements(bool value); - virtual WebFrame* GetMainFrame(); - virtual WebFrame* GetFocusedFrame(); - virtual void SetFocusedFrame(WebFrame* frame); - virtual WebFrame* GetFrameWithName(const std::wstring& name); - virtual WebFrame* GetPreviousFrameBefore(WebFrame* frame, bool wrap); - virtual WebFrame* GetNextFrameAfter(WebFrame* frame, bool wrap); + virtual WebKit::WebFrame* GetMainFrame(); + virtual WebKit::WebFrame* GetFocusedFrame(); + virtual void SetFocusedFrame(WebKit::WebFrame* frame); + virtual WebKit::WebFrame* GetFrameWithName(const std::wstring& name); + virtual WebKit::WebFrame* GetPreviousFrameBefore(WebKit::WebFrame* frame, bool wrap); + virtual WebKit::WebFrame* GetNextFrameAfter(WebKit::WebFrame* frame, bool wrap); virtual void ClearFocusedNode(); virtual void StopLoading(); virtual void SetBackForwardListSize(int size); diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc index af1c652..da8a273 100644 --- a/webkit/glue/webworker_impl.cc +++ b/webkit/glue/webworker_impl.cc @@ -36,6 +36,7 @@ #include "webkit/glue/webworker_impl.h" using WebKit::WebCursorInfo; +using WebKit::WebFrame; using WebKit::WebMessagePortChannel; using WebKit::WebNavigationPolicy; using WebKit::WebRect; diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index f3754ce..f80262b 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -14,9 +14,9 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/string_util.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebScriptSource.h" #include "webkit/glue/dom_operations.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_navigation_controller.h" @@ -329,7 +329,7 @@ class WorkItemLoadingScript : public LayoutTestController::WorkItem { public: WorkItemLoadingScript(const string& script) : script_(script) {} bool Run(TestShell* shell) { - shell->webView()->GetMainFrame()->ExecuteScript( + shell->webView()->GetMainFrame()->executeScript( WebScriptSource(WebString::fromUTF8(script_))); return true; // TODO(darin): Did it really start a navigation? } @@ -341,7 +341,7 @@ class WorkItemNonLoadingScript : public LayoutTestController::WorkItem { public: WorkItemNonLoadingScript(const string& script) : script_(script) {} bool Run(TestShell* shell) { - shell->webView()->GetMainFrame()->ExecuteScript( + shell->webView()->GetMainFrame()->executeScript( WebScriptSource(WebString::fromUTF8(script_))); return false; } @@ -380,7 +380,7 @@ class WorkItemLoad : public LayoutTestController::WorkItem { void LayoutTestController::queueLoad( const CppArgumentList& args, CppVariant* result) { if (args.size() > 0 && args[0].isString()) { - GURL current_url = shell_->webView()->GetMainFrame()->GetURL(); + GURL current_url = shell_->webView()->GetMainFrame()->url(); GURL full_url = current_url.Resolve(args[0].ToString()); string target = ""; @@ -532,8 +532,8 @@ void LayoutTestController::execCommand( value = args[2].ToString(); // Note: webkit's version does not return the boolean, so neither do we. - shell_->webView()->GetFocusedFrame()->ExecuteEditCommandByName(command, - value); + shell_->webView()->GetFocusedFrame()->executeCommand( + WebString::fromUTF8(command), WebString::fromUTF8(value)); } result->SetNull(); } @@ -546,7 +546,8 @@ void LayoutTestController::isCommandEnabled( } std::string command = args[0].ToString(); - bool rv = shell_->webView()->GetFocusedFrame()->IsEditCommandEnabled(command); + bool rv = shell_->webView()->GetFocusedFrame()->isCommandEnabled( + WebString::fromUTF8(command)); result->Set(rv); } @@ -802,7 +803,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld( const CppArgumentList& args, CppVariant* result) { if (args.size() > 0 && args[0].isString()) { WebScriptSource source(WebString::fromUTF8(args[0].ToString())); - shell_->webView()->GetMainFrame()->ExecuteScriptInNewWorld(&source, 1, 1); + shell_->webView()->GetMainFrame()->executeScriptInNewWorld(&source, 1, 1); } result->SetNull(); } diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc index 0d8d8d0..729bc33 100644 --- a/webkit/tools/test_shell/plugin_tests.cc +++ b/webkit/tools/test_shell/plugin_tests.cc @@ -11,13 +11,14 @@ #include "net/base/escape.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebScriptSource.h" -#include "webkit/glue/webframe.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::WebFrame; using WebKit::WebScriptSource; using WebKit::WebString; @@ -97,23 +98,23 @@ TEST_F(PluginTest, Refresh) { // test plugin from a previous test. DeleteTestPlugin(); ASSERT_FALSE(file_util::PathExists(plugin_file_path_)); - test_shell_->webView()->GetMainFrame()->ExecuteScript(refresh); + test_shell_->webView()->GetMainFrame()->executeScript(refresh); - test_shell_->webView()->GetMainFrame()->LoadHTMLString( + test_shell_->webView()->GetMainFrame()->loadHTMLString( html, GURL("about:blank")); test_shell_->WaitTestFinished(); - std::wstring text; - test_shell_->webView()->GetMainFrame()->ExecuteScript(call_check); - test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); - ASSERT_EQ(text, L"FAIL"); + std::string text; + test_shell_->webView()->GetMainFrame()->executeScript(call_check); + text = test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8(); + ASSERT_EQ(text, "FAIL"); CopyTestPlugin(); - test_shell_->webView()->GetMainFrame()->ExecuteScript(refresh); - test_shell_->webView()->GetMainFrame()->ExecuteScript(call_check); - test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); - ASSERT_EQ(text, L"DONE"); + test_shell_->webView()->GetMainFrame()->executeScript(refresh); + test_shell_->webView()->GetMainFrame()->executeScript(call_check); + text = test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8(); + ASSERT_EQ(text, "DONE"); } #if defined(OS_WIN) @@ -136,14 +137,13 @@ TEST_F(PluginTest, DefaultPluginLoadTest) { </DIV>\ "; - test_shell_->webView()->GetMainFrame()->LoadHTMLString( + test_shell_->webView()->GetMainFrame()->loadHTMLString( html, GURL("about:blank")); test_shell_->WaitTestFinished(); - std::wstring text; - test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); - - ASSERT_EQ(true, StartsWith(text, L"DONE", true)); + std::string text = + test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8(); + ASSERT_EQ(true, StartsWithASCII(text, "DONE", true)); } #endif @@ -194,13 +194,13 @@ TEST_F(PluginTest, PluginVisibilty) { ASSERT_TRUE(plugin_hwnd != NULL); ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); - main_frame->ExecuteScript(WebString::fromUTF8("showPlugin(true)")); + main_frame->executeScript(WebString::fromUTF8("showPlugin(true)")); ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); - main_frame->ExecuteScript(WebString::fromUTF8("showFrame(false)")); + main_frame->executeScript(WebString::fromUTF8("showFrame(false)")); ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); - main_frame->ExecuteScript(WebString::fromUTF8("showFrame(true)")); + main_frame->executeScript(WebString::fromUTF8("showFrame(true)")); ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); } #endif diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 3f9fcde..1d296bf 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -31,15 +31,15 @@ #include "skia/ext/bitmap_platform_device.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" -#include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" +#include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/public/WebURLResponse.h" #include "webkit/glue/glue_serialize.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" @@ -47,6 +47,7 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_switches.h" +using WebKit::WebFrame; using WebKit::WebNavigationPolicy; using WebKit::WebRect; using WebKit::WebSize; @@ -201,7 +202,7 @@ void TestShell::Dump(TestShell* shell) { if (!should_dump_as_text) { // Plain text pages should be dumped as text const string16& mime_type = - frame->GetDataSource()->response().mimeType(); + frame->dataSource()->response().mimeType(); should_dump_as_text = EqualsASCII(mime_type, "text/plain"); } if (should_dump_as_text) { @@ -474,7 +475,7 @@ void TestShell::DumpBackForwardList(std::wstring* result) { } void TestShell::CallJSGC() { - webView()->GetMainFrame()->CallJSGC(); + webView()->GetMainFrame()->collectGarbage(); } WebView* TestShell::CreateWebView(WebView* webview) { @@ -530,14 +531,14 @@ bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { // If we are reloading, then WebKit will use the state of the current page. // Otherwise, we give it the state to navigate to. if (reload) { - frame->Reload(); + frame->reload(); } else if (!entry.GetContentState().empty()) { DCHECK(entry.GetPageID() != -1); - frame->LoadHistoryItem( + frame->loadHistoryItem( webkit_glue::HistoryItemFromString(entry.GetContentState())); } else { DCHECK(entry.GetPageID() == -1); - frame->LoadRequest(WebURLRequest(entry.GetURL())); + frame->loadRequest(WebURLRequest(entry.GetURL())); } // In case LoadRequest failed before DidCreateDataSource was called. diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 8c92ca3..1c18e4f 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -188,7 +188,7 @@ public: // Called by the WebView delegate WindowObjectCleared() method, this // binds the layout_test_controller_ and other C++ controller classes to // window JavaScript objects so they can be accessed by layout tests. - virtual void BindJSObjectsToWindow(WebFrame* frame); + virtual void BindJSObjectsToWindow(WebKit::WebFrame* frame); // Runs a layout test. Loads a single file (specified in params.test_url) // into the first available window, then dumps the requested text diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index efa884a..27aafcd 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -25,7 +25,6 @@ #include "net/base/net_util.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index aa34720..dff44c9 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -29,7 +29,6 @@ #include "net/base/mime_util.h" #include "skia/ext/bitmap_platform_device.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 9c22f8d..30b38dc 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -27,7 +27,7 @@ #include "net/base/net_module.h" #include "net/url_request/url_request_file_job.h" #include "skia/ext/bitmap_platform_device.h" -#include "webkit/glue/webframe.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 5280c06..e665c84 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -22,6 +22,7 @@ #include "webkit/api/public/WebDataSource.h" #include "webkit/api/public/WebDragData.h" #include "webkit/api/public/WebHistoryItem.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebString.h" @@ -35,7 +36,6 @@ #include "webkit/glue/media/simple_data_source.h" #include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" @@ -56,6 +56,7 @@ using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; +using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebNavigationType; using WebKit::WebNavigationPolicy; @@ -240,7 +241,6 @@ WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction( bool is_redirect) { WebNavigationPolicy result; if (policy_delegate_enabled_) { - std::wstring frame_name = frame->GetName(); printf("Policy delegate: attempt to load %s with navigation type '%s'\n", GetURLDescription(request.url()).c_str(), WebNavigationTypeToString(type)); @@ -371,7 +371,7 @@ void TestWebViewDelegate::DidStartProvisionalLoadForFrame( if (shell_->layout_test_controller()->StopProvisionalFrameLoads()) { printf("%S - stopping load in didStartProvisionalLoadForFrame callback\n", GetFrameDescription(frame).c_str()); - frame->StopLoading(); + frame->stopLoading(); } UpdateAddressBar(webview); } @@ -408,7 +408,7 @@ void TestWebViewDelegate::DidFailProvisionalLoadWithError( if (error.reason == net::ERR_ABORTED) return; - const WebDataSource* failed_ds = frame->GetProvisionalDataSource(); + const WebDataSource* failed_ds = frame->provisionalDataSource(); TestShellExtraData* extra_data = static_cast<TestShellExtraData*>(failed_ds->extraData()); @@ -419,9 +419,9 @@ void TestWebViewDelegate::DidFailProvisionalLoadWithError( failed_ds->request().url().spec().data()); // Make sure we never show errors in view source mode. - frame->SetInViewSourceMode(false); + frame->enableViewSourceMode(false); - frame->LoadHTMLString( + frame->loadHTMLString( error_text, GURL("testshell-error:"), error.unreachableURL, replace); } @@ -453,7 +453,7 @@ void TestWebViewDelegate::DidReceiveTitle(WebView* webview, void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { - TRACE_EVENT_END("frame.load", this, frame->GetURL().spec()); + TRACE_EVENT_END("frame.load", this, frame->url().spec()); if (shell_->ShouldDumpFrameLoadCallbacks()) { printf("%S - didFinishLoadForFrame\n", GetFrameDescription(frame).c_str()); @@ -480,7 +480,7 @@ void TestWebViewDelegate::DidFinishDocumentLoadForFrame(WebView* webview, printf("%S - didFinishDocumentLoadForFrame\n", GetFrameDescription(frame).c_str()); } else { - unsigned pending_unload_events = frame->PendingFrameUnloadEventCount(); + unsigned pending_unload_events = frame->unloadListenerCount(); if (pending_unload_events) { printf("%S - has %u onunload handler(s)\n", GetFrameDescription(frame).c_str(), pending_unload_events); @@ -498,7 +498,7 @@ void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview, void TestWebViewDelegate::DidChangeLocationWithinPageForFrame( WebView* webview, WebFrame* frame, bool is_new_navigation) { - frame->GetDataSource()->setExtraData(pending_extra_data_.release()); + frame->dataSource()->setExtraData(pending_extra_data_.release()); if (shell_->ShouldDumpFrameLoadCallbacks()) { printf("%S - didChangeLocationWithinPageForFrame\n", @@ -884,9 +884,9 @@ void TestWebViewDelegate::WaitForPolicyDelegate() { void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { WebFrame* mainFrame = webView->GetMainFrame(); - WebDataSource* dataSource = mainFrame->GetDataSource(); + WebDataSource* dataSource = mainFrame->dataSource(); if (!dataSource) - dataSource = mainFrame->GetProvisionalDataSource(); + dataSource = mainFrame->provisionalDataSource(); if (!dataSource) return; @@ -915,7 +915,7 @@ void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, bool is_new_navigation) { // Code duplicated from RenderView::DidCommitLoadForFrame. TestShellExtraData* extra_data = static_cast<TestShellExtraData*>( - frame->GetDataSource()->extraData()); + frame->dataSource()->extraData()); if (is_new_navigation) { // New navigation. @@ -936,7 +936,7 @@ void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, } void TestWebViewDelegate::UpdateURL(WebFrame* frame) { - WebDataSource* ds = frame->GetDataSource(); + WebDataSource* ds = frame->dataSource(); DCHECK(ds); const WebURLRequest& request = ds->request(); @@ -953,7 +953,7 @@ void TestWebViewDelegate::UpdateURL(WebFrame* frame) { entry->SetURL(request.url()); } - const WebHistoryItem& history_item = frame->GetCurrentHistoryItem(); + const WebHistoryItem& history_item = frame->currentHistoryItem(); if (!history_item.isNull()) entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); @@ -975,7 +975,7 @@ void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { return; const WebHistoryItem& history_item = - shell_->webView()->GetMainFrame()->GetPreviousHistoryItem(); + shell_->webView()->GetMainFrame()->previousHistoryItem(); if (history_item.isNull()) return; @@ -983,7 +983,7 @@ void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { } std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { - std::wstring name = webframe->GetName(); + std::wstring name = UTF16ToWideHack(webframe->name()); if (webframe == shell_->webView()->GetMainFrame()) { if (name.length()) diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 183bc4f..81e7bab 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -111,11 +111,11 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, const GURL& referrer, WebKit::WebNavigationPolicy policy); virtual void DidMovePlugin(const WebPluginGeometry& move); - virtual void RunJavaScriptAlert(WebFrame* webframe, + virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, const std::wstring& message); - virtual bool RunJavaScriptConfirm(WebFrame* webframe, + virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, const std::wstring& message); - virtual bool RunJavaScriptPrompt(WebFrame* webframe, + virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, const std::wstring& message, const std::wstring& default_value, std::wstring* result); @@ -143,58 +143,60 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, int edit_flags, const std::string& security_info, const std::string& frame_charset); - virtual void DidCreateDataSource(WebFrame* frame, + virtual void DidCreateDataSource(WebKit::WebFrame* frame, WebKit::WebDataSource* ds); virtual void DidStartProvisionalLoadForFrame( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, NavigationGesture gesture); virtual void DidReceiveProvisionalLoadServerRedirect( - WebView* webview, WebFrame* frame); + WebView* webview, WebKit::WebFrame* frame); virtual void DidFailProvisionalLoadWithError( WebView* webview, const WebKit::WebURLError& error, - WebFrame* frame); - virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, - bool is_new_navigation); + WebKit::WebFrame* frame); + virtual void DidCommitLoadForFrame( + WebView* webview, + WebKit::WebFrame* frame, + bool is_new_navigation); virtual void DidReceiveTitle(WebView* webview, const std::wstring& title, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidFinishDocumentLoadForFrame(WebView* webview, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidHandleOnloadEventsForFrame(WebView* webview, - WebFrame* frame); + WebKit::WebFrame* frame); virtual void DidChangeLocationWithinPageForFrame(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, bool is_new_navigation); - virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame); + virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame); virtual void WillPerformClientRedirect(WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const GURL& src_url, const GURL& dest_url, unsigned int delay_seconds, unsigned int fire_date); virtual void DidCancelClientRedirect(WebView* webview, - WebFrame* frame); + WebKit::WebFrame* frame); - virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame); + virtual void DidFinishLoadForFrame(WebView* webview, WebKit::WebFrame* frame); virtual void DidFailLoadWithError(WebView* webview, const WebKit::WebURLError& error, - WebFrame* for_frame); + WebKit::WebFrame* for_frame); - virtual void AssignIdentifierToRequest(WebFrame* webframe, + virtual void AssignIdentifierToRequest(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLRequest& request); - virtual void WillSendRequest(WebFrame* webframe, + virtual void WillSendRequest(WebKit::WebFrame* webframe, uint32 identifier, WebKit::WebURLRequest* request, const WebKit::WebURLResponse& redirect_response); - virtual void DidReceiveResponse(WebFrame* webframe, + virtual void DidReceiveResponse(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLResponse& response); - virtual void DidFinishLoading(WebFrame* webframe, uint32 identifier); - virtual void DidFailLoadingWithError(WebFrame* webframe, + virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier); + virtual void DidFailLoadingWithError(WebKit::WebFrame* webframe, uint32 identifier, const WebKit::WebURLError& error); @@ -227,10 +229,10 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void DidStartLoading(WebView* webview); virtual void DidStopLoading(WebView* webview); - virtual void WindowObjectCleared(WebFrame* webframe); + virtual void WindowObjectCleared(WebKit::WebFrame* webframe); virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, - WebFrame* frame, + WebKit::WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, WebKit::WebNavigationPolicy default_policy, @@ -259,7 +261,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, void SetSelectTrailingWhitespaceEnabled(bool enabled); // Additional accessors - WebFrame* top_loading_frame() { return top_loading_frame_; } + WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; } #if defined(OS_WIN) IDropTarget* drop_delegate() { return drop_delegate_.get(); } IDropSource* drag_delegate() { return drag_delegate_.get(); } @@ -313,17 +315,17 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, // In the Mac code, this is called to trigger the end of a test after the // page has finished loading. From here, we can generate the dump for the // test. - void LocationChangeDone(WebFrame*); + void LocationChangeDone(WebKit::WebFrame*); WebWidgetHost* GetWidgetHost(); - void UpdateForCommittedLoad(WebFrame* webframe, bool is_new_navigation); - void UpdateURL(WebFrame* frame); - void UpdateSessionHistory(WebFrame* frame); + void UpdateForCommittedLoad(WebKit::WebFrame* webframe, bool is_new_navigation); + void UpdateURL(WebKit::WebFrame* frame); + void UpdateSessionHistory(WebKit::WebFrame* frame); void UpdateSelectionClipboard(bool is_empty_selection); // Get a string suitable for dumping a frame to the console. - std::wstring GetFrameDescription(WebFrame* webframe); + std::wstring GetFrameDescription(WebKit::WebFrame* webframe); private: // Causes navigation actions just printout the intended navigation instead @@ -342,7 +344,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, TestShell* shell_; // This is non-NULL IFF a load is in progress. - WebFrame* top_loading_frame_; + WebKit::WebFrame* top_loading_frame_; // For tracking session history. See RenderView. int page_id_; diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index 93c086c..66d7a62 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -15,11 +15,13 @@ #include "base/string_util.h" #include "net/base/net_errors.h" #include "chrome/common/page_transition_types.h" +#include "webkit/api/public/WebCString.h" #include "webkit/api/public/WebCursorInfo.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebString.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webkit_glue.h" @@ -32,6 +34,7 @@ #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebCursorInfo; +using WebKit::WebFrame; using WebKit::WebNavigationPolicy; using WebKit::WebRect; @@ -59,7 +62,12 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard, frame = webview->GetMainFrame(); DCHECK(frame); - std::string selection = frame->GetSelection(TEXT_HTML == info); + std::string selection; + if (TEXT_HTML == info) { + selection = frame->selectionAsMarkup().utf8(); + } else { + selection = frame->selectionAsText().utf8(); + } if (TEXT_HTML == info) { gtk_selection_data_set(selection_data, GetTextHtmlAtom(), diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index 592802b..d49cb9d 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -20,9 +20,9 @@ #include "base/trace_event.h" #include "net/base/net_errors.h" #include "webkit/api/public/WebCursorInfo.h" +#include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebRect.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webkit_glue.h" @@ -159,7 +159,7 @@ void TestWebViewDelegate::runModal() { if (!host) return; - show(WebNavigationPolicy() /*XXX NEW_WINDOW*/); + show(WebKit::WebNavigationPolicyNewWindow); WindowList* wl = TestShell::windowList(); for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) { diff --git a/webkit/tools/test_shell/text_input_controller.cc b/webkit/tools/test_shell/text_input_controller.cc index a371881..8dfb9a1 100644 --- a/webkit/tools/test_shell/text_input_controller.cc +++ b/webkit/tools/test_shell/text_input_controller.cc @@ -1,15 +1,20 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// 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. #include "webkit/tools/test_shell/text_input_controller.h" #include "base/string_util.h" +#include "webkit/api/public/WebFrame.h" +#include "webkit/api/public/WebRange.h" +#include "webkit/api/public/WebString.h" #include "webkit/glue/webview.h" -#include "webkit/glue/webframe.h" -#include "webkit/glue/webtextinput.h" #include "webkit/tools/test_shell/test_shell.h" +using WebKit::WebFrame; +using WebKit::WebRange; +using WebKit::WebString; + TestShell* TextInputController::shell_ = NULL; TextInputController::TextInputController(TestShell* shell) { @@ -34,51 +39,46 @@ TextInputController::TextInputController(TestShell* shell) { BindMethod("makeAttributedString", &TextInputController::makeAttributedString); } -/* static */ WebView* TextInputController::webview() { - return shell_->webView(); -} - -/* static */ WebTextInput* TextInputController::GetTextInput() { - return webview()->GetMainFrame()->GetTextInput(); +// static +WebFrame* TextInputController::GetMainFrame() { + return shell_->webView()->GetMainFrame(); } void TextInputController::insertText( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; - if (args.size() >= 1 && args[0].isString()) { - text_input->InsertText(UTF8ToUTF16(args[0].ToString())); - } + if (args.size() >= 1 && args[0].isString()) + main_frame->insertText(WebString::fromUTF8(args[0].ToString())); } void TextInputController::doCommand( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; - if (args.size() >= 1 && args[0].isString()) { - text_input->DoCommand(UTF8ToUTF16(args[0].ToString())); - } + if (args.size() >= 1 && args[0].isString()) + main_frame->executeCommand(WebString::fromUTF8(args[0].ToString())); } void TextInputController::setMarkedText( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; if (args.size() >= 3 && args[0].isString() && args[1].isNumber() && args[2].isNumber()) { - text_input->SetMarkedText(UTF8ToUTF16(args[0].ToString()), + main_frame->setMarkedText(WebString::fromUTF8(args[0].ToString()), args[1].ToInt32(), args[2].ToInt32()); } @@ -88,72 +88,54 @@ void TextInputController::unmarkText( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; - text_input->UnMarkText(); + main_frame->unmarkText(); } void TextInputController::hasMarkedText( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; - result->Set(text_input->HasMarkedText()); + result->Set(main_frame->hasMarkedText()); } void TextInputController::conversationIdentifier( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - text_input->ConversationIdentifier(); } void TextInputController::substringFromRange( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) { - text_input->SubstringFromRange(args[0].ToInt32(), args[1].ToInt32()); - } } void TextInputController::attributedSubstringFromRange( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) { - text_input->AttributedSubstringFromRange(args[0].ToInt32(), - args[1].ToInt32()); - } } void TextInputController::markedRange( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; + WebRange range = main_frame->markedRange(); + std::string range_str; - text_input->MarkedRange(&range_str); + SStringPrintf(&range_str, "%d,%d", range.startOffset(), range.endOffset()); result->Set(range_str); } @@ -161,65 +143,43 @@ void TextInputController::selectedRange( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; + WebRange range = main_frame->selectionRange(); + std::string range_str; - text_input->SelectedRange(&range_str); + SStringPrintf(&range_str, "%d,%d", range.startOffset(), range.endOffset()); result->Set(range_str); } void TextInputController::firstRectForCharacterRange( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) { - text_input->FirstRectForCharacterRange(args[0].ToInt32(), - args[1].ToInt32()); - } } void TextInputController::characterIndexForPoint( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - if (args.size() >= 2 && args[0].isDouble() && args[1].isDouble()) { - text_input->CharacterIndexForPoint(args[0].ToDouble(), - args[1].ToDouble()); - } } void TextInputController::validAttributesForMarkedText( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - WebTextInput* text_input = GetTextInput(); - if (!text_input) + WebFrame* main_frame = GetMainFrame(); + if (!main_frame) return; - std::string attributes_str; - text_input->ValidAttributesForMarkedText(&attributes_str); - result->Set(attributes_str); + result->Set("NSUnderline,NSUnderlineColor,NSMarkedClauseSegment," + "NSTextInputReplacementRangeAttributeName"); } void TextInputController::makeAttributedString( const CppArgumentList& args, CppVariant* result) { + NOTIMPLEMENTED(); result->SetNull(); - - WebTextInput* text_input = GetTextInput(); - if (!text_input) - return; - - if (args.size() >= 1 && args[0].isString()) { - text_input->MakeAttributedString(args[0].ToString()); - } } diff --git a/webkit/tools/test_shell/text_input_controller.h b/webkit/tools/test_shell/text_input_controller.h index 014a243..4e94708 100644 --- a/webkit/tools/test_shell/text_input_controller.h +++ b/webkit/tools/test_shell/text_input_controller.h @@ -14,8 +14,10 @@ #include "webkit/glue/cpp_bound_class.h" class TestShell; -class WebView; -class WebTextInput; + +namespace WebKit { +class WebFrame; +} class TextInputController : public CppBoundClass { public: @@ -37,10 +39,8 @@ class TextInputController : public CppBoundClass { void makeAttributedString(const CppArgumentList& args, CppVariant* result); private: - static WebTextInput* GetTextInput(); - - // Returns the test shell's webview. - static WebView* webview(); + // Returns the test shell's main WebFrame. + static WebKit::WebFrame* GetMainFrame(); // Non-owning pointer. The LayoutTestController is owned by the host. static TestShell* shell_; diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 3d55f6a..c072275 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -986,6 +986,7 @@ 'api/public/WebDataSource.h', 'api/public/WebDragData.h', 'api/public/WebFindOptions.h', + 'api/public/WebFrame.h', 'api/public/WebForm.h', 'api/public/WebHistoryItem.h', 'api/public/WebHTTPBody.h', @@ -1006,6 +1007,7 @@ 'api/public/WebPoint.h', 'api/public/WebPopupMenu.h', 'api/public/WebPopupMenuInfo.h', + 'api/public/WebRange.h', 'api/public/WebRect.h', 'api/public/WebScreenInfo.h', 'api/public/WebScriptSource.h', @@ -1069,6 +1071,7 @@ 'api/src/WebNode.cpp', 'api/src/WebPluginListBuilderImpl.cpp', 'api/src/WebPluginListBuilderImpl.h', + 'api/src/WebRange.cpp', 'api/src/WebSettingsImpl.cpp', 'api/src/WebSettingsImpl.h', 'api/src/WebStorageAreaImpl.cpp', @@ -1408,7 +1411,6 @@ 'glue/webdropdata.cc', 'glue/webdropdata_win.cc', 'glue/webdropdata.h', - 'glue/webframe.h', 'glue/webframe_impl.cc', 'glue/webframe_impl.h', 'glue/webframeloaderclient_impl.cc', @@ -1431,9 +1433,6 @@ 'glue/webpopupmenu_impl.cc', 'glue/webpopupmenu_impl.h', 'glue/webpreferences.h', - 'glue/webtextinput.h', - 'glue/webtextinput_impl.cc', - 'glue/webtextinput_impl.h', 'glue/webthemeengine_impl_win.cc', 'glue/weburlloader_impl.cc', 'glue/weburlloader_impl.h', |