Repository navigation
Refactor NativeWindow (Part 9): Use views::Widget on macOS - #12696
Conversation
|
|
||
| options.Get(options::kSimpleFullScreen, &always_simple_fullscreen_); | ||
| if (!has_frame() || use_content_size) | ||
| SetContentSize(gfx::Size(width, height)); |
There was a problem hiding this comment.
does this change the semantic meaning of width and height to refer to the contents rather than the whole window (including the border)?
There was a problem hiding this comment.
The views::Widget forces setting window size with window borders, which is opposite to when we manually created NSWindow. So I need to replace SetSize with SetContentSize here, for frameless window both calls are the same.
| base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); | ||
| [background_layer | ||
| setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; | ||
| [[window_ contentView] setLayer:background_layer]; |
There was a problem hiding this comment.
i'm curious, what happened without the CALayer set?
There was a problem hiding this comment.
Without setting a layer we would have a black flash when showing window. Cocoa seems to behave differently when we have more than one views with layers.
| } | ||
|
|
||
| void NativeWindowMac::DeleteDelegate() { | ||
| } |
There was a problem hiding this comment.
When is this called (and do we need to do anything here)?
There was a problem hiding this comment.
It is not really needed, I'll remove it.
| // on the fly. | ||
| // TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating | ||
| // window delegate. | ||
| views::BridgedNativeWidget* bridget_view = |
This PR uses
views::Widgetto replace current manual creation ofNSWindow, it would allow us to put arbitraryviews::ViewinsideTopLevelWindowon macOS.To make the migration graceful, I'm still using our own logics for managing window's styles and states, so this change should have minimal affects on window's behaviors. But it can still cause quirks and regressions since Chromium is adding a lot of custom logics to
NSWindowinviews::Widget, please let me know if you noticed any quirk after this change.