diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 23:32:40 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 23:32:40 +0000 |
commit | 3398cc13afd187ca86482ade8a2cdf03903e62cf (patch) | |
tree | 414ee75f2934e33f3fdaacd0675e80acd33c6456 /content | |
parent | c0b554a0e06074342188471e775f5a065d7db3a2 (diff) | |
download | chromium_src-3398cc13afd187ca86482ade8a2cdf03903e62cf.zip chromium_src-3398cc13afd187ca86482ade8a2cdf03903e62cf.tar.gz chromium_src-3398cc13afd187ca86482ade8a2cdf03903e62cf.tar.bz2 |
Make the "get window rect" message handlers report the work area, rather than the true window size, for maximized windows, since that's how the calling code expects them to function.
BUG=88523
TEST=Open DevTools maximized (full single screen) on Windows Vista/7, click the Gearbox button in the Elements panel's Styles pane. The SELECT popup should not stick beyond the right screen edge and should be right-aligned with the right edge of the button. Move the Windows taskbar to the right edge of the screen and repeat. The popup should still get the correct alignment and should not get clipped in any way.
Review URL: http://codereview.chromium.org/7799004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/render_message_filter_win.cc | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/content/browser/renderer_host/render_message_filter_win.cc b/content/browser/renderer_host/render_message_filter_win.cc index e5353e7..c48159b 100644 --- a/content/browser/renderer_host/render_message_filter_win.cc +++ b/content/browser/renderer_host/render_message_filter_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,33 +8,50 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h" -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; +namespace { -// We get null window_ids passed into the two functions below; please see -// http://crbug.com/9060 for more details. +// Returns the "visible window rect" for |window|, defined roughly as "what the +// user thinks of as the window". See comments below regarding the difference +// between this and the true window rect when the window is maximized. +gfx::Rect GetVisibleWindowRect(HWND window) { + // We get null |window_id|s passed into the two functions below; see bug 9060. + // Probably this should be removed and we should prevent this case. + if (!IsWindow(window)) + return gfx::Rect(); + + RECT window_rect = {0}; + GetWindowRect(window, &window_rect); + gfx::Rect rect(window_rect); + + // Maximized windows are outdented from the work area by the frame thickness + // even though this "frame" is not painted. This confuses code (and people) + // that think of a maximized window as corresponding exactly to the work area. + // Correct for this by subtracting the frame thickness back off. + if (IsZoomed(window)) { + rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME), + GetSystemMetrics(SM_CYSIZEFRAME)); + } + return rect; +} + +} // TODO(shess): Provide a mapping from reply_msg->routing_id() to HWND // so that we can eliminate the NativeViewId parameter. void RenderMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* rect) { - HWND window = gfx::NativeViewFromId(window_id); - RECT window_rect = {0}; - GetWindowRect(window, &window_rect); - *rect = window_rect; + *rect = GetVisibleWindowRect(gfx::NativeViewFromId(window_id)); } void RenderMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, gfx::Rect* rect) { - HWND window = gfx::NativeViewFromId(window_id); - RECT window_rect = {0}; - HWND root_window = ::GetAncestor(window, GA_ROOT); - GetWindowRect(root_window, &window_rect); - *rect = window_rect; + *rect = GetVisibleWindowRect(GetAncestor(gfx::NativeViewFromId(window_id), + GA_ROOT)); } void RenderMessageFilter::OnGetScreenInfo(gfx::NativeViewId view, WebKit::WebScreenInfo* results) { - *results = WebScreenInfoFactory::screenInfo(gfx::NativeViewFromId(view)); + *results = + WebKit::WebScreenInfoFactory::screenInfo(gfx::NativeViewFromId(view)); } |