diff options
Diffstat (limited to 'content')
9 files changed, 120 insertions, 125 deletions
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index eb7ee88..2a506d0 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -114,9 +114,9 @@ void RenderWidgetHost::SetView(RenderWidgetHostView* view) { process_->SetCompositingSurface(routing_id_, gfx::kNullPluginWindow); } -gfx::NativeViewId RenderWidgetHost::GetNativeViewId() { +gfx::NativeViewId RenderWidgetHost::GetNativeViewId() const { if (view_) - return gfx::IdFromNativeView(view_->GetNativeView()); + return view_->GetNativeViewId(); return 0; } @@ -1111,6 +1111,28 @@ void RenderWidgetHost::OnMsgDidActivateAcceleratedCompositing(bool activated) { #endif } +#if defined(OS_POSIX) +void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, + WebKit::WebScreenInfo* results) { + if (view_) + view_->GetScreenInfo(results); + else + RenderWidgetHostView::GetDefaultScreenInfo(results); +} + +void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, + gfx::Rect* results) { + if (view_) + *results = view_->GetViewBounds(); +} + +void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id, + gfx::Rect* results) { + if (view_) + *results = view_->GetRootWindowBounds(); +} +#endif + void RenderWidgetHost::PaintBackingStoreRect( TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 3ae1c42..776bbc6 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -384,7 +384,7 @@ class RenderWidgetHost : public IPC::Channel::Listener, // Retrieves an id the renderer can use to refer to its view. // This is used for various IPC messages, including plugins. - gfx::NativeViewId GetNativeViewId(); + gfx::NativeViewId GetNativeViewId() const; // Retrieves an id for the surface that the renderer can draw to // when accelerated compositing is enabled. diff --git a/content/browser/renderer_host/render_widget_host_gtk.cc b/content/browser/renderer_host/render_widget_host_gtk.cc index 77877ca..e378edf 100644 --- a/content/browser/renderer_host/render_widget_host_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_gtk.cc @@ -4,89 +4,7 @@ #include "content/browser/renderer_host/render_widget_host.h" -#include <gdk/gdkx.h> -#include <gtk/gtk.h> - -#include "base/synchronization/lock.h" #include "content/browser/renderer_host/render_widget_host_view.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h" -#include "ui/gfx/gtk_native_view_id_manager.h" -#include "ui/gfx/rect.h" - -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; - -// We get a null |view| passed into this function please see -// http://crbug.com/9060 for more details. -void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, - WebScreenInfo* results) { - GtkWidget* widget = NULL; - GdkWindow* gdk_window = NULL; - if (GtkNativeViewManager::GetInstance()->GetNativeViewForId( - &widget, view) && widget) { - gdk_window = widget->window; - } else { - GdkDisplay* display = gdk_display_get_default(); - gdk_window = gdk_display_get_default_group(display); - } - if (!gdk_window) - return; - GdkScreen* screen = gdk_drawable_get_screen(gdk_window); - *results = WebScreenInfoFactory::screenInfo( - gdk_x11_drawable_get_xdisplay(gdk_window), - gdk_x11_screen_get_screen_number(screen)); - - // TODO(tony): We should move this code into WebScreenInfoFactory. - int monitor_number = gdk_screen_get_monitor_at_window(screen, gdk_window); - GdkRectangle monitor_rect; - gdk_screen_get_monitor_geometry(screen, monitor_number, &monitor_rect); - results->rect = WebKit::WebRect(monitor_rect.x, monitor_rect.y, - monitor_rect.width, monitor_rect.height); - // TODO(tony): Should we query _NET_WORKAREA to get the workarea? - results->availableRect = results->rect; -} - -// We get null window_ids passed into this function please see -// http://crbug.com/9060 for more details. -void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, - gfx::Rect* results) { - GtkWidget* widget = NULL; - if (!GtkNativeViewManager::GetInstance()->GetNativeViewForId( - &widget, window_id) || !widget) { - return; - } - GdkWindow* gdk_window = widget->window; - if (!gdk_window) - return; - GdkRectangle window_rect; - gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y); - gdk_drawable_get_size(gdk_window, &window_rect.width, &window_rect.height); - *results = window_rect; -} - -// We get null window_ids passed into this function please see -// http://crbug.com/9060 for more details. -void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id, - gfx::Rect* results) { - GtkWidget* widget = NULL; - if (!GtkNativeViewManager::GetInstance()->GetNativeViewForId( - &widget, window_id) || !widget) { - return; - } - GtkWidget* toplevel = gtk_widget_get_toplevel(widget); - if (!toplevel) - return; - - GdkRectangle frame_extents; - GdkWindow* gdk_window = toplevel->window; - if (!gdk_window) - return; - - gdk_window_get_frame_extents(gdk_window, &frame_extents); - *results = gfx::Rect(frame_extents.x, frame_extents.y, - frame_extents.width, frame_extents.height); -} void RenderWidgetHost::OnMsgCreatePluginContainer(gfx::PluginWindowHandle id) { // TODO(piman): view_ can only be NULL with delayed view creation in diff --git a/content/browser/renderer_host/render_widget_host_mac.cc b/content/browser/renderer_host/render_widget_host_mac.cc index b4641e7..38a8fac 100644 --- a/content/browser/renderer_host/render_widget_host_mac.cc +++ b/content/browser/renderer_host/render_widget_host_mac.cc @@ -3,33 +3,7 @@ // found in the LICENSE file. #include "content/browser/renderer_host/render_widget_host.h" - #include "content/browser/renderer_host/render_widget_host_view.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFactory.h" - -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; - -void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, - WebScreenInfo* results) { - gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL; - *results = WebScreenInfoFactory::screenInfo(native_view); -} - -void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, - gfx::Rect* results) { - if (view_) { - *results = view_->GetViewBounds(); - } -} - -void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id, - gfx::Rect* results) { - if (view_) { - *results = view_->GetRootWindowRect(); - } -} void RenderWidgetHost::OnMsgPluginFocusChanged(bool focused, int plugin_id) { if (view_) diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index 38f281e..3a85148 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -49,6 +49,12 @@ struct WebPluginGeometry; } } +#if defined(OS_POSIX) +namespace WebKit { +struct WebScreenInfo; +} +#endif + // RenderWidgetHostView is an interface implemented by an object that acts as // the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its // associated RenderProcessHost own the "Model" in this case which is the @@ -101,7 +107,8 @@ class RenderWidgetHostView { // Retrieves the native view used to contain plugins and identify the // renderer in IPC messages. - virtual gfx::NativeView GetNativeView() = 0; + virtual gfx::NativeView GetNativeView() const = 0; + virtual gfx::NativeViewId GetNativeViewId() const = 0; // Moves all plugin windows as described in the given list. virtual void MovePluginWindows( @@ -203,9 +210,6 @@ class RenderWidgetHostView { // Even though this returns an gfx::Rect, the result is NOT IN PIXELS. virtual gfx::Rect GetViewCocoaBounds() const = 0; - // Get the view's window's position on the screen. - virtual gfx::Rect GetRootWindowRect() = 0; - // Set the view's active state (i.e., tint state of controls). virtual void SetActive(bool active) = 0; @@ -282,6 +286,12 @@ class RenderWidgetHostView { virtual void ShowCompositorHostWindow(bool show) = 0; #endif +#if defined(OS_POSIX) + static void GetDefaultScreenInfo(WebKit::WebScreenInfo* results); + virtual void GetScreenInfo(WebKit::WebScreenInfo* results) = 0; + virtual gfx::Rect GetRootWindowBounds() = 0; +#endif + virtual gfx::PluginWindowHandle GetCompositingSurface() = 0; // Toggles visual muting of the render view area. This is on when a diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 9a9ab04..b6b5ec9 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -32,7 +32,9 @@ #include "content/browser/renderer_host/render_widget_host.h" #include "content/common/content_switches.h" #include "content/common/native_web_keyboard_event.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h" #include "ui/base/text/text_elider.h" #include "ui/base/x/x11_util.h" #include "ui/gfx/gtk_native_view_id_manager.h" @@ -92,6 +94,23 @@ GdkCursor* GetMozSpinningCursor() { return moz_spinning_cursor; } +void GetScreenInfoFromNativeWindow( + GdkWindow* gdk_window, WebKit::WebScreenInfo* results) { + GdkScreen* screen = gdk_drawable_get_screen(gdk_window); + *results = WebKit::WebScreenInfoFactory::screenInfo( + gdk_x11_drawable_get_xdisplay(gdk_window), + gdk_x11_screen_get_screen_number(screen)); + + // TODO(tony): We should move this code into WebScreenInfoFactory. + gint monitor_number = gdk_screen_get_monitor_at_window(screen, gdk_window); + GdkRectangle monitor_rect; + gdk_screen_get_monitor_geometry(screen, monitor_number, &monitor_rect); + results->rect = WebKit::WebRect(monitor_rect.x, monitor_rect.y, + monitor_rect.width, monitor_rect.height); + // TODO(tony): Should we query _NET_WORKAREA to get the workarea? + results->availableRect = results->rect; +} + } // namespace using WebKit::WebInputEventFactory; @@ -665,10 +684,14 @@ void RenderWidgetHostViewGtk::SetBounds(const gfx::Rect& rect) { SetSize(rect.size()); } -gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { +gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() const { return view_.get(); } +gfx::NativeViewId RenderWidgetHostViewGtk::GetNativeViewId() const { + return GtkNativeViewManager::GetInstance()->GetIdForWidget(view_.get()); +} + void RenderWidgetHostViewGtk::MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) { for (size_t i = 0; i < moves.size(); ++i) { @@ -1140,10 +1163,36 @@ void RenderWidgetHostViewGtk::AcceleratedCompositingActivated(bool activated) { gtk_preserve_window_delegate_resize(widget, activated); } +void RenderWidgetHostViewGtk::GetScreenInfo(WebKit::WebScreenInfo* results) { + GdkWindow* gdk_window = view_.get()->window; + if (!gdk_window) { + GdkDisplay* display = gdk_display_get_default(); + gdk_window = gdk_display_get_default_group(display); + } + if (!gdk_window) + return; + GetScreenInfoFromNativeWindow(gdk_window, results); +} + +gfx::Rect RenderWidgetHostViewGtk::GetRootWindowBounds() { + GtkWidget* toplevel = gtk_widget_get_toplevel(view_.get()); + if (!toplevel) + return gfx::Rect(); + + GdkRectangle frame_extents; + GdkWindow* gdk_window = toplevel->window; + if (!gdk_window) + return gfx::Rect(); + + gdk_window_get_frame_extents(gdk_window, &frame_extents); + return gfx::Rect(frame_extents.x, frame_extents.y, + frame_extents.width, frame_extents.height); +} + gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() { if (compositing_surface_ == gfx::kNullPluginWindow) { GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); - gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); + gfx::NativeViewId view_id = GetNativeViewId(); if (!manager->GetPermanentXIDForId(&compositing_surface_, view_id)) { DLOG(ERROR) << "Can't find XID for view id " << view_id; @@ -1199,3 +1248,11 @@ void RenderWidgetHostViewGtk::set_last_mouse_down(GdkEventButton* event) { last_mouse_down_ = temp; } + +// static +void RenderWidgetHostView::GetDefaultScreenInfo( + WebKit::WebScreenInfo* results) { + GdkWindow* gdk_window = + gdk_display_get_default_group(gdk_display_get_default()); + GetScreenInfoFromNativeWindow(gdk_window, results); +} diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 5dbac2e..1aa159a 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -60,7 +60,8 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; - virtual gfx::NativeView GetNativeView() OVERRIDE; + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; virtual void Focus() OVERRIDE; @@ -102,6 +103,8 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual void SetScrollOffsetPinning( bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; virtual void AcceleratedCompositingActivated(bool activated) OVERRIDE; + virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; + virtual gfx::Rect GetRootWindowBounds() OVERRIDE; virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE; // ui::AnimationDelegate implementation. diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index a757d79..1ddb875 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -137,10 +137,14 @@ RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { return NULL; } -gfx::NativeView TestRenderWidgetHostView::GetNativeView() { +gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { return NULL; } +gfx::NativeViewId TestRenderWidgetHostView::GetNativeViewId() const { + return 0; +} + bool TestRenderWidgetHostView::HasFocus() { return true; } @@ -177,10 +181,6 @@ gfx::Rect TestRenderWidgetHostView::GetViewCocoaBounds() const { return gfx::Rect(); } -gfx::Rect TestRenderWidgetHostView::GetRootWindowRect() { - return gfx::Rect(); -} - void TestRenderWidgetHostView::SetActive(bool active) { // <viettrungluu@gmail.com>: Do I need to do anything here? } @@ -233,6 +233,7 @@ void TestRenderWidgetHostView::AcceleratedSurfaceBuffersSwapped( void TestRenderWidgetHostView::GpuRenderingStateDidChange() { } + #elif defined(OS_WIN) void TestRenderWidgetHostView::WillWmDestroy() { } @@ -241,6 +242,12 @@ void TestRenderWidgetHostView::ShowCompositorHostWindow(bool show) { } #endif +#if defined(OS_POSIX) +gfx::Rect TestRenderWidgetHostView::GetRootWindowBounds() { + return gfx::Rect(); +} +#endif + gfx::PluginWindowHandle TestRenderWidgetHostView::GetCompositingSurface() { return gfx::kNullPluginWindow; } diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 6a3841e..9a79900 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -61,7 +61,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void WasHidden() OVERRIDE {} virtual void SetSize(const gfx::Size& size) OVERRIDE {} virtual void SetBounds(const gfx::Rect& rect) OVERRIDE {} - virtual gfx::NativeView GetNativeView() OVERRIDE; + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE {} virtual void Focus() OVERRIDE {} @@ -89,7 +90,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { #if defined(OS_MACOSX) virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {} virtual gfx::Rect GetViewCocoaBounds() const OVERRIDE; - virtual gfx::Rect GetRootWindowRect() OVERRIDE; virtual void SetActive(bool active) OVERRIDE; virtual void SetWindowVisibility(bool visible) OVERRIDE {} virtual void WindowFrameChanged() OVERRIDE {} @@ -123,6 +123,10 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void WillWmDestroy() OVERRIDE; virtual void ShowCompositorHostWindow(bool show) OVERRIDE; #endif +#if defined(OS_POSIX) + virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE {}; + virtual gfx::Rect GetRootWindowBounds() OVERRIDE; +#endif virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) { } virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) { } |