|
|
Chromium Code Reviews|
Created:
3 years, 11 months ago by tapted Modified:
3 years, 11 months ago Reviewers:
Robert Sesek CC:
chromium-reviews, tfarina, mac-reviews_chromium.org, chrome-apps-syd-reviews_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionMacViews: Support -[NSWindow close] on sheets.
Usually a sheet is closed with a call to endSheet:, which blocks the UI
thread to run the close animation, then runs the didEndSelector passed
to -[NSApp beginSheet:..]. Calling -[NSWindow close] bypasses this and
shouldn't be used. However, there are times where we need to close a
sheet more violently. E.g.: When -[NSWindow close] is invoked on the
parent window currently hosting a sheet, or during a dialog test that
wants to invoke the synchronous Widget::CloseNow() rather than
asynchronous Widget::Close(). Attempts to do this used to DCHECK().
Now, support -[NSWindow close] of a sheet by posting a task to
-[NSWindow endSheet:] on the parent when the sheet is closed. This has
tricky lifetime implications, but is necessary to ensure the modal
session on the parent window is unblocked.
BUG=681049
Review-Url: https://codereview.chromium.org/2629593005
Cr-Commit-Position: refs/heads/master@{#443718}
Committed: https://chromium.googlesource.com/chromium/src/+/caeaf7c8f5c0daf2db7fd1a0dad1828dac26d62c
Patch Set 1 #Patch Set 2 : Fix lifetime #
Total comments: 7
Patch Set 3 : Test show failure #
Total comments: 1
Patch Set 4 : no doNothing #
Messages
Total messages: 25 (18 generated)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== MacViews: Support -[NSWindow close] on sheets. BUG= ========== to ========== MacViews: Support -[NSWindow close] on sheets. Usually a sheet is closed with a call to endSheet:, which blocks the UI thread to run the close animation, then runs the didEndSelector passed to -[NSApp beginSheet:..]. Calling -[NSWindow close] bypasses this and shouldn't be used. However, there are times where we need to close a sheet more violently. E.g.: When -[NSWindow close] is invoked on the parent window currently hosting a sheet, or during a dialog test that wants to invoke the synchronous Widget::CloseNow() rather than asynchronous Widget::Close(). Attempts to do this used to DCHECK(). Now, support -[NSWindow close] of a sheet by posting a task to -[NSWindow endSheet:] on the parent when the sheet is closed. This has tricky lifetime implications, but is necessary to ensure the modal session on the parent window is unblocked. BUG=681049 ==========
tapted@chromium.org changed reviewers: + rsesek@chromium.org
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hi Robert, please take a look https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... File ui/views/widget/native_widget_mac.mm (left): https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... ui/views/widget/native_widget_mac.mm:385: // Cocoa ignores -close calls on open sheets, so they should be closed I think when I wrote this things were structured a bit different and the problem was that -close wasn't triggering sheetDidEnd: . Hopefully I've catered for all the dragons now.. (but this should only come up in tests and during process shutdown anyway, since having a sheet will disable the close button for users).
lgtm w/ two questions https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... File ui/views/cocoa/views_nswindow_delegate.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... ui/views/cocoa/views_nswindow_delegate.mm:95: // Does nothing: Used to force |self| to be retained in a block. Could you instead just put another keepAlive in the block? https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... File ui/views/widget/native_widget_mac_unittest.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... ui/views/widget/native_widget_mac_unittest.mm:1170: // Tests behavior when closing a window that is a sheet, or that hosts a sheet. Also worth testing re-showing a sheet on a window that had previously closed a sheet?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... File ui/views/cocoa/views_nswindow_delegate.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... ui/views/cocoa/views_nswindow_delegate.mm:95: // Does nothing: Used to force |self| to be retained in a block. On 2017/01/13 20:02:47, Robert Sesek wrote: > Could you instead just put another keepAlive in the block? That would take (and release) an additional reference :). Currently there's just the reference being held by the ObjC block machinery. i.e. It would work, but it would effectively be replacing [self doNothing]; with [self retain]; [self release]; So I don't know if that's better. I do think `doNothing` is weird, but I didn't want to use additional retain/release since it might suggest that the block doesn't already have a ref to begin with that exists for the lifetime of the block (or that we need to account for some other hidden weirdness..) But I'm not otherwise attached to `doNothing` - e.g. I thought about calling some random NSObject property, but thought "doNothing" gave slightly more meaning. https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... File ui/views/widget/native_widget_mac_unittest.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/widget/native_... ui/views/widget/native_widget_mac_unittest.mm:1170: // Tests behavior when closing a window that is a sheet, or that hosts a sheet. On 2017/01/13 20:02:47, Robert Sesek wrote: > Also worth testing re-showing a sheet on a window that had previously closed a > sheet? Done. https://codereview.chromium.org/2629593005/diff/40001/ui/views/widget/native_... File ui/views/widget/native_widget_mac_unittest.mm (right): https://codereview.chromium.org/2629593005/diff/40001/ui/views/widget/native_... ui/views/widget/native_widget_mac_unittest.mm:1196: EXPECT_TRUE([sheet_widget->GetNativeWindow() isVisible]); (added this to check re-showing - it fails without the RunUntilIdle() bit above for example)
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
LGTM, take or leave the suggestion https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... File ui/views/cocoa/views_nswindow_delegate.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... ui/views/cocoa/views_nswindow_delegate.mm:95: // Does nothing: Used to force |self| to be retained in a block. On 2017/01/13 20:52:51, tapted wrote: > On 2017/01/13 20:02:47, Robert Sesek wrote: > > Could you instead just put another keepAlive in the block? > > That would take (and release) an additional reference :). Currently there's just > the reference being held by the ObjC block machinery. i.e. It would work, but it > would effectively be replacing > > [self doNothing]; > > with > > [self retain]; > [self release]; > > So I don't know if that's better. I do think `doNothing` is weird, but I didn't > want to use additional retain/release since it might suggest that the block > doesn't already have a ref to begin with that exists for the lifetime of the > block (or that we need to account for some other hidden weirdness..) > > But I'm not otherwise attached to `doNothing` - e.g. I thought about calling > some random NSObject property, but thought "doNothing" gave slightly more > meaning. Hm, I see your point. Maybe rather than doNothing, you end the block with [[self retain] release]; ?
https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... File ui/views/cocoa/views_nswindow_delegate.mm (right): https://codereview.chromium.org/2629593005/diff/20001/ui/views/cocoa/views_ns... ui/views/cocoa/views_nswindow_delegate.mm:95: // Does nothing: Used to force |self| to be retained in a block. On 2017/01/13 21:46:00, Robert Sesek wrote: > On 2017/01/13 20:52:51, tapted wrote: > > On 2017/01/13 20:02:47, Robert Sesek wrote: > > > Could you instead just put another keepAlive in the block? > > > > That would take (and release) an additional reference :). Currently there's > just > > the reference being held by the ObjC block machinery. i.e. It would work, but > it > > would effectively be replacing > > > > [self doNothing]; > > > > with > > > > [self retain]; > > [self release]; > > > > So I don't know if that's better. I do think `doNothing` is weird, but I > didn't > > want to use additional retain/release since it might suggest that the block > > doesn't already have a ref to begin with that exists for the lifetime of the > > block (or that we need to account for some other hidden weirdness..) > > > > But I'm not otherwise attached to `doNothing` - e.g. I thought about calling > > some random NSObject property, but thought "doNothing" gave slightly more > > meaning. > > Hm, I see your point. Maybe rather than doNothing, you end the block with [[self > retain] release]; ? Done!
The CQ bit was checked by tapted@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from rsesek@chromium.org Link to the patchset: https://codereview.chromium.org/2629593005/#ps60001 (title: "no doNothing")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1484346773823210,
"parent_rev": "16af7e87fbb7d49f79185b33209249f4877f8950", "commit_rev":
"caeaf7c8f5c0daf2db7fd1a0dad1828dac26d62c"}
Message was sent while issue was closed.
Description was changed from ========== MacViews: Support -[NSWindow close] on sheets. Usually a sheet is closed with a call to endSheet:, which blocks the UI thread to run the close animation, then runs the didEndSelector passed to -[NSApp beginSheet:..]. Calling -[NSWindow close] bypasses this and shouldn't be used. However, there are times where we need to close a sheet more violently. E.g.: When -[NSWindow close] is invoked on the parent window currently hosting a sheet, or during a dialog test that wants to invoke the synchronous Widget::CloseNow() rather than asynchronous Widget::Close(). Attempts to do this used to DCHECK(). Now, support -[NSWindow close] of a sheet by posting a task to -[NSWindow endSheet:] on the parent when the sheet is closed. This has tricky lifetime implications, but is necessary to ensure the modal session on the parent window is unblocked. BUG=681049 ========== to ========== MacViews: Support -[NSWindow close] on sheets. Usually a sheet is closed with a call to endSheet:, which blocks the UI thread to run the close animation, then runs the didEndSelector passed to -[NSApp beginSheet:..]. Calling -[NSWindow close] bypasses this and shouldn't be used. However, there are times where we need to close a sheet more violently. E.g.: When -[NSWindow close] is invoked on the parent window currently hosting a sheet, or during a dialog test that wants to invoke the synchronous Widget::CloseNow() rather than asynchronous Widget::Close(). Attempts to do this used to DCHECK(). Now, support -[NSWindow close] of a sheet by posting a task to -[NSWindow endSheet:] on the parent when the sheet is closed. This has tricky lifetime implications, but is necessary to ensure the modal session on the parent window is unblocked. BUG=681049 Review-Url: https://codereview.chromium.org/2629593005 Cr-Commit-Position: refs/heads/master@{#443718} Committed: https://chromium.googlesource.com/chromium/src/+/caeaf7c8f5c0daf2db7fd1a0dad1... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/caeaf7c8f5c0daf2db7fd1a0dad1... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
