fix: incorrect wco bounds in macOS fullscreen (#40179)
This commit is contained in:
parent
c9f6f15df6
commit
f362e089b1
4 changed files with 27 additions and 15 deletions
|
@ -537,7 +537,7 @@ void NativeWindow::PreviewFile(const std::string& path,
|
||||||
|
|
||||||
void NativeWindow::CloseFilePreview() {}
|
void NativeWindow::CloseFilePreview() {}
|
||||||
|
|
||||||
gfx::Rect NativeWindow::GetWindowControlsOverlayRect() {
|
absl::optional<gfx::Rect> NativeWindow::GetWindowControlsOverlayRect() {
|
||||||
return overlay_rect_;
|
return overlay_rect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,6 +665,7 @@ void NativeWindow::NotifyWindowMoved() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowEnterFullScreen() {
|
void NativeWindow::NotifyWindowEnterFullScreen() {
|
||||||
|
NotifyLayoutWindowControlsOverlay();
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.OnWindowEnterFullScreen();
|
observer.OnWindowEnterFullScreen();
|
||||||
}
|
}
|
||||||
|
@ -690,6 +691,7 @@ void NativeWindow::NotifyWindowSheetEnd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||||
|
NotifyLayoutWindowControlsOverlay();
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.OnWindowLeaveFullScreen();
|
observer.OnWindowLeaveFullScreen();
|
||||||
}
|
}
|
||||||
|
@ -733,10 +735,10 @@ void NativeWindow::NotifyWindowSystemContextMenu(int x,
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyLayoutWindowControlsOverlay() {
|
void NativeWindow::NotifyLayoutWindowControlsOverlay() {
|
||||||
gfx::Rect bounding_rect = GetWindowControlsOverlayRect();
|
auto bounding_rect = GetWindowControlsOverlayRect();
|
||||||
if (!bounding_rect.IsEmpty()) {
|
if (bounding_rect.has_value()) {
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.UpdateWindowControlsOverlay(bounding_rect);
|
observer.UpdateWindowControlsOverlay(bounding_rect.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
return weak_factory_.GetWeakPtr();
|
return weak_factory_.GetWeakPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual gfx::Rect GetWindowControlsOverlayRect();
|
virtual absl::optional<gfx::Rect> GetWindowControlsOverlayRect();
|
||||||
virtual void SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect);
|
virtual void SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect);
|
||||||
|
|
||||||
// Methods called by the WebContents.
|
// Methods called by the WebContents.
|
||||||
|
|
|
@ -153,7 +153,7 @@ class NativeWindowMac : public NativeWindow,
|
||||||
void CloseFilePreview() override;
|
void CloseFilePreview() override;
|
||||||
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
||||||
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
||||||
gfx::Rect GetWindowControlsOverlayRect() override;
|
absl::optional<gfx::Rect> GetWindowControlsOverlayRect() override;
|
||||||
void NotifyWindowEnterFullScreen() override;
|
void NotifyWindowEnterFullScreen() override;
|
||||||
void NotifyWindowLeaveFullScreen() override;
|
void NotifyWindowLeaveFullScreen() override;
|
||||||
void SetActive(bool is_key) override;
|
void SetActive(bool is_key) override;
|
||||||
|
|
|
@ -1899,23 +1899,33 @@ void NativeWindowMac::SetForwardMouseMessages(bool forward) {
|
||||||
[window_ setAcceptsMouseMovedEvents:forward];
|
[window_ setAcceptsMouseMovedEvents:forward];
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect NativeWindowMac::GetWindowControlsOverlayRect() {
|
absl::optional<gfx::Rect> NativeWindowMac::GetWindowControlsOverlayRect() {
|
||||||
if (titlebar_overlay_ && buttons_proxy_ &&
|
if (!titlebar_overlay_)
|
||||||
window_button_visibility_.value_or(true)) {
|
return absl::nullopt;
|
||||||
|
|
||||||
|
// On macOS, when in fullscreen mode, window controls (the menu bar, title
|
||||||
|
// bar, and toolbar) are attached to a separate NSView that slides down from
|
||||||
|
// the top of the screen, independent of, and overlapping the WebContents.
|
||||||
|
// Disable WCO when in fullscreen, because this space is inaccessible to
|
||||||
|
// WebContents. https://crbug.com/915110.
|
||||||
|
if (IsFullscreen())
|
||||||
|
return gfx::Rect();
|
||||||
|
|
||||||
|
if (buttons_proxy_ && window_button_visibility_.value_or(true)) {
|
||||||
NSRect buttons = [buttons_proxy_ getButtonsContainerBounds];
|
NSRect buttons = [buttons_proxy_ getButtonsContainerBounds];
|
||||||
gfx::Rect overlay;
|
gfx::Rect overlay;
|
||||||
overlay.set_width(GetContentSize().width() - NSWidth(buttons));
|
overlay.set_width(GetContentSize().width() - NSWidth(buttons));
|
||||||
if ([buttons_proxy_ useCustomHeight]) {
|
overlay.set_height([buttons_proxy_ useCustomHeight]
|
||||||
overlay.set_height(titlebar_overlay_height());
|
? titlebar_overlay_height()
|
||||||
} else {
|
: NSHeight(buttons));
|
||||||
overlay.set_height(NSHeight(buttons));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!base::i18n::IsRTL())
|
if (!base::i18n::IsRTL())
|
||||||
overlay.set_x(NSMaxX(buttons));
|
overlay.set_x(NSMaxX(buttons));
|
||||||
|
|
||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
return gfx::Rect();
|
|
||||||
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
Loading…
Reference in a new issue