summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 04:41:34 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 04:41:34 +0000
commit6dee7c46b6e47769b1f2b3e032b1dc5ccdd8863a (patch)
treee61a13869ded3789cfaa1d43f04f7aaa9b16abd4
parent0c3bf9563dcd51310abbf9856db4aba416a664bf (diff)
downloadchromium_src-6dee7c46b6e47769b1f2b3e032b1dc5ccdd8863a.zip
chromium_src-6dee7c46b6e47769b1f2b3e032b1dc5ccdd8863a.tar.gz
chromium_src-6dee7c46b6e47769b1f2b3e032b1dc5ccdd8863a.tar.bz2
Final conversion step. Convert FocusManager, WidgetWin, SpeechInputBubble, and remove old functions now no-one uses them.
Continuation of: Land the new functions added by 76483 - but do not use them anywhere outside of their tests. This will help me incrementally re-deploy these functions and identify what is causing the buildbot test redness. BUG=72040 TEST=none TBR=sky (all code originally reviewed here: http://codereview.chromium.org/6598069/ ) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76716 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/speech/speech_input_bubble_views.cc11
-rw-r--r--views/focus/focus_manager_win.cc6
-rw-r--r--views/view_unittest.cc33
-rw-r--r--views/widget/widget.cc4
-rw-r--r--views/widget/widget.h18
-rw-r--r--views/widget/widget_gtk.cc88
-rw-r--r--views/widget/widget_utils.cc4
-rw-r--r--views/widget/widget_win.cc78
8 files changed, 20 insertions, 222 deletions
diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_input_bubble_views.cc
index 17d81f5..e1906c2e 100644
--- a/chrome/browser/speech/speech_input_bubble_views.cc
+++ b/chrome/browser/speech/speech_input_bubble_views.cc
@@ -319,12 +319,11 @@ void SpeechInputBubbleImpl::Show() {
bubble_content_ = new ContentView(delegate_);
UpdateLayout();
- views::Widget* tab = views::Widget::GetWidgetFromNativeView(
- tab_contents()->view()->GetNativeView());
- views::Widget* parent = tab ? tab->GetRootWidget() : NULL;
-
- if (parent) {
- info_bubble_ = InfoBubble::Show(parent,
+ views::NativeWidget* toplevel_widget =
+ views::NativeWidget::GetTopLevelNativeWidget(
+ tab_contents()->view()->GetNativeView());
+ if (toplevel_widget) {
+ info_bubble_ = InfoBubble::Show(toplevel_widget->GetWidget(),
GetInfoBubbleTarget(element_rect_),
BubbleBorder::TOP_LEFT, bubble_content_,
this);
diff --git a/views/focus/focus_manager_win.cc b/views/focus/focus_manager_win.cc
index faf3815..d6f1e02 100644
--- a/views/focus/focus_manager_win.cc
+++ b/views/focus/focus_manager_win.cc
@@ -23,8 +23,10 @@ void FocusManager::FocusNativeView(gfx::NativeView native_view) {
// static
FocusManager* FocusManager::GetFocusManagerForNativeView(
gfx::NativeView native_view) {
- WidgetWin* widget = WidgetWin::GetRootWidget(native_view);
- return widget ? widget->GetFocusManager() : NULL;
+ // TODO(beng): This method probably isn't necessary.
+ views::NativeWidget* native_widget =
+ views::NativeWidget::GetTopLevelNativeWidget(native_view);
+ return native_widget ? native_widget->GetWidget()->GetFocusManager() : NULL;
}
// static
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 8207c76b..16109f7 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -1439,33 +1439,22 @@ class TestChangeNativeViewHierarchy {
view_test_->RunPendingMessages();
}
- void CheckEnumeratingRootViews() {
- std::vector<RootView*> enumerated_root_views;
-#if defined(OS_WIN)
- views::Widget::FindAllRootViews(host_->GetNativeView(),
- &enumerated_root_views);
-#else
- // host_->GetNativeView() returns gfx::NativeView which is GtkWidget on
- // systems other than Windows and views::Widget::FindAllRootViews()
- // requires GtkWindow.
- if (host_->GetWindow()) {
- views::Widget::FindAllRootViews(host_->GetWindow()->GetNativeWindow(),
- &enumerated_root_views);
- } else {
+ void CheckEnumeratingNativeWidgets() {
+ if (!host_->GetWindow())
return;
- }
-#endif
- EXPECT_EQ(TestNativeViewHierarchy::kTotalViews + 1,
- enumerated_root_views.size());
+ NativeWidget::NativeWidgets widgets;
+ NativeWidget::GetAllNativeWidgets(host_->GetNativeView(), &widgets);
+ EXPECT_EQ(TestNativeViewHierarchy::kTotalViews + 1, widgets.size());
// Unfortunately there is no guarantee the sequence of views here so always
// go through all of them.
- for (std::vector<RootView*>::iterator i = enumerated_root_views.begin();
- i != enumerated_root_views.end(); ++i) {
- if (host_->GetRootView() == *i)
+ for (NativeWidget::NativeWidgets::iterator i = widgets.begin();
+ i != widgets.end(); ++i) {
+ RootView* root_view = (*i)->GetWidget()->GetRootView();
+ if (host_->GetRootView() == root_view)
continue;
size_t j;
for (j = 0; j < TestNativeViewHierarchy::kTotalViews; ++j)
- if (root_views_[j] == *i)
+ if (root_views_[j] == root_view)
break;
// EXPECT_LT/GT/GE() fails to compile with class-defined constants
// with gcc, with error
@@ -1509,7 +1498,7 @@ TEST_F(ViewTest, ChangeNativeViewHierarchyFindRoots) {
// TODO(georgey): Fix the test for Linux
#if defined(OS_WIN)
TestChangeNativeViewHierarchy test(this);
- test.CheckEnumeratingRootViews();
+ test.CheckEnumeratingNativeWidgets();
#endif
}
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 5f07976..c280206 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -94,10 +94,6 @@ RootView* Widget::GetRootView() {
return root_view_.get();
}
-Widget* Widget::GetRootWidget() const {
- return NULL;
-}
-
bool Widget::IsVisible() const {
return false;
}
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 8f92542..b1860d1 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -88,21 +88,6 @@ class Widget : public internal::NativeWidgetDelegate,
DeleteParam delete_on_destroy,
MirroringParam mirror_in_rtl);
- // Returns the root view for |native_window|. If |native_window| does not have
- // a rootview, this recurses through all of |native_window|'s children until
- // one is found. If a root view isn't found, null is returned.
- static RootView* FindRootView(gfx::NativeWindow native_window);
-
- // Returns list of all root views for the native window and its
- // children.
- static void FindAllRootViews(gfx::NativeWindow native_window,
- std::vector<RootView*>* root_views);
-
- // Retrieve the Widget corresponding to the specified native_view, or NULL
- // if there is no such Widget.
- static Widget* GetWidgetFromNativeView(gfx::NativeView native_view);
- static Widget* GetWidgetFromNativeWindow(gfx::NativeWindow native_window);
-
// Enumerates all windows pertaining to us and notifies their
// view hierarchies that the locale has changed.
static void NotifyLocaleChanged();
@@ -185,9 +170,6 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns the RootView contained by this Widget.
virtual RootView* GetRootView();
- // Returns the Widget associated with the root ancestor.
- virtual Widget* GetRootWidget() const;
-
// Returns whether the Widget is visible to the user.
virtual bool IsVisible() const;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 11cb8fb..f109f86 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -1568,94 +1568,6 @@ Widget* Widget::CreatePopupWidget(TransparencyParam transparent,
return popup;
}
-// Callback from gtk_container_foreach. Locates the first root view of widget
-// or one of it's descendants.
-static void RootViewLocatorCallback(GtkWidget* widget,
- gpointer root_view_p) {
- RootView** root_view = static_cast<RootView**>(root_view_p);
- if (!*root_view) {
-
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(widget);
- *root_view =
- native_widget ? native_widget->GetWidget()->GetRootView() : NULL;
- if (!*root_view && GTK_IS_CONTAINER(widget)) {
- // gtk_container_foreach only iterates over children, not all descendants,
- // so we have to recurse here to get all descendants.
- gtk_container_foreach(GTK_CONTAINER(widget), RootViewLocatorCallback,
- root_view_p);
- }
- }
-}
-
-// static
-RootView* Widget::FindRootView(GtkWindow* window) {
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(GTK_WIDGET(window));
- if (native_widget)
- return native_widget->GetWidget()->GetRootView();
-
- // Enumerate all children and check if they have a RootView.
- RootView* root_view = NULL;
- gtk_container_foreach(GTK_CONTAINER(window), RootViewLocatorCallback,
- static_cast<gpointer>(&root_view));
- return root_view;
-}
-
-static void AllRootViewsLocatorCallback(GtkWidget* widget,
- gpointer root_view_p) {
- std::set<RootView*>* root_views_set =
- reinterpret_cast<std::set<RootView*>*>(root_view_p);
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(widget);
- RootView* root_view =
- native_widget ? native_widget->GetWidget()->GetRootView() : NULL;
- if (!root_view && GTK_IS_CONTAINER(widget)) {
- // gtk_container_foreach only iterates over children, not all descendants,
- // so we have to recurse here to get all descendants.
- gtk_container_foreach(GTK_CONTAINER(widget), AllRootViewsLocatorCallback,
- root_view_p);
- } else {
- if (root_view)
- root_views_set->insert(root_view);
- }
-}
-
-// static
-void Widget::FindAllRootViews(GtkWindow* window,
- std::vector<RootView*>* root_views) {
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(GTK_WIDGET(window));
- if (native_widget)
- root_views->push_back(native_widget->GetWidget()->GetRootView());
-
- std::set<RootView*> root_views_set;
-
- // Enumerate all children and check if they have a RootView.
- gtk_container_foreach(GTK_CONTAINER(window), AllRootViewsLocatorCallback,
- reinterpret_cast<gpointer>(&root_views_set));
- root_views->clear();
- root_views->reserve(root_views_set.size());
- for (std::set<RootView*>::iterator it = root_views_set.begin();
- it != root_views_set.end();
- ++it)
- root_views->push_back(*it);
-}
-
-// static
-Widget* Widget::GetWidgetFromNativeView(gfx::NativeView native_view) {
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(native_view);
- return native_widget ? native_widget->GetWidget() : NULL;
-}
-
-// static
-Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) {
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeWindow(native_window);
- return native_widget ? native_widget->GetWidget() : NULL;
-}
-
// static
void Widget::NotifyLocaleChanged() {
GList *window_list = gtk_window_list_toplevels();
diff --git a/views/widget/widget_utils.cc b/views/widget/widget_utils.cc
index 581550d..d63a00c 100644
--- a/views/widget/widget_utils.cc
+++ b/views/widget/widget_utils.cc
@@ -11,11 +11,7 @@
namespace views {
ThemeProvider* GetWidgetThemeProvider(const Widget* widget) {
-#if defined(TOOLKIT_USES_GTK)
const Widget* root_widget = widget->GetTopLevelWidget();
-#else
- Widget* root_widget = widget->GetRootWidget();
-#endif
if (root_widget && root_widget != widget) {
// Attempt to get the theme provider, and fall back to the default theme
// provider if not found.
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index c65d60d..bf60882 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -94,27 +94,6 @@ bool ProcessChildWindowMessage(UINT message,
return false;
}
-BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM l_param) {
- RootView* root_view = GetRootViewForHWND(hwnd);
- if (root_view) {
- *reinterpret_cast<RootView**>(l_param) = root_view;
- return FALSE; // Stop enumerating.
- }
- return TRUE; // Keep enumerating.
-}
-
-// Enumerate child windows as they could have RootView distinct from
-// the HWND's root view.
-BOOL CALLBACK EnumAllRootViewsChildProc(HWND hwnd, LPARAM l_param) {
- RootView* root_view = GetRootViewForHWND(hwnd);
- if (root_view) {
- std::set<RootView*>* root_views_set =
- reinterpret_cast<std::set<RootView*>*>(l_param);
- root_views_set->insert(root_view);
- }
- return TRUE; // Keep enumerating.
-}
-
// Enumeration callback for NativeWidget::GetAllNativeWidgets(). Called for each
// child HWND beneath the original HWND.
BOOL CALLBACK EnumerateChildWindowsForNativeWidgets(HWND hwnd, LPARAM l_param) {
@@ -128,15 +107,9 @@ BOOL CALLBACK EnumerateChildWindowsForNativeWidgets(HWND hwnd, LPARAM l_param) {
return TRUE;
}
-// Property used to link the HWND to its RootView.
-const char* const kRootViewWindowProperty = "__ROOT_VIEW__";
-
// Links the HWND to its NativeWidget.
const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__";
-// Links the HWND to it's Widget (as a Widget, not a WidgetWin).
-const char* const kWidgetKey = "__VIEWS_WIDGET__";
-
// A custom MSAA object id used to determine if a screen reader is actively
// listening for MSAA events.
const int kCustomObjectID = 1;
@@ -146,11 +119,6 @@ const int kCustomObjectID = 1;
// static
bool WidgetWin::screen_reader_active_ = false;
-RootView* GetRootViewForHWND(HWND hwnd) {
- return reinterpret_cast<RootView*>(
- ViewProp::GetValue(hwnd, kRootViewWindowProperty));
-}
-
////////////////////////////////////////////////////////////////////////////////
// WidgetWin, public:
@@ -276,9 +244,6 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
focus_manager_.reset(new FocusManager(this));
}
- // Sets the RootView as a property, so the automation can introspect windows.
- 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
// WM_PAINT messages are starved and we get flickery redrawing when resizing
@@ -656,7 +621,6 @@ void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) {
LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
// Widget::GetWidgetFromNativeView expects the contents of this property
// to be of type Widget, so the cast is necessary.
- SetNativeWindowProperty(kWidgetKey, static_cast<Widget*>(this));
SetNativeWindowProperty(kNativeWidgetKey, this);
use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED);
LayoutRootView();
@@ -1316,48 +1280,6 @@ Widget* Widget::CreatePopupWidget(TransparencyParam transparent,
}
// static
-RootView* Widget::FindRootView(HWND hwnd) {
- RootView* root_view = GetRootViewForHWND(hwnd);
- if (root_view)
- return root_view;
-
- // Enumerate all children and check if they have a RootView.
- EnumChildWindows(hwnd, EnumChildProc, reinterpret_cast<LPARAM>(&root_view));
-
- return root_view;
-}
-
-// static
-void Widget::FindAllRootViews(HWND window,
- std::vector<RootView*>* root_views) {
- RootView* root_view = GetRootViewForHWND(window);
- std::set<RootView*> root_views_set;
- if (root_view)
- root_views_set.insert(root_view);
- // Enumerate all children and check if they have a RootView.
- EnumChildWindows(window, EnumAllRootViewsChildProc,
- reinterpret_cast<LPARAM>(&root_views_set));
- root_views->clear();
- root_views->reserve(root_views_set.size());
- for (std::set<RootView*>::iterator it = root_views_set.begin();
- it != root_views_set.end();
- ++it)
- root_views->push_back(*it);
-}
-
-// static
-Widget* Widget::GetWidgetFromNativeView(gfx::NativeView native_view) {
- return IsWindow(native_view) ?
- reinterpret_cast<Widget*>(ViewProp::GetValue(native_view, kWidgetKey)) :
- NULL;
-}
-
-// static
-Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) {
- return Widget::GetWidgetFromNativeView(native_window);
-}
-
-// static
void Widget::NotifyLocaleChanged() {
NOTIMPLEMENTED();
}