diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 21:39:15 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 21:39:15 +0000 |
commit | 18bcc3c1e8ac29683e6d09a9c2d8b3037b0fb360 (patch) | |
tree | c1941e26ff0fa733258e7c91d2f84ad436df6963 | |
parent | ab58e6cec813b33eefb397be3cebc11fcc280bdf (diff) | |
download | chromium_src-18bcc3c1e8ac29683e6d09a9c2d8b3037b0fb360.zip chromium_src-18bcc3c1e8ac29683e6d09a9c2d8b3037b0fb360.tar.gz chromium_src-18bcc3c1e8ac29683e6d09a9c2d8b3037b0fb360.tar.bz2 |
POSIX: gfx::NativeViewId and CrossProcessEvent
Create a couple new typedefs for porting work. Firstly,
gfx::NativeViewId is a handle to a platform specific widget in the
renderer process. For Windows, this is just a HWND as before. However,
in other platforms the ids used in the renderer process will be
something else.
CrossProcessEvent is the type of a HANDLE to a Windows event object
which is used across processes. Since we aren't going to support these
sorts of events on non-Windows platforms, this will have to go away at
some point. For now, however, this lets us build code without too many
ifdefs all over the place.
Review URL: http://codereview.chromium.org/18768
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8756 0039d316-1c4b-4281-b951-d872f2087c98
32 files changed, 237 insertions, 169 deletions
@@ -12,7 +12,7 @@ deps = { "http://googletest.googlecode.com/svn/trunk@167", "src/third_party/WebKit": - "/trunk/deps/third_party/WebKit@8646", + "/trunk/deps/third_party/WebKit@8753", "src/third_party/icu38": "/trunk/deps/third_party/icu38@7525", diff --git a/base/gfx/native_widget_types.h b/base/gfx/native_widget_types.h index 1f696b0..95e2292 100644 --- a/base/gfx/native_widget_types.h +++ b/base/gfx/native_widget_types.h @@ -5,14 +5,29 @@ #ifndef BASE_GFX_NATIVE_WIDGET_TYPES_H_ #define BASE_GFX_NATIVE_WIDGET_TYPES_H_ +#include "base/basictypes.h" #include "build/build_config.h" // This file provides cross platform typedefs for native widget types. // NativeWindow: this is a handle to a native, top-level window // NativeView: this is a handle to a native UI element. It may be the // same type as a NativeWindow on some platforms. -// NativeEditView: a handle to a native edit-box. The Mac folks wanted -// this specific typedef. +// NativeViewId: Often, in our cross process model, we need to pass around a +// reference to a "window". This reference will, say, be echoed back from a +// renderer to the browser when it wishes to query it's size. On Windows, a +// HWND can be used for this. On other platforms, we may wish to pass +// around X window ids, or maybe abstract identifiers. +// +// As a rule of thumb - if you're in the renderer, you should be dealing +// with NativeViewIds. This should remind you that you shouldn't be doing +// direct operations on platform widgets from the renderer process. +// +// If you're in the browser, you're probably dealing with NativeViews, +// unless you're in the IPC layer, which will be translating between +// NativeViewIds from the renderer and NativeViews. +// +// NativeEditView: a handle to a native edit-box. The Mac folks wanted this +// specific typedef. // // The name 'View' here meshes with OS X where the UI elements are called // 'views' and with our Chrome UI code where the elements are also called @@ -52,6 +67,31 @@ typedef GtkWidget* NativeEditView; #error No known OS defined #endif +// Note: for test_shell we're packing a pointer into the NativeViewId. So, if +// you make it a type which is smaller than a pointer, you have to fix +// test_shell. +// +// See comment at the top of the file for usage. +typedef intptr_t NativeViewId; + +// Convert a NativeViewId to a NativeView. At the moment, we assume that the +// ids are the same as the NativeViews. This is correct on Windows (where +// NativeView == HWND). +// TODO(port): figure out what ids are going to be and implement this function +// This is only to be called in the browser process. +static inline NativeView NativeViewFromId(NativeViewId id) { + return reinterpret_cast<NativeView>(id); +} + +// Convert a NativeView to a NativeViewId. At the moment, we assume that the +// ids are the same as the NativeViews. This is correct on Windows (where +// NativeView == HWND). +// TODO(port): figure out what ids are going to be and implement this function +// This is only to be called in the browser process. +static inline NativeViewId IdFromNativeView(NativeView view) { + return reinterpret_cast<NativeViewId>(view); +} + } // namespace gfx #endif // BASE_GFX_NATIVE_WIDGET_TYPES_H_ diff --git a/chrome/browser/download/download_file.h b/chrome/browser/download/download_file.h index ea74318..8811005 100644 --- a/chrome/browser/download/download_file.h +++ b/chrome/browser/download/download_file.h @@ -45,6 +45,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/gfx/native_widget_types.h" #include "base/hash_tables.h" #include "base/lock.h" #include "base/ref_counted.h" @@ -196,7 +197,8 @@ class DownloadFileManager void OnShowDownloadInShell(const FilePath& full_path); // Handler to open or execute a downloaded file. void OnOpenDownloadInShell(const FilePath& full_path, - const std::wstring& url, HWND parent_window); + const std::wstring& url, + gfx::NativeView parent_window); // The download manager has provided a final name for a download. Sent from // the UI thread and run on the download thread. diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index adfebaa..5bd9af5 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -7,6 +7,7 @@ #include <string> #include <vector> +#include "base/gfx/native_widget_types.h" #include "base/string_util.h" #include "base/waitable_event.h" #include "chrome/app/result_codes.h" @@ -129,7 +130,8 @@ bool RenderViewHost::CreateRenderView() { renderer_initialized_ = true; - HANDLE modal_dialog_event; +#if defined(OS_WIN) + HANDLE modal_dialog_event_handle; HANDLE renderer_process_handle = process()->process().handle(); if (renderer_process_handle == NULL) renderer_process_handle = GetCurrentProcess(); @@ -137,14 +139,21 @@ bool RenderViewHost::CreateRenderView() { BOOL result = DuplicateHandle(GetCurrentProcess(), modal_dialog_event_->handle(), renderer_process_handle, - &modal_dialog_event, + &modal_dialog_event_handle, SYNCHRONIZE, FALSE, 0); DCHECK(result) << "Couldn't duplicate the modal dialog handle for the renderer."; +#endif DCHECK(view()); - Send(new ViewMsg_New(view()->GetPluginHWND(), + + ModalDialogEvent modal_dialog_event; +#if defined(OS_WIN) + modal_dialog_event.event = modal_dialog_event_handle; +#endif + + Send(new ViewMsg_New(gfx::IdFromNativeView(view()->GetPluginHWND()), modal_dialog_event, delegate_->GetWebkitPrefs(), routing_id())); @@ -751,11 +760,17 @@ void RenderViewHost::Shutdown() { } void RenderViewHost::OnMsgCreateWindow(int route_id, - HANDLE modal_dialog_event) { + ModalDialogEvent modal_dialog_event) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + base::WaitableEvent* waitable_event = new base::WaitableEvent( +#if defined(OS_WIN) + modal_dialog_event.event); +#else + true, false); +#endif + if (view) - view->CreateNewWindow(route_id, - new base::WaitableEvent(modal_dialog_event)); + view->CreateNewWindow(route_id, waitable_event); } void RenderViewHost::OnMsgCreateWidget(int route_id, bool activatable) { diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index f4c40ed..0c968e4 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -11,6 +11,7 @@ #include "base/scoped_ptr.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_zoom.h" #ifdef CHROME_PERSONALIZATION #include "chrome/personalization/personalization.h" @@ -416,7 +417,7 @@ class RenderViewHost : public RenderWidgetHost { virtual void NotifyRendererResponsive(); // IPC message handlers. - void OnMsgCreateWindow(int route_id, HANDLE modal_dialog_event); + void OnMsgCreateWindow(int route_id, ModalDialogEvent modal_dialog_event); void OnMsgCreateWidget(int route_id, bool activatable); void OnMsgShowView(int route_id, WindowOpenDisposition disposition, diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index d92ff301..85da6dd 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -189,37 +189,36 @@ void RenderWidgetHelper::OnCrossSiteClosePageACK( void RenderWidgetHelper::CreateNewWindow(int opener_id, bool user_gesture, base::ProcessHandle render_process, - int* route_id -#if defined(OS_WIN) - , HANDLE* modal_dialog_event) { -#else - ) { -#endif + int* route_id, + ModalDialogEvent* modal_dialog_event) { if (!user_gesture && block_popups_) { *route_id = MSG_ROUTING_NONE; - *modal_dialog_event = NULL; +#if defined(OS_WIN) + modal_dialog_event->event = NULL; +#endif return; } *route_id = GetNextRoutingID(); + ModalDialogEvent modal_dialog_event_internal; #if defined(OS_WIN) HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL); + modal_dialog_event_internal.event = event; + BOOL result = DuplicateHandle(GetCurrentProcess(), event, render_process, - modal_dialog_event, + &modal_dialog_event->event, SYNCHRONIZE, FALSE, 0); DCHECK(result) << "Couldn't duplicate modal dialog event for the renderer."; +#endif // The easiest way to reach RenderViewHost is just to send a routed message. - ViewHostMsg_CreateWindowWithRoute msg(opener_id, *route_id, event); -#else - // TODO(port) figure out how the modal dialog event should work. - ViewHostMsg_CreateWindowWithRoute msg(opener_id, *route_id); -#endif + ViewHostMsg_CreateWindowWithRoute msg(opener_id, *route_id, + modal_dialog_event_internal); ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( this, &RenderWidgetHelper::OnSimulateReceivedMessage, msg)); diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h index b73ce03..83cedb0 100644 --- a/chrome/browser/renderer_host/render_widget_helper.h +++ b/chrome/browser/renderer_host/render_widget_helper.h @@ -12,6 +12,7 @@ #include "base/ref_counted.h" #include "base/lock.h" #include "base/waitable_event.h" +#include "chrome/common/modal_dialog_event.h" namespace IPC { class Message; @@ -109,11 +110,8 @@ class RenderWidgetHelper : void CreateNewWindow(int opener_id, bool user_gesture, base::ProcessHandle render_process, - int* route_id -#if defined(OS_WIN) - , HANDLE* modal_dialog_event -#endif - ); + int* route_id, + ModalDialogEvent* modal_dialog_event); void CreateNewWidget(int opener_id, bool activatable, int* route_id); private: diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 865abbb..b3108b5 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -68,7 +68,8 @@ void RenderWidgetHost::Init() { // Send the ack along with the information on placement. HWND plugin_hwnd = view_->GetPluginHWND(); - Send(new ViewMsg_CreatingNew_ACK(routing_id_, plugin_hwnd)); + Send(new ViewMsg_CreatingNew_ACK(routing_id_, + gfx::IdFromNativeView(plugin_hwnd))); WasResized(); } diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index c07de07..33d971c 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_H_ #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_H_ +#include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" #include "build/build_config.h" #include "chrome/common/render_messages.h" @@ -59,10 +60,8 @@ class RenderWidgetHostView { // Tells the View to size itself to the specified size. virtual void SetSize(const gfx::Size& size) = 0; -#if defined(OS_WIN) // Retrieves the HWND used to contain plugin HWNDs. - virtual HWND GetPluginHWND() = 0; -#endif + virtual gfx::NativeView GetPluginHWND() = 0; // Moves all plugin windows as described in the given list. virtual void MovePluginWindows( diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc index e97c46c..753590c 100644 --- a/chrome/browser/resource_message_filter.cc +++ b/chrome/browser/resource_message_filter.cc @@ -5,6 +5,7 @@ #include "chrome/browser/resource_message_filter.h" #include "base/clipboard.h" +#include "base/gfx/native_widget_types.h" #include "base/histogram.h" #include "base/thread.h" #include "chrome/browser/chrome_plugin_browsing_context.h" @@ -244,10 +245,9 @@ bool ResourceMessageFilter::Send(IPC::Message* message) { return channel_->Send(message); } -void ResourceMessageFilter::OnMsgCreateWindow(int opener_id, - bool user_gesture, - int* route_id, - HANDLE* modal_dialog_event) { +void ResourceMessageFilter::OnMsgCreateWindow( + int opener_id, bool user_gesture, int* route_id, + ModalDialogEvent* modal_dialog_event) { render_widget_helper_->CreateNewWindow(opener_id, user_gesture, render_handle_, @@ -406,8 +406,8 @@ void ResourceMessageFilter::OnLoadFont(LOGFONT font) { } void ResourceMessageFilter::OnGetScreenInfo( - gfx::NativeView window, webkit_glue::ScreenInfo* results) { - *results = webkit_glue::GetScreenInfoHelper(window); + gfx::NativeViewId window, webkit_glue::ScreenInfo* results) { + *results = webkit_glue::GetScreenInfoHelper(gfx::NativeViewFromId(window)); } void ResourceMessageFilter::OnGetPlugins(bool refresh, @@ -474,20 +474,25 @@ void ResourceMessageFilter::OnClipboardReadHTML(std::wstring* markup, #if defined(OS_WIN) -void ResourceMessageFilter::OnGetWindowRect(HWND window, gfx::Rect *rect) { +void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id, + gfx::Rect* rect) { + HWND window = gfx::NativeViewFromId(window_id); RECT window_rect = {0}; GetWindowRect(window, &window_rect); *rect = window_rect; } -void ResourceMessageFilter::OnGetRootWindowRect(HWND window, gfx::Rect *rect) { +void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, + gfx::Rect* rect) { + HWND window = gfx::NativeViewFromId(window_id); RECT window_rect = {0}; HWND root_window = ::GetAncestor(window, GA_ROOT); GetWindowRect(root_window, &window_rect); *rect = window_rect; } -void ResourceMessageFilter::OnGetRootWindowResizerRect(HWND window, gfx::Rect *rect) { +void ResourceMessageFilter::OnGetRootWindowResizerRect(gfx::NativeViewId window, + gfx::Rect* rect) { RECT window_rect = {0}; *rect = window_rect; } @@ -581,10 +586,12 @@ void ResourceMessageFilter::OnGetDefaultPrintSettingsReply( #if defined(OS_WIN) -void ResourceMessageFilter::OnScriptedPrint(HWND host_window, +void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id, int cookie, int expected_pages_count, IPC::Message* reply_msg) { + HWND host_window = gfx::NativeViewFromId(host_window_id); + scoped_refptr<printing::PrinterQuery> printer_query; print_job_manager_->PopPrinterQuery(cookie, &printer_query); if (!printer_query.get()) { diff --git a/chrome/browser/resource_message_filter.h b/chrome/browser/resource_message_filter.h index 09d42b6..026c232 100644 --- a/chrome/browser/resource_message_filter.h +++ b/chrome/browser/resource_message_filter.h @@ -82,7 +82,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, private: void OnMsgCreateWindow(int opener_id, bool user_gesture, int* route_id, - HANDLE* modal_dialog_event); + ModalDialogEvent* modal_dialog_event); void OnMsgCreateWidget(int opener_id, bool activatable, int* route_id); void OnRequestResource(const IPC::Message& msg, int request_id, const ViewHostMsg_Resource_Request& request); @@ -115,7 +115,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnLoadFont(LOGFONT font); #endif - void OnGetScreenInfo(gfx::NativeView window, + void OnGetScreenInfo(gfx::NativeViewId window, webkit_glue::ScreenInfo* results); void OnGetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); void OnGetPluginPath(const GURL& url, @@ -142,9 +142,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnClipboardReadAsciiText(std::string* result); void OnClipboardReadHTML(std::wstring* markup, GURL* src_url); #if defined(OS_WIN) - void OnGetWindowRect(HWND window, gfx::Rect *rect); - void OnGetRootWindowRect(HWND window, gfx::Rect *rect); - void OnGetRootWindowResizerRect(HWND window, gfx::Rect *rect); + void OnGetWindowRect(gfx::NativeViewId window, gfx::Rect *rect); + void OnGetRootWindowRect(gfx::NativeViewId window, gfx::Rect *rect); + void OnGetRootWindowResizerRect(gfx::NativeViewId window, gfx::Rect *rect); #endif void OnGetMimeTypeFromExtension(const std::wstring& ext, std::string* mime_type); @@ -168,7 +168,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // A javascript code requested to print the current page. The renderer host // have to show to the user the print dialog and returns the selected print // settings. - void OnScriptedPrint(HWND host_window, + void OnScriptedPrint(gfx::NativeViewId host_window, int cookie, int expected_pages_count, IPC::Message* reply_msg); diff --git a/chrome/common/modal_dialog_event.h b/chrome/common/modal_dialog_event.h new file mode 100644 index 0000000..2a14c87 --- /dev/null +++ b/chrome/common/modal_dialog_event.h @@ -0,0 +1,20 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_MODAL_DIALOG_EVENT_H_ +#define CHROME_COMMON_MODAL_DIALOG_EVENT_H_ + +// This structure is passed around where we need a modal dialog event, which +// is currently not plumbed on Mac & Linux. +// +// TODO(port) Fix this. This structure should probably go away and we should +// do the modal dialog event in some portable way. If you remove this, be +// sure to also remove the ParamTraits for it in resource_messages.h +struct ModalDialogEvent { +#if defined(OS_WIN) + HANDLE event; +#endif +}; + +#endif // CHROME_COMMON_MODAL_DIALOG_EVENT_H_ diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index b0338b7..83dddb1 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -15,6 +15,7 @@ #include "chrome/common/filter_policy.h" #include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" +#include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_transition_types.h" #include "googleurl/src/gurl.h" #include "net/base/upload_data.h" @@ -1723,6 +1724,29 @@ struct ParamTraits<webkit_glue::ScreenInfo> { } }; +template<> +struct ParamTraits<ModalDialogEvent> { + typedef ModalDialogEvent param_type; +#if defined(OS_WIN) + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.event); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->event); + } +#else + static void Write(Message* m, const param_type& p) { + } + static bool Read(const Message* m, void** iter, param_type* p) { + return true; + } +#endif + + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ModalDialogEvent>"); + } +}; + } // namespace IPC #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 1081e54..30c6469 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -13,6 +13,7 @@ #include "base/clipboard.h" #include "base/gfx/rect.h" +#include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" #include "chrome/common/ipc_message_macros.h" #include "skia/include/SkBitmap.h" @@ -39,12 +40,14 @@ IPC_BEGIN_MESSAGES(View, 1) IPC_MESSAGE_CONTROL1(ViewMsg_SetNextPageID, int32 /* next_page_id */) -#if defined(OS_WIN) // Tells the renderer to create a new view. // This message is slightly different, the view it takes is the view to // create, the message itself is sent as a non-view control message. - IPC_MESSAGE_CONTROL4(ViewMsg_New, HWND, HANDLE, WebPreferences, int32) -#endif // defined(OS_WIN) + IPC_MESSAGE_CONTROL4(ViewMsg_New, + gfx::NativeViewId, /* parent window */ + ModalDialogEvent, /* model dialog box event */ + WebPreferences, + int32 /* view id */) // Tells the renderer to set its maximum cache size to the supplied value IPC_MESSAGE_CONTROL3(ViewMsg_SetCacheCapacities, @@ -61,13 +64,8 @@ IPC_BEGIN_MESSAGES(View, 1) // Reply in response to ViewHostMsg_ShowView or ViewHostMsg_ShowWidget. // similar to the new command, but used when the renderer created a view // first, and we need to update it -#if defined(OS_WIN) IPC_MESSAGE_ROUTED1(ViewMsg_CreatingNew_ACK, - HWND /* parent_hwnd */) -#else // defined(OS_WIN) - // On POSIX, we don't pass "window handles" between processes. - IPC_MESSAGE_ROUTED0(ViewMsg_CreatingNew_ACK) -#endif + gfx::NativeViewId /* parent_hwnd */) // Tells the render view to close. IPC_MESSAGE_ROUTED0(ViewMsg_Close) @@ -495,7 +493,6 @@ IPC_END_MESSAGES(View) // These are messages sent from the renderer to the browser process. IPC_BEGIN_MESSAGES(ViewHost, 2) -#if defined(OS_WIN) // Sent by the renderer when it is creating a new window. The browser creates // a tab for it and responds with a ViewMsg_CreatingNew_ACK. If route_id is // MSG_ROUTING_NONE, the view couldn't be created. modal_dialog_event is set @@ -504,16 +501,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) int /* opener_id */, bool /* user_gesture */, int /* route_id */, - HANDLE /* modal_dialog_event */) -#else // defined(OS_WIN) - // On POSIX, we don't use the cross process events for modal dialogs. At some - // point, we won't use them on any platform, but for now we just define a - // message without the last parameter. - IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWindow, - int /* opener_id */, - bool /* user_gesture */, - int /* route_id */) -#endif + ModalDialogEvent /* modal_dialog_event */) // Similar to ViewHostMsg_CreateView, except used for sub-widgets, like // <select> dropdowns. This message is sent to the WebContents that @@ -523,13 +511,11 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) bool /* focus on show */, int /* route_id */) -#if defined(OS_WIN) // These two messages are sent as a result of the above two, in the browser // process, from RenderWidgetHelper to RenderViewHost. IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateWindowWithRoute, int /* route_id */, - HANDLE /* modal_dialog_event */) -#endif // defined(OS_WIN) + ModalDialogEvent /* modal_dialog_event */) IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateWidgetWithRoute, int /* route_id */, @@ -643,7 +629,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) // generates a ViewMsg_ScrollRect_ACK message. IPC_MESSAGE_ROUTED1(ViewHostMsg_ScrollRect, ViewHostMsg_ScrollRect_Params) -#endif // defined(OS_WIN) +#endif // Acknowledges receipt of a ViewMsg_HandleInputEvent message. // Payload is a WebInputEvent::Type which is the type of the event, followed @@ -654,12 +640,10 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) IPC_MESSAGE_ROUTED0(ViewHostMsg_Focus) IPC_MESSAGE_ROUTED0(ViewHostMsg_Blur) -#if defined(OS_WIN) // Returns the window location of the given window. IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetWindowRect, - HWND /* window */, + gfx::NativeViewId /* window */, gfx::Rect /* Out: Window location */) -#endif // defined(OS_WIN) IPC_MESSAGE_ROUTED1(ViewHostMsg_SetCursor, WebCursor) // Result of string search in the page. @@ -850,12 +834,12 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) // Please see ResourceMessageFilter::OnLoadFont for details. IPC_SYNC_MESSAGE_CONTROL1_0(ViewHostMsg_LoadFont, LOGFONT /* font data */) +#endif // defined(OS_WIN) // Returns ScreenInfo corresponding to the given window. IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetScreenInfo, - gfx::NativeView /* window */, + gfx::NativeViewId /* window */, webkit_glue::ScreenInfo /* results */) -#endif // defined(OS_WIN) // Send the tooltip text for the current mouse position to the browser. IPC_MESSAGE_ROUTED1(ViewHostMsg_SetTooltipText, @@ -967,7 +951,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) // final print settings. The output parameter is the same as // ViewMsg_PrintPages which is executed implicitly. IPC_SYNC_MESSAGE_ROUTED3_1(ViewHostMsg_ScriptedPrint, - HWND /* host_window */, + gfx::NativeViewId /* host_window */, int /* cookie */, int /* expected_pages_count */, ViewMsg_PrintPages_Params /* settings choosen by @@ -1106,18 +1090,16 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) IPC_MESSAGE_ROUTED1(ViewHostMsg_UnloadListenerChanged, bool /* has_listener */) -#if defined(OS_WIN) // Returns the window location of the window this widget is embeded. IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowRect, - HWND /* window */, + gfx::NativeViewId /* window */, gfx::Rect /* Out: Window location */) // Returns the resizer box location in the window this widget is embeded. // Important for Mac OS X, but not Win or Linux. IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowResizerRect, - HWND /* window */, + gfx::NativeViewId /* window */, gfx::Rect /* Out: Window location */) -#endif // defined(OS_WIN) // Queries the browser for suggestion for autofill in a form input field. IPC_MESSAGE_ROUTED4(ViewHostMsg_QueryFormFieldAutofill, diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index d39800f..6c45a3d 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -230,21 +230,23 @@ void RenderThread::OnSetNextPageID(int32 next_page_id) { #endif } -// TODO(port) -#if defined(OS_WIN) -void RenderThread::OnCreateNewView(HWND parent_hwnd, - HANDLE modal_dialog_event, +void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd, + ModalDialogEvent modal_dialog_event, const WebPreferences& webkit_prefs, int32 view_id) { + base::WaitableEvent* waitable_event = new base::WaitableEvent( +#if defined(OS_WIN) + modal_dialog_event.event); +#else + true, false); +#endif + // TODO(darin): once we have a RenderThread per RenderView, this will need to // change to assert that we are not creating more than one view. - base::WaitableEvent* waitable_event = - new base::WaitableEvent(modal_dialog_event); RenderView::Create( this, parent_hwnd, waitable_event, MSG_ROUTING_NONE, webkit_prefs, new SharedRenderViewCounter(0), view_id); } -#endif void RenderThread::OnSetCacheCapacities(size_t min_dead_capacity, size_t max_dead_capacity, diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index 5a2e80a..95ee58f 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -6,6 +6,7 @@ #define CHROME_RENDERER_RENDER_THREAD_H_ #include "base/file_path.h" +#include "base/gfx/native_widget_types.h" #include "base/ref_counted.h" #include "base/shared_memory.h" #include "base/task.h" @@ -13,6 +14,7 @@ #include "build/build_config.h" #include "chrome/common/ipc_sync_channel.h" #include "chrome/common/message_router.h" +#include "chrome/common/modal_dialog_event.h" class SkBitmap; class Task; @@ -102,14 +104,10 @@ class RenderThread : public IPC::Channel::Listener, void OnPluginMessage(const FilePath& plugin_path, const std::vector<uint8>& data); void OnSetNextPageID(int32 next_page_id); -#if defined(OS_WIN) - // TODO(port): we'll need to support that at some point, but it's not clear - // if we'll be using the same sort of messages for setting this up - void OnCreateNewView(HWND parent_hwnd, - HANDLE modal_dialog_event, + void OnCreateNewView(gfx::NativeViewId parent_hwnd, + ModalDialogEvent modal_dialog_event, const WebPreferences& webkit_prefs, int32 view_id); -#endif void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); void OnSetCacheCapacities(size_t min_dead_capacity, size_t max_dead_capacity, diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 1d3d7af..1544198 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/gfx/png_encoder.h" +#include "base/gfx/native_widget_types.h" #include "base/string_piece.h" #include "base/string_util.h" #include "build/build_config.h" @@ -210,7 +211,7 @@ RenderView::~RenderView() { /*static*/ RenderView* RenderView::Create( RenderThreadBase* render_thread, - HWND parent_hwnd, + gfx::NativeViewId parent_hwnd, base::WaitableEvent* modal_dialog_event, int32 opener_id, const WebPreferences& webkit_prefs, @@ -266,7 +267,7 @@ void RenderView::JSOutOfMemory() { Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); } -void RenderView::Init(HWND parent_hwnd, +void RenderView::Init(gfx::NativeViewId parent_hwnd, base::WaitableEvent* modal_dialog_event, int32 opener_id, const WebPreferences& webkit_prefs, @@ -425,14 +426,8 @@ void RenderView::OnMessageReceived(const IPC::Message& message) { // Got a response from the browser after the renderer decided to create a new // view. -void RenderView::OnCreatingNewAck -#if defined(OS_WIN) - (HWND parent) { +void RenderView::OnCreatingNewAck(gfx::NativeViewId parent) { CompleteInit(parent); -#else - () { -#endif - waiting_for_create_window_ack_ = false; while (!queued_resource_messages_.empty()) { @@ -1854,29 +1849,19 @@ WebView* RenderView::CreateWebView(WebView* webview, bool user_gesture) { int32 routing_id = MSG_ROUTING_NONE; -#if defined(OS_WIN) - HANDLE modal_dialog_event = NULL; + ModalDialogEvent modal_dialog_event; render_thread_->Send( new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id, &modal_dialog_event)); if (routing_id == MSG_ROUTING_NONE) { - DCHECK(modal_dialog_event == NULL); return NULL; } -#else // defined(OS_WIN) - // On POSIX we don't have a HANDLE parameter as we don't have cross process - // events. All platforms should be ported across to this at some point. - render_thread_->Send( - new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id)); - if (routing_id == MSG_ROUTING_NONE) - return NULL; -#endif // The WebView holds a reference to this new RenderView const WebPreferences& prefs = webview->GetPreferences(); base::WaitableEvent* waitable_event = new base::WaitableEvent #if defined(OS_WIN) - (modal_dialog_event); + (modal_dialog_event.event); #else (true, false); #endif @@ -1946,7 +1931,8 @@ WebPluginDelegate* RenderView::CreatePluginDelegate( if (is_gears) ChromePluginLib::Create(path, GetCPBrowserFuncsForRenderer()); return WebPluginDelegateImpl::Create(path, - mime_type_to_use, host_window_); + mime_type_to_use, + gfx::NativeViewFromId(host_window_)); } WebPluginDelegateProxy* proxy = diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 8933655..49b0be1 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -91,7 +91,7 @@ class RenderView : public RenderWidget, // (in which case we treat this RenderView as a top level window). static RenderView* Create( RenderThreadBase* render_thread, - HWND parent_hwnd, + gfx::NativeViewId parent_hwnd, base::WaitableEvent* modal_dialog_event, // takes ownership int32 opener_id, const WebPreferences& webkit_prefs, @@ -111,7 +111,7 @@ class RenderView : public RenderWidget, return static_cast<WebView*>(webwidget()); } - HWND host_window() const { + gfx::NativeViewId host_window() const { return host_window_; } @@ -334,7 +334,7 @@ class RenderView : public RenderWidget, // Initializes this view with the given parent and ID. The |routing_id| can be // set to 'MSG_ROUTING_NONE' if the true ID is not yet known. In this case, // CompleteInit must be called later with the true ID. - void Init(HWND parent, + void Init(gfx::NativeViewId parent, base::WaitableEvent* modal_dialog_event, // takes ownership int32 opener_id, const WebPreferences& webkit_prefs, @@ -396,11 +396,7 @@ class RenderView : public RenderWidget, void GoToEntryAtOffset(int offset); // RenderView IPC message handlers -#if defined(OS_WIN) - void OnCreatingNewAck(HWND parent); -#else - void OnCreatingNewAck(); -#endif + void OnCreatingNewAck(gfx::NativeViewId parent); void SendThumbnail(); void OnPrintPage(const ViewMsg_PrintPage_Params& params); void OnGetPrintedPagesCount(const ViewMsg_Print_Params& params); diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 82a7fe7..5d3fa3c 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -143,9 +143,8 @@ void RenderWidget::Init(int32 opener_id) { // This is used to complete pending inits and non-pending inits. For non- // pending cases, the parent will be the same as the current parent. This // indicates we do not need to reparent or anything. -void RenderWidget::CompleteInit(HWND parent_hwnd) { +void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { DCHECK(routing_id_ != MSG_ROUTING_NONE); - DCHECK(parent_hwnd); host_window_ = parent_hwnd; @@ -197,7 +196,7 @@ bool RenderWidget::InSend() const { // Got a response from the browser after the renderer decided to create a new // view. -void RenderWidget::OnCreatingNewAck(HWND parent) { +void RenderWidget::OnCreatingNewAck(gfx::NativeViewId parent) { DCHECK(routing_id_ != MSG_ROUTING_NONE); CompleteInit(parent); @@ -503,7 +502,7 @@ void RenderWidget::DoDeferredScroll() { /////////////////////////////////////////////////////////////////////////////// // WebWidgetDelegate -gfx::NativeView RenderWidget::GetContainingView(WebWidget* webwidget) { +gfx::NativeViewId RenderWidget::GetContainingView(WebWidget* webwidget) { return host_window_; } diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index f567f88..c594f64 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -7,6 +7,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/gfx/native_widget_types.h" #include "base/gfx/point.h" #include "base/gfx/rect.h" #include "base/gfx/size.h" @@ -64,7 +65,7 @@ class RenderWidget : public IPC::Channel::Listener, bool InSend() const; // WebWidgetDelegate - virtual gfx::NativeView GetContainingView(WebWidget* webwidget); + virtual gfx::NativeViewId GetContainingView(WebWidget* webwidget); virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, const gfx::Rect& clip_rect); @@ -97,7 +98,7 @@ class RenderWidget : public IPC::Channel::Listener, void Init(int32 opener_id); // Finishes creation of a pending view started with Init. - void CompleteInit(HWND parent); + void CompleteInit(gfx::NativeViewId parent); // Paints the given rectangular region of the WebWidget into paint_buf (a // shared memory segment returned by AllocPaintBuf). The caller must ensure @@ -117,7 +118,7 @@ class RenderWidget : public IPC::Channel::Listener, // RenderWidget IPC message handlers void OnClose(); - void OnCreatingNewAck(HWND parent); + void OnCreatingNewAck(gfx::NativeViewId parent); void OnResize(const gfx::Size& new_size); void OnWasHidden(); void OnWasRestored(bool needs_repainting); @@ -195,7 +196,7 @@ class RenderWidget : public IPC::Channel::Listener, gfx::Rect initial_pos_; // The window we are embedded within. TODO(darin): kill this. - HWND host_window_; + gfx::NativeViewId host_window_; // We store the current cursor object so we can avoid spamming SetCursor // messages. diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index a24e06f..03c52a2 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -261,15 +261,10 @@ bool EnsureFontLoaded(HFONT font) { } #endif -webkit_glue::ScreenInfo GetScreenInfo(gfx::NativeView window) { +webkit_glue::ScreenInfo GetScreenInfo(gfx::NativeViewId window) { webkit_glue::ScreenInfo results; -#if defined(OS_WIN) g_render_thread->Send( new ViewHostMsg_GetScreenInfo(window, &results)); -#else - // TODO(agl): this will start working on GetScreenInfo is fixed - NOTIMPLEMENTED(); -#endif return results; } diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index a13053b..0cb2f1f 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -12,6 +12,7 @@ #include "base/ref_counted.h" #include "base/string_util.h" #include "base/gfx/size.h" +#include "base/gfx/native_widget_types.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/common/gfx/chrome_canvas.h" @@ -231,7 +232,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, // Now tell the PluginInstance in the plugin process to initialize. PluginMsg_Init_Params params; - params.containing_window = render_view_->host_window(); + params.containing_window = gfx::NativeViewFromId(render_view_->host_window()); params.url = url; for (int i = 0; i < argc; ++i) { params.arg_names.push_back(argn[i]); diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index 680ae9e..4780fa6 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -62,14 +62,10 @@ namespace { -gfx::NativeView ToPlatform(WebCore::Widget* widget) { +gfx::NativeViewId ToNativeId(WebCore::Widget* widget) { if (!widget) return 0; - PlatformWidget widget_id = widget->root()->hostWindow()->platformWindow(); - // TODO(eseidel): This cast is a hack. We should replace gfx::NativeView with - // something more abstract like PlatformWidget since webkit/glue should not - // know about actual native widgets. - return static_cast<gfx::NativeView>(widget_id); + return widget->root()->hostWindow()->platformWindow(); } #if PLATFORM(WIN_OS) @@ -433,25 +429,25 @@ PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) { // Screen --------------------------------------------------------------------- int ChromiumBridge::screenDepth(Widget* widget) { - return webkit_glue::GetScreenInfo(ToPlatform(widget)).depth; + return webkit_glue::GetScreenInfo(ToNativeId(widget)).depth; } int ChromiumBridge::screenDepthPerComponent(Widget* widget) { - return webkit_glue::GetScreenInfo(ToPlatform(widget)).depth_per_component; + return webkit_glue::GetScreenInfo(ToNativeId(widget)).depth_per_component; } bool ChromiumBridge::screenIsMonochrome(Widget* widget) { - return webkit_glue::GetScreenInfo(ToPlatform(widget)).is_monochrome; + return webkit_glue::GetScreenInfo(ToNativeId(widget)).is_monochrome; } IntRect ChromiumBridge::screenRect(Widget* widget) { return webkit_glue::ToIntRect( - webkit_glue::GetScreenInfo(ToPlatform(widget)).rect); + webkit_glue::GetScreenInfo(ToNativeId(widget)).rect); } IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { return webkit_glue::ToIntRect( - webkit_glue::GetScreenInfo(ToPlatform(widget)).available_rect); + webkit_glue::GetScreenInfo(ToNativeId(widget)).available_rect); } // SharedTimers ---------------------------------------------------------------- diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index f3335b5..50cd2c4 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -241,7 +241,7 @@ bool EnsureFontLoaded(HFONT font); #endif // Returns screen information corresponding to the given window. -ScreenInfo GetScreenInfo(gfx::NativeView window); +ScreenInfo GetScreenInfo(gfx::NativeViewId window); // Functions implemented by webkit_glue for WebKit ---------------------------- diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index 7350df4..773752f 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -11,11 +11,11 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/gfx/rect.h" +#include "base/gfx/native_widget_types.h" -// TODO(port): type typedefs are obviously incorrect on non-Windows +// TODO(port): this typedef is obviously incorrect on non-Windows // platforms, but now a lot of code now accidentally depends on them // existing. #ifdef out these declarations and fix all the users. -typedef struct HWND__* HWND; typedef void* HANDLE; class GURL; @@ -58,7 +58,7 @@ struct WebPluginInfo { // Describes the new location for a plugin window. struct WebPluginGeometry { - HWND window; + gfx::NativeView window; gfx::Rect window_rect; // Clip rect (include) and cutouts (excludes), relative to // window_rect origin. @@ -89,7 +89,8 @@ class WebPlugin { // The pump_messages_event is a event handle which is valid only for // windowless plugins and is used in NPP_HandleEvent calls to pump messages // if the plugin enters a modal loop. - virtual void SetWindow(HWND window, HANDLE pump_messages_event) = 0; + virtual void SetWindow(gfx::NativeView window, + HANDLE pump_messages_event) = 0; // Cancels a pending request. virtual void CancelResource(int id) = 0; virtual void Invalidate() = 0; diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index d7d32a4..5bf2f72 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -328,7 +328,8 @@ WebPluginImpl::WebPluginImpl(WebCore::Element* element, WebPluginImpl::~WebPluginImpl() { } -void WebPluginImpl::SetWindow(HWND window, HANDLE pump_messages_event) { +void WebPluginImpl::SetWindow(gfx::NativeView window, + HANDLE pump_messages_event) { if (window) { DCHECK(!windowless_); // Make sure not called twice. window_ = window; diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h index b99b784..58c633e 100644 --- a/webkit/glue/webplugin_impl.h +++ b/webkit/glue/webplugin_impl.h @@ -11,6 +11,7 @@ #include "config.h" #include "base/compiler_specific.h" +#include "base/gfx/native_widget_types.h" MSVC_PUSH_WARNING_LEVEL(0); #include "ResourceHandle.h" @@ -146,7 +147,7 @@ class WebPluginImpl : public WebPlugin, int arg_count, char** arg_names, char** arg_values); // WebPlugin implementation: - void SetWindow(HWND window, HANDLE pump_messages_event); + void SetWindow(gfx::NativeView window, HANDLE pump_messages_event); // Given a (maybe partial) url, completes using the base url. bool CompleteURL(const std::string& url_in, std::string* url_out); @@ -323,7 +324,7 @@ class WebPluginImpl : public WebPlugin, std::vector<ClientInfo> clients_; bool windowless_; - HWND window_; + gfx::NativeView window_; WebCore::Element* element_; WebFrameImpl* webframe_; diff --git a/webkit/glue/webwidget_delegate.h b/webkit/glue/webwidget_delegate.h index cd84041..81caeb31 100644 --- a/webkit/glue/webwidget_delegate.h +++ b/webkit/glue/webwidget_delegate.h @@ -20,7 +20,7 @@ struct WebPluginGeometry; class WebWidgetDelegate { public: // Returns the view in which the WebWidget is embedded. - virtual gfx::NativeView GetContainingView(WebWidget* webwidget) = 0; + virtual gfx::NativeViewId GetContainingView(WebWidget* webwidget) = 0; // Called when a region of the WebWidget needs to be re-painted. virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect) = 0; diff --git a/webkit/pending/AccessibleBase.cpp b/webkit/pending/AccessibleBase.cpp index aed40ce..c211bbb 100644 --- a/webkit/pending/AccessibleBase.cpp +++ b/webkit/pending/AccessibleBase.cpp @@ -127,7 +127,7 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::get_accParent(IDispatch** parent) return S_OK; } - HMODULE accessibilityLib = ::LoadLibrary(TEXT("oleacc.dll")); + HMODULE accessibilityLib = ::LoadLibrary(TEXT("oleacc.dll")); static LPFNACCESSIBLEOBJECTFROMWINDOW procPtr = reinterpret_cast<LPFNACCESSIBLEOBJECTFROMWINDOW>(::GetProcAddress(accessibilityLib, "AccessibleObjectFromWindow")); if (!procPtr) @@ -137,8 +137,8 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::get_accParent(IDispatch** parent) // identifier corresponding to the HWND WebKit is embedded in. It happens // to be the case that platformWindow is a valid HWND pointer (inaccessible // from the sandboxed renderer). - HWND window = static_cast<HWND>(m_object->topDocumentFrameView()->hostWindow()->platformWindow()); - return procPtr(window, OBJID_WINDOW, __uuidof(IAccessible), reinterpret_cast<void**>(parent)); + HWND window = reinterpret_cast<HWND>(m_object->topDocumentFrameView()->hostWindow()->platformWindow()); + return procPtr(window, OBJID_WINDOW, __uuidof(IAccessible), reinterpret_cast<void**>(parent)); } HRESULT STDMETHODCALLTYPE AccessibleBase::get_accChildCount(long* count) diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index c1ae406..ceeb6e6 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -595,8 +595,8 @@ bool SpellCheckWord(const wchar_t* word, int word_len, return true; } -ScreenInfo GetScreenInfo(gfx::NativeView window) { - return GetScreenInfoHelper(window); +ScreenInfo GetScreenInfo(gfx::NativeViewId window) { + return GetScreenInfoHelper(gfx::NativeViewFromId(window)); } bool IsPluginRunningInRendererProcess() { diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 631d48e..684b22a 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -10,6 +10,7 @@ #include "base/file_util.h" #include "base/gfx/point.h" +#include "base/gfx/native_widget_types.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/trace_event.h" @@ -664,9 +665,11 @@ void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { // WebWidgetDelegate --------------------------------------------------------- -gfx::NativeView TestWebViewDelegate::GetContainingView(WebWidget* webwidget) { +gfx::NativeViewId TestWebViewDelegate::GetContainingView(WebWidget* webwidget) { + // For test shell, we pack a NativeView pointer into the NativeViewId since + // everything is single process. if (WebWidgetHost* host = GetHostForWidget(webwidget)) - return host->view_handle(); + return gfx::IdFromNativeView(host->view_handle()); return NULL; } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index d934bcc..65d0723 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -205,7 +205,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual int GetHistoryForwardListCount(); // WebWidgetDelegate - virtual gfx::NativeView GetContainingView(WebWidget* webwidget); + virtual gfx::NativeViewId GetContainingView(WebWidget* webwidget); virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, const gfx::Rect& clip_rect); |