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

Issue 2404783002: [Mac] Avoid "adding unknown subview" warning. (Closed)

Created:
4 years, 2 months ago by Eugene But (OOO till 7-30)
Modified:
4 years, 2 months ago
Reviewers:
tapted, erikchen, shrike, yunchao
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mac] Avoid "adding unknown subview" warning. Chrome Mac has added a subview above the window's content view, which the Appkit warns about at runtime. Presumably, doing so may break in a future macOS release. This cl adds Chrome's top-level subview to the window's content view, which is what the Appkit wants. The change is done only for macOS 10.11 and later. Using correct view hierarchy breaks a few things which had to be fixed: 1.) Window buttons are now placed in NSToolbarContainerView which height is 22 points and to move buttons down the whole NSToolbarContainerView should be moved down. NSToolbarContainerView is not movable via NSLayoutConstraints and simply resized every time its bounds changed. 2.) Window buttons are not movable anymore by changing their frame. Their position is controlled by layout constraints received from autoresizing mask and buttons can be moved via NSLayoutConstraints. 3.) The hight of browserFrameViewPaintHeight should be the same as tab strip height in order to paint content area correctly. 4.) NSVisualEffect view for titlebar should be hidden in fullscreen. With old view hierarchy NSVisualEffectView was moved offscreen for some reason. Now it is always shown on the titlebar. 5.) Window does not update tracking area which highlights window buttons when those buttons are moved (rdar://28535344). As a workaround addTrackingArea: method is swizzled to prevent unnecessarily adding an extra tracking area. Swizzling is necessary because OS does not provide any signals that tracking area was updated ( NSViewDidUpdateTrackingAreasNotification is called before adding a tracking area, not after). 6.) Windows w/o tab strip should not use NSFullSizeContentViewWindowMask style mask, otherwise they will show up without toolbar. 7.) Tab should not allow moving window when dragged. This is done by overriding _opaqueRectForWindowMoveWhenInTitlebar (AppKit follows the same approach for NSButton, to prevent it from moving the window). BUG=605219 Committed: https://crrev.com/42c6683729d8e049fdcc89e552bdcff5fb337227 Cr-Commit-Position: refs/heads/master@{#424609}

Patch Set 1 #

Patch Set 2 : Merged with head #

Total comments: 18

Patch Set 3 : Addressed review comments #

Patch Set 4 : Added comments to the code that adds fullscreen enter/exit observer #

Total comments: 2

Patch Set 5 : Addressed final comments #

Total comments: 2

Patch Set 6 : Merged with head #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+323 lines, -55 lines) Patch
M base/mac/sdk_forward_declarations.h View 1 2 chunks +20 lines, -0 lines 3 comments Download
M chrome/browser/ui/cocoa/browser_window_layout.h View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/browser_window_layout.mm View 1 chunk +10 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/framed_browser_window.h View 2 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/ui/cocoa/framed_browser_window.mm View 1 2 3 4 5 7 chunks +169 lines, -19 lines 0 comments Download
M chrome/browser/ui/cocoa/full_size_content_window.mm View 2 chunks +18 lines, -14 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm View 1 2 2 chunks +12 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_strip_view.mm View 2 chunks +6 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_view.mm View 1 2 2 chunks +15 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_window_controller.h View 1 2 3 4 2 chunks +4 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_window_controller.mm View 1 2 3 4 7 chunks +61 lines, -17 lines 0 comments Download

Messages

Total messages: 55 (28 generated)
Eugene But (OOO till 7-30)
4 years, 2 months ago (2016-10-10 22:33:23 UTC) #6
tapted
I'm waiting for a build to finish to have more of a play, but this ...
4 years, 2 months ago (2016-10-10 23:38:07 UTC) #7
Eugene But (OOO till 7-30)
https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm File chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm (right): https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm#newcode235 chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm:235: - (NSRect)_opaqueRectForWindowMoveWhenInTitlebar { On 2016/10/10 23:38:06, tapted wrote: > ...
4 years, 2 months ago (2016-10-11 00:33:10 UTC) #10
Eugene But (OOO till 7-30)
Added comments to tab_window_controller.mm to explain why notification center is used.
4 years, 2 months ago (2016-10-11 04:08:09 UTC) #13
tapted
sweet! lgtm. https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm File chrome/browser/ui/cocoa/tabs/tab_window_controller.mm (right): https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm#newcode387 chrome/browser/ui/cocoa/tabs/tab_window_controller.mm:387: [rootView addSubview:tabStripBackgroundView_ On 2016/10/11 00:33:10, Eugene But ...
4 years, 2 months ago (2016-10-11 04:21:43 UTC) #14
Eugene But (OOO till 7-30)
Thanks! https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm File chrome/browser/ui/cocoa/tabs/tab_window_controller.mm (right): https://codereview.chromium.org/2404783002/diff/20001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm#newcode387 chrome/browser/ui/cocoa/tabs/tab_window_controller.mm:387: [rootView addSubview:tabStripBackgroundView_ On 2016/10/11 04:21:43, tapted wrote: > ...
4 years, 2 months ago (2016-10-11 04:35:46 UTC) #15
Eugene But (OOO till 7-30)
+thakis for base/mac/sdk_forward_declarations.h
4 years, 2 months ago (2016-10-11 04:36:31 UTC) #19
Eugene But (OOO till 7-30)
-thakis (tapted has ownership for base/mac)
4 years, 2 months ago (2016-10-11 04:45:05 UTC) #21
Eugene But (OOO till 7-30)
erikchen@, shrike@, do you want to take a look before I land this? Had to ...
4 years, 2 months ago (2016-10-11 04:46:13 UTC) #23
erikchen
lgtm with a question. Thanks for looking into this! https://codereview.chromium.org/2404783002/diff/80001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm File chrome/browser/ui/cocoa/tabs/tab_window_controller.mm (right): https://codereview.chromium.org/2404783002/diff/80001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm#newcode449 chrome/browser/ui/cocoa/tabs/tab_window_controller.mm:449: ...
4 years, 2 months ago (2016-10-11 17:39:46 UTC) #26
shrike
Took a quick look - lgtm. I defer to other reviewers for a more thorough ...
4 years, 2 months ago (2016-10-11 19:06:10 UTC) #27
Eugene But (OOO till 7-30)
Thanks everyone! https://codereview.chromium.org/2404783002/diff/80001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm File chrome/browser/ui/cocoa/tabs/tab_window_controller.mm (right): https://codereview.chromium.org/2404783002/diff/80001/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm#newcode449 chrome/browser/ui/cocoa/tabs/tab_window_controller.mm:449: [[visualEffectView_ animator] setAlphaValue:0.0]; On 2016/10/11 17:39:45, erikchen ...
4 years, 2 months ago (2016-10-11 21:06:16 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2404783002/80001
4 years, 2 months ago (2016-10-11 21:06:44 UTC) #32
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/278616)
4 years, 2 months ago (2016-10-11 21:17:25 UTC) #34
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2404783002/100001
4 years, 2 months ago (2016-10-11 23:10:35 UTC) #40
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 2 months ago (2016-10-12 00:17:37 UTC) #42
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/42c6683729d8e049fdcc89e552bdcff5fb337227 Cr-Commit-Position: refs/heads/master@{#424609}
4 years, 2 months ago (2016-10-12 00:19:59 UTC) #44
yunchao
latest Chromium failed to build by this CL. Could you take a look? https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_declarations.h File ...
4 years, 2 months ago (2016-10-12 04:18:57 UTC) #46
tapted
https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_declarations.h File base/mac/sdk_forward_declarations.h (right): https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_declarations.h#newcode270 base/mac/sdk_forward_declarations.h:270: @interface NSLayoutXAxisAnchor : NSObject On 2016/10/12 04:18:56, yunchao wrote: ...
4 years, 2 months ago (2016-10-12 04:22:34 UTC) #47
yunchao
Thanks for your quick response. please see the comment inline. https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_declarations.h File base/mac/sdk_forward_declarations.h (right): https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_declarations.h#newcode270 ...
4 years, 2 months ago (2016-10-12 04:30:37 UTC) #48
tapted
On 2016/10/12 04:30:37, yunchao wrote: > Thanks for your quick response. please see the comment ...
4 years, 2 months ago (2016-10-12 04:32:04 UTC) #49
tapted
On 2016/10/12 04:30:37, yunchao wrote: > Thanks for your quick response. please see the comment ...
4 years, 2 months ago (2016-10-12 04:32:05 UTC) #50
tapted
On 2016/10/12 04:32:05, tapted wrote: > On 2016/10/12 04:30:37, yunchao wrote: > > Thanks for ...
4 years, 2 months ago (2016-10-12 04:38:22 UTC) #51
Eugene But (OOO till 7-30)
On 2016/10/12 04:32:05, tapted wrote: > On 2016/10/12 04:30:37, yunchao wrote: > > Thanks for ...
4 years, 2 months ago (2016-10-12 04:38:25 UTC) #52
yunchao
On 2016/10/12 04:32:05, tapted wrote: > On 2016/10/12 04:30:37, yunchao wrote: > > Thanks for ...
4 years, 2 months ago (2016-10-12 04:39:56 UTC) #53
Eugene But (OOO till 7-30)
On 2016/10/12 04:39:56, yunchao wrote: > On 2016/10/12 04:32:05, tapted wrote: > > On 2016/10/12 ...
4 years, 2 months ago (2016-10-12 04:43:50 UTC) #54
yunchao
4 years, 2 months ago (2016-10-12 04:58:57 UTC) #55
Message was sent while issue was closed.
On 2016/10/12 04:43:50, Eugene But wrote:
> On 2016/10/12 04:39:56, yunchao wrote:
> > On 2016/10/12 04:32:05, tapted wrote:
> > > On 2016/10/12 04:30:37, yunchao wrote:
> > > > Thanks for your quick response. please see the comment inline.
> > > > 
> > > >
> > >
> >
>
https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_d...
> > > > File base/mac/sdk_forward_declarations.h (right):
> > > > 
> > > >
> > >
> >
>
https://codereview.chromium.org/2404783002/diff/100001/base/mac/sdk_forward_d...
> > > > base/mac/sdk_forward_declarations.h:270: @interface NSLayoutXAxisAnchor
:
> > > > NSObject
> > > > On 2016/10/12 04:22:34, tapted wrote:
> > > > > On 2016/10/12 04:18:56, yunchao wrote:
> > > > > > Sorry to bother you, I failed to build chrome on MacOSX (both on Mac
> > 10.11
> > > > and
> > > > > > 10.12). The build error showed that there is duplicated definition
for
> > > this
> > > > > > class. It has been defined in MacOSX system lib.
> > > > > > 
> > > > > >
> > > > >
> > > >
> > >
> >
>
Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSLayoutAnchor.h:50:12:
> > > > > > note: previous definition is here
> > > > > > @interface NSLayoutXAxisAnchor :
NSLayoutAnchor<NSLayoutXAxisAnchor*>
> > > > > > 
> > > > > > Could you help to verify that Chrome can build on MacOSX
10.11/10.12? 
> > > > > 
> > > > > 
> > > > > I think this lines needs to be
> > > > > 
> > > > > @interface NSLayoutXAxisAnchor (ElCapitanSDK) : NSObject
> > > > > 
> > > > > does that fix the error for you?
> > > > > 
> > > > > 
> > > > > > BTW, do we have MacOSX 10.11/10.12 buildbots before merge a patch? 
> > > > > 
> > > > > We run tests on the OSes, but don't iterate all developer build
> > > configurations
> > > > -
> > > > > Apple update them too regularly. Still, it's important to fix this, so
> if
> > > the
> > > > > above works for you I'll land a quick fix.
> > > > 
> > > > Still not work. But the error is "expected unqualified-id" now, the
error
> at
> > > the
> > > > ":"
> > > 
> > > gah - sorry. Just 
> > > 
> > > @interface NSLayoutXAxisAnchor (ElCapitanSDK)
> > > 
> > > should do the trick. I'm fetching HEAD now to test it out
> > 
> > It works on MacOSX 10.11 now. What about for 10.12?
> What kind of error do you get on 10.12?

Sorry, the fix works on 10.12 too.

Powered by Google App Engine
This is Rietveld 408576698