diff options
author | vollick@google.com <vollick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 17:48:20 +0000 |
---|---|---|
committer | vollick@google.com <vollick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 17:48:20 +0000 |
commit | 03d12f0c42aa5c11673e9b2dcec1d1966fb49589 (patch) | |
tree | e5bd24af8ade6f77100576bb144a90fe7a8374df /content | |
parent | 13fc4b42892ee3f0821e49a368afbd2693bcf227 (diff) | |
download | chromium_src-03d12f0c42aa5c11673e9b2dcec1d1966fb49589.zip chromium_src-03d12f0c42aa5c11673e9b2dcec1d1966fb49589.tar.gz chromium_src-03d12f0c42aa5c11673e9b2dcec1d1966fb49589.tar.bz2 |
Revert 121896 - Extract RenderWidgetHostView (for Chrome-like embedders) vs. RenderWidgetHostViewBase
(for content itself, and for embedders porting to other platforms).
Attempting to fix win_aura build failure.
BUG=98716
Review URL: http://codereview.chromium.org/9307055
TBR=joi@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9348090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
23 files changed, 246 insertions, 353 deletions
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index 924efe4..53a3ee1 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -74,8 +74,7 @@ class ScopedSendOnIOThread { bool cancelled_; }; -RenderWidgetHostViewBase* GetRenderWidgetHostViewFromSurfaceID( - int surface_id) { +RenderWidgetHostView* GetRenderWidgetHostViewFromSurfaceID(int surface_id) { int render_process_id = 0; int render_widget_id = 0; if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( @@ -89,7 +88,7 @@ RenderWidgetHostViewBase* GetRenderWidgetHostViewFromSurfaceID( RenderWidgetHost* host = static_cast<RenderWidgetHost*>( process->GetListenerByID(render_widget_id)); - return host ? RenderWidgetHostViewBase::FromRWHV(host->view()) : NULL; + return host ? host->view() : NULL; } } // namespace @@ -245,8 +244,7 @@ void GpuProcessHostUIShim::OnResizeView(int32 surface_id, host_id_, new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); - RenderWidgetHostViewBase* view = - GetRenderWidgetHostViewFromSurfaceID(surface_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID(surface_id); if (!view) return; @@ -289,7 +287,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( params.surface_handle, TransportDIB::DefaultHandleValue())); - RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( params.surface_id); if (!view) return; @@ -344,7 +342,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( host_id_, new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); - RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( params.surface_id); if (!view) return; @@ -364,8 +362,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( host_id_, new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); - RenderWidgetHostViewBase* view = - GetRenderWidgetHostViewFromSurfaceID(params.surface_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + params.surface_id); if (!view) return; @@ -379,8 +377,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend(int32 surface_id) { TRACE_EVENT0("renderer", "GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend"); - RenderWidgetHostViewBase* view = - GetRenderWidgetHostViewFromSurfaceID(surface_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID(surface_id); if (!view) return; @@ -391,7 +388,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend(int32 surface_id) { void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { - RenderWidgetHostViewBase* view = GetRenderWidgetHostViewFromSurfaceID( + RenderWidgetHostView* 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 3252504..fe0f9f2 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 564543d..1a6b65e 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) - : view_(NULL), - renderer_initialized_(false), + : 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_ = RenderWidgetHostViewBase::FromRWHV(view); + view_ = view; if (!view_) { GpuSurfaceTracker::Get()->SetSurfaceHandle( @@ -160,10 +160,6 @@ void RenderWidgetHost::SetView(RenderWidgetHostView* view) { } } -RenderWidgetHostView* RenderWidgetHost::view() const { - return view_; -} - gfx::NativeViewId RenderWidgetHost::GetNativeViewId() const { if (view_) return view_->GetNativeViewId(); @@ -960,7 +956,7 @@ void RenderWidgetHost::OnMsgSetTooltipText( } } if (view()) - view_->SetTooltipText(wrapped_tooltip_text); + view()->SetTooltipText(wrapped_tooltip_text); } void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { @@ -1267,7 +1263,7 @@ void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id, if (view_) view_->GetScreenInfo(results); else - RenderWidgetHostViewBase::GetDefaultScreenInfo(results); + RenderWidgetHostView::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 46b0b83..59f8eaf 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -32,7 +32,6 @@ class BackingStore; struct EditCommand; class RenderWidgetHostView; -class RenderWidgetHostViewBase; class TransportDIB; struct ViewHostMsg_UpdateRect_Params; class WebCursor; @@ -156,7 +155,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; + RenderWidgetHostView* view() const { return view_; } content::RenderProcessHost* process() const { return process_; } int routing_id() const { return routing_id_; } @@ -541,13 +540,6 @@ 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. @@ -668,6 +660,13 @@ 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 8cda30f8..a279c88 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->GetBackground().width()); - EXPECT_EQ(4, view->GetBackground().height()); - EXPECT_EQ(background.getSize(), view->GetBackground().getSize()); + EXPECT_EQ(4, view->background().width()); + EXPECT_EQ(4, view->background().height()); + EXPECT_EQ(background.getSize(), view->background().getSize()); EXPECT_TRUE(0 == memcmp(background.getPixels(), - view->GetBackground().getPixels(), + view->background().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 83cc1b7..53768f2 100644 --- a/content/browser/renderer_host/render_widget_host_view.cc +++ b/content/browser/renderer_host/render_widget_host_view.cc @@ -15,13 +15,7 @@ #include "content/browser/renderer_host/gtk_window_utils.h" #endif -RenderWidgetHostView::RenderWidgetHostView() { -} - -RenderWidgetHostView::~RenderWidgetHostView() { -} - -RenderWidgetHostViewBase::RenderWidgetHostViewBase() +RenderWidgetHostView::RenderWidgetHostView() : popup_type_(WebKit::WebPopupTypeNone), mouse_locked_(false), showing_context_menu_(false), @@ -29,54 +23,34 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() selection_range_(ui::Range::InvalidRange()) { } -RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { +RenderWidgetHostView::~RenderWidgetHostView() { DCHECK(!mouse_locked_); } -// 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) { +void RenderWidgetHostView::SetBackground(const SkBitmap& background) { background_ = background; } -const SkBitmap& RenderWidgetHostViewBase::GetBackground() { - return background_; -} - BrowserAccessibilityManager* - RenderWidgetHostViewBase::GetBrowserAccessibilityManager() const { + RenderWidgetHostView::GetBrowserAccessibilityManager() const { return browser_accessibility_manager_.get(); } -void RenderWidgetHostViewBase::SetBrowserAccessibilityManager( +void RenderWidgetHostView::SetBrowserAccessibilityManager( BrowserAccessibilityManager* manager) { browser_accessibility_manager_.reset(manager); } -void RenderWidgetHostViewBase::SelectionChanged(const string16& text, - size_t offset, - const ui::Range& range) { +void RenderWidgetHostView::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()); } -bool RenderWidgetHostViewBase::IsShowingContextMenu() const { - return showing_context_menu_; -} - -void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { +void RenderWidgetHostView::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 8141475..a93fef8 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -68,11 +68,9 @@ struct WebScreenInfo; // the surrounding environment and passing them to the RenderWidgetHost, and // for actually displaying the content of the RenderWidgetHost when it // changes. -// -// TODO(joi): Move this to content/public/browser -class CONTENT_EXPORT RenderWidgetHostView { +class RenderWidgetHostView { public: - virtual ~RenderWidgetHostView(); + CONTENT_EXPORT virtual ~RenderWidgetHostView(); // Platform-specific creator. Use this to construct new RenderWidgetHostViews // rather than using RenderWidgetHostViewWin & friends. @@ -92,9 +90,26 @@ class CONTENT_EXPORT 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; @@ -108,8 +123,14 @@ class CONTENT_EXPORT RenderWidgetHostView { virtual gfx::NativeViewId GetNativeViewId() const = 0; virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; - // Set focus to the associated View component. + // 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. virtual void Focus() = 0; + virtual void Blur() = 0; + // Returns true if the View currently has the focus. virtual bool HasFocus() const = 0; @@ -124,111 +145,6 @@ class CONTENT_EXPORT 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; @@ -279,9 +195,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView { virtual void SetTooltipText(const string16& tooltip_text) = 0; // Notifies the View that the renderer text selection has changed. - virtual void SelectionChanged(const string16& text, - size_t offset, - const ui::Range& range); + CONTENT_EXPORT 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 @@ -289,6 +205,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public 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; @@ -313,12 +232,32 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public 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; @@ -361,6 +300,12 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public 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) @@ -376,6 +321,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public 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 @@ -390,31 +337,29 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView { virtual bool LockMouse() = 0; virtual void UnlockMouse() = 0; - virtual void OnAccessibilityNotifications( - const std::vector<AccessibilityHostMsg_NotificationParams>& params) { - } - - virtual void SetBackground(const SkBitmap& background) OVERRIDE; - virtual const SkBitmap& GetBackground() OVERRIDE; - - 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_; } + // 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 OnAccessibilityNotifications( + const std::vector<AccessibilityHostMsg_NotificationParams>& params) { + } + + 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. - RenderWidgetHostViewBase(); + CONTENT_EXPORT RenderWidgetHostView(); // Whether this view is a popup and what kind of popup it is (select, // autofill...). @@ -448,7 +393,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView { // Manager of the tree representation of the WebKit render tree. scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; - DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostView); }; #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 272eb3b..12bcda1 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) { - RenderWidgetHostViewBase::SetBackground(background); + RenderWidgetHostView::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 RenderWidgetHostViewBase::GetDefaultScreenInfo( +void RenderWidgetHostView::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 aea4688..f7c1ea6 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 RenderWidgetHostViewAura - : public RenderWidgetHostViewBase, +class CONTENT_EXPORT RenderWidgetHostViewAura + : NON_EXPORTED_BASE(public RenderWidgetHostView), #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) public ui::CompositorObserver, #endif @@ -49,34 +49,29 @@ class RenderWidgetHostViewAura public: virtual ~RenderWidgetHostViewAura(); - // RenderWidgetHostView implementation. - virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; + // 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; 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, @@ -108,8 +103,11 @@ class 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 c84dab1..5614fd4 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->IsShowingContextMenu()) { + if (!host_view->showing_context_menu()) { 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) { - RenderWidgetHostViewBase::SelectionChanged(text, offset, range); + RenderWidgetHostView::SelectionChanged(text, offset, range); if (text.empty() || range.is_empty()) return; @@ -1027,7 +1027,7 @@ void RenderWidgetHostViewGtk::AcceleratedSurfaceSuspend() { void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { - RenderWidgetHostViewBase::SetBackground(background); + RenderWidgetHostView::SetBackground(background); host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); } @@ -1409,7 +1409,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( } // static -void RenderWidgetHostViewBase::GetDefaultScreenInfo( +void RenderWidgetHostView::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 9adc0d1..c709483 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -44,42 +44,33 @@ typedef struct _GtkSelectionData GtkSelectionData; // ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. // ----------------------------------------------------------------------------- -class RenderWidgetHostViewGtk : public RenderWidgetHostViewBase { +class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { 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, @@ -107,8 +98,16 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostViewBase { 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 fd9aab9..3208611 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -158,47 +158,41 @@ class RenderWidgetHostViewMacEditCommandHelper; // If the render process dies, the RenderWidgetHost* goes away and all // references to it must become NULL." // -class RenderWidgetHostViewMac : public RenderWidgetHostViewBase { +class RenderWidgetHostViewMac : public RenderWidgetHostView { 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); - // RenderWidgetHostView implementation. + // Implementation of RenderWidgetHostView: 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, @@ -217,10 +211,16 @@ class RenderWidgetHostViewMac : public RenderWidgetHostViewBase { 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,6 +277,8 @@ class RenderWidgetHostViewMac : public RenderWidgetHostViewBase { // 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; @@ -346,13 +348,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostViewBase { 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 f4bce4c..40ef236 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 RenderWidgetHostViewBase::GetDefaultScreenInfo( +void RenderWidgetHostView::GetDefaultScreenInfo( WebKit::WebScreenInfo* results) { *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); } @@ -257,6 +257,12 @@ void RenderWidgetHostViewMac::SetDelegate( [cocoa_view_ setRWHVDelegate:delegate]; } +namespace render_widget_host_view_mac { +RenderWidgetHostView *CreateRenderWidgetHostView(RenderWidgetHost *widget) { + return new RenderWidgetHostViewMac(widget); +} +} + /////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewMac, RenderWidgetHostView implementation: @@ -491,7 +497,7 @@ void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { // a page? TODO(avi): decide // Don't update the cursor if a context menu is being shown. - if (IsShowingContextMenu()) + if (showing_context_menu()) return; // Can we synchronize to the event stream? Switch to -[NSWindow @@ -689,7 +695,7 @@ void RenderWidgetHostViewMac::SelectionChanged(const string16& text, } void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { - RenderWidgetHostViewBase::SetShowingContextMenu(showing); + RenderWidgetHostView::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. @@ -1114,7 +1120,7 @@ void RenderWidgetHostViewMac::WindowFrameChanged() { } void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { - RenderWidgetHostViewBase::SetBackground(background); + RenderWidgetHostView::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 24003d5..d053200 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,8 +103,7 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperTest, // RenderWidgetHostViewMac self destructs (RenderWidgetHostViewMacCocoa // takes ownership) so no need to delete it ourselves. - RenderWidgetHostViewMac* rwhvm = static_cast<RenderWidgetHostViewMac*>( - RenderWidgetHostView::CreateViewForWidget(&render_widget)); + RenderWidgetHostViewMac* rwhvm = new RenderWidgetHostViewMac(&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 93371d9..7e26064 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,8 +29,7 @@ class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { old_rwhv_ = rvh()->view(); // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. - rwhv_mac_ = static_cast<RenderWidgetHostViewMac*>( - RenderWidgetHostView::CreateViewForWidget(rvh())); + rwhv_mac_ = new RenderWidgetHostViewMac(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 fd2b64f..33dcc25 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) { - RenderWidgetHostViewBase::SetBackground(background); + RenderWidgetHostView::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 cdac151..7da9120 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 RenderWidgetHostViewBase, + public RenderWidgetHostView, public content::NotificationObserver, public BrowserAccessibilityDelegate { public: @@ -148,34 +148,29 @@ class RenderWidgetHostViewWin MESSAGE_HANDLER(WM_GESTURE, OnGestureEvent) END_MSG_MAP() - // RenderWidgetHostView implementation. + // Implementation of RenderWidgetHostView: 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, @@ -195,6 +190,9 @@ 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 045d1be..b3276e7 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -54,50 +54,33 @@ void SimulateUpdateRect(RenderWidgetHost* widget, // Subclass the RenderViewHost's view so that we can call Show(), etc., // without having side-effects. -class TestRenderWidgetHostView : public RenderWidgetHostViewBase { +class TestRenderWidgetHostView : public RenderWidgetHostView { 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, @@ -121,7 +104,11 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { 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( @@ -147,6 +134,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { 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 { } @@ -163,6 +152,10 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { #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 8a91f42..9f5184b 100644 --- a/content/browser/tab_contents/interstitial_page_impl.cc +++ b/content/browser/tab_contents/interstitial_page_impl.cc @@ -273,8 +273,7 @@ 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()) { - RenderWidgetHostViewBase::FromRWHV( - tab_->GetRenderViewHost()->view())->Focus(); + tab_->GetRenderViewHost()->view()->Focus(); } render_view_host_->Shutdown(); @@ -595,7 +594,7 @@ void InterstitialPageImpl::SetSize(const gfx::Size& size) { void InterstitialPageImpl::Focus() { // Focus the native window. - RenderWidgetHostViewBase::FromRWHV(render_view_host_->view())->Focus(); + 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 3fd25e6..30c6396b 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()) - RenderWidgetHostViewBase::FromRWHV(render_view_host_->view())->Focus(); + 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 126019a..370d825 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()) - RenderWidgetHostViewBase::FromRWHV(host->view())->WillWmDestroy(); + host->view()->WillWmDestroy(); } #endif @@ -761,8 +761,7 @@ void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { void TabContents::DidBecomeSelected() { controller_.SetActive(true); - RenderWidgetHostViewBase* rwhv = - RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); + RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); if (rwhv) { rwhv->DidBecomeSelected(); #if defined(OS_MACOSX) @@ -795,8 +794,7 @@ void TabContents::WasHidden() { // removes the |GetRenderViewHost()|; then when we actually destroy the // window, OnWindowPosChanged() notices and calls HideContents() (which // calls us). - RenderWidgetHostViewBase* rwhv = - RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); + RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); if (rwhv) rwhv->WasHidden(); } @@ -808,8 +806,7 @@ void TabContents::WasHidden() { } void TabContents::ShowContents() { - RenderWidgetHostViewBase* rwhv = - RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); + RenderWidgetHostView* rwhv = 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 4cbb7ce..75896d3c 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); - RenderWidgetHostViewBase* widget_view = - RenderWidgetHostViewBase::CreateViewForWidget(widget_host); + RenderWidgetHostView* widget_view = + RenderWidgetHostView::CreateViewForWidget(widget_host); if (!is_fullscreen) { // Popups should not get activated. widget_view->set_popup_type(popup_type); @@ -167,8 +167,7 @@ RenderWidgetHostView* TabContentsViewHelper::ShowCreatedWidget( if (web_contents->GetDelegate()) web_contents->GetDelegate()->RenderWidgetShowing(); - RenderWidgetHostViewBase* widget_host_view = - RenderWidgetHostViewBase::FromRWHV(GetCreatedWidget(route_id)); + RenderWidgetHostView* widget_host_view = 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 9691ae1..21b3b36 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 = static_cast<RenderWidgetHostViewMac*>( - RenderWidgetHostView::CreateViewForWidget(render_widget_host)); + RenderWidgetHostViewMac* view = + new RenderWidgetHostViewMac(render_widget_host); if (delegate()) { NSObject<RenderWidgetHostViewMacDelegate>* rw_delegate = delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host); |