From 15b1a753aaf6908d938ce41a7cf0abcdfebf86fa Mon Sep 17 00:00:00 2001 From: Butkovits Atila Date: Thu, 21 Nov 2024 13:12:06 +0200 Subject: [PATCH] Backed out changeset 9d9fe1cd50ec (bug 1930292) for causing Win11 visual regressions. CLOSED TREE --- browser/base/content/browser-tabsintitlebar.js | 4 +++- browser/base/content/browser.xhtml | 6 +++++- mozglue/misc/PreXULSkeletonUI.cpp | 16 +++++++++++----- .../tests/browser/browser_findbar_marks.js | 5 ++--- ...ndow_maximized_persist_with_no_titlebar.xhtml | 2 +- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/browser/base/content/browser-tabsintitlebar.js b/browser/base/content/browser-tabsintitlebar.js index 7d39d033ab5c..84e2c4523711 100644 --- a/browser/base/content/browser-tabsintitlebar.js +++ b/browser/base/content/browser-tabsintitlebar.js @@ -69,9 +69,11 @@ var TabsInTitlebar = { !Object.keys(this._disallowed).length; if (allowed) { document.documentElement.setAttribute("tabsintitlebar", "true"); - document.documentElement.setAttribute("chromemargin", "0,0,0,0"); if (AppConstants.platform == "macosx") { + document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1"); document.documentElement.removeAttribute("drawtitle"); + } else { + document.documentElement.setAttribute("chromemargin", "0,2,2,2"); } } else { document.documentElement.removeAttribute("tabsintitlebar"); diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml index 7c6b7c146f80..ca8953f3604f 100644 --- a/browser/base/content/browser.xhtml +++ b/browser/base/content/browser.xhtml @@ -17,7 +17,11 @@ #endif data-l10n-args="{"content-title":"CONTENTTITLE"}" data-l10n-attrs="data-content-title-default, data-content-title-private, data-title-default, data-title-private" - chromemargin="0,0,0,0" +#ifdef XP_WIN + chromemargin="0,2,2,2" +#else + chromemargin="0,-1,-1,-1" +#endif tabsintitlebar="true" windowtype="navigator:browser" macanimationtype="document" diff --git a/mozglue/misc/PreXULSkeletonUI.cpp b/mozglue/misc/PreXULSkeletonUI.cpp index 584a1e2b6b15..3c5744a78515 100644 --- a/mozglue/misc/PreXULSkeletonUI.cpp +++ b/mozglue/misc/PreXULSkeletonUI.cpp @@ -1995,16 +1995,22 @@ static Result CreateAndStorePreXULSkeletonUIImpl( sCaptionHeight = sVerticalResizeMargin + sGetSystemMetricsForDpi(SM_CYCAPTION, sDpi); - // These match the offsets that we get with default prefs. We don't use the - // skeleton ui if tabsInTitlebar is disabled, see bug 1673092. + // These match the margins set in browser-tabsintitlebar.js with default prefs + // on Windows. We don't use the skeleton ui if tabsInTitlebar is disabled, see + // bug 1673092. + const Margin nonClientMargin{0, 2, 2, 2}; + if (sMaximized) { sNonClientOffset.top = sCaptionHeight - sVerticalResizeMargin; } else { // See nsWindow::NormalWindowNonClientOffset() sNonClientOffset.top = sCaptionHeight; - sNonClientOffset.bottom = sVerticalResizeMargin; - sNonClientOffset.left = sHorizontalResizeMargin; - sNonClientOffset.right = sHorizontalResizeMargin; + sNonClientOffset.bottom = + std::min(sVerticalResizeMargin, nonClientMargin.bottom); + sNonClientOffset.left = + std::min(sHorizontalResizeMargin, nonClientMargin.left); + sNonClientOffset.right = + std::min(sHorizontalResizeMargin, nonClientMargin.right); } if (sMaximized) { diff --git a/toolkit/content/tests/browser/browser_findbar_marks.js b/toolkit/content/tests/browser/browser_findbar_marks.js index d75d539d8959..bd025086f723 100644 --- a/toolkit/content/tests/browser/browser_findbar_marks.js +++ b/toolkit/content/tests/browser/browser_findbar_marks.js @@ -197,9 +197,8 @@ add_task(async function test_found_resize() { info(`values: ${JSON.stringify(values)}`); info(`resizedValues: ${JSON.stringify(resizedValues)}`); isfuzzy(resizedValues[0], values[0], 2, "first value"); - const kSlop = 50; - Assert.greaterOrEqual(resizedValues[1] - kSlop, values[1], "second value"); - Assert.greaterOrEqual(resizedValues[2] - kSlop, values[2], "third value"); + Assert.greater(resizedValues[1] - 50, values[1], "second value"); + Assert.greater(resizedValues[2] - 50, values[2], "third value"); endFn(); diff --git a/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml b/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml index 785f3bff967f..e104dfa6525a 100644 --- a/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml +++ b/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml @@ -5,7 +5,7 @@ height="300" width="300" sizemode="normal" - chromemargin="0,0,0,0" + chromemargin="0,2,2,2" id="window" persist="height width sizemode">