From 9756ba445d7c6c7be8b9c885e944ccbf21742b3f Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Fri, 13 May 2011 17:01:46 +0000 Subject: Revert 85269 - Split the hierarchy. * Widget ---- Now recognizes a supplied NativeWidget via InitParams. If this is specified then a default one is not created. Is now created directly rather than using a factory. NativeWidget creation is not performed until Init() is called. This means some functions that rely on a NativeWidget must not be called until _AFTER_ Init() (explains some of the function call reordering in this CL, e.g. moving SetOpacity() until after Init()). ResetLastMouseMovedFlag() moved to this API so that BaseTabStrip can call it in a cross-platform way. Made last remaining unimplemented methods on Widget pass-thru to NativeWidget implementations. * WidgetWin/WidgetGtk ---- The NativeWidget implementations now both require a NativeWidgetDelegate implementation upon construction. This is passed through the constructor by the static factory method NativeWidget::CreateNativeWidget and by subclasses such as WindowWin, BubbleWidgetWin, etc. Some classes that are constructed directly (e.g. LockWindow, in ChromeOS) never have a Widget created for them, so they create the Widget themselves in their base class initializer. Code in these classes (and their WindowWin/WindowGtk, BrowserFrameWin, BrowserFrameGtk subclasses) must now call GetWidget() etc to call Widget API methods since they are no longer subclasses. static_casting to this (and derived) types must now be done on the Widget's native_widget(). GetWindow() is renamed to GetContainingWindow() to avoid naming conflicts. * Window ---- Window is now a subclass of Widget. Now recognizes a supplied NativeWindow via InitParams. If this is specified then a default one is not created. Window::CloseWindow becomes an override of Widget::Close. CloseAllSecondaryWindows() becomes CloseAllSecondaryWidgets() and moves to widget.h IsAppWindow() is removed and replaced by set_is_secondary_widget on Widget. * MenuHost ---- Subclasses Widget now. * TabContentsViewViews ---- It looks like the Gtk-views code here was still using the old implementation of the Native version of this class - i.e. a class that subclassed TabContentsView AND WidgetGtk. A no-no. I had to write NativeTabContentsViewGtk, which is almost identical to NativeTabContentsViewWin with the Gtk bits of TabContentsViewGtk thrown in. * BrowserFrame ---- Platform-specific functionality is now restricted to BrowserFrameWin/BrowserFrameGtk behind a NativeBrowserFrame interface. Construction is exposed via a static factory method on NativeBrowserFrame. BrowserFrame becomes a concrete class that now subclasses Window. As a result, it no longer needs a GetWindow() accessor method, so people with a BrowserFrame* can just call Window methods directly on it. It is constructed directly, replacing the BrowserFrame::Create() method. NativeBrowserFrameDelegate is no longer needed. BrowserFrameChromeos is simpler as a couple of #ifdefs in BrowserFrame, so I got rid of that too. * AutocompletePopupWin/Gtk ---- No longer required. AutocompletePopupContentsView now just uses a Widget directly. * There is some lingering ugliness: - If you set a native_window field on Window::InitParams you must also manually set widget_init_params.native_widget. I will make InitParams do more of this automatically later. - It'd be nice for the ContentsView to be specified via InitParams. I'll get to this later. - NativeBrowserFrame could probably disappear as an interface. It only exists to provide a couple of methods that may be implemented in other ways. - delete_on_destroy should now be an ownership directionality enum. I will do this later. - Secondary-widgetness should somehow be inferred from transience. Later. - set_focus_on_creation for both the NativeWidgets should probably move to Widget if it is really needed. - WidgetWin/Gtk::SetInitialFocus seems like it could move to Widget. - I need to clean up function order in some cases. BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7012006 TBR=ben@chromium.org Review URL: http://codereview.chromium.org/7011038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85283 0039d316-1c4b-4281-b951-d872f2087c98 --- views/widget/widget_win.h | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'views/widget/widget_win.h') diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index d013ddb..3c2974b 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -23,6 +23,7 @@ #include "views/ime/input_method_delegate.h" #include "views/layout/layout_manager.h" #include "views/widget/native_widget.h" +#include "views/widget/widget.h" namespace ui { class ViewProp; @@ -44,6 +45,8 @@ namespace internal { class NativeWidgetDelegate; } +RootView* GetRootViewForHWND(HWND hwnd); + // A Windows message reflected from other windows. This message is sent // with the following arguments: // hWnd - Target window @@ -77,11 +80,12 @@ const int WM_NCUAHDRAWFRAME = 0xAF; // /////////////////////////////////////////////////////////////////////////////// class WidgetWin : public ui::WindowImpl, + public Widget, public NativeWidget, public MessageLoopForUI::Observer, public internal::InputMethodDelegate { public: - explicit WidgetWin(internal::NativeWidgetDelegate* delegate); + WidgetWin(); virtual ~WidgetWin(); // Returns true if we are on Windows Vista or greater and composition is @@ -109,6 +113,20 @@ class WidgetWin : public ui::WindowImpl, // Clear a view that has recently been removed on a hierarchy change. void ClearAccessibilityViewEvent(View* view); + // Overridden from Widget: + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; + virtual bool GetAccelerator(int cmd_id, + ui::Accelerator* accelerator) OVERRIDE; + virtual Window* GetWindow() OVERRIDE; + virtual const Window* GetWindow() const OVERRIDE; + virtual void ViewHierarchyChanged(bool is_add, View *parent, + View *child) OVERRIDE; + virtual void NotifyAccessibilityEvent( + View* view, + ui::AccessibilityTypes::Event event_type, + bool send_native_event); + BOOL IsWindow() const { return ::IsWindow(GetNativeView()); } @@ -165,26 +183,24 @@ class WidgetWin : public ui::WindowImpl, return ::GetClientRect(GetNativeView(), rect); } + // Resets the last move flag so that we can go around the optimization + // that disregards duplicate mouse moves when ending animation requires + // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation + // to cause the close button to highlight. + void ResetLastMouseMoveFlag() { + last_mouse_event_was_move_ = false; + } + // Overridden from NativeWidget: virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; virtual Widget* GetWidget() OVERRIDE; - virtual const Widget* GetWidget() const OVERRIDE; - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; - virtual Window* GetContainingWindow() OVERRIDE; - virtual const Window* GetContainingWindow() const OVERRIDE; - virtual void ViewRemoved(View* view) OVERRIDE; virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; virtual TooltipManager* GetTooltipManager() const OVERRIDE; virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; virtual void SetMouseCapture() OVERRIDE; virtual void ReleaseMouseCapture() OVERRIDE; virtual bool HasMouseCapture() const OVERRIDE; - virtual bool IsMouseButtonDown() const OVERRIDE; virtual InputMethod* GetInputMethodNative() OVERRIDE; virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; @@ -427,7 +443,6 @@ class WidgetWin : public ui::WindowImpl, virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; // A delegate implementation that handles events received here. - // See class documentation for Widget in widget.h for a note about ownership. internal::NativeWidgetDelegate* delegate_; // The following factory is used for calls to close the WidgetWin @@ -466,7 +481,8 @@ class WidgetWin : public ui::WindowImpl, // A factory that allows us to schedule a redraw for layered windows. ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; - // See class documentation for Widget in widget.h for a note about ownership. + // Whether or not the window should delete itself when it is destroyed. + // Set this to false via its setter for stack allocated instances. bool delete_on_destroy_; // True if we are allowed to update the layered window from the DIB backing -- cgit v1.1