Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1732)

Issue 2562653002: Mac: Fix window ordering for certificate viewer/selector sheets and overlays.

Created:
4 years ago by Patti Lor
Modified:
4 years ago
Reviewers:
tapted
CC:
chromium-reviews, mac-reviews_chromium.org, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Mac: Fix window ordering for certificate viewer/selector sheets and overlays. Currently, the macOS-provided native dialogs for the certificate viewer and the certificate chooser both use an invisible overlay window to make them tab-modal instead of window modal (which is the default). If two of these dialogs with invisible overlays are open at the same time, the overlay window order can get mixed up and the overlay window ends up on top of the native dialog. For the MacViews certificate viewer especially, the dialog itself and its corresponding overlay can get incorrect window ordering, where the overlay ends up in front of the dialog. Both these situations will render the native dialog unclickable because the overlay is intercepting mouse events. To fix, adjust the window order manually every time the overlay and dialog are hidden/shown. BUG=671150, 650898

Patch Set 1 #

Total comments: 2

Patch Set 2 : Switch to using NSFooWindowLevels. #

Total comments: 2

Patch Set 3 : Switch to reordering the child window array instead of setting the window level manually. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+27 lines, -2 lines) Patch
M chrome/browser/ui/cocoa/certificate_viewer_mac_cocoa.mm View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm View 1 2 1 chunk +13 lines, -2 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 19 (14 generated)
Patti Lor
Hi Trent, PTAL. Thanks!
4 years ago (2016-12-09 03:45:44 UTC) #7
tapted
https://codereview.chromium.org/2562653002/diff/1/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm File chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm (right): https://codereview.chromium.org/2562653002/diff/1/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm#newcode291 chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm:291: [overlayWindow_ setLevel:0]; We should be passing an NSFooWindowLevel to ...
4 years ago (2016-12-09 04:02:00 UTC) #8
Patti Lor
https://codereview.chromium.org/2562653002/diff/1/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm File chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm (right): https://codereview.chromium.org/2562653002/diff/1/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm#newcode291 chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm:291: [overlayWindow_ setLevel:0]; On 2016/12/09 04:02:00, tapted wrote: > We ...
4 years ago (2016-12-09 05:02:49 UTC) #9
tapted
https://codereview.chromium.org/2562653002/diff/20001/components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm File components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm (right): https://codereview.chromium.org/2562653002/diff/20001/components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm#newcode35 components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm:35: [overlay setLevel:visible ? NSFloatingWindowLevel : NSNormalWindowLevel]; I think NSFloatingWindowLevel ...
4 years ago (2016-12-11 23:28:20 UTC) #14
Patti Lor
4 years ago (2016-12-12 01:29:04 UTC) #19
Thanks Trent, PTAL! Your theory was correct :)

https://codereview.chromium.org/2562653002/diff/20001/components/constrained_...
File
components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm
(right):

https://codereview.chromium.org/2562653002/diff/20001/components/constrained_...
components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm:35:
[overlay setLevel:visible ? NSFloatingWindowLevel : NSNormalWindowLevel];
On 2016/12/11 23:28:20, tapted wrote:
> I think NSFloatingWindowLevel would mean that dragging another window over the
> overlay would cause the overlay window to remain floating above it. (maybe
> sheets and parent/child relationships alter this behaviour, but that's
normally
> what setLevel is for, so I don't think we want it here).
> 
> I have a theory about what's happening. When there are two overlay windows
> attached, AppKit has multiple childWindows to keep "on top" of the browser
> window. But it might be using the order that they were added to childWindows
to
> decide how they should be ordered amongst themselves.
> 
> When showing, can you try something like
> 
> NSWindow* parent = [overlay parentWindow];
> [parent removeChildWindow:parent];
> [parent addChildWindow:overlay];
> 
> That might insert the window at the end, to ensure AppKit always puts the most
> recently shown one on top.

That works! Have done this for all three cases. All of them also required the
sheet to be reparented as well.

Powered by Google App Engine
This is Rietveld 408576698