Skip to content

Commit

Permalink
Make javascript dialogs into top-level windows for desktop aura.
Browse files Browse the repository at this point in the history
Also, correct aura window sizing on desktop aura for Windows.

BUG=230935, 234558, 225252
TEST=NONE (yet)

Review URL: https://chromiumcodereview.appspot.com/13896011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197949 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
robertshield@chromium.org committed May 2, 2013
1 parent 9959eeb commit 884401d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,20 @@ JavaScriptAppModalDialog::~JavaScriptAppModalDialog() {
NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() {
gfx::NativeWindow parent_window =
web_contents()->GetView()->GetTopLevelNativeWindow();

#if defined(USE_AURA)
#if defined(OS_WIN)
// JS dialogs should always be top-level windows in desktop Aura on Windows.
parent_window = NULL;
#else
if (!parent_window->GetRootWindow()) {
// When we are part of a WebContents that isn't actually being displayed on
// the screen, we can't actually attach to it.
parent_window = NULL;
}
#endif
#endif // defined(OS_WIN)
#endif // defined(USE_AURA)

return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this,
parent_window);
}
Expand Down
6 changes: 5 additions & 1 deletion ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,11 @@ void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) {

void DesktopNativeWidgetAura::ClearNativeFocus() {
desktop_root_window_host_->ClearNativeFocus();
aura::client::GetFocusClient(window_)->ResetFocusWithinActiveWindow(window_);

if (ShouldActivate()) {
aura::client::GetFocusClient(window_)->
ResetFocusWithinActiveWindow(window_);
}
}

gfx::Rect DesktopNativeWidgetAura::GetWorkAreaBoundsInScreen() const {
Expand Down
3 changes: 3 additions & 0 deletions ui/views/win/hwnd_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define UI_VIEWS_WIN_HWND_UTIL_H_

#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "ui/views/views_export.h"

namespace views {
Expand All @@ -25,6 +26,8 @@ VIEWS_EXPORT HWND HWNDForNativeView(gfx::NativeView view);
// Returns the HWND for the specified NativeWindow.
VIEWS_EXPORT HWND HWNDForNativeWindow(gfx::NativeWindow window);

VIEWS_EXPORT gfx::Rect GetWindowBoundsForClientBounds(
View* view, const gfx::Rect& client_bounds);
}

#endif // UI_VIEWS_WIN_HWND_UTIL_H_
16 changes: 16 additions & 0 deletions ui/views/win/hwnd_util_aurawin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ HWND HWNDForNativeWindow(gfx::NativeWindow window) {
window->GetRootWindow()->GetAcceleratedWidget() : NULL;
}

gfx::Rect GetWindowBoundsForClientBounds(View* view,
const gfx::Rect& client_bounds) {
DCHECK(view);
aura::RootWindow* window =
view->GetWidget()->GetNativeWindow()->GetRootWindow();
if (window) {
HWND hwnd = window->GetAcceleratedWidget();
RECT rect = client_bounds.ToRECT();
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
return gfx::Rect(rect);
}
return client_bounds;
}

} // namespace views
11 changes: 11 additions & 0 deletions ui/views/win/hwnd_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,15 @@ HWND HWNDForNativeWindow(gfx::NativeWindow window) {
return window;
}

gfx::Rect GetWindowBoundsForClientBounds(View* view,
const gfx::Rect& client_bounds) {
DCHECK(view);
HWND hwnd = view->GetWidget()->GetNativeWindow();
RECT rect = client_bounds.ToRECT();
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
return gfx::Rect(rect);
}

} // namespace views
13 changes: 7 additions & 6 deletions ui/views/window/native_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"

#if defined(OS_WIN)
#include "ui/views/win/hwnd_util.h"
#endif

namespace views {

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -29,12 +33,9 @@ gfx::Rect NativeFrameView::GetBoundsForClientView() const {

gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
#if defined(OS_WIN) && !defined(USE_AURA)
RECT rect = client_bounds.ToRECT();
DWORD style = ::GetWindowLong(GetWidget()->GetNativeView(), GWL_STYLE);
DWORD ex_style = ::GetWindowLong(GetWidget()->GetNativeView(), GWL_EXSTYLE);
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
return gfx::Rect(rect);
#if defined(OS_WIN)
return views::GetWindowBoundsForClientBounds(
static_cast<View*>(const_cast<NativeFrameView*>(this)), client_bounds);
#else
// TODO(sad):
return client_bounds;
Expand Down

0 comments on commit 884401d

Please sign in to comment.