diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 18:37:09 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 18:37:09 +0000 |
commit | 11dc620017dcdd87936e7a9c8647a78fe6730175 (patch) | |
tree | 025eb911f0dc04fdec61cf2ba59148705a35da70 | |
parent | d1a2558144a7472d0b1ae4a196f46774618ec18d (diff) | |
download | chromium_src-11dc620017dcdd87936e7a9c8647a78fe6730175.zip chromium_src-11dc620017dcdd87936e7a9c8647a78fe6730175.tar.gz chromium_src-11dc620017dcdd87936e7a9c8647a78fe6730175.tar.bz2 |
Fix crash in KeyboardController when widget is being destroyed or crashed
widget->GetView() may return NULL so adding check for that.
BUG=381091
Review URL: https://codereview.chromium.org/314113002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275201 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/keyboard/keyboard_controller.cc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc index 99bddd8..e43e036 100644 --- a/ui/keyboard/keyboard_controller.cc +++ b/ui/keyboard/keyboard_controller.cc @@ -251,18 +251,23 @@ void KeyboardController::NotifyKeyboardBoundsChanging( aura::Window *root_window = keyboard_window->GetRootWindow(); while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { content::RenderWidgetHostView* view = widget->GetView(); - aura::Window *window = view->GetNativeView(); - if (window != keyboard_window && window->GetRootWindow() == root_window) - { - gfx::Rect window_bounds = window->GetBoundsInScreen(); - gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); - int overlap = intersect.height(); - if (overlap > 0 && overlap < window_bounds.height()) - view->SetInsets(gfx::Insets(0, 0, overlap, 0)); - else - view->SetInsets(gfx::Insets(0, 0, 0, 0)); - // TODO(kevers): Add window observer to native window to update insets - // on a window move or resize. + // Can be NULL, e.g. if the RenderWidget is being destroyed or + // the render process crashed. + if (view) { + aura::Window *window = view->GetNativeView(); + if (window != keyboard_window && + window->GetRootWindow() == root_window) { + gfx::Rect window_bounds = window->GetBoundsInScreen(); + gfx::Rect intersect = gfx::IntersectRects(window_bounds, + new_bounds); + int overlap = intersect.height(); + if (overlap > 0 && overlap < window_bounds.height()) + view->SetInsets(gfx::Insets(0, 0, overlap, 0)); + else + view->SetInsets(gfx::Insets(0, 0, 0, 0)); + // TODO(kevers): Add window observer to native window to update + // insets on a window move or resize. + } } } } |