summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 21:58:24 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 21:58:24 +0000
commita1a9e7c87641ad88d189c154293bf602859249f3 (patch)
treeb04b48cd64234951f45bd6ff16752b1be3c6ff61
parentce0cb2221ce904f7e18db8e6fcbbba689e0d44d0 (diff)
downloadchromium_src-a1a9e7c87641ad88d189c154293bf602859249f3.zip
chromium_src-a1a9e7c87641ad88d189c154293bf602859249f3.tar.gz
chromium_src-a1a9e7c87641ad88d189c154293bf602859249f3.tar.bz2
Removes code added to track down crash. The crash seems to have
occurred for two reasons: . window class name changing out from under us. . CreateWindow returning NULL because we're out of memory. I've changed the following: . Left in CHECK on return from CreateWindow. . Removed dependency on class name. We don't really need it anyway. I've also changed View::PaintFocusableBorder to check focusable last, as that requires looking up the FocusManager BUG=77651 TEST=none Review URL: http://codereview.chromium.org/6865023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81812 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc13
-rw-r--r--ui/base/win/window_impl.cc15
-rw-r--r--ui/base/win/window_impl.h3
-rw-r--r--ui/views/widget/native_widget_win.cc2
-rw-r--r--views/view.cc2
-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.cc70
-rw-r--r--views/widget/widget_win.h3
10 files changed, 3 insertions, 135 deletions
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 3b8d045..d5565ec 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -2143,19 +2143,6 @@ void BrowserView::LoadAccelerators() {
views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
- // Debugging code to help track 77651.
- if (!focus_manager) {
- int reason = -1;
- views::Widget* widget = GetWidget();
- views::Widget* top_level_widget =
- widget ? widget->GetTopLevelWidgetWithReason(&reason) : NULL;
- volatile int v_reason = reason;
- volatile bool got_native_widget_created =
- widget ? widget->got_native_widget_created() : false;
- CHECK(false) << widget << " " << top_level_widget << " " << v_reason <<
- " " << got_native_widget_created;
- }
-
// Let's fill our own accelerator table.
for (int i = 0; i < count; ++i) {
bool alt_down = (accelerators[i].fVirt & FALT) == FALT;
diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc
index 1d2c55b..d07c8c3 100644
--- a/ui/base/win/window_impl.cc
+++ b/ui/base/win/window_impl.cc
@@ -159,33 +159,20 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) {
reinterpret_cast<LPWSTR>(&error_string),
0, // Buffer size.
0); // Arguments (unused).
+ // Typical reason for failure is ERROR_NOT_ENOUGH_MEMORY (8).
CHECK(false) << "Create failed error=" << last_error <<
" message=" << error_string << " name=" << name << " style=" <<
window_style_ << " ex_style=" << window_ex_style_;
- if (error_string)
- LocalFree(error_string);
}
// The window procedure should have set the data for us.
CHECK_EQ(this, ui::GetWindowUserData(hwnd_));
-
- CHECK(IsWindowImpl(hwnd_));
}
HICON WindowImpl::GetDefaultWindowIcon() const {
return NULL;
}
-// static
-bool WindowImpl::IsWindowImpl(HWND hwnd) {
- wchar_t tmp[128];
- if (!::GetClassName(hwnd, tmp, 128))
- return false;
-
- std::wstring class_name(tmp);
- return class_name.find(kBaseClassName) == 0;
-}
-
LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
LRESULT result = 0;
diff --git a/ui/base/win/window_impl.h b/ui/base/win/window_impl.h
index 59b7562..5a59819 100644
--- a/ui/base/win/window_impl.h
+++ b/ui/base/win/window_impl.h
@@ -71,9 +71,6 @@ class WindowImpl : public MessageMapInterface {
}
UINT initial_class_style() const { return class_style_; }
- // Returns true if the specified |hwnd| is a WindowImpl.
- static bool IsWindowImpl(HWND hwnd);
-
protected:
// Handles the WndProc callback for this object.
virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param);
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index e9c2d2f..8a5ad92 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -631,8 +631,6 @@ NativeWidget* NativeWidget::CreateNativeWidget(
// static
NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
- if (!WindowImpl::IsWindowImpl(native_view))
- return NULL;
return reinterpret_cast<internal::NativeWidgetWin*>(
ViewProp::GetValue(native_view, internal::kNativeWidgetKey));
}
diff --git a/views/view.cc b/views/view.cc
index 37f71d0..9d1c976 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -1133,7 +1133,7 @@ void View::OnPaintBorder(gfx::Canvas* canvas) {
}
void View::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if (HasFocus() && (IsFocusable() || IsAccessibilityFocusableInRootView()))
+ if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus())
canvas->DrawFocusRect(0, 0, width(), height());
}
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 9ef9070..b7692f3 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -44,13 +44,6 @@ 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 ae12bce..924c448 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -52,8 +52,7 @@ Widget::Widget()
last_mouse_event_was_move_(false),
native_widget_(NULL),
widget_delegate_(NULL),
- dragged_view_(NULL),
- got_native_widget_created_(false) {
+ dragged_view_(NULL) {
}
Widget::~Widget() {
@@ -118,14 +117,6 @@ 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());
@@ -309,7 +300,6 @@ 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 aac024e..ec126a0 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -153,11 +153,6 @@ 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();
@@ -289,9 +284,6 @@ 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;
@@ -377,9 +369,6 @@ 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 05ba37d..0e14983 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -6,9 +6,7 @@
#include <dwmapi.h>
-#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_source.h"
@@ -160,16 +158,6 @@ WidgetWin::~WidgetWin() {
}
// static
-WidgetWin* WidgetWin::GetWidget(HWND hwnd) {
- // TODO(jcivelli): http://crbug.com/44499 We need a way to test that hwnd is
- // associated with a WidgetWin (it might be a pure
- // WindowImpl).
- if (!WindowImpl::IsWindowImpl(hwnd))
- return NULL;
- return reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(hwnd));
-}
-
-// static
bool WidgetWin::IsAeroGlassEnabled() {
if (base::win::GetVersion() < base::win::VERSION_VISTA)
return false;
@@ -609,21 +597,6 @@ void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) {
}
LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
- // Debugging code to help track 77651.
- CHECK(hwnd());
- if (!ui::WindowImpl::IsWindowImpl(hwnd())) {
- std::wstring class_name;
- wchar_t tmp[128];
- if (!::GetClassName(hwnd(), tmp, 128)) {
- class_name = L"unable to get class name error=" +
- UTF8ToWide(base::IntToString(GetLastError()));
- } else {
- class_name = std::wstring(tmp);
- }
-
- CHECK(false) << " Not a window impl, hwnd=" << hwnd() <<
- " class_name=" << class_name << " is_window=" << ::IsWindow(hwnd());
- }
SetNativeWindowProperty(kNativeWidgetKey, this);
CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd()));
@@ -1192,8 +1165,6 @@ bool Widget::ConvertRect(const Widget* source,
NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
- if (!ui::WindowImpl::IsWindowImpl(native_view))
- return NULL;
return reinterpret_cast<WidgetWin*>(
ViewProp::GetValue(native_view, kNativeWidgetKey));
}
@@ -1203,47 +1174,6 @@ 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);
-
- if (!widget && !ui::WindowImpl::IsWindowImpl(native_view))
- *reason = 1000;
-
- return widget;
-}
-
NativeWidget* NativeWidget::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
if (!native_view)
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 778606b..6a46968 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -88,9 +88,6 @@ class WidgetWin : public ui::WindowImpl,
WidgetWin();
virtual ~WidgetWin();
- // Returns the Widget associated with the specified HWND (if any).
- static WidgetWin* GetWidget(HWND hwnd);
-
// Returns true if we are on Windows Vista or greater and composition is
// enabled.
static bool IsAeroGlassEnabled();