revert: compensate for title bar height when setting bounds on BrowserView (#39004)

This reverts commit 75f9573e53.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2023-07-10 15:57:55 +02:00
committed by GitHub
parent 13d224e816
commit b0b87b098e
2 changed files with 9 additions and 39 deletions

View File

@@ -58,21 +58,9 @@ void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
auto* view = iwc_view->GetNativeView().GetNativeNSView();
auto* superview = view.superview;
const auto superview_height = superview ? superview.frame.size.height : 0;
// We need to use the content rect to calculate the titlebar height if the
// superview is an framed NSWindow, otherwise it will be offset incorrectly by
// the height of the titlebar.
auto titlebar_height = 0;
if (auto* win = [superview window]) {
const auto content_rect_height =
[win contentRectForFrameRect:superview.frame].size.height;
titlebar_height = superview_height - content_rect_height;
}
auto new_height =
superview_height - bounds.y() - bounds.height() + titlebar_height;
view.frame =
NSMakeRect(bounds.x(), new_height, bounds.width(), bounds.height());
NSMakeRect(bounds.x(), superview_height - bounds.y() - bounds.height(),
bounds.width(), bounds.height());
}
gfx::Rect NativeBrowserViewMac::GetBounds() {
@@ -80,23 +68,12 @@ gfx::Rect NativeBrowserViewMac::GetBounds() {
if (!iwc_view)
return gfx::Rect();
NSView* view = iwc_view->GetNativeView().GetNativeNSView();
auto* superview = view.superview;
const int superview_height = superview ? superview.frame.size.height : 0;
// We need to use the content rect to calculate the titlebar height if the
// superview is an framed NSWindow, otherwise it will be offset incorrectly by
// the height of the titlebar.
auto titlebar_height = 0;
if (auto* win = [superview window]) {
const auto content_rect_height =
[win contentRectForFrameRect:superview.frame].size.height;
titlebar_height = superview_height - content_rect_height;
}
auto new_height = superview_height - view.frame.origin.y -
view.frame.size.height + titlebar_height;
return gfx::Rect(view.frame.origin.x, new_height, view.frame.size.width,
view.frame.size.height);
const int superview_height =
(view.superview) ? view.superview.frame.size.height : 0;
return gfx::Rect(
view.frame.origin.x,
superview_height - view.frame.origin.y - view.frame.size.height,
view.frame.size.width, view.frame.size.height);
}
void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {