Closed Bug 1576387 Opened 5 years ago Closed 5 years ago

Remove the override of -[NSWindow setContentView:] and use NSFullSizeContentViewWindowMask instead

Categories

(Core :: Widget: Cocoa, task, P3)

All
macOS
task

Tracking

()

RESOLVED DUPLICATE of bug 1576391

People

(Reporter: mstange, Assigned: mstange)

Details

Attachments

(2 obsolete files)

We have an override of -[NSWindow setContentView:] which makes sure that the window's content view is underneath the titlebar window buttons. The override is only necessary because we don't tell the system that our content view extends into the titlebar: If we were using NSFullSizeContentViewWindowMask (also known as NSWindowStyleMaskFullSizeContentView), the content view would automatically be in the right place in z-order.

We should remove the override. It's a hack and it can cause problems, see bug 1576113 for an example.

Blocks: 1576391

Oh no! It looks like NSFullSizeContentViewWindowMask only causes the window buttons to be on top of the content view if we also allow the NSThemeFrame to return YES from _wantsFloatingTitlebar. So the dependency between this bug and bug 1576391 is actually cyclic, and we have to land both at the same time.

This makes them only apply in windows with titlebars, which is the only place
where they're needed. The setContentView override can even cause harm for other
windows, such as sheet windows, because it'll move the content view below a
full-window covering solid grey view provided by the system, in builds that
link against the 10.14 SDK and don't override _wantsFloatingTitlebar.

This gives us two behaviors for free which we were achieving through manual
overrides:

  • The content view is sized to cover the entire window frame.
  • The window controls are placed on top of the content view (instead of
    underneath it in z-order).

It also forces CoreAnimation layers for the window's entire NSView hierarchy, so
we only use it when the CoreAnimation pref is enabled.

NSFullSizeContentViewWindowMask is only available on 10.10 and up, but we still
support 10.9, so we cannot remove the code with the manual overrides just yet.

This change also requires a change to NonDraggableView in order to preserve
window dragging behavior in the titlebar: When NSFullSizeContentViewWindowMask
is used, the method which assembles the window's draggable region takes a
different path. It treats the titlebar specially, and traverses the NSView
hierarchy twice, once for the titlebar area and once for the rest of the window.
Outside the titlebar, it calls _opaqueRect on every visible NSView, but for the
titlebar area, it calls _opaqueRectForWindowMoveWhenInTitlebar instead.

Overriding _opaqueRectForWindowMoveWhenInTitlebar allows us to achieve the old
dragging behavior.

Depends on D43340

Assignee: nobody → mstange
Status: NEW → ASSIGNED
No longer blocks: 1576391

Comment on attachment 9087945 [details]
Bug 1576387 - Move some method overrides to ToolbarWindow. r=spohl

Revision D43340 was moved to bug 1576391. Setting attachment 9087945 [details] to obsolete.

Attachment #9087945 - Attachment is obsolete: true

Comment on attachment 9087946 [details]
Bug 1576387 - Use NSFullSizeContentViewWindowMask for ToolbarWindows. r=spohl

Revision D43341 was moved to bug 1576391. Setting attachment 9087946 [details] to obsolete.

Attachment #9087946 - Attachment is obsolete: true

Folded into bug 1576391.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: