diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 17:37:11 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 17:37:11 +0000 |
commit | 80d560d2c50848be0100db7ce00fedac298a3187 (patch) | |
tree | 93e1e5fbdbd8a0a1662ec6c6c8ed2181823d6132 | |
parent | fbcadc38c944402bc183b4c154251480b27ef2a3 (diff) | |
download | chromium_src-80d560d2c50848be0100db7ce00fedac298a3187.zip chromium_src-80d560d2c50848be0100db7ce00fedac298a3187.tar.gz chromium_src-80d560d2c50848be0100db7ce00fedac298a3187.tar.bz2 |
Move RootView construction, DefaultThemeProvider construction, and FocusTraversable implementation to Widget base class.
BUG=72040
TEST=existing
Review URL: http://codereview.chromium.org/6591009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76063 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/widget/widget.cc | 68 | ||||
-rw-r--r-- | views/widget/widget.h | 42 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 100 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 29 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 111 | ||||
-rw-r--r-- | views/widget/widget_win.h | 35 |
6 files changed, 139 insertions, 246 deletions
diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 64c6af0..487b3c0 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -4,28 +4,40 @@ #include "views/widget/widget.h" +#include "base/logging.h" +#include "views/widget/default_theme_provider.h" +#include "views/widget/root_view.h" + namespace views { //////////////////////////////////////////////////////////////////////////////// // Widget, public: -Widget::Widget() { +Widget::Widget() : delegate_(NULL) { +} + +Widget::~Widget() { } void Widget::Init(gfx::NativeView parent, const gfx::Rect& bounds) { + // TODO(beng): This is called before the native widget is created. + GetRootView(); + default_theme_provider_.reset(new DefaultThemeProvider); } void Widget::InitWithWidget(Widget* parent, const gfx::Rect& bounds) { } WidgetDelegate* Widget::GetWidgetDelegate() { - return NULL; + return delegate_; } void Widget::SetWidgetDelegate(WidgetDelegate* delegate) { + delegate_ = delegate; } void Widget::SetContentsView(View* view) { + root_view_->SetContentsView(view); } void Widget::GetBounds(gfx::Rect* out, bool including_frame) const { @@ -63,7 +75,11 @@ void Widget::SetAlwaysOnTop(bool on_top) { } RootView* Widget::GetRootView() { - return NULL; + if (!root_view_.get()) { + // First time the root view is being asked for, create it now. + root_view_.reset(CreateRootView()); + } + return root_view_.get(); } Widget* Widget::GetRootWidget() const { @@ -113,7 +129,7 @@ ThemeProvider* Widget::GetThemeProvider() const { } ThemeProvider* Widget::GetDefaultThemeProvider() const { - return NULL; + return default_theme_provider_.get(); } FocusManager* Widget::GetFocusManager() { @@ -143,13 +159,55 @@ void Widget::SetCursor(gfx::NativeCursor cursor) { } FocusTraversable* Widget::GetFocusTraversable() { - return NULL; + return root_view_.get(); } void Widget::ThemeChanged() { + root_view_->ThemeChanged(); } void Widget::LocaleChanged() { + root_view_->LocaleChanged(); +} + +void Widget::SetFocusTraversableParent(FocusTraversable* parent) { + root_view_->SetFocusTraversableParent(parent); +} + +void Widget::SetFocusTraversableParentView(View* parent_view) { + root_view_->SetFocusTraversableParentView(parent_view); +} + +//////////////////////////////////////////////////////////////////////////////// +// Widget, protected: + +RootView* Widget::CreateRootView() { + return new RootView(this); +} + +void Widget::DestroyRootView() { + root_view_.reset(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Widget, FocusTraversable implementation: + +FocusSearch* Widget::GetFocusSearch() { + return root_view_->GetFocusSearch(); +} + +FocusTraversable* Widget::GetFocusTraversableParent() { + // We are a proxy to the root view, so we should be bypassed when traversing + // up and as a result this should not be called. + NOTREACHED(); + return NULL; +} + +View* Widget::GetFocusTraversableParentView() { + // We are a proxy to the root view, so we should be bypassed when traversing + // up and as a result this should not be called. + NOTREACHED(); + return NULL; } } // namespace views diff --git a/views/widget/widget.h b/views/widget/widget.h index 45e128c..7d2d9a3 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -8,7 +8,9 @@ #include <vector> +#include "base/scoped_ptr.h" #include "ui/gfx/native_widget_types.h" +#include "views/focus/focus_manager.h" namespace gfx { class Path; @@ -25,8 +27,7 @@ using ui::ThemeProvider; namespace views { -class FocusManager; -class FocusTraversable; +class DefaultThemeProvider; class RootView; class TooltipManager; class View; @@ -50,10 +51,8 @@ class Window; // implementation. Multiple inheritance is required for this // transitional step. // -class Widget { +class Widget : public FocusTraversable { public: - virtual ~Widget() { } - enum TransparencyParam { Transparent, NotTransparent @@ -74,6 +73,8 @@ class Widget { DontMirrorOriginInRTL }; + virtual ~Widget(); + // Creates a transient popup widget specific to the current platform. // If |mirror_in_rtl| is set to MirrorOriginInRTL, the contents of the // popup will be mirrored if the current locale is RTL. You should use @@ -257,7 +258,38 @@ class Widget { // changed. virtual void LocaleChanged(); + void SetFocusTraversableParent(FocusTraversable* parent); + void SetFocusTraversableParentView(View* parent_view); + + protected: + // Creates the RootView to be used within this Widget. Subclasses may override + // to create custom RootViews that do specialized event processing. + // TODO(beng): Investigate whether or not this is needed. + virtual RootView* CreateRootView(); + + // Provided to allow the WidgetWin/Gtk implementations to destroy the RootView + // _before_ the focus manager/tooltip manager. + // TODO(beng): remove once we fold those objects onto this one. + void DestroyRootView(); + + // Overridden from FocusTraversable: + virtual FocusSearch* GetFocusSearch(); + virtual FocusTraversable* GetFocusTraversableParent(); + virtual View* GetFocusTraversableParentView(); + private: + // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is + // being used. + WidgetDelegate* delegate_; + + // The root of the View hierarchy attached to this window. + // WARNING: see warning in tooltip_manager_ for ordering dependencies with + // this and tooltip_manager_. + scoped_ptr<RootView> root_view_; + + // A theme provider to use when no other theme provider is specified. + scoped_ptr<DefaultThemeProvider> default_theme_provider_; + DISALLOW_COPY_AND_ASSIGN(Widget); }; diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 28e7b3c..1485820 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -22,7 +22,6 @@ #include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/path.h" #include "views/focus/view_storage.h" -#include "views/widget/default_theme_provider.h" #include "views/widget/drop_target_gtk.h" #include "views/widget/gtk_views_fixed.h" #include "views/widget/gtk_views_window.h" @@ -278,6 +277,7 @@ WidgetGtk::WidgetGtk(Type type) } WidgetGtk::~WidgetGtk() { + DestroyRootView(); DCHECK(delete_on_destroy_ || widget_ == NULL); if (type_ != TYPE_CHILD) ActiveWindowWatcherX::RemoveObserver(this); @@ -415,14 +415,6 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) { } } -void WidgetGtk::SetFocusTraversableParent(FocusTraversable* parent) { - root_view_->SetFocusTraversableParent(parent); -} - -void WidgetGtk::SetFocusTraversableParentView(View* parent_view) { - root_view_->SetFocusTraversableParentView(parent_view); -} - void WidgetGtk::IsActiveChanged() { if (GetWidgetDelegate()) GetWidgetDelegate()->IsActiveChanged(IsActive()); @@ -500,12 +492,9 @@ void WidgetGtk::InitWithWidget(Widget* parent, void WidgetGtk::Init(GtkWidget* parent, const gfx::Rect& bounds) { + Widget::Init(parent, bounds); if (type_ != TYPE_CHILD) ActiveWindowWatcherX::AddObserver(this); - // Force creation of the RootView if it hasn't been created yet. - GetRootView(); - - default_theme_provider_.reset(new DefaultThemeProvider()); // Make container here. CreateGtkWidget(parent, bounds); @@ -527,7 +516,7 @@ void WidgetGtk::Init(GtkWidget* parent, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); - SetRootViewForWidget(widget_, root_view_.get()); + SetRootViewForWidget(widget_, GetRootView()); g_signal_connect_after(G_OBJECT(window_contents_), "size_request", G_CALLBACK(&OnSizeRequestThunk), this); @@ -614,18 +603,6 @@ void WidgetGtk::Init(GtkWidget* parent, } } -WidgetDelegate* WidgetGtk::GetWidgetDelegate() { - return delegate_; -} - -void WidgetGtk::SetWidgetDelegate(WidgetDelegate* delegate) { - delegate_ = delegate; -} - -void WidgetGtk::SetContentsView(View* view) { - root_view_->SetContentsView(view); -} - void WidgetGtk::GetBounds(gfx::Rect* out, bool including_frame) const { if (!widget_) { // Due to timing we can get a request for the bounds after Close. @@ -757,14 +734,6 @@ void WidgetGtk::SetAlwaysOnTop(bool on_top) { gtk_window_set_keep_above(GTK_WINDOW(widget_), on_top); } -RootView* WidgetGtk::GetRootView() { - if (!root_view_.get()) { - // First time the root view is being asked for, create it now. - root_view_.reset(CreateRootView()); - } - return root_view_.get(); -} - Widget* WidgetGtk::GetRootWidget() const { GtkWidget* parent = widget_; GtkWidget* last_parent = parent; @@ -822,10 +791,6 @@ ThemeProvider* WidgetGtk::GetThemeProvider() const { return GetWidgetThemeProvider(this); } -ThemeProvider* WidgetGtk::GetDefaultThemeProvider() const { - return default_theme_provider_.get(); -} - FocusManager* WidgetGtk::GetFocusManager() { if (focus_manager_) return focus_manager_; @@ -898,39 +863,6 @@ void WidgetGtk::SetCursor(gfx::NativeCursor cursor) { gdk_window_set_cursor(widget_->window, cursor); } -FocusTraversable* WidgetGtk::GetFocusTraversable() { - return root_view_.get(); -} - -void WidgetGtk::ThemeChanged() { - root_view_->ThemeChanged(); -} - -void WidgetGtk::LocaleChanged() { - root_view_->LocaleChanged(); -} - -//////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, FocusTraversable implementation: - -FocusSearch* WidgetGtk::GetFocusSearch() { - return root_view_->GetFocusSearch(); -} - -FocusTraversable* WidgetGtk::GetFocusTraversableParent() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - -View* WidgetGtk::GetFocusTraversableParentView() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - void WidgetGtk::ClearNativeFocus() { DCHECK(type_ != TYPE_CHILD); if (!GetNativeView()) { @@ -1009,7 +941,7 @@ void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) { // preferred size for these would prevents us from setting smaller window // sizes. if (type_ == TYPE_CHILD) { - gfx::Size size(root_view_->GetPreferredSize()); + gfx::Size size(GetRootView()->GetPreferredSize()); requisition->width = size.width(); requisition->height = size.height(); } @@ -1024,8 +956,8 @@ void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { if (new_size == size_) return; size_ = new_size; - root_view_->SetBounds(0, 0, allocation->width, allocation->height); - root_view_->SchedulePaint(); + GetRootView()->SetBounds(0, 0, allocation->width, allocation->height); + GetRootView()->SchedulePaint(); } gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { @@ -1057,7 +989,7 @@ gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { gfx::CanvasSkiaPaint canvas(event); if (!canvas.is_empty()) { canvas.set_composite_alpha(is_transparent()); - root_view_->Paint(&canvas); + GetRootView()->Paint(&canvas); } return false; // False indicates other widgets should get the event as well. } @@ -1168,7 +1100,7 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { ui::EF_MIDDLE_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN)); MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags); - root_view_->OnMouseMoved(mouse_move); + GetRootView()->OnMouseMoved(mouse_move); } return false; @@ -1177,7 +1109,7 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { last_mouse_event_was_move_ = false; if (!has_capture_ && !is_mouse_down_) - root_view_->ProcessOnMouseExited(); + GetRootView()->ProcessOnMouseExited(); return false; } @@ -1189,7 +1121,7 @@ gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { last_mouse_event_was_move_ = false; int flags = Event::GetFlagsFromGdkState(event->state); MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED, x, y, flags); - root_view_->OnMouseDragged(mouse_drag); + GetRootView()->OnMouseDragged(mouse_drag); return true; } gfx::Point screen_loc(event->x_root, event->y_root); @@ -1203,7 +1135,7 @@ gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { last_mouse_event_was_move_ = true; int flags = Event::GetFlagsFromGdkState(event->state); MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags); - root_view_->OnMouseMoved(mouse_move); + GetRootView()->OnMouseMoved(mouse_move); return true; } @@ -1266,7 +1198,7 @@ gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { bool handled = false; // Dispatch the key event to View hierarchy first. - handled = root_view_->ProcessKeyEvent(key); + handled = GetRootView()->ProcessKeyEvent(key); // Dispatch the key event to native GtkWidget hierarchy. // To prevent GtkWindow from handling the key event as a keybinding, we need @@ -1354,7 +1286,7 @@ void WidgetGtk::ReleaseGrab() { void WidgetGtk::HandleGrabBroke() { if (has_capture_) { if (is_mouse_down_) - root_view_->ProcessMouseDragCanceled(); + GetRootView()->ProcessMouseDragCanceled(); is_mouse_down_ = false; has_capture_ = false; } @@ -1397,7 +1329,7 @@ bool WidgetGtk::ProcessMousePressed(GdkEventButton* event) { MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, x, y, GetFlagsForEventButton(*event)); - if (root_view_->OnMousePressed(mouse_pressed)) { + if (GetRootView()->OnMousePressed(mouse_pressed)) { is_mouse_down_ = true; if (!has_capture_) DoGrab(); @@ -1422,7 +1354,7 @@ void WidgetGtk::ProcessMouseReleased(GdkEventButton* event) { is_mouse_down_ = false; // GTK generates a mouse release at the end of dnd. We need to ignore it. if (!drag_data_) - root_view_->OnMouseReleased(mouse_up, false); + GetRootView()->OnMouseReleased(mouse_up, false); } bool WidgetGtk::ProcessScroll(GdkEventScroll* event) { @@ -1435,7 +1367,7 @@ bool WidgetGtk::ProcessScroll(GdkEventScroll* event) { translated_event.y = y; MouseWheelEvent wheel_event(reinterpret_cast<GdkEvent*>(&translated_event)); - return root_view_->OnMouseWheel(wheel_event); + return GetRootView()->OnMouseWheel(wheel_event); } // static diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index a75f586..067f522 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -28,7 +28,6 @@ using ui::OSExchangeDataProviderGtk; namespace views { -class DefaultThemeProvider; class DropTargetGtk; class FocusSearch; class TooltipManagerGtk; @@ -36,10 +35,8 @@ class View; class WindowGtk; // Widget implementation for GTK. -class WidgetGtk - : public Widget, - public FocusTraversable, - public ui::ActiveWindowWatcherX::Observer { +class WidgetGtk : public Widget, + public ui::ActiveWindowWatcherX::Observer { public: // Type of widget. enum Type { @@ -127,10 +124,6 @@ class WidgetGtk // Starts a drag on this widget. This blocks until the drag is done. void DoDrag(const OSExchangeData& data, int operation); - // Sets the focus traversable parents. - void SetFocusTraversableParent(FocusTraversable* parent); - void SetFocusTraversableParentView(View* parent_view); - // Invoked when the active status changes. virtual void IsActiveChanged(); @@ -160,9 +153,6 @@ class WidgetGtk // Overridden from Widget: virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds); virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds); - virtual WidgetDelegate* GetWidgetDelegate(); - virtual void SetWidgetDelegate(WidgetDelegate* delegate); - virtual void SetContentsView(View* view); virtual void GetBounds(gfx::Rect* out, bool including_frame) const; virtual void SetBounds(const gfx::Rect& bounds); virtual void MoveAbove(Widget* other); @@ -174,7 +164,6 @@ class WidgetGtk virtual gfx::NativeView GetNativeView() const; virtual void SetOpacity(unsigned char opacity); virtual void SetAlwaysOnTop(bool on_top); - virtual RootView* GetRootView(); virtual Widget* GetRootWidget() const; virtual bool IsVisible() const; virtual bool IsActive() const; @@ -188,7 +177,6 @@ class WidgetGtk virtual void SetNativeWindowProperty(const char* name, void* value); virtual void* GetNativeWindowProperty(const char* name); virtual ThemeProvider* GetThemeProvider() const; - virtual ThemeProvider* GetDefaultThemeProvider() const; virtual FocusManager* GetFocusManager(); virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); @@ -199,14 +187,6 @@ class WidgetGtk virtual View* GetDraggedView(); virtual void SchedulePaintInRect(const gfx::Rect& rect); virtual void SetCursor(gfx::NativeCursor cursor); - virtual FocusTraversable* GetFocusTraversable(); - virtual void ThemeChanged(); - virtual void LocaleChanged(); - - // Overridden from FocusTraversable: - virtual FocusSearch* GetFocusSearch(); - virtual FocusTraversable* GetFocusTraversableParent(); - virtual View* GetFocusTraversableParentView(); // Clears the focus on the native widget having the focus. virtual void ClearNativeFocus(); @@ -369,9 +349,6 @@ class WidgetGtk // must be destroyed AFTER root_view_. FocusManager* focus_manager_; - // The root of the View hierarchy attached to this window. - scoped_ptr<RootView> root_view_; - // If true, the mouse is currently down. bool is_mouse_down_; @@ -401,8 +378,6 @@ class WidgetGtk // See description above MakeIgnoreEvents for details. bool ignore_events_; - scoped_ptr<DefaultThemeProvider> default_theme_provider_; - // See note in DropObserver for details on this. bool ignore_drag_leave_; diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 78b6732..3f1ca3c 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -29,7 +29,6 @@ #include "views/views_delegate.h" #include "views/widget/aero_tooltip_manager.h" #include "views/widget/child_window_message_processor.h" -#include "views/widget/default_theme_provider.h" #include "views/widget/drop_target_win.h" #include "views/widget/root_view.h" #include "views/widget/widget_delegate.h" @@ -86,7 +85,6 @@ WidgetWin::WidgetWin() is_mouse_down_(false), is_window_(false), restore_focus_when_enabled_(false), - delegate_(NULL), accessibility_view_events_index_(-1), accessibility_view_events_(kMaxAccessibilityViewEvents), dragged_view_(NULL), @@ -94,6 +92,7 @@ WidgetWin::WidgetWin() } WidgetWin::~WidgetWin() { + DestroyRootView(); } // static @@ -183,6 +182,7 @@ void WidgetWin::ClearAccessibilityViewEvent(View* view) { // Widget implementation: void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { + Widget::Init(parent, bounds); // Force creation of the RootView; otherwise, we may get a WM_SIZE after the // window is created and before the root view is set up. GetRootView(); @@ -194,11 +194,9 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { if (!IsAccessibleWidget()) NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), OBJID_CUSTOM, CHILDID_SELF); - default_theme_provider_.reset(new DefaultThemeProvider()); - props_.push_back(SetWindowSupportsRerouteMouseWheel(hwnd())); - drop_target_ = new DropTargetWin(root_view_.get()); + drop_target_ = new DropTargetWin(GetRootView()); if ((window_style() & WS_CHILD) == 0 || (WidgetWin::GetRootWidget(parent) == NULL && @@ -211,7 +209,7 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { } // Sets the RootView as a property, so the automation can introspect windows. - SetNativeWindowProperty(kRootViewWindowProperty, root_view_.get()); + SetNativeWindowProperty(kRootViewWindowProperty, GetRootView()); // We need to add ourselves as a message loop observer so that we can repaint // aggressively if the contents of our window become invalid. Unfortunately @@ -244,18 +242,6 @@ void WidgetWin::InitWithWidget(Widget* parent, const gfx::Rect& bounds) { Init(parent->GetNativeView(), bounds); } -WidgetDelegate* WidgetWin::GetWidgetDelegate() { - return delegate_; -} - -void WidgetWin::SetWidgetDelegate(WidgetDelegate* delegate) { - delegate_ = delegate; -} - -void WidgetWin::SetContentsView(View* view) { - root_view_->SetContentsView(view); -} - void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const { CRect crect; if (including_frame) { @@ -349,14 +335,6 @@ void WidgetWin::SetAlwaysOnTop(bool on_top) { set_window_ex_style(window_ex_style() & ~WS_EX_TOPMOST); } -RootView* WidgetWin::GetRootView() { - if (!root_view_.get()) { - // First time the root view is being asked for, create it now. - root_view_.reset(CreateRootView()); - } - return root_view_.get(); -} - Widget* WidgetWin::GetRootWidget() const { return GetRootWidget(hwnd()); } @@ -381,7 +359,7 @@ void WidgetWin::GenerateMousePressedForView(View* view, const gfx::Point& point) { gfx::Point point_in_widget(point); View::ConvertPointToWidget(view, &point_in_widget); - root_view_->SetMouseHandler(view); + GetRootView()->SetMouseHandler(view); ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false); } @@ -418,10 +396,6 @@ ThemeProvider* WidgetWin::GetThemeProvider() const { return GetWidgetThemeProvider(this); } -ThemeProvider* WidgetWin::GetDefaultThemeProvider() const { - return default_theme_provider_.get(); -} - FocusManager* WidgetWin::GetFocusManager() { if (focus_manager_.get()) return focus_manager_.get(); @@ -514,18 +488,6 @@ void WidgetWin::SetCursor(gfx::NativeCursor cursor) { } } -FocusTraversable* WidgetWin::GetFocusTraversable() { - return root_view_.get(); -} - -void WidgetWin::ThemeChanged() { - root_view_->ThemeChanged(); -} - -void WidgetWin::LocaleChanged() { - root_view_->LocaleChanged(); -} - //////////////////////////////////////////////////////////////////////////////// // MessageLoop::Observer @@ -536,35 +498,6 @@ void WidgetWin::DidProcessMessage(const MSG& msg) { RedrawInvalidRect(); } -//////////////////////////////////////////////////////////////////////////////// -// FocusTraversable - -FocusSearch* WidgetWin::GetFocusSearch() { - return root_view_->GetFocusSearch(); -} - -FocusTraversable* WidgetWin::GetFocusTraversableParent() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - -void WidgetWin::SetFocusTraversableParent(FocusTraversable* parent) { - root_view_->SetFocusTraversableParent(parent); -} - -View* WidgetWin::GetFocusTraversableParentView() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - -void WidgetWin::SetFocusTraversableParentView(View* parent_view) { - root_view_->SetFocusTraversableParentView(parent_view); -} - /////////////////////////////////////////////////////////////////////////////// // Message handlers @@ -588,7 +521,7 @@ void WidgetWin::OnCancelMode() { void WidgetWin::OnCaptureChanged(HWND hwnd) { if (has_capture_) { if (is_mouse_down_) - root_view_->ProcessMouseDragCanceled(); + GetRootView()->ProcessMouseDragCanceled(); is_mouse_down_ = false; has_capture_ = false; } @@ -700,7 +633,7 @@ void WidgetWin::OnInitMenuPopup(HMENU menu, LRESULT WidgetWin::OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param) { RootView* root_view = GetFocusedViewRootView(); if (!root_view) - root_view = root_view_.get(); + root_view = GetRootView(); MSG msg; MakeMSG(&msg, message, w_param, l_param); @@ -711,7 +644,7 @@ LRESULT WidgetWin::OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param) { LRESULT WidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) { RootView* root_view = GetFocusedViewRootView(); if (!root_view) - root_view = root_view_.get(); + root_view = GetRootView(); MSG msg; MakeMSG(&msg, message, w_param, l_param); @@ -783,7 +716,7 @@ LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { MSG msg; MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)); - return root_view_->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; + return GetRootView()->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; } void WidgetWin::OnMove(const CPoint& point) { @@ -907,7 +840,7 @@ void WidgetWin::OnPaint(HDC dc) { contents_->save(SkCanvas::kClip_SaveFlag); contents_->ClipRectInt(r.left, r.top, r.right - r.left, r.bottom - r.top); - root_view_->Paint(contents_.get()); + GetRootView()->Paint(contents_.get()); contents_->restore(); RECT wr; @@ -923,7 +856,7 @@ void WidgetWin::OnPaint(HDC dc) { } else { scoped_ptr<gfx::CanvasPaint> canvas( gfx::CanvasPaint::CreateCanvasPaint(hwnd())); - root_view_->Paint(canvas->AsCanvas()); + GetRootView()->Paint(canvas->AsCanvas()); } } @@ -1058,14 +991,14 @@ bool WidgetWin::ProcessMousePressed(const CPoint& point, // expects window coordinates; convert if necessary. gfx::Point converted_point(point); if (non_client) - View::ConvertPointToView(NULL, root_view_.get(), &converted_point); + View::ConvertPointToView(NULL, GetRootView(), &converted_point); MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, converted_point.x(), converted_point.y(), (dbl_click ? ui::EF_IS_DOUBLE_CLICK : 0) | (non_client ? ui::EF_IS_NON_CLIENT : 0) | Event::ConvertWindowsFlags(flags)); - if (root_view_->OnMousePressed(mouse_pressed)) { + if (GetRootView()->OnMousePressed(mouse_pressed)) { is_mouse_down_ = true; if (!has_capture_) { SetCapture(); @@ -1082,7 +1015,7 @@ void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) { point.x, point.y, Event::ConvertWindowsFlags(flags)); - root_view_->OnMouseDragged(mouse_drag); + GetRootView()->OnMouseDragged(mouse_drag); } void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) { @@ -1098,7 +1031,7 @@ void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) { ReleaseCapture(); } is_mouse_down_ = false; - root_view_->OnMouseReleased(mouse_up, false); + GetRootView()->OnMouseReleased(mouse_up, false); } void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags, @@ -1112,7 +1045,7 @@ void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags, ProcessMouseDragged(point, flags); } else { gfx::Point screen_loc(point); - View::ConvertPointToScreen(root_view_.get(), &screen_loc); + View::ConvertPointToScreen(GetRootView(), &screen_loc); if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && last_mouse_move_y_ == screen_loc.y()) { // Don't generate a mouse event for the same location as the last. @@ -1125,13 +1058,13 @@ void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags, point.x, point.y, Event::ConvertWindowsFlags(flags)); - root_view_->OnMouseMoved(mouse_move); + GetRootView()->OnMouseMoved(mouse_move); } } void WidgetWin::ProcessMouseExited() { last_mouse_event_was_move_ = false; - root_view_->ProcessOnMouseExited(); + GetRootView()->ProcessOnMouseExited(); // Reset our tracking flag so that future mouse movement over this WidgetWin // results in a new tracking session. active_mouse_tracking_flags_ = 0; @@ -1145,8 +1078,8 @@ void WidgetWin::LayoutRootView() { // Resizing changes the size of the view hierarchy and thus forces a // complete relayout. - root_view_->SetBounds(0, 0, size.width(), size.height()); - root_view_->SchedulePaint(); + GetRootView()->SetBounds(0, 0, size.width(), size.height()); + GetRootView()->SchedulePaint(); } void WidgetWin::OnScreenReaderDetected() { @@ -1157,10 +1090,6 @@ bool WidgetWin::ReleaseCaptureOnMouseReleased() { return true; } -RootView* WidgetWin::CreateRootView() { - return new RootView(this); -} - /////////////////////////////////////////////////////////////////////////////// // WidgetWin, private: diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index baaa5b3..071040f 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -34,7 +34,6 @@ class Rect; namespace views { -class DefaultThemeProvider; class DropTargetWin; class FocusSearch; class RootView; @@ -77,8 +76,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; /////////////////////////////////////////////////////////////////////////////// class WidgetWin : public ui::WindowImpl, public Widget, - public MessageLoopForUI::Observer, - public FocusTraversable { + public MessageLoopForUI::Observer { public: WidgetWin(); virtual ~WidgetWin(); @@ -213,9 +211,6 @@ class WidgetWin : public ui::WindowImpl, // Overridden from Widget: virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds); virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds); - virtual WidgetDelegate* GetWidgetDelegate(); - virtual void SetWidgetDelegate(WidgetDelegate* delegate); - virtual void SetContentsView(View* view); virtual void GetBounds(gfx::Rect* out, bool including_frame) const; virtual void SetBounds(const gfx::Rect& bounds); virtual void MoveAbove(Widget* other); @@ -227,7 +222,6 @@ class WidgetWin : public ui::WindowImpl, virtual gfx::NativeView GetNativeView() const; virtual void SetOpacity(unsigned char opacity); virtual void SetAlwaysOnTop(bool on_top); - virtual RootView* GetRootView(); virtual Widget* GetRootWidget() const; virtual bool IsVisible() const; virtual bool IsActive() const; @@ -241,7 +235,6 @@ class WidgetWin : public ui::WindowImpl, virtual void SetNativeWindowProperty(const char* name, void* value); virtual void* GetNativeWindowProperty(const char* name); virtual ThemeProvider* GetThemeProvider() const; - virtual ThemeProvider* GetDefaultThemeProvider() const; virtual FocusManager* GetFocusManager(); virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); @@ -252,22 +245,11 @@ class WidgetWin : public ui::WindowImpl, virtual View* GetDraggedView(); virtual void SchedulePaintInRect(const gfx::Rect& rect); virtual void SetCursor(gfx::NativeCursor cursor); - virtual FocusTraversable* GetFocusTraversable(); - virtual void ThemeChanged(); - virtual void LocaleChanged(); // Overridden from MessageLoop::Observer: void WillProcessMessage(const MSG& msg); virtual void DidProcessMessage(const MSG& msg); - // Overridden from FocusTraversable: - virtual FocusSearch* GetFocusSearch(); - virtual FocusTraversable* GetFocusTraversableParent(); - virtual View* GetFocusTraversableParentView(); - - void SetFocusTraversableParent(FocusTraversable* parent); - void SetFocusTraversableParentView(View* parent_view); - BOOL IsWindow() const { return ::IsWindow(GetNativeView()); } @@ -464,10 +446,6 @@ class WidgetWin : public ui::WindowImpl, // is true. virtual bool ReleaseCaptureOnMouseReleased(); - // Creates the RootView to be used within this Widget. Can be overridden to - // create specialized RootView implementations. - virtual RootView* CreateRootView(); - // The TooltipManager. // WARNING: RootView's destructor calls into the TooltipManager. As such, this // must be destroyed AFTER root_view_. @@ -481,11 +459,6 @@ class WidgetWin : public ui::WindowImpl, // must be destroyed AFTER root_view_. scoped_ptr<FocusManager> focus_manager_; - // The root of the View hierarchy attached to this window. - // WARNING: see warning in tooltip_manager_ for ordering dependencies with - // this and tooltip_manager_. - scoped_ptr<RootView> root_view_; - // Whether or not we have capture the mouse. bool has_capture_; @@ -582,12 +555,6 @@ class WidgetWin : public ui::WindowImpl, // Instance of accessibility information and handling for MSAA root base::win::ScopedComPtr<IAccessible> accessibility_root_; - scoped_ptr<DefaultThemeProvider> default_theme_provider_; - - // Non owned pointer to optional delegate. May be NULL if no delegate is - // being used. - WidgetDelegate* delegate_; - // Value determines whether the Widget is customized for accessibility. static bool screen_reader_active_; |