diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 17:22:35 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 17:22:35 +0000 |
commit | 8dfde667dad8d1df78ae57918e1adf95329eab8c (patch) | |
tree | cebdba936256dc3cb95fe414b556c3739b1d10eb /content/browser | |
parent | 5c8875d2272180166742e7e08b55d1bfb92a00a2 (diff) | |
download | chromium_src-8dfde667dad8d1df78ae57918e1adf95329eab8c.zip chromium_src-8dfde667dad8d1df78ae57918e1adf95329eab8c.tar.gz chromium_src-8dfde667dad8d1df78ae57918e1adf95329eab8c.tar.bz2 |
Extract RenderWidgetHostView (for Chrome-like embedders) vs. RenderWidgetHostViewBase
(for content itself, and for embedders porting to other platforms).
BUG=98716
Review URL: http://codereview.chromium.org/9307055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
23 files changed, 353 insertions, 246 deletions
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index 53a3ee1..924efe4 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -74,7 +74,8 @@ class ScopedSendOnIOThread { bool cancelled_; }; -RenderWidgetHostView* GetRenderWidgetHostViewFromSurfaceID(int surface_id) { +RenderWidgetHostViewBase* GetRenderWidgetHostViewFromSurfaceID( + int surface_id) { int render_process_id = 0; int render_widget_id = 0; if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( @@ -88,7 +89,7 @@ RenderWidgetHostView* GetRenderWidgetHostViewFromSurfaceID(int surface_id) { RenderWidgetHost* host = static_cast<RenderWidgetHost*>( process->GetListenerByID(render_widget_id)); - return host ? host->view() : NULL; + return host ? RenderWidgetHostViewBase::FromRWHV(host->view()) : NULL; } } // namespace @@ -244,7 +245,8 @@ void GpuProcessHostUIShim::OnResizeView(int32 surface_id, host_id_, new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID(surface_id); + RenderWidgetHostViewBase* view = + GetRenderWidgetHostViewFromSurfaceID(surface_id); if (!view) return; @@ -287,7 +289,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( params.surface_handle, TransportDIB::DefaultHandleValue())); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( params.surface_id); if (!view) return; @@ -342,7 +344,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( host_id_, new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( params.surface_id); if (!view) return; @@ -362,8 +364,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( host_id_, new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( - params.surface_id); + RenderWidgetHostViewBase* view = + GetRenderWidgetHostViewFromSurfaceID(params.surface_id); if (!view) return; @@ -377,7 +379,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend(int32 surface_id) { TRACE_EVENT0("renderer", "GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend"); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID(surface_id); + RenderWidgetHostViewBase* view = + GetRenderWidgetHostViewFromSurfaceID(surface_id); if (!view) return; @@ -388,7 +391,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend(int32 surface_id) { void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { - RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( params.surface_id); if (!view) return; diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index fe0f9f2..3252504 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -1085,14 +1085,14 @@ void RenderViewHost::OnRenderAutoResized(const gfx::Size& new_size) { void RenderViewHost::OnMsgDidChangeScrollbarsForMainFrame( bool has_horizontal_scrollbar, bool has_vertical_scrollbar) { - if (view()) - view()->SetHasHorizontalScrollbar(has_horizontal_scrollbar); + if (view_) + view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar); } void RenderViewHost::OnMsgDidChangeScrollOffsetPinningForMainFrame( bool is_pinned_to_left, bool is_pinned_to_right) { - if (view()) - view()->SetScrollOffsetPinning(is_pinned_to_left, is_pinned_to_right); + if (view_) + view_->SetScrollOffsetPinning(is_pinned_to_left, is_pinned_to_right); } void RenderViewHost::OnMsgDidChangeNumWheelEvents(int count) { @@ -1101,15 +1101,15 @@ void RenderViewHost::OnMsgDidChangeNumWheelEvents(int count) { void RenderViewHost::OnMsgSelectionChanged(const string16& text, size_t offset, const ui::Range& range) { - if (view()) - view()->SelectionChanged(text, offset, range); + if (view_) + view_->SelectionChanged(text, offset, range); } void RenderViewHost::OnMsgSelectionBoundsChanged( const gfx::Rect& start_rect, const gfx::Rect& end_rect) { - if (view()) - view()->SelectionBoundsChanged(start_rect, end_rect); + if (view_) + view_->SelectionBoundsChanged(start_rect, end_rect); } void RenderViewHost::OnMsgRunJavaScriptMessage( @@ -1441,8 +1441,8 @@ void RenderViewHost::StopFinding(content::StopFindAction action) { void RenderViewHost::OnAccessibilityNotifications( const std::vector<AccessibilityHostMsg_NotificationParams>& params) { - if (view() && !is_swapped_out_) - view()->OnAccessibilityNotifications(params); + if (view_ && !is_swapped_out_) + view_->OnAccessibilityNotifications(params); if (!params.empty()) { for (unsigned i = 0; i < params.size(); i++) { diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 1a6b65e..564543d 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -77,10 +77,10 @@ bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process, int routing_id) - : renderer_initialized_(false), + : view_(NULL), + renderer_initialized_(false), hung_renderer_delay_ms_(kHungRendererDelayMs), renderer_accessible_(false), - view_(NULL), process_(process), routing_id_(routing_id), surface_id_(0), @@ -152,7 +152,7 @@ RenderWidgetHost::~RenderWidgetHost() { } void RenderWidgetHost::SetView(RenderWidgetHostView* view) { - view_ = view; + view_ = RenderWidgetHostViewBase::FromRWHV(view); if (!view_) { GpuSurfaceTracker::Get()->SetSurfaceHandle( @@ -160,6 +160,10 @@ void RenderWidgetHost::SetView(RenderWidgetHostView* view) { } } +RenderWidgetHostView* RenderWidgetHost::view() const { + return view_; +} + gfx::NativeViewId RenderWidgetHost::GetNativeViewId() const { if (view_) return view_->GetNativeViewId(); @@ -956,7 +960,7 @@ void RenderWidgetHost::OnMsgSetTooltipText( } } if (view()) - view()->SetTooltipText(wrapped_tooltip_text); + view_->SetTooltipText(wrapped_tooltip_text); } void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { @@ -1263,7 +1267,7 @@ void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, if (view_) view_->GetScreenInfo(results); else - RenderWidgetHostView::GetDefaultScreenInfo(results); + RenderWidgetHostViewBase::GetDefaultScreenInfo(results); } void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 59f8eaf..46b0b83 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -32,6 +32,7 @@ class BackingStore; struct EditCommand; class RenderWidgetHostView; +class RenderWidgetHostViewBase; class TransportDIB; struct ViewHostMsg_UpdateRect_Params; class WebCursor; @@ -155,7 +156,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // never cache this pointer since it can become NULL if the renderer crashes, // instead you should always ask for it using the accessor. void SetView(RenderWidgetHostView* view); - RenderWidgetHostView* view() const { return view_; } + RenderWidgetHostView* view() const; content::RenderProcessHost* process() const { return process_; } int routing_id() const { return routing_id_; } @@ -540,6 +541,13 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, void SetShouldAutoResize(bool enable); protected: + // The View associated with the RenderViewHost. The lifetime of this object + // is associated with the lifetime of the Render process. If the Renderer + // crashes, its View is destroyed and this pointer becomes NULL, even though + // render_view_host_ lives on to load another URL (creating a new View while + // doing so). + RenderWidgetHostViewBase* view_; + // true if a renderer has once been valid. We use this flag to display a sad // tab only when we lose our renderer and not if a paint occurs during // initialization. @@ -660,13 +668,6 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // screenreader is detected as it can potentially slow down Chrome. bool renderer_accessible_; - // The View associated with the RenderViewHost. The lifetime of this object - // is associated with the lifetime of the Render process. If the Renderer - // crashes, its View is destroyed and this pointer becomes NULL, even though - // render_view_host_ lives on to load another URL (creating a new View while - // doing so). - RenderWidgetHostView* view_; - // Created during construction but initialized during Init*(). Therefore, it // is guaranteed never to be NULL, but its channel may be NULL if the // renderer crashed, so you must always check that. diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index a279c88..8cda30f8 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -447,11 +447,11 @@ TEST_F(RenderWidgetHostTest, Background) { // Set the background and make sure we get back a copy. view->SetBackground(background); - EXPECT_EQ(4, view->background().width()); - EXPECT_EQ(4, view->background().height()); - EXPECT_EQ(background.getSize(), view->background().getSize()); + EXPECT_EQ(4, view->GetBackground().width()); + EXPECT_EQ(4, view->GetBackground().height()); + EXPECT_EQ(background.getSize(), view->GetBackground().getSize()); EXPECT_TRUE(0 == memcmp(background.getPixels(), - view->background().getPixels(), + view->GetBackground().getPixels(), background.getSize())); #if defined(OS_WIN) diff --git a/content/browser/renderer_host/render_widget_host_view.cc b/content/browser/renderer_host/render_widget_host_view.cc index 53768f2..83cc1b7 100644 --- a/content/browser/renderer_host/render_widget_host_view.cc +++ b/content/browser/renderer_host/render_widget_host_view.cc @@ -15,7 +15,13 @@ #include "content/browser/renderer_host/gtk_window_utils.h" #endif -RenderWidgetHostView::RenderWidgetHostView() +RenderWidgetHostView::RenderWidgetHostView() { +} + +RenderWidgetHostView::~RenderWidgetHostView() { +} + +RenderWidgetHostViewBase::RenderWidgetHostViewBase() : popup_type_(WebKit::WebPopupTypeNone), mouse_locked_(false), showing_context_menu_(false), @@ -23,34 +29,54 @@ RenderWidgetHostView::RenderWidgetHostView() selection_range_(ui::Range::InvalidRange()) { } -RenderWidgetHostView::~RenderWidgetHostView() { +RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { DCHECK(!mouse_locked_); } -void RenderWidgetHostView::SetBackground(const SkBitmap& background) { +// static +RenderWidgetHostViewBase* RenderWidgetHostViewBase::FromRWHV( + RenderWidgetHostView* rwhv) { + return static_cast<RenderWidgetHostViewBase*>(rwhv); +} + +// static +RenderWidgetHostViewBase* RenderWidgetHostViewBase::CreateViewForWidget( + RenderWidgetHost* widget) { + return FromRWHV(RenderWidgetHostView::CreateViewForWidget(widget)); +} + +void RenderWidgetHostViewBase::SetBackground(const SkBitmap& background) { background_ = background; } +const SkBitmap& RenderWidgetHostViewBase::GetBackground() { + return background_; +} + BrowserAccessibilityManager* - RenderWidgetHostView::GetBrowserAccessibilityManager() const { + RenderWidgetHostViewBase::GetBrowserAccessibilityManager() const { return browser_accessibility_manager_.get(); } -void RenderWidgetHostView::SetBrowserAccessibilityManager( +void RenderWidgetHostViewBase::SetBrowserAccessibilityManager( BrowserAccessibilityManager* manager) { browser_accessibility_manager_.reset(manager); } -void RenderWidgetHostView::SelectionChanged(const string16& text, - size_t offset, - const ui::Range& range) { +void RenderWidgetHostViewBase::SelectionChanged(const string16& text, + size_t offset, + const ui::Range& range) { selection_text_ = text; selection_text_offset_ = offset; selection_range_.set_start(range.start()); selection_range_.set_end(range.end()); } -void RenderWidgetHostView::SetShowingContextMenu(bool showing) { +bool RenderWidgetHostViewBase::IsShowingContextMenu() const { + return showing_context_menu_; +} + +void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { DCHECK_NE(showing_context_menu_, showing); showing_context_menu_ = showing; } diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index a93fef8..8141475 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -68,9 +68,11 @@ struct WebScreenInfo; // the surrounding environment and passing them to the RenderWidgetHost, and // for actually displaying the content of the RenderWidgetHost when it // changes. -class RenderWidgetHostView { +// +// TODO(joi): Move this to content/public/browser +class CONTENT_EXPORT RenderWidgetHostView { public: - CONTENT_EXPORT virtual ~RenderWidgetHostView(); + virtual ~RenderWidgetHostView(); // Platform-specific creator. Use this to construct new RenderWidgetHostViews // rather than using RenderWidgetHostViewWin & friends. @@ -90,26 +92,9 @@ class RenderWidgetHostView { // a child window. virtual void InitAsChild(gfx::NativeView parent_view) = 0; - // Perform all the initialization steps necessary for this object to represent - // a popup (such as a <select> dropdown), then shows the popup at |pos|. - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) = 0; - - // Perform all the initialization steps necessary for this object to represent - // a full screen window. - // |reference_host_view| is the view associated with the creating page that - // helps to position the full screen widget on the correct monitor. - virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; - // Returns the associated RenderWidgetHost. virtual RenderWidgetHost* GetRenderWidgetHost() const = 0; - // Notifies the View that it has become visible. - virtual void DidBecomeSelected() = 0; - - // Notifies the View that it has been hidden. - virtual void WasHidden() = 0; - // Tells the View to size itself to the specified size. virtual void SetSize(const gfx::Size& size) = 0; @@ -123,14 +108,8 @@ class RenderWidgetHostView { virtual gfx::NativeViewId GetNativeViewId() const = 0; virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; - // Moves all plugin windows as described in the given list. - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) = 0; - - // Actually set/take focus to/from the associated View component. + // Set focus to the associated View component. virtual void Focus() = 0; - virtual void Blur() = 0; - // Returns true if the View currently has the focus. virtual bool HasFocus() const = 0; @@ -145,6 +124,111 @@ class RenderWidgetHostView { // Retrieve the bounds of the View, in screen coordinates. virtual gfx::Rect GetViewBounds() const = 0; + // Returns true if the View's context menu is showing. + virtual bool IsShowingContextMenu() const = 0; + + // Tells the View whether the context menu is showing. + virtual void SetShowingContextMenu(bool showing) = 0; + +#if defined(OS_MACOSX) + // Set the view's active state (i.e., tint state of controls). + virtual void SetActive(bool active) = 0; + + // Tells the view whether or not to accept first responder status. If |flag| + // is true, the view does not accept first responder status and instead + // manually becomes first responder when it receives a mouse down event. If + // |flag| is false, the view participates in the key-view chain as normal. + virtual void SetTakesFocusOnlyOnMouseDown(bool flag) = 0; + + // Notifies the view that its enclosing window has changed visibility + // (minimized/unminimized, app hidden/unhidden, etc). + // TODO(stuartmorgan): This is a temporary plugin-specific workaround for + // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding + // message and renderer-side handling) can be removed in favor of using + // WasHidden/DidBecomeSelected. + virtual void SetWindowVisibility(bool visible) = 0; + + // Informs the view that its containing window's frame changed. + virtual void WindowFrameChanged() = 0; +#endif // defined(OS_MACOSX) + +#if defined(TOOLKIT_USES_GTK) + // Gets the event for the last mouse down. + virtual GdkEventButton* GetLastMouseDown() = 0; +#if !defined(TOOLKIT_VIEWS) + // Builds a submenu containing all the gtk input method commands. + virtual gfx::NativeView BuildInputMethodsGtkMenu() = 0; +#endif // !defined(TOOLKIT_VIEWS) +#endif // defined(TOOLKIT_USES_GTK) + + // TODO(joi): May be able to move into impl if RWHVMacDelegate stops + // being exposed to Chrome. + virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) = 0; + + // Subclasses should override this method to do what is appropriate to set + // the custom background for their platform. + virtual void SetBackground(const SkBitmap& background) = 0; + virtual const SkBitmap& GetBackground() = 0; + + // TODO(joi): Remove this when we remove the dependency by chrome/ + // on browser_accessibility* files in content. + virtual BrowserAccessibilityManager* + GetBrowserAccessibilityManager() const = 0; + + protected: + RenderWidgetHostView(); + + private: + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostView); +}; + +// This is the larger RenderWidgetHostView interface exposed only +// within content/, plus some basic implementation. +// +// TODO(joi): Extract a pure virtual interface from these additional +// methods (named RenderWidgetHostViewPort?), move it to content/port, +// and have content/ use that interface everywhere except where it is +// using concrete implementation classes. The RWHVBase class might +// still exist for shared implementation between existing concrete +// implementations. +class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView { + public: + virtual ~RenderWidgetHostViewBase(); + + // Does the cast for you. + static RenderWidgetHostViewBase* FromRWHV(RenderWidgetHostView* rwhv); + + // Convenience function instead of + // RenderWidgetHostView::CreateViewForWidget if you want a + // RenderWidgetHostViewBase. + static RenderWidgetHostViewBase* CreateViewForWidget( + RenderWidgetHost* widget); + + // Perform all the initialization steps necessary for this object to represent + // a popup (such as a <select> dropdown), then shows the popup at |pos|. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) = 0; + + // Perform all the initialization steps necessary for this object to represent + // a full screen window. + // |reference_host_view| is the view associated with the creating page that + // helps to position the full screen widget on the correct monitor. + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) = 0; + + // Notifies the View that it has become visible. + virtual void DidBecomeSelected() = 0; + + // Notifies the View that it has been hidden. + virtual void WasHidden() = 0; + + // Moves all plugin windows as described in the given list. + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) = 0; + + // Take focus from the associated View component. + virtual void Blur() = 0; + // Sets the cursor to the one associated with the specified cursor_type virtual void UpdateCursor(const WebCursor& cursor) = 0; @@ -195,9 +279,9 @@ class RenderWidgetHostView { virtual void SetTooltipText(const string16& tooltip_text) = 0; // Notifies the View that the renderer text selection has changed. - CONTENT_EXPORT virtual void SelectionChanged(const string16& text, - size_t offset, - const ui::Range& range); + virtual void SelectionChanged(const string16& text, + size_t offset, + const ui::Range& range); // Notifies the View that the renderer selection bounds has changed. // |start_rect| and |end_rect| are the bounds end of the selection in the @@ -205,9 +289,6 @@ class RenderWidgetHostView { virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, const gfx::Rect& end_rect) {} - // Tells the View whether the context menu is showing. - CONTENT_EXPORT virtual void SetShowingContextMenu(bool showing); - // Allocate a backing store for this view. virtual BackingStore* AllocBackingStore(const gfx::Size& size) = 0; @@ -232,32 +313,12 @@ class RenderWidgetHostView { virtual void AcceleratedSurfaceSuspend() = 0; #if defined(OS_MACOSX) - // Tells the view whether or not to accept first responder status. If |flag| - // is true, the view does not accept first responder status and instead - // manually becomes first responder when it receives a mouse down event. If - // |flag| is false, the view participates in the key-view chain as normal. - virtual void SetTakesFocusOnlyOnMouseDown(bool flag) = 0; - // Retrieve the bounds of the view, in cocoa view coordinates. // If the UI scale factor is 2, |GetViewBounds()| will return a size of e.g. // (400, 300) in pixels, while this method will return (200, 150). // Even though this returns an gfx::Rect, the result is NOT IN PIXELS. virtual gfx::Rect GetViewCocoaBounds() const = 0; - // Set the view's active state (i.e., tint state of controls). - virtual void SetActive(bool active) = 0; - - // Notifies the view that its enclosing window has changed visibility - // (minimized/unminimized, app hidden/unhidden, etc). - // TODO(stuartmorgan): This is a temporary plugin-specific workaround for - // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding - // message and renderer-side handling) can be removed in favor of using - // WasHidden/DidBecomeSelected. - virtual void SetWindowVisibility(bool visible) = 0; - - // Informs the view that its containing window's frame changed. - virtual void WindowFrameChanged() = 0; - // Informs the view that a plugin gained or lost focus. virtual void PluginFocusChanged(bool focused, int plugin_id) = 0; @@ -300,12 +361,6 @@ class RenderWidgetHostView { #if defined(TOOLKIT_USES_GTK) virtual void CreatePluginContainer(gfx::PluginWindowHandle id) = 0; virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) = 0; - // Gets the event for the last mouse down. - virtual GdkEventButton* GetLastMouseDown() = 0; -#if !defined(TOOLKIT_VIEWS) - // Builds a submenu containing all the gtk input method commands. - virtual gfx::NativeView BuildInputMethodsGtkMenu() = 0; -#endif // !defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_USES_GTK) #if defined(OS_WIN) && !defined(USE_AURA) @@ -321,8 +376,6 @@ class RenderWidgetHostView { virtual gfx::GLSurfaceHandle GetCompositingSurface() = 0; - virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) = 0; - // Because the associated remote WebKit instance can asynchronously // prevent-default on a dispatched touch event, the touch events are queued in // the GestureRecognizer until invocation of ProcessTouchAck releases it to be @@ -337,29 +390,31 @@ class RenderWidgetHostView { virtual bool LockMouse() = 0; virtual void UnlockMouse() = 0; - void set_popup_type(WebKit::WebPopupType popup_type) { - popup_type_ = popup_type; + virtual void OnAccessibilityNotifications( + const std::vector<AccessibilityHostMsg_NotificationParams>& params) { } - WebKit::WebPopupType popup_type() const { return popup_type_; } - // Subclasses should override this method to do what is appropriate to set - // the custom background for their platform. - CONTENT_EXPORT virtual void SetBackground(const SkBitmap& background); - const SkBitmap& background() const { return background_; } + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + virtual const SkBitmap& GetBackground() OVERRIDE; - virtual void OnAccessibilityNotifications( - const std::vector<AccessibilityHostMsg_NotificationParams>& params) { + virtual bool IsShowingContextMenu() const OVERRIDE; + virtual void SetShowingContextMenu(bool) OVERRIDE; + + virtual BrowserAccessibilityManager* + GetBrowserAccessibilityManager() const OVERRIDE; + + void set_popup_type(WebKit::WebPopupType popup_type) { + popup_type_ = popup_type; } + WebKit::WebPopupType popup_type() const { return popup_type_; } - BrowserAccessibilityManager* GetBrowserAccessibilityManager() const; void SetBrowserAccessibilityManager(BrowserAccessibilityManager* manager); bool mouse_locked() const { return mouse_locked_; } - bool showing_context_menu() const { return showing_context_menu_; } protected: // Interface class only, do not construct. - CONTENT_EXPORT RenderWidgetHostView(); + RenderWidgetHostViewBase(); // Whether this view is a popup and what kind of popup it is (select, // autofill...). @@ -393,7 +448,7 @@ class RenderWidgetHostView { // Manager of the tree representation of the WebKit render tree. scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; - DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostView); + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); }; #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_H_ diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 12bcda1..272eb3b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -477,7 +477,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( #endif void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { - RenderWidgetHostView::SetBackground(background); + RenderWidgetHostViewBase::SetBackground(background); host_->SetBackground(background); #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); @@ -1085,7 +1085,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( } // static -void RenderWidgetHostView::GetDefaultScreenInfo( +void RenderWidgetHostViewBase::GetDefaultScreenInfo( WebKit::WebScreenInfo* results) { const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index f7c1ea6..aea4688 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -38,8 +38,8 @@ class WebTouchEvent; class ImageTransportClient; #endif -class CONTENT_EXPORT RenderWidgetHostViewAura - : NON_EXPORTED_BASE(public RenderWidgetHostView), +class RenderWidgetHostViewAura + : public RenderWidgetHostViewBase, #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) public ui::CompositorObserver, #endif @@ -49,29 +49,34 @@ class CONTENT_EXPORT RenderWidgetHostViewAura public: virtual ~RenderWidgetHostViewAura(); - // Overridden from RenderWidgetHostView: - virtual void InitAsChild(gfx::NativeView parent_host_view) OVERRIDE; - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE; - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE; + // RenderWidgetHostView implementation. + virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; - virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; virtual bool HasFocus() const OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) OVERRIDE; + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + + // Overridden from RenderWidgetHostViewBase: + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void DidBecomeSelected() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void TextInputStateChanged(ui::TextInputType type, @@ -103,11 +108,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura TransportDIB::Handle* surface_handle) OVERRIDE; virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; #endif - virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; virtual gfx::Rect GetRootWindowBounds() OVERRIDE; - virtual void UnhandledWheelEvent( - const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void ProcessTouchAck(bool processed) OVERRIDE; virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE; 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 5614fd4..c84dab1 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -244,7 +244,7 @@ class RenderWidgetHostViewGtkWidget { gdk_window_set_cursor(gtk_widget_get_window(widget), NULL); // If we are showing a context menu, maintain the illusion that webkit has // focus. - if (!host_view->showing_context_menu()) { + if (!host_view->IsShowingContextMenu()) { host_view->GetRenderWidgetHost()->SetActive(false); host_view->GetRenderWidgetHost()->Blur(); } @@ -907,7 +907,7 @@ void RenderWidgetHostViewGtk::SetTooltipText(const string16& tooltip_text) { void RenderWidgetHostViewGtk::SelectionChanged(const string16& text, size_t offset, const ui::Range& range) { - RenderWidgetHostView::SelectionChanged(text, offset, range); + RenderWidgetHostViewBase::SelectionChanged(text, offset, range); if (text.empty() || range.is_empty()) return; @@ -1027,7 +1027,7 @@ void RenderWidgetHostViewGtk::AcceleratedSurfaceSuspend() { void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { - RenderWidgetHostView::SetBackground(background); + RenderWidgetHostViewBase::SetBackground(background); host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); } @@ -1409,7 +1409,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( } // static -void RenderWidgetHostView::GetDefaultScreenInfo( +void RenderWidgetHostViewBase::GetDefaultScreenInfo( WebKit::WebScreenInfo* results) { GdkWindow* gdk_window = gdk_display_get_default_group(gdk_display_get_default()); 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 c709483..9adc0d1 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -44,33 +44,42 @@ typedef struct _GtkSelectionData GtkSelectionData; // ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. // ----------------------------------------------------------------------------- -class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { +class RenderWidgetHostViewGtk : public RenderWidgetHostViewBase { public: virtual ~RenderWidgetHostViewGtk(); // RenderWidgetHostView implementation. virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE; - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE; virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; - virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; virtual bool HasFocus() const OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; + virtual GdkEventButton* GetLastMouseDown() OVERRIDE; +#if !defined(TOOLKIT_VIEWS) + virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; +#endif // !defined(TOOLKIT_VIEWS) + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) OVERRIDE; + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + + // RenderWidgetHostViewBase implementation. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void DidBecomeSelected() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void TextInputStateChanged(ui::TextInputType type, @@ -98,16 +107,8 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, int gpu_host_id) OVERRIDE; virtual void AcceleratedSurfaceSuspend() OVERRIDE; - virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE; virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE; - virtual GdkEventButton* GetLastMouseDown() OVERRIDE; -#if !defined(TOOLKIT_VIEWS) - // Builds a submenu containing all the gtk input method commands. - virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; -#endif - virtual void UnhandledWheelEvent( - const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void ProcessTouchAck(bool processed) OVERRIDE; virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 3208611..fd9aab9 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -158,41 +158,47 @@ class RenderWidgetHostViewMacEditCommandHelper; // If the render process dies, the RenderWidgetHost* goes away and all // references to it must become NULL." // -class RenderWidgetHostViewMac : public RenderWidgetHostView { +class RenderWidgetHostViewMac : public RenderWidgetHostViewBase { public: - // The view will associate itself with the given widget. The native view must - // be hooked up immediately to the view hierarchy, or else when it is - // deleted it will delete this out from under the caller. - explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); virtual ~RenderWidgetHostViewMac(); RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } void SetDelegate(NSObject<RenderWidgetHostViewMacDelegate>* delegate); - // Implementation of RenderWidgetHostView: + // RenderWidgetHostView implementation. virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE; - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE; virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; - virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; virtual bool HasFocus() const OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; + virtual void SetShowingContextMenu(bool showing) OVERRIDE; + virtual void SetActive(bool active) OVERRIDE; + virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; + virtual void SetWindowVisibility(bool visible) OVERRIDE; + virtual void WindowFrameChanged() OVERRIDE; + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) OVERRIDE; + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + + // Implementation of RenderWidgetHostViewBase. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void DidBecomeSelected() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void TextInputStateChanged(ui::TextInputType state, @@ -211,16 +217,10 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void SelectionChanged(const string16& text, size_t offset, const ui::Range& range) OVERRIDE; - virtual void SetShowingContextMenu(bool showing) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; - virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; // See comment in RenderWidgetHostView! virtual gfx::Rect GetViewCocoaBounds() const OVERRIDE; - virtual void SetActive(bool active) OVERRIDE; - virtual void SetWindowVisibility(bool visible) OVERRIDE; - virtual void WindowFrameChanged() OVERRIDE; - virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void OnAccessibilityNotifications( const std::vector<AccessibilityHostMsg_NotificationParams>& params @@ -277,8 +277,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // to be reloaded. void ForceTextureReload(); - virtual void UnhandledWheelEvent( - const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void ProcessTouchAck(bool processed) OVERRIDE; virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE; @@ -348,6 +346,13 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { AcceleratedSurfaceContainerManagerMac plugin_container_manager_; private: + friend class RenderWidgetHostView; + + // The view will associate itself with the given widget. The native view must + // be hooked up immediately to the view hierarchy, or else when it is + // deleted it will delete this out from under the caller. + explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); + // If the window is at the root of the plugin container hierachy, // we need to update the geometry manually. void UpdatePluginGeometry(gfx::PluginWindowHandle window, diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 40ef236..f4bce4c 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -220,7 +220,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( } // static -void RenderWidgetHostView::GetDefaultScreenInfo( +void RenderWidgetHostViewBase::GetDefaultScreenInfo( WebKit::WebScreenInfo* results) { *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); } @@ -257,12 +257,6 @@ void RenderWidgetHostViewMac::SetDelegate( [cocoa_view_ setRWHVDelegate:delegate]; } -namespace render_widget_host_view_mac { -RenderWidgetHostView *CreateRenderWidgetHostView(RenderWidgetHost *widget) { - return new RenderWidgetHostViewMac(widget); -} -} - /////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewMac, RenderWidgetHostView implementation: @@ -497,7 +491,7 @@ void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { // a page? TODO(avi): decide // Don't update the cursor if a context menu is being shown. - if (showing_context_menu()) + if (IsShowingContextMenu()) return; // Can we synchronize to the event stream? Switch to -[NSWindow @@ -695,7 +689,7 @@ void RenderWidgetHostViewMac::SelectionChanged(const string16& text, } void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { - RenderWidgetHostView::SetShowingContextMenu(showing); + RenderWidgetHostViewBase::SetShowingContextMenu(showing); // If the menu was closed, restore the cursor to the saved version initially, // as the renderer will not re-send it if there was no change. @@ -1120,7 +1114,7 @@ void RenderWidgetHostViewMac::WindowFrameChanged() { } void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { - RenderWidgetHostView::SetBackground(background); + RenderWidgetHostViewBase::SetBackground(background); if (render_widget_host_) render_widget_host_->Send(new ViewMsg_SetBackground( render_widget_host_->routing_id(), background)); diff --git a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm index d053200..24003d5 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -103,7 +103,8 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperTest, // RenderWidgetHostViewMac self destructs (RenderWidgetHostViewMacCocoa // takes ownership) so no need to delete it ourselves. - RenderWidgetHostViewMac* rwhvm = new RenderWidgetHostViewMac(&render_widget); + RenderWidgetHostViewMac* rwhvm = static_cast<RenderWidgetHostViewMac*>( + RenderWidgetHostView::CreateViewForWidget(&render_widget)); RenderWidgetHostViewMacOwner* rwhwvm_owner = [[[RenderWidgetHostViewMacOwner alloc] diff --git a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm index 7e26064..93371d9 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm @@ -29,7 +29,8 @@ class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { old_rwhv_ = rvh()->view(); // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. - rwhv_mac_ = new RenderWidgetHostViewMac(rvh()); + rwhv_mac_ = static_cast<RenderWidgetHostViewMac*>( + RenderWidgetHostView::CreateViewForWidget(rvh())); rwhv_cocoa_.reset([rwhv_mac_->cocoa_view() retain]); } virtual void TearDown() { diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 33dcc25..fd2b64f 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -910,7 +910,7 @@ BackingStore* RenderWidgetHostViewWin::AllocBackingStore( } void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { - RenderWidgetHostView::SetBackground(background); + RenderWidgetHostViewBase::SetBackground(background); render_widget_host_->SetBackground(background); } diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 7da9120..cdac151 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -85,7 +85,7 @@ class RenderWidgetHostViewWin : public CWindowImpl<RenderWidgetHostViewWin, CWindow, RenderWidgetHostHWNDTraits>, - public RenderWidgetHostView, + public RenderWidgetHostViewBase, public content::NotificationObserver, public BrowserAccessibilityDelegate { public: @@ -148,29 +148,34 @@ class RenderWidgetHostViewWin MESSAGE_HANDLER(WM_GESTURE, OnGestureEvent) END_MSG_MAP() - // Implementation of RenderWidgetHostView: + // RenderWidgetHostView implementation. virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE; - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE; virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; - virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; virtual bool HasFocus() const OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) OVERRIDE; + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + + // Implementation of RenderWidgetHostViewBase. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void DidBecomeSelected() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void TextInputStateChanged(ui::TextInputType type, @@ -190,9 +195,6 @@ class RenderWidgetHostViewWin virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; - virtual void SetBackground(const SkBitmap& background) OVERRIDE; - virtual void UnhandledWheelEvent( - const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void ProcessTouchAck(bool processed) OVERRIDE; virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE; diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index b3276e7..045d1be 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -54,33 +54,50 @@ void SimulateUpdateRect(RenderWidgetHost* widget, // Subclass the RenderViewHost's view so that we can call Show(), etc., // without having side-effects. -class TestRenderWidgetHostView : public RenderWidgetHostView { +class TestRenderWidgetHostView : public RenderWidgetHostViewBase { public: explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); virtual ~TestRenderWidgetHostView(); + // RenderWidgetHostView implementation. virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE {} - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE {} - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE {} virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE {} - virtual void WasHidden() OVERRIDE {} virtual void SetSize(const gfx::Size& size) OVERRIDE {} virtual void SetBounds(const gfx::Rect& rect) OVERRIDE {} virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual void MovePluginWindows( - const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE {} - virtual void Focus() OVERRIDE {} - virtual void Blur() OVERRIDE {} virtual bool HasFocus() const OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; +#if defined(OS_MACOSX) + virtual void SetActive(bool active) OVERRIDE; + virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {} + virtual void SetWindowVisibility(bool visible) OVERRIDE {} + virtual void WindowFrameChanged() OVERRIDE {} +#endif // defined(OS_MACOSX) +#if defined(TOOLKIT_USES_GTK) + virtual GdkEventButton* GetLastMouseDown() OVERRIDE; +#if !defined(TOOLKIT_VIEWS) + virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; +#endif // !defined(TOOLKIT_VIEWS) +#endif // defined(TOOLKIT_USES_GTK) + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) OVERRIDE {} + + // RenderWidgetHostViewBase implementation. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE {} + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE {} + virtual void DidBecomeSelected() OVERRIDE {} + virtual void WasHidden() OVERRIDE {} + virtual void MovePluginWindows( + const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE {} + virtual void Focus() OVERRIDE {} + virtual void Blur() OVERRIDE {} virtual void SetIsLoading(bool is_loading) OVERRIDE {} virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE {} virtual void TextInputStateChanged(ui::TextInputType state, @@ -104,11 +121,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { int gpu_host_id) OVERRIDE; virtual void AcceleratedSurfaceSuspend() OVERRIDE; #if defined(OS_MACOSX) - virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {} virtual gfx::Rect GetViewCocoaBounds() const OVERRIDE; - virtual void SetActive(bool active) OVERRIDE; - virtual void SetWindowVisibility(bool visible) OVERRIDE {} - virtual void WindowFrameChanged() OVERRIDE {} virtual void PluginFocusChanged(bool focused, int plugin_id) OVERRIDE; virtual void StartPluginIme() OVERRIDE; virtual bool PostProcessEventForPluginIme( @@ -134,8 +147,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE {} virtual gfx::Rect GetRootWindowBounds() OVERRIDE; #endif - virtual void UnhandledWheelEvent( - const WebKit::WebMouseWheelEvent& event) OVERRIDE { } virtual void ProcessTouchAck(bool processed) OVERRIDE { } virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE { } @@ -152,10 +163,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { #if defined(TOOLKIT_USES_GTK) virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE { } virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE { } - virtual GdkEventButton* GetLastMouseDown() OVERRIDE; -#if !defined(TOOLKIT_VIEWS) - virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; -#endif // !defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_USES_GTK) virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; diff --git a/content/browser/tab_contents/interstitial_page_impl.cc b/content/browser/tab_contents/interstitial_page_impl.cc index 9f5184b..8a91f42 100644 --- a/content/browser/tab_contents/interstitial_page_impl.cc +++ b/content/browser/tab_contents/interstitial_page_impl.cc @@ -273,7 +273,8 @@ void InterstitialPageImpl::Hide() { // (Note that in unit-tests the RVH may not have a view). if (render_view_host_->view() && render_view_host_->view()->HasFocus() && tab_->GetRenderViewHost()->view()) { - tab_->GetRenderViewHost()->view()->Focus(); + RenderWidgetHostViewBase::FromRWHV( + tab_->GetRenderViewHost()->view())->Focus(); } render_view_host_->Shutdown(); @@ -594,7 +595,7 @@ void InterstitialPageImpl::SetSize(const gfx::Size& size) { void InterstitialPageImpl::Focus() { // Focus the native window. - render_view_host_->view()->Focus(); + RenderWidgetHostViewBase::FromRWHV(render_view_host_->view())->Focus(); } void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) { diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 30c6396b..3fd25e6 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -610,7 +610,7 @@ void RenderViewHostManager::CommitPending() { if (will_focus_location_bar) delegate_->SetFocusToLocationBar(false); else if (focus_render_view && render_view_host_->view()) - render_view_host_->view()->Focus(); + RenderWidgetHostViewBase::FromRWHV(render_view_host_->view())->Focus(); std::pair<RenderViewHost*, RenderViewHost*> details = std::make_pair(old_render_view_host, render_view_host_); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 370d825..126019a 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -292,7 +292,7 @@ TabContents::~TabContents() { if (GetNativeView()) { RenderViewHost* host = GetRenderViewHost(); if (host && host->view()) - host->view()->WillWmDestroy(); + RenderWidgetHostViewBase::FromRWHV(host->view())->WillWmDestroy(); } #endif @@ -761,7 +761,8 @@ void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { void TabContents::DidBecomeSelected() { controller_.SetActive(true); - RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); + RenderWidgetHostViewBase* rwhv = + RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); if (rwhv) { rwhv->DidBecomeSelected(); #if defined(OS_MACOSX) @@ -794,7 +795,8 @@ void TabContents::WasHidden() { // removes the |GetRenderViewHost()|; then when we actually destroy the // window, OnWindowPosChanged() notices and calls HideContents() (which // calls us). - RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); + RenderWidgetHostViewBase* rwhv = + RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); if (rwhv) rwhv->WasHidden(); } @@ -806,7 +808,8 @@ void TabContents::WasHidden() { } void TabContents::ShowContents() { - RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); + RenderWidgetHostViewBase* rwhv = + RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); if (rwhv) rwhv->DidBecomeSelected(); } diff --git a/content/browser/tab_contents/tab_contents_view_helper.cc b/content/browser/tab_contents/tab_contents_view_helper.cc index 75896d3c..4cbb7ce 100644 --- a/content/browser/tab_contents/tab_contents_view_helper.cc +++ b/content/browser/tab_contents/tab_contents_view_helper.cc @@ -92,8 +92,8 @@ RenderWidgetHostView* TabContentsViewHelper::CreateNewWidget( WebKit::WebPopupType popup_type) { content::RenderProcessHost* process = web_contents->GetRenderProcessHost(); RenderWidgetHost* widget_host = new RenderWidgetHost(process, route_id); - RenderWidgetHostView* widget_view = - RenderWidgetHostView::CreateViewForWidget(widget_host); + RenderWidgetHostViewBase* widget_view = + RenderWidgetHostViewBase::CreateViewForWidget(widget_host); if (!is_fullscreen) { // Popups should not get activated. widget_view->set_popup_type(popup_type); @@ -167,7 +167,8 @@ RenderWidgetHostView* TabContentsViewHelper::ShowCreatedWidget( if (web_contents->GetDelegate()) web_contents->GetDelegate()->RenderWidgetShowing(); - RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id); + RenderWidgetHostViewBase* widget_host_view = + RenderWidgetHostViewBase::FromRWHV(GetCreatedWidget(route_id)); if (is_fullscreen) { widget_host_view->InitAsFullscreen(web_contents->GetRenderWidgetHostView()); } else { diff --git a/content/browser/tab_contents/web_contents_view_mac.mm b/content/browser/tab_contents/web_contents_view_mac.mm index 21b3b36..9691ae1 100644 --- a/content/browser/tab_contents/web_contents_view_mac.mm +++ b/content/browser/tab_contents/web_contents_view_mac.mm @@ -102,8 +102,8 @@ RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget( return render_widget_host->view(); } - RenderWidgetHostViewMac* view = - new RenderWidgetHostViewMac(render_widget_host); + RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>( + RenderWidgetHostView::CreateViewForWidget(render_widget_host)); if (delegate()) { NSObject<RenderWidgetHostViewMacDelegate>* rw_delegate = delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host); |