summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 20:15:03 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 20:15:03 +0000
commit9861ae9e58cee87e1780ba00e2887a5f855a8ddf (patch)
treeaad2eea2e0b5c9ab8395d50c75eab2dc256daf10
parent44b871fde45eacd5e843740a6c74e7cf6948da23 (diff)
downloadchromium_src-9861ae9e58cee87e1780ba00e2887a5f855a8ddf.zip
chromium_src-9861ae9e58cee87e1780ba00e2887a5f855a8ddf.tar.gz
chromium_src-9861ae9e58cee87e1780ba00e2887a5f855a8ddf.tar.bz2
Clean up more of Widget.
- Move cross platform code to Widget. - Move platform-specific code into focused Widget* implementations. BUG=72040 TEST=existing Review URL: http://codereview.chromium.org/6609023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76790 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc2
-rw-r--r--chrome/browser/chromeos/login/user_controller.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.h1
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.h1
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view.cc2
-rw-r--r--views/controls/menu/menu_controller.cc2
-rw-r--r--views/view.cc16
-rw-r--r--views/views.gyp2
-rw-r--r--views/widget/native_widget.h11
-rw-r--r--views/widget/widget.cc88
-rw-r--r--views/widget/widget.h72
-rw-r--r--views/widget/widget_gtk.cc90
-rw-r--r--views/widget/widget_gtk.h16
-rw-r--r--views/widget/widget_utils.cc29
-rw-r--r--views/widget/widget_utils.h22
-rw-r--r--views/widget/widget_win.cc129
-rw-r--r--views/widget/widget_win.h20
19 files changed, 214 insertions, 301 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 4787064..9b07195 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -338,7 +338,7 @@ void DragBookmarks(Profile* profile,
views::NativeWidget* native_widget =
views::NativeWidget::GetNativeWidgetForNativeView(view);
if (native_widget) {
- native_widget->GetWidget()->StartDragForViewFromMouseEvent(NULL, data,
+ native_widget->GetWidget()->RunShellDrag(NULL, data,
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE |
ui::DragDropTypes::DRAG_LINK);
}
diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc
index f2da8ae..1059dfc 100644
--- a/chrome/browser/chromeos/login/user_controller.cc
+++ b/chrome/browser/chromeos/login/user_controller.cc
@@ -101,7 +101,7 @@ class ClickNotifyingWidget : public views::WidgetGtk {
void CloseWindow(views::WidgetGtk* window) {
if (!window)
return;
- window->SetWidgetDelegate(NULL);
+ window->set_widget_delegate(NULL);
window->Close();
}
@@ -333,7 +333,7 @@ void UserController::ConfigureLoginWindow(WidgetGtk* window,
window->MakeTransparent();
window->Init(NULL, bounds);
window->SetContentsView(contents_view);
- window->SetWidgetDelegate(this);
+ window->set_widget_delegate(this);
std::vector<int> params;
params.push_back(index);
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
index 4aeefb4..2b41b5e 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
@@ -101,10 +101,6 @@ ThemeProvider* BrowserFrameGtk::GetThemeProvider() const {
return profile_->GetThemeProvider();
}
-ThemeProvider* BrowserFrameGtk::GetDefaultThemeProvider() const {
- return profile_->GetThemeProvider();
-}
-
views::RootView* BrowserFrameGtk::CreateRootView() {
root_view_ = new BrowserRootView(browser_view_, this);
return root_view_;
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.h b/chrome/browser/ui/views/frame/browser_frame_gtk.h
index 44be1a1..95e5b6b 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.h
@@ -40,7 +40,6 @@ class BrowserFrameGtk : public BrowserFrame,
// Overridden from views::Widget:
virtual ui::ThemeProvider* GetThemeProvider() const;
- virtual ui::ThemeProvider* GetDefaultThemeProvider() const;
virtual void IsActiveChanged();
virtual void SetInitialFocus();
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc
index 1db3f49..a63d652 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -233,10 +233,6 @@ ThemeProvider* BrowserFrameWin::GetThemeProvider() const {
return profile_->GetThemeProvider();
}
-ThemeProvider* BrowserFrameWin::GetDefaultThemeProvider() const {
- return profile_->GetThemeProvider();
-}
-
void BrowserFrameWin::OnScreenReaderDetected() {
BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
WindowWin::OnScreenReaderDetected();
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.h b/chrome/browser/ui/views/frame/browser_frame_win.h
index c106385..835ff3f 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.h
+++ b/chrome/browser/ui/views/frame/browser_frame_win.h
@@ -64,7 +64,6 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin {
virtual LRESULT OnNCHitTest(const CPoint& pt);
virtual void OnWindowPosChanged(WINDOWPOS* window_pos);
virtual ui::ThemeProvider* GetThemeProvider() const;
- virtual ui::ThemeProvider* GetDefaultThemeProvider() const;
virtual void OnScreenReaderDetected();
// Overridden from views::Window:
diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc
index 311a221..0c09b2a 100644
--- a/chrome/browser/ui/views/notifications/balloon_view.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view.cc
@@ -333,7 +333,7 @@ void BalloonViewImpl::Show(Balloon* balloon) {
Widget::AcceptEvents,
Widget::DeleteOnDestroy,
Widget::DontMirrorOriginInRTL);
- frame_container_->SetWidgetDelegate(this);
+ frame_container_->set_widget_delegate(this);
frame_container_->SetAlwaysOnTop(true);
frame_container_->Init(NULL, balloon_rect);
frame_container_->SetContentsView(this);
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index 3fca407..906bd40 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -463,7 +463,7 @@ void MenuController::OnMouseDragged(SubmenuView* source,
StopScrolling();
int drag_ops = item->GetDelegate()->GetDragOperations(item);
drag_in_progress_ = true;
- item->GetWidget()->StartDragForViewFromMouseEvent(NULL, data, drag_ops);
+ item->GetWidget()->RunShellDrag(NULL, data, drag_ops);
drag_in_progress_ = false;
if (GetActiveInstance() == this) {
diff --git a/views/view.cc b/views/view.cc
index 088c57f..bd778c645 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -18,6 +18,7 @@
#include "views/background.h"
#include "views/layout/layout_manager.h"
#include "views/views_delegate.h"
+#include "views/widget/native_widget.h"
#include "views/widget/root_view.h"
#include "views/widget/tooltip_manager.h"
#include "views/widget/widget.h"
@@ -1155,8 +1156,8 @@ void View::Blur() {
void View::TooltipTextChanged() {
Widget* widget = GetWidget();
- if (widget && widget->GetTooltipManager())
- widget->GetTooltipManager()->TooltipTextChanged(this);
+ if (widget)
+ widget->native_widget()->GetTooltipManager()->TooltipTextChanged(this);
}
// Context menus ---------------------------------------------------------------
@@ -1184,7 +1185,7 @@ void View::WriteDragData(const gfx::Point& press_pt, OSExchangeData* data) {
bool View::InDrag() {
Widget* widget = GetWidget();
- return widget ? widget->GetDraggedView() == this : false;
+ return widget ? widget->dragged_view() == this : false;
}
////////////////////////////////////////////////////////////////////////////////
@@ -1604,8 +1605,11 @@ void View::PropagateLocaleChanged() {
void View::UpdateTooltip() {
Widget* widget = GetWidget();
- if (widget && widget->GetTooltipManager())
- widget->GetTooltipManager()->UpdateTooltip();
+ // TODO(beng): The TooltipManager NULL check can be removed when we
+ // consolidate Init() methods and make views_unittests Init() all
+ // Widgets that it uses.
+ if (widget && widget->native_widget()->GetTooltipManager())
+ widget->native_widget()->GetTooltipManager()->UpdateTooltip();
}
// Drag and drop ---------------------------------------------------------------
@@ -1620,7 +1624,7 @@ void View::DoDrag(const MouseEvent& e, const gfx::Point& press_pt) {
// Message the RootView to do the drag and drop. That way if we're removed
// the RootView can detect it and avoid calling us back.
- GetWidget()->StartDragForViewFromMouseEvent(this, data, drag_operations);
+ GetWidget()->RunShellDrag(this, data, drag_operations);
}
} // namespace views
diff --git a/views/views.gyp b/views/views.gyp
index a8c1fa3..f8b145c 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -352,8 +352,6 @@
'widget/widget.h',
'widget/widget_gtk.cc',
'widget/widget_gtk.h',
- 'widget/widget_utils.cc',
- 'widget/widget_utils.h',
'widget/widget_win.cc',
'widget/widget_win.h',
'window/client_view.cc',
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 9d0cb24..8587625 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -14,6 +14,7 @@ class Rect;
namespace views {
+class TooltipManager;
class Widget;
////////////////////////////////////////////////////////////////////////////////
@@ -55,6 +56,10 @@ class NativeWidget {
virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
virtual void* GetNativeWindowProperty(const char* name) = 0;
+ // Returns the native widget's tooltip manager. Called from the View hierarchy
+ // to update tooltips.
+ virtual TooltipManager* GetTooltipManager() const = 0;
+
// Widget pass-thrus ---------------------------------------------------------
// TODO(beng): Investigate if we can move these to a NativeWidgetPrivate
// interface.
@@ -62,6 +67,12 @@ class NativeWidget {
// See method documentation in Widget:
virtual gfx::Rect GetWindowScreenBounds() const = 0;
virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
+ virtual bool ContainsNativeView(gfx::NativeView native_view) const = 0;
+ virtual void RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) = 0;
+ virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
+ virtual void SetCursor(gfx::NativeCursor cursor) = 0;
};
} // namespace views
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 1455d5f..18f39fb 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -14,7 +14,10 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// Widget, public:
-Widget::Widget() : native_widget_(NULL), delegate_(NULL) {
+Widget::Widget()
+ : native_widget_(NULL),
+ widget_delegate_(NULL),
+ dragged_view_(NULL) {
}
Widget::~Widget() {
@@ -40,14 +43,6 @@ const Widget* Widget::GetTopLevelWidget() const {
return native_widget ? native_widget->GetWidget() : NULL;
}
-WidgetDelegate* Widget::GetWidgetDelegate() {
- return delegate_;
-}
-
-void Widget::SetWidgetDelegate(WidgetDelegate* delegate) {
- delegate_ = delegate;
-}
-
void Widget::SetContentsView(View* view) {
root_view_->SetContentsView(view);
}
@@ -114,10 +109,6 @@ bool Widget::IsAccessibleWidget() const {
void Widget::GenerateMousePressedForView(View* view, const gfx::Point& point) {
}
-TooltipManager* Widget::GetTooltipManager() {
- return NULL;
-}
-
bool Widget::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
return false;
}
@@ -131,10 +122,18 @@ const Window* Widget::GetWindow() const {
}
ThemeProvider* Widget::GetThemeProvider() const {
- return NULL;
-}
-
-ThemeProvider* Widget::GetDefaultThemeProvider() const {
+ const Widget* root_widget = GetTopLevelWidget();
+ if (root_widget && root_widget != this) {
+ // Attempt to get the theme provider, and fall back to the default theme
+ // provider if not found.
+ ThemeProvider* provider = root_widget->GetThemeProvider();
+ if (provider)
+ return provider;
+
+ provider = root_widget->default_theme_provider_.get();
+ if (provider)
+ return provider;
+ }
return default_theme_provider_.get();
}
@@ -143,25 +142,38 @@ FocusManager* Widget::GetFocusManager() {
}
void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+ if (!is_add && child == dragged_view_)
+ dragged_view_ = NULL;
}
bool Widget::ContainsNativeView(gfx::NativeView native_view) {
- return false;
-}
-
-void Widget::StartDragForViewFromMouseEvent(View* view,
- const ui::OSExchangeData& data,
- int operation) {
-}
-
-View* Widget::GetDraggedView() {
- return NULL;
+ if (native_widget_->ContainsNativeView(native_view))
+ return true;
+
+ // A views::NativeViewHost may contain the given native view, without it being
+ // an ancestor of hwnd(), so traverse the views::View hierarchy looking for
+ // such views.
+ return GetRootView()->ContainsNativeView(native_view);
+}
+
+void Widget::RunShellDrag(View* view, const ui::OSExchangeData& data,
+ int operation) {
+ dragged_view_ = view;
+ native_widget_->RunShellDrag(view, data, operation);
+ // If the view is removed during the drag operation, dragged_view_ is set to
+ // NULL.
+ if (view && dragged_view_ == view) {
+ dragged_view_ = NULL;
+ view->OnDragDone();
+ }
}
void Widget::SchedulePaintInRect(const gfx::Rect& rect) {
+ native_widget_->SchedulePaintInRect(rect);
}
void Widget::SetCursor(gfx::NativeCursor cursor) {
+ native_widget_->SetCursor(cursor);
}
FocusTraversable* Widget::GetFocusTraversable() {
@@ -185,17 +197,6 @@ void Widget::SetFocusTraversableParentView(View* parent_view) {
}
////////////////////////////////////////////////////////////////////////////////
-// Widget, protected:
-
-RootView* Widget::CreateRootView() {
- return new RootView(this);
-}
-
-void Widget::DestroyRootView() {
- root_view_.reset();
-}
-
-////////////////////////////////////////////////////////////////////////////////
// Widget, FocusTraversable implementation:
FocusSearch* Widget::GetFocusSearch() {
@@ -216,4 +217,15 @@ View* Widget::GetFocusTraversableParentView() {
return NULL;
}
+////////////////////////////////////////////////////////////////////////////////
+// Widget, protected:
+
+RootView* Widget::CreateRootView() {
+ return new RootView(this);
+}
+
+void Widget::DestroyRootView() {
+ root_view_.reset();
+}
+
} // namespace views
diff --git a/views/widget/widget.h b/views/widget/widget.h
index a0e0179..a9eb040 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -115,17 +115,17 @@ class Widget : public internal::NativeWidgetDelegate,
Widget* GetTopLevelWidget();
const Widget* GetTopLevelWidget() const;
- // Returns the WidgetDelegate for delegating certain events.
- virtual WidgetDelegate* GetWidgetDelegate();
-
- // Sets the WidgetDelegate.
- virtual void SetWidgetDelegate(WidgetDelegate* delegate);
+ // Gets/Sets the WidgetDelegate.
+ WidgetDelegate* widget_delegate() const { return widget_delegate_; }
+ void set_widget_delegate(WidgetDelegate* widget_delegate) {
+ widget_delegate_ = widget_delegate;
+ }
// Sets the specified view as the contents of this Widget. There can only
// be one contents view child of this Widget's RootView. This view is sized to
// fit the entire size of the RootView. The RootView takes ownership of this
// View, unless it is set as not being parent-owned.
- virtual void SetContentsView(View* view);
+ void SetContentsView(View* view);
// Returns the bounds of the Widget in screen coordinates.
gfx::Rect GetWindowScreenBounds() const;
@@ -183,10 +183,6 @@ class Widget : public internal::NativeWidgetDelegate,
virtual void GenerateMousePressedForView(View* view,
const gfx::Point& point);
- // Returns the TooltipManager for this Widget. If this Widget does not support
- // tooltips, NULL is returned.
- virtual TooltipManager* GetTooltipManager();
-
// Returns the accelerator given a command id. Returns false if there is
// no accelerator associated with a given id, which is a common condition.
virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
@@ -196,14 +192,9 @@ class Widget : public internal::NativeWidgetDelegate,
virtual Window* GetWindow();
virtual const Window* GetWindow() const;
- // Gets the theme provider.
+ // Returns the ThemeProvider that provides theme resources for this Widget.
virtual ThemeProvider* GetThemeProvider() const;
- // Gets the default theme provider; this is necessary for when a widget has
- // no profile (and ThemeProvider) associated with it. The default theme
- // provider provides a default set of bitmaps that such widgets can use.
- virtual ThemeProvider* GetDefaultThemeProvider() const;
-
// Returns the FocusManager for this widget.
// Note that all widgets in a widget hierarchy share the same focus manager.
virtual FocusManager* GetFocusManager();
@@ -213,39 +204,49 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns true if the native view |native_view| is contained in the
// views::View hierarchy rooted at this widget.
- virtual bool ContainsNativeView(gfx::NativeView native_view);
+ // TODO(beng): const.
+ bool ContainsNativeView(gfx::NativeView native_view);
- // Starts a drag operation for the specified view. This blocks until done.
- // If the view has not been deleted during the drag, OnDragDone is invoked
- // on the view.
- // NOTE: |view| may be NULL.
- virtual void StartDragForViewFromMouseEvent(View* view,
- const ui::OSExchangeData& data,
- int operation);
+ // Starts a drag operation for the specified view. This blocks until the drag
+ // operation completes. |view| can be NULL.
+ // If the view is non-NULL it can be accessed during the drag by calling
+ // dragged_view(). If the view has not been deleted during the drag,
+ // OnDragDone() is called on it.
+ void RunShellDrag(View* view, const ui::OSExchangeData& data, int operation);
- // If a view is dragging, this returns it. Otherwise returns NULL.
- virtual View* GetDraggedView();
+ // Returns the view that requested the current drag operation via
+ // RunShellDrag(), or NULL if there is no such view or drag operation.
+ View* dragged_view() { return dragged_view_; }
- virtual void SchedulePaintInRect(const gfx::Rect& rect);
+ // Adds the specified |rect| in client area coordinates to the rectangle to be
+ // redrawn.
+ void SchedulePaintInRect(const gfx::Rect& rect);
- virtual void SetCursor(gfx::NativeCursor cursor);
+ // Sets the currently visible cursor. If |cursor| is NULL, the cursor used
+ // before the current is restored.
+ void SetCursor(gfx::NativeCursor cursor);
// Retrieves the focus traversable for this widget.
virtual FocusTraversable* GetFocusTraversable();
// Notifies the view hierarchy contained in this widget that theme resources
// changed.
- virtual void ThemeChanged();
+ void ThemeChanged();
// Notifies the view hierarchy contained in this widget that locale resources
// changed.
- virtual void LocaleChanged();
+ void LocaleChanged();
void SetFocusTraversableParent(FocusTraversable* parent);
void SetFocusTraversableParentView(View* parent_view);
NativeWidget* native_widget() { return native_widget_; }
+ // Overridden from FocusTraversable:
+ virtual FocusSearch* GetFocusSearch();
+ virtual FocusTraversable* GetFocusTraversableParent();
+ virtual View* GetFocusTraversableParentView();
+
protected:
// Creates the RootView to be used within this Widget. Subclasses may override
// to create custom RootViews that do specialized event processing.
@@ -263,17 +264,12 @@ class Widget : public internal::NativeWidgetDelegate,
native_widget_ = native_widget;
}
- // Overridden from FocusTraversable:
- virtual FocusSearch* GetFocusSearch();
- virtual FocusTraversable* GetFocusTraversableParent();
- virtual View* GetFocusTraversableParentView();
-
private:
NativeWidget* native_widget_;
// Non-owned pointer to the Widget's delegate. May be NULL if no delegate is
// being used.
- WidgetDelegate* delegate_;
+ WidgetDelegate* widget_delegate_;
// The root of the View hierarchy attached to this window.
// WARNING: see warning in tooltip_manager_ for ordering dependencies with
@@ -283,6 +279,10 @@ class Widget : public internal::NativeWidgetDelegate,
// A theme provider to use when no other theme provider is specified.
scoped_ptr<DefaultThemeProvider> default_theme_provider_;
+ // Valid for the lifetime of RunShellDrag(), indicates the view the drag
+ // started from.
+ View* dragged_view_;
+
DISALLOW_COPY_AND_ASSIGN(Widget);
};
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 70cfa8b..0ae89cb 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -28,7 +28,6 @@
#include "views/widget/root_view.h"
#include "views/widget/tooltip_manager_gtk.h"
#include "views/widget/widget_delegate.h"
-#include "views/widget/widget_utils.h"
#include "views/window/window_gtk.h"
#if defined(TOUCH_UI)
@@ -436,8 +435,8 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
}
void WidgetGtk::IsActiveChanged() {
- if (GetWidgetDelegate())
- GetWidgetDelegate()->IsActiveChanged(IsActive());
+ if (widget_delegate())
+ widget_delegate()->IsActiveChanged(IsActive());
}
void WidgetGtk::ResetDropTarget() {
@@ -739,10 +738,6 @@ void WidgetGtk::GenerateMousePressedForView(View* view,
NOTIMPLEMENTED();
}
-TooltipManager* WidgetGtk::GetTooltipManager() {
- return tooltip_manager_.get();
-}
-
bool WidgetGtk::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
NOTIMPLEMENTED();
return false;
@@ -756,10 +751,6 @@ const Window* WidgetGtk::GetWindow() const {
return GetWindowImpl(widget_);
}
-ThemeProvider* WidgetGtk::GetThemeProvider() const {
- return GetWidgetThemeProvider(this);
-}
-
FocusManager* WidgetGtk::GetFocusManager() {
if (focus_manager_)
return focus_manager_;
@@ -788,49 +779,6 @@ void WidgetGtk::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
}
}
-bool WidgetGtk::ContainsNativeView(gfx::NativeView native_view) {
- // TODO(port) See implementation in WidgetWin::ContainsNativeView.
- NOTREACHED() << "WidgetGtk::ContainsNativeView is not implemented.";
- return false;
-}
-
-void WidgetGtk::StartDragForViewFromMouseEvent(
- View* view,
- const OSExchangeData& data,
- int operation) {
- // NOTE: view may be null.
- dragged_view_ = view;
- DoDrag(data, operation);
- // If the view is removed during the drag operation, dragged_view_ is set to
- // NULL.
- if (view && dragged_view_ == view) {
- dragged_view_ = NULL;
- view->OnDragDone();
- }
-}
-
-View* WidgetGtk::GetDraggedView() {
- return dragged_view_;
-}
-
-void WidgetGtk::SchedulePaintInRect(const gfx::Rect& rect) {
- if (widget_ && GTK_WIDGET_DRAWABLE(widget_)) {
- gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(),
- rect.height());
- }
-}
-
-void WidgetGtk::SetCursor(gfx::NativeCursor cursor) {
-#if defined(TOUCH_UI) && defined(HAVE_XINPUT2)
- if (!TouchFactory::GetInstance()->is_cursor_visible())
- cursor = gfx::GetCursor(GDK_BLANK_CURSOR);
-#endif
- // |window_contents_| is placed on top of |widget_|. So the cursor needs to be
- // set on |window_contents_| instead of |widget_|.
- if (window_contents_)
- gdk_window_set_cursor(window_contents_->window, cursor);
-}
-
void WidgetGtk::ClearNativeFocus() {
DCHECK(type_ != TYPE_CHILD);
if (!GetNativeView()) {
@@ -915,6 +863,10 @@ void* WidgetGtk::GetNativeWindowProperty(const char* name) {
return g_object_get_data(G_OBJECT(widget_), name);
}
+TooltipManager* WidgetGtk::GetTooltipManager() const {
+ return tooltip_manager_.get();
+}
+
gfx::Rect WidgetGtk::GetWindowScreenBounds() const {
// Client == Window bounds on Gtk.
return GetClientAreaScreenBounds();
@@ -940,6 +892,36 @@ gfx::Rect WidgetGtk::GetClientAreaScreenBounds() const {
return gfx::Rect(x, y, w, h);
}
+bool WidgetGtk::ContainsNativeView(gfx::NativeView native_view) const {
+ // TODO(port) See implementation in WidgetWin::ContainsNativeView.
+ NOTREACHED() << "WidgetGtk::ContainsNativeView is not implemented.";
+ return false;
+}
+
+void WidgetGtk::RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) {
+ DoDrag(data, operation);
+}
+
+void WidgetGtk::SchedulePaintInRect(const gfx::Rect& rect) {
+ if (widget_ && GTK_WIDGET_DRAWABLE(widget_)) {
+ gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(),
+ rect.height());
+ }
+}
+
+void WidgetGtk::SetCursor(gfx::NativeCursor cursor) {
+#if defined(TOUCH_UI) && defined(HAVE_XINPUT2)
+ if (!TouchFactory::GetInstance()->is_cursor_visible())
+ cursor = gfx::GetCursor(GDK_BLANK_CURSOR);
+#endif
+ // |window_contents_| is placed on top of |widget_|. So the cursor needs to be
+ // set on |window_contents_| instead of |widget_|.
+ if (window_contents_)
+ gdk_window_set_cursor(window_contents_->window, cursor);
+}
+
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, protected:
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index df5fc62..9facf90 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -167,21 +167,12 @@ class WidgetGtk : public Widget,
virtual bool IsAccessibleWidget() const;
virtual void GenerateMousePressedForView(View* view,
const gfx::Point& point);
- virtual TooltipManager* GetTooltipManager();
virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
virtual Window* GetWindow();
virtual const Window* GetWindow() const;
- virtual ThemeProvider* GetThemeProvider() const;
virtual FocusManager* GetFocusManager();
virtual void ViewHierarchyChanged(bool is_add, View *parent,
View *child);
- virtual bool ContainsNativeView(gfx::NativeView native_view);
- virtual void StartDragForViewFromMouseEvent(View* view,
- const OSExchangeData& data,
- int operation);
- virtual View* GetDraggedView();
- virtual void SchedulePaintInRect(const gfx::Rect& rect);
- virtual void SetCursor(gfx::NativeCursor cursor);
// Clears the focus on the native widget having the focus.
virtual void ClearNativeFocus();
@@ -200,8 +191,15 @@ class WidgetGtk : public Widget,
virtual Widget* GetWidget() OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
+ virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
+ virtual bool ContainsNativeView(gfx::NativeView native_view) const OVERRIDE;
+ virtual void RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) OVERRIDE;
+ virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
+ virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
protected:
// If widget contains another widget, translates event coordinates to the
diff --git a/views/widget/widget_utils.cc b/views/widget/widget_utils.cc
deleted file mode 100644
index d63a00c..0000000
--- a/views/widget/widget_utils.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "views/widget/widget_utils.h"
-
-#include <string>
-
-#include "views/widget/widget.h"
-
-namespace views {
-
-ThemeProvider* GetWidgetThemeProvider(const Widget* widget) {
- const Widget* root_widget = widget->GetTopLevelWidget();
- if (root_widget && root_widget != widget) {
- // Attempt to get the theme provider, and fall back to the default theme
- // provider if not found.
- ThemeProvider* provider = root_widget->GetThemeProvider();
- if (provider)
- return provider;
-
- provider = root_widget->GetDefaultThemeProvider();
- if (provider)
- return provider;
- }
- return widget->GetDefaultThemeProvider();
-}
-
-} // namespace views
diff --git a/views/widget/widget_utils.h b/views/widget/widget_utils.h
deleted file mode 100644
index d447935..0000000
--- a/views/widget/widget_utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef VIEWS_WIDGET_WIDGET_UTILS_H_
-#define VIEWS_WIDGET_WIDGET_UTILS_H_
-#pragma once
-
-namespace ui {
-class ThemeProvider;
-}
-using ui::ThemeProvider;
-
-namespace views {
-
-class Widget;
-
-ThemeProvider* GetWidgetThemeProvider(const Widget* widget);
-
-} // namespace views
-
-#endif // VIEWS_WIDGET_WIDGET_UTILS_H_
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 196e24e..e81d5c2 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -32,7 +32,6 @@
#include "views/widget/drop_target_win.h"
#include "views/widget/root_view.h"
#include "views/widget/widget_delegate.h"
-#include "views/widget/widget_utils.h"
#include "views/window/window_win.h"
#pragma comment(lib, "dwmapi.lib")
@@ -137,7 +136,6 @@ WidgetWin::WidgetWin()
restore_focus_when_enabled_(false),
accessibility_view_events_index_(-1),
accessibility_view_events_(kMaxAccessibilityViewEvents),
- dragged_view_(NULL),
previous_cursor_(NULL) {
set_native_widget(this);
}
@@ -368,10 +366,6 @@ bool WidgetWin::IsAccessibleWidget() const {
return screen_reader_active_;
}
-TooltipManager* WidgetWin::GetTooltipManager() {
- return tooltip_manager_.get();
-}
-
void WidgetWin::GenerateMousePressedForView(View* view,
const gfx::Point& point) {
gfx::Point point_in_widget(point);
@@ -392,10 +386,6 @@ const Window* WidgetWin::GetWindow() const {
return GetWindowImpl(hwnd());
}
-ThemeProvider* WidgetWin::GetThemeProvider() const {
- return GetWidgetThemeProvider(this);
-}
-
FocusManager* WidgetWin::GetFocusManager() {
if (focus_manager_.get())
return focus_manager_.get();
@@ -411,15 +401,13 @@ FocusManager* WidgetWin::GetFocusManager() {
void WidgetWin::ViewHierarchyChanged(bool is_add, View* parent,
View* child) {
+ Widget::ViewHierarchyChanged(is_add, parent, child);
if (drop_target_.get())
drop_target_->ResetTargetViewIfEquals(child);
if (!is_add) {
ClearAccessibilityViewEvent(child);
- if (child == dragged_view_)
- dragged_view_ = NULL;
-
FocusManager* focus_manager = GetFocusManager();
if (focus_manager) {
if (focus_manager->GetFocusedView() == child)
@@ -430,7 +418,49 @@ void WidgetWin::ViewHierarchyChanged(bool is_add, View* parent,
}
}
-bool WidgetWin::ContainsNativeView(gfx::NativeView native_view) {
+////////////////////////////////////////////////////////////////////////////////
+// WidgetWin, NativeWidget implementation:
+
+Widget* WidgetWin::GetWidget() {
+ return this;
+}
+
+void WidgetWin::SetNativeWindowProperty(const char* name, void* value) {
+ // Remove the existing property (if any).
+ for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) {
+ if ((*i)->Key() == name) {
+ props_.erase(i);
+ break;
+ }
+ }
+
+ if (value)
+ props_.push_back(new ViewProp(hwnd(), name, value));
+}
+
+void* WidgetWin::GetNativeWindowProperty(const char* name) {
+ return ViewProp::GetValue(hwnd(), name);
+}
+
+TooltipManager* WidgetWin::GetTooltipManager() const {
+ return tooltip_manager_.get();
+}
+
+gfx::Rect WidgetWin::GetWindowScreenBounds() const {
+ RECT r;
+ GetWindowRect(&r);
+ return gfx::Rect(r);
+}
+
+gfx::Rect WidgetWin::GetClientAreaScreenBounds() const {
+ RECT r;
+ GetClientRect(&r);
+ POINT point = { r.left, r.top };
+ ClientToScreen(hwnd(), &point);
+ return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top);
+}
+
+bool WidgetWin::ContainsNativeView(gfx::NativeView native_view) const {
if (hwnd() == native_view)
return true;
@@ -444,33 +474,16 @@ bool WidgetWin::ContainsNativeView(gfx::NativeView native_view) {
previous_child = parent_window;
parent_window = ::GetParent(parent_window);
}
-
- // A views::NativeViewHost may contain the given native view, without it being
- // an ancestor of hwnd(), so traverse the views::View hierarchy looking for
- // such views.
- return GetRootView()->ContainsNativeView(native_view);
+ return false;
}
-void WidgetWin::StartDragForViewFromMouseEvent(
- View* view,
- const ui::OSExchangeData& data,
- int operation) {
- // NOTE: view may be null.
- dragged_view_ = view;
+void WidgetWin::RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) {
scoped_refptr<ui::DragSource> drag_source(new ui::DragSource);
DWORD effects;
DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source,
ui::DragDropTypes::DragOperationToDropEffect(operation), &effects);
- // If the view is removed during the drag operation, dragged_view_ is set to
- // NULL.
- if (view && dragged_view_ == view) {
- dragged_view_ = NULL;
- view->OnDragDone();
- }
-}
-
-View* WidgetWin::GetDraggedView() {
- return dragged_view_;
}
void WidgetWin::SchedulePaintInRect(const gfx::Rect& rect) {
@@ -495,44 +508,6 @@ void WidgetWin::SetCursor(gfx::NativeCursor cursor) {
}
////////////////////////////////////////////////////////////////////////////////
-// WidgetWin, NativeWidget implementation:
-
-Widget* WidgetWin::GetWidget() {
- return this;
-}
-
-void WidgetWin::SetNativeWindowProperty(const char* name, void* value) {
- // Remove the existing property (if any).
- for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) {
- if ((*i)->Key() == name) {
- props_.erase(i);
- break;
- }
- }
-
- if (value)
- props_.push_back(new ViewProp(hwnd(), name, value));
-}
-
-void* WidgetWin::GetNativeWindowProperty(const char* name) {
- return ViewProp::GetValue(hwnd(), name);
-}
-
-gfx::Rect WidgetWin::GetWindowScreenBounds() const {
- RECT r;
- GetWindowRect(&r);
- return gfx::Rect(r);
-}
-
-gfx::Rect WidgetWin::GetClientAreaScreenBounds() const {
- RECT r;
- GetClientRect(&r);
- POINT point = { r.left, r.top };
- ClientToScreen(hwnd(), &point);
- return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// WidgetWin, MessageLoop::Observer implementation:
void WidgetWin::WillProcessMessage(const MSG& msg) {
@@ -635,8 +610,8 @@ void WidgetWin::OnDestroy() {
}
void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
- if (GetWidgetDelegate())
- GetWidgetDelegate()->DisplayChanged();
+ if (widget_delegate())
+ widget_delegate()->DisplayChanged();
}
LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg,
@@ -962,8 +937,8 @@ LRESULT WidgetWin::OnSetText(const wchar_t* text) {
}
void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
- if (flags == SPI_SETWORKAREA && GetWidgetDelegate())
- GetWidgetDelegate()->WorkAreaChanged();
+ if (flags == SPI_SETWORKAREA && widget_delegate())
+ widget_delegate()->WorkAreaChanged();
SetMsgHandled(FALSE);
}
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 638fb09..72414be 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -137,23 +137,14 @@ class WidgetWin : public ui::WindowImpl,
virtual bool IsVisible() const;
virtual bool IsActive() const;
virtual bool IsAccessibleWidget() const;
- virtual TooltipManager* GetTooltipManager();
virtual void GenerateMousePressedForView(View* view,
const gfx::Point& point);
virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
virtual Window* GetWindow();
virtual const Window* GetWindow() const;
- virtual ThemeProvider* GetThemeProvider() const;
virtual FocusManager* GetFocusManager();
virtual void ViewHierarchyChanged(bool is_add, View *parent,
View *child);
- virtual bool ContainsNativeView(gfx::NativeView native_view);
- virtual void StartDragForViewFromMouseEvent(View* view,
- const OSExchangeData& data,
- int operation);
- virtual View* GetDraggedView();
- virtual void SchedulePaintInRect(const gfx::Rect& rect);
- virtual void SetCursor(gfx::NativeCursor cursor);
BOOL IsWindow() const {
return ::IsWindow(GetNativeView());
@@ -228,8 +219,15 @@ class WidgetWin : public ui::WindowImpl,
virtual Widget* GetWidget() OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
+ virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
+ virtual bool ContainsNativeView(gfx::NativeView native_view) const OVERRIDE;
+ virtual void RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) OVERRIDE;
+ virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
+ virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
protected:
// Overridden from MessageLoop::Observer:
@@ -587,10 +585,6 @@ class WidgetWin : public ui::WindowImpl,
// we always mod this value with the max view events above .
int accessibility_view_events_index_;
- // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the
- // view the drag started from.
- View* dragged_view_;
-
// The last cursor that was active before the current one was selected. Saved
// so that we can restore it.
gfx::NativeCursor previous_cursor_;