summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 23:21:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 23:21:02 +0000
commit14282e20f8709e9128fcdcf30fa246806e797f48 (patch)
tree95ec30660d4e99b1f9c32e1c22729554aa7540ec /views
parentbd81dd9136cf7f67722658352beff53a90f87a08 (diff)
downloadchromium_src-14282e20f8709e9128fcdcf30fa246806e797f48.zip
chromium_src-14282e20f8709e9128fcdcf30fa246806e797f48.tar.gz
chromium_src-14282e20f8709e9128fcdcf30fa246806e797f48.tar.bz2
Adds more debugging code in hopes of figuring out a crash. Sorry for
needing to add so much plumbing here. We're not creating the FocusManager for BrowserView. I can only think that either we're not getting the create event, or we're getting the wrong parent widget. This should help us nail down which one is happening. BUG=77651 TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/6820009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/native_widget.h7
-rw-r--r--views/widget/widget.cc12
-rw-r--r--views/widget/widget.h11
-rw-r--r--views/widget/widget_win.cc38
4 files changed, 67 insertions, 1 deletions
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index c46aff3..fe20388 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -44,6 +44,13 @@ class NativeWidget {
static NativeWidget* GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window);
+#if defined(OS_WIN)
+ // Debugging code to help track 77651.
+ static NativeWidget* GetTopLevelNativeWidgetWithReason(
+ gfx::NativeView native_view,
+ int* reason);
+#endif
+
// Retrieves the top NativeWidget in the hierarchy containing the given
// NativeView, or NULL if there is no NativeWidget that contains it.
static NativeWidget* GetTopLevelNativeWidget(gfx::NativeView native_view);
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 6a3eb04..4472d93 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -52,7 +52,8 @@ Widget::Widget()
last_mouse_event_was_move_(false),
native_widget_(NULL),
widget_delegate_(NULL),
- dragged_view_(NULL) {
+ dragged_view_(NULL),
+ got_native_widget_created_(false) {
}
Widget::~Widget() {
@@ -117,6 +118,14 @@ void Widget::NotifyNativeViewHierarchyChanged(bool attached,
// Converted methods (see header) ----------------------------------------------
+#if defined(OS_WIN)
+Widget* Widget::GetTopLevelWidgetWithReason(int* reason) {
+ NativeWidget* native_widget =
+ NativeWidget::GetTopLevelNativeWidgetWithReason(GetNativeView(), reason);
+ return native_widget ? native_widget->GetWidget() : NULL;
+}
+#endif
+
Widget* Widget::GetTopLevelWidget() {
return const_cast<Widget*>(
const_cast<const Widget*>(this)->GetTopLevelWidget());
@@ -296,6 +305,7 @@ void Widget::OnNativeBlur(gfx::NativeView focused_view) {
}
void Widget::OnNativeWidgetCreated() {
+ got_native_widget_created_ = true;
if (GetTopLevelWidget() == this) {
// Only the top level Widget in a native widget hierarchy has a focus
// manager.
diff --git a/views/widget/widget.h b/views/widget/widget.h
index e4c1035..c35202a 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -153,6 +153,11 @@ class Widget : public internal::NativeWidgetDelegate,
// Widget subclasses are implementing these methods by implementing
// NativeWidget. Remove this comment once complete.
+#if defined(OS_WIN)
+ // Debugging code to help track 77651.
+ Widget* GetTopLevelWidgetWithReason(int* reason);
+#endif
+
// Returns the topmost Widget in a hierarchy. Will return NULL if called
// before the underlying Native Widget has been initialized.
Widget* GetTopLevelWidget();
@@ -283,6 +288,9 @@ class Widget : public internal::NativeWidgetDelegate,
NativeWidget* native_widget() { return native_widget_; }
+ // Debugging code to help track 77651.
+ bool got_native_widget_created() const { return got_native_widget_created_; }
+
// Overridden from NativeWidgetDelegate:
virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE;
virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE;
@@ -368,6 +376,9 @@ class Widget : public internal::NativeWidgetDelegate,
// The compositor for accelerated drawing.
scoped_refptr<ui::Compositor> compositor_;
+ // Debugging code to help track 77651.
+ bool got_native_widget_created_;
+
DISALLOW_COPY_AND_ASSIGN(Widget);
};
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 7c4cdb4..424386b 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -1182,6 +1182,44 @@ NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow(
return GetNativeWidgetForNativeView(native_window);
}
+NativeWidget* NativeWidget::GetTopLevelNativeWidgetWithReason(
+ gfx::NativeView native_view,
+ int* reason) {
+ *reason = 0;
+ if (!native_view) {
+ *reason = 1;
+ return NULL;
+ }
+
+ // First, check if the top-level window is a Widget.
+ HWND root = ::GetAncestor(native_view, GA_ROOT);
+ if (!root) {
+ *reason = 2;
+ return NULL;
+ }
+
+ NativeWidget* widget = GetNativeWidgetForNativeView(root);
+ if (widget) {
+ *reason = 3;
+ return widget;
+ }
+
+ // Second, try to locate the last Widget window in the parent hierarchy.
+ HWND parent_hwnd = native_view;
+ NativeWidget* parent_widget;
+ *reason = 4;
+ do {
+ parent_widget = GetNativeWidgetForNativeView(parent_hwnd);
+ if (parent_widget) {
+ widget = parent_widget;
+ (*reason)++;
+ parent_hwnd = ::GetAncestor(parent_hwnd, GA_PARENT);
+ }
+ } while (parent_hwnd != NULL && parent_widget != NULL);
+
+ return widget;
+}
+
NativeWidget* NativeWidget::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
if (!native_view)