summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:40:45 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:40:45 +0000
commit10946079e34f1a627e9afa232049469a6655cc17 (patch)
tree6de5c4fa11f7fb6ede9601de1acc86e4a53aa1b2 /views/widget
parent334bef925113a03dac5dc92184ab7ce51e06a386 (diff)
downloadchromium_src-10946079e34f1a627e9afa232049469a6655cc17.zip
chromium_src-10946079e34f1a627e9afa232049469a6655cc17.tar.gz
chromium_src-10946079e34f1a627e9afa232049469a6655cc17.tar.bz2
Move RootView to the internal namespace.
Most people should not be using the RootView type. The few cases that do should static_cast for now, until I can find a way to expose the functionality they need on Widget. BUG=72040 TEST=none TBR=sky Review URL: http://codereview.chromium.org/7040018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/drop_helper.cc6
-rw-r--r--views/widget/drop_helper.h6
-rw-r--r--views/widget/drop_target_gtk.cc2
-rw-r--r--views/widget/drop_target_gtk.h6
-rw-r--r--views/widget/drop_target_win.cc2
-rw-r--r--views/widget/drop_target_win.h6
-rw-r--r--views/widget/native_widget_gtk.cc8
-rw-r--r--views/widget/native_widget_win.cc3
-rw-r--r--views/widget/root_view.cc16
-rw-r--r--views/widget/root_view.h15
-rw-r--r--views/widget/tooltip_manager_gtk.cc4
-rw-r--r--views/widget/tooltip_manager_win.cc5
-rw-r--r--views/widget/widget.cc24
-rw-r--r--views/widget/widget.h18
14 files changed, 69 insertions, 52 deletions
diff --git a/views/widget/drop_helper.cc b/views/widget/drop_helper.cc
index a0b7b76..4e5ce109 100644
--- a/views/widget/drop_helper.cc
+++ b/views/widget/drop_helper.cc
@@ -6,11 +6,11 @@
#include "ui/base/dragdrop/drag_drop_types.h"
#include "views/view.h"
-#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
namespace views {
-DropHelper::DropHelper(RootView* root_view)
+DropHelper::DropHelper(View* root_view)
: root_view_(root_view),
target_view_(NULL),
deepest_view_(NULL) {
@@ -61,7 +61,7 @@ int DropHelper::OnDrop(const OSExchangeData& data,
}
gfx::Point view_location(root_view_location);
- View* root_view = drop_view->GetRootView();
+ View* root_view = drop_view->GetWidget()->GetRootView();
View::ConvertPointToView(root_view, drop_view, &view_location);
DropTargetEvent drop_event(data, view_location.x(), view_location.y(),
drag_operation);
diff --git a/views/widget/drop_helper.h b/views/widget/drop_helper.h
index 453a04e..cc62bfc 100644
--- a/views/widget/drop_helper.h
+++ b/views/widget/drop_helper.h
@@ -29,14 +29,14 @@ class View;
// then either OnDragExit or OnDrop when the drop is done.
class DropHelper {
public:
- explicit DropHelper(RootView* root_view);
+ explicit DropHelper(View* root_view);
~DropHelper();
// Current view drop events are targeted at, may be NULL.
View* target_view() const { return target_view_; }
// Returns the RootView the DropHelper was created with.
- RootView* root_view() const { return root_view_; }
+ View* root_view() const { return root_view_; }
// Resets the target_view_ to NULL if it equals view.
//
@@ -92,7 +92,7 @@ class DropHelper {
void NotifyDragExit();
// RootView we were created for.
- RootView* root_view_;
+ View* root_view_;
// View we're targeting events at.
View* target_view_;
diff --git a/views/widget/drop_target_gtk.cc b/views/widget/drop_target_gtk.cc
index 4fecfcb..8d8e760 100644
--- a/views/widget/drop_target_gtk.cc
+++ b/views/widget/drop_target_gtk.cc
@@ -69,7 +69,7 @@ int CalculateTypes(GList* targets, std::set<GdkAtom>* type_set) {
namespace views {
-DropTargetGtk::DropTargetGtk(RootView* root_view,
+DropTargetGtk::DropTargetGtk(internal::RootView* root_view,
GdkDragContext* context)
: helper_(root_view),
requested_formats_(0),
diff --git a/views/widget/drop_target_gtk.h b/views/widget/drop_target_gtk.h
index 75fd1c0..bc2c3ca 100644
--- a/views/widget/drop_target_gtk.h
+++ b/views/widget/drop_target_gtk.h
@@ -21,8 +21,10 @@ using ui::OSExchangeDataProviderGtk;
namespace views {
-class RootView;
class View;
+namespace internal {
+class RootView;
+}
// DropTarget implementation for Gtk.
//
@@ -37,7 +39,7 @@ class View;
// which results in deleting the DropTargetGtk.
class DropTargetGtk {
public:
- explicit DropTargetGtk(RootView* root_view,
+ explicit DropTargetGtk(internal::RootView* root_view,
GdkDragContext* context);
~DropTargetGtk();
diff --git a/views/widget/drop_target_win.cc b/views/widget/drop_target_win.cc
index 7632f6a..c4c8e2c 100644
--- a/views/widget/drop_target_win.cc
+++ b/views/widget/drop_target_win.cc
@@ -16,7 +16,7 @@ using ui::OSExchangeDataProviderWin;
namespace views {
-DropTargetWin::DropTargetWin(RootView* root_view)
+DropTargetWin::DropTargetWin(internal::RootView* root_view)
: ui::DropTarget(root_view->GetWidget()->GetNativeView()),
helper_(root_view) {
}
diff --git a/views/widget/drop_target_win.h b/views/widget/drop_target_win.h
index 1498841..966bbc2 100644
--- a/views/widget/drop_target_win.h
+++ b/views/widget/drop_target_win.h
@@ -11,8 +11,10 @@
namespace views {
-class RootView;
class View;
+namespace internal {
+class RootView;
+}
// DropTargetWin takes care of managing drag and drop for NativeWidgetWin. It
// converts Windows OLE drop messages into Views drop messages.
@@ -21,7 +23,7 @@ class View;
// drop messages at.
class DropTargetWin : public ui::DropTarget {
public:
- explicit DropTargetWin(RootView* root_view);
+ explicit DropTargetWin(internal::RootView* root_view);
virtual ~DropTargetWin();
// If a drag and drop is underway and view is the current drop target, the
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 92ddd11..0aeb451 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -31,7 +31,6 @@
#include "views/widget/drop_target_gtk.h"
#include "views/widget/gtk_views_fixed.h"
#include "views/widget/gtk_views_window.h"
-#include "views/widget/root_view.h"
#include "views/widget/tooltip_manager_gtk.h"
#include "views/widget/widget_delegate.h"
#include "views/window/native_window_gtk.h"
@@ -1170,8 +1169,11 @@ gboolean NativeWidgetGtk::OnDragMotion(GtkWidget* widget,
gint x,
gint y,
guint time) {
- if (!drop_target_.get())
- drop_target_.reset(new DropTargetGtk(GetWidget()->GetRootView(), context));
+ if (!drop_target_.get()) {
+ drop_target_.reset(new DropTargetGtk(
+ reinterpret_cast<internal::RootView*>(GetWidget()->GetRootView()),
+ context));
+ }
return drop_target_->OnDragMotion(context, x, y, time);
}
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index 50f4cca..ce28ef3 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -558,7 +558,8 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
props_.push_back(SetWindowSupportsRerouteMouseWheel(hwnd()));
- drop_target_ = new DropTargetWin(GetWidget()->GetRootView());
+ drop_target_ = new DropTargetWin(
+ static_cast<internal::RootView*>(GetWidget()->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
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 6942d3d..9537bd8 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -22,6 +22,7 @@
#endif
namespace views {
+namespace internal {
// static
const char RootView::kViewClassName[] = "views/RootView";
@@ -415,19 +416,6 @@ bool RootView::GetKeepMouseCursor() {
#endif
-namespace {
-// Set to true if a pure Views implementation is preferred
-bool use_pure_views;
-}
-
-void RootView::SetPureViews(bool pure) {
- use_pure_views = pure;
-}
-
-bool RootView::IsPureViews() {
- return use_pure_views;
-}
-
////////////////////////////////////////////////////////////////////////////////
// RootView, protected:
@@ -481,4 +469,6 @@ void RootView::SetMouseLocationAndFlags(const MouseEvent& event) {
last_mouse_event_y_ = event.y();
}
+} // namespace internal
} // namespace views
+
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index fc8b632..587967f 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -20,6 +20,10 @@ class Widget;
class GestureManager;
#endif
+// This is a views-internal API and should not be used externally.
+// Widget exposes this object as a View*.
+namespace internal {
+
////////////////////////////////////////////////////////////////////////////////
// RootView class
//
@@ -34,9 +38,7 @@ class GestureManager;
// initialized to attach the contents view to the RootView.
// TODO(beng): Enforce no other callers to AddChildView/tree functions by
// overriding those methods as private here.
-// TODO(beng): Move to internal namespace and remove accessors from
-// View/Widget.
-// TODO(beng): Clean up API further, make WidgetImpl a friend.
+// TODO(beng): Clean up API further, make Widget a friend.
//
class RootView : public View,
public FocusTraversable {
@@ -118,11 +120,6 @@ class RootView : public View,
static bool GetKeepMouseCursor();
#endif
- // SetPureViews and IsPureViews update and return the state of a global
- // setting that tracks whether to use available pure Views implementations
- static void SetPureViews(bool pure);
- static bool IsPureViews();
-
protected:
// Overridden from View:
virtual void ViewHierarchyChanged(bool is_add, View* parent,
@@ -214,6 +211,8 @@ class RootView : public View,
DISALLOW_IMPLICIT_CONSTRUCTORS(RootView);
};
+
+} // namespace internal
} // namespace views
#endif // VIEWS_WIDGET_ROOT_VIEW_H_
diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc
index 909dc57..d88f345 100644
--- a/views/widget/tooltip_manager_gtk.cc
+++ b/views/widget/tooltip_manager_gtk.cc
@@ -9,8 +9,8 @@
#include "ui/gfx/font.h"
#include "views/focus/focus_manager.h"
#include "views/screen.h"
+#include "views/view.h"
#include "views/widget/native_widget_gtk.h"
-#include "views/widget/root_view.h"
// WARNING: this implementation is good for a start, but it doesn't give us
// control of tooltip positioning both on mouse events and when showing from
@@ -85,7 +85,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
view = keyboard_view_;
view_loc.SetPoint(view->width() / 2, view->height() / 2);
} else if (!for_keyboard) {
- RootView* root_view = widget_->GetWidget()->GetRootView();
+ View* root_view = widget_->GetWidget()->GetRootView();
view = root_view->GetEventHandlerForPoint(gfx::Point(x, y));
view_loc.SetPoint(x, y);
View::ConvertPointFromWidget(view, &view_loc);
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index e905218..9158818 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -16,7 +16,6 @@
#include "views/screen.h"
#include "views/view.h"
#include "views/widget/monitor_win.h"
-#include "views/widget/root_view.h"
#include "views/widget/widget.h"
namespace views {
@@ -148,7 +147,7 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
case TTN_GETDISPINFO: {
if (last_view_out_of_sync_) {
// View under the mouse is out of sync, determine it now.
- RootView* root_view = widget_->GetRootView();
+ View* root_view = widget_->GetRootView();
last_tooltip_view_ =
root_view->GetEventHandlerForPoint(last_mouse_pos_);
last_view_out_of_sync_ = false;
@@ -271,7 +270,7 @@ int TooltipManagerWin::CalcTooltipHeight() {
}
void TooltipManagerWin::UpdateTooltip(const gfx::Point& mouse_pos) {
- RootView* root_view = widget_->GetRootView();
+ View* root_view = widget_->GetRootView();
View* view = root_view->GetEventHandlerForPoint(mouse_pos);
if (view != last_tooltip_view_) {
// NOTE: This *must* be sent regardless of the visibility of the tooltip.
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 6e1e693..8f28fec 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -16,6 +16,12 @@
namespace views {
+namespace {
+// Set to true if a pure Views implementation is preferred
+bool use_pure_views;
+}
+
+
////////////////////////////////////////////////////////////////////////////////
// Widget, InitParams:
@@ -78,6 +84,14 @@ Widget::~Widget() {
delete native_widget_;
}
+void Widget::SetPureViews(bool pure) {
+ use_pure_views = pure;
+}
+
+bool Widget::IsPureViews() {
+ return use_pure_views;
+}
+
void Widget::Init(const InitParams& params) {
delete_on_destroy_ = params.delete_on_destroy;
native_widget_ =
@@ -206,7 +220,7 @@ void Widget::SetAlwaysOnTop(bool on_top) {
native_widget_->SetAlwaysOnTop(on_top);
}
-RootView* Widget::GetRootView() {
+View* Widget::GetRootView() {
if (!root_view_.get()) {
// First time the root view is being asked for, create it now.
root_view_.reset(CreateRootView());
@@ -291,7 +305,7 @@ void Widget::ResetLastMouseMoveFlag() {
}
FocusTraversable* Widget::GetFocusTraversable() {
- return root_view_.get();
+ return static_cast<internal::RootView*>(root_view_.get());
}
void Widget::ThemeChanged() {
@@ -381,7 +395,7 @@ void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
}
bool Widget::OnKeyEvent(const KeyEvent& event) {
- return GetRootView()->OnKeyEvent(event);
+ return static_cast<internal::RootView*>(GetRootView())->OnKeyEvent(event);
}
bool Widget::OnMouseEvent(const MouseEvent& event) {
@@ -468,8 +482,8 @@ View* Widget::GetFocusTraversableParentView() {
////////////////////////////////////////////////////////////////////////////////
// Widget, protected:
-RootView* Widget::CreateRootView() {
- return new RootView(this);
+internal::RootView* Widget::CreateRootView() {
+ return new internal::RootView(this);
}
void Widget::DestroyRootView() {
diff --git a/views/widget/widget.h b/views/widget/widget.h
index f7c12ae..c19be52 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -36,11 +36,13 @@ namespace views {
class DefaultThemeProvider;
class InputMethod;
class NativeWidget;
-class RootView;
class TooltipManager;
class View;
class WidgetDelegate;
class Window;
+namespace internal {
+class RootView;
+}
////////////////////////////////////////////////////////////////////////////////
// Widget class
@@ -120,6 +122,11 @@ class Widget : public internal::NativeWidgetDelegate,
const Widget* target,
gfx::Rect* rect);
+ // SetPureViews and IsPureViews update and return the state of a global
+ // setting that tracks whether to use available pure Views implementations
+ static void SetPureViews(bool pure);
+ static bool IsPureViews();
+
void Init(const InitParams& params);
// Unconverted methods -------------------------------------------------------
@@ -212,8 +219,9 @@ class Widget : public internal::NativeWidgetDelegate,
// Sets the widget to be on top of all other widgets in the windowing system.
void SetAlwaysOnTop(bool on_top);
- // Returns the RootView contained by this Widget.
- RootView* GetRootView();
+ // Returns the View at the root of the View hierarchy contained by this
+ // Widget.
+ View* GetRootView();
// A secondary widget is one that is automatically closed (via Close()) when
// all non-secondary widgets are closed.
@@ -334,7 +342,7 @@ class Widget : public internal::NativeWidgetDelegate,
// 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();
+ virtual internal::RootView* CreateRootView();
// Provided to allow the NativeWidget implementations to destroy the RootView
// _before_ the focus manager/tooltip manager.
@@ -373,7 +381,7 @@ class Widget : public internal::NativeWidgetDelegate,
// 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_;
+ scoped_ptr<internal::RootView> root_view_;
// The focus manager keeping track of focus for this Widget and any of its
// children. NULL for non top-level widgets.