Bug 1892934 - Domain highlighting doesn't work when detaching tabs. r=jteow

There's a timing issue where sometimes formatting happens too early on new
windows opening, so we await for the next RAF to happen.
Note there's already a test in browser_UrlbarInput_formatValue_detachedTab.js
covering this, and it's indeed failing intermittently, this may fix it.

The patch also avoids trimming when active mixed content may show a strikeout
https protocol. This is an uncommon state anyway because we block active mixed
content, and in the future we'll rely on the insecure label.

Differential Revision: https://phabricator.services.mozilla.com/D212906
This commit is contained in:
Marco Bonardo
2024-06-19 11:17:27 +00:00
parent d006e0761b
commit c33e249b2b
7 changed files with 103 additions and 72 deletions

View File

@@ -2523,12 +2523,11 @@ export class UrlbarInput {
// Check overflow again to ensure it didn't change in the meanwhile.
let input = this.inputField;
if (input && this._overflowing) {
// Normally we would overflow at the final side of text direction,
// though RTL domains may cause us to overflow at the opposite side.
// This happens dynamically as a consequence of the input field contents
// and the call to _ensureFormattedHostVisible, this code only reports
// the final state of all that scrolling into an attribute, because
// there's no other way to capture this in css.
// Normally we overflow at the end side of the text direction, though
// RTL domains may cause us to overflow at the opposite side.
// The outcome differs depending on the input field contents and applied
// formatting, and reports the final state of all the scrolling into an
// attribute available to css rules.
// Note it's also possible to scroll an unfocused input field using
// SHIFT + mousewheel on Windows, or with just the mousewheel / touchpad
// scroll (without modifiers) on Mac.
@@ -2738,8 +2737,10 @@ export class UrlbarInput {
let trimmedValue = lazy.UrlbarPrefs.get("trimURLs")
? lazy.BrowserUIUtils.trimURL(val)
: val;
// Only trim value if the directionality doesn't change to RTL.
return lazy.UrlbarUtils.isTextDirectionRTL(trimmedValue, this.window)
// Only trim value if the directionality doesn't change to RTL and we're not
// showing a strikeout https protocol.
return lazy.UrlbarUtils.isTextDirectionRTL(trimmedValue, this.window) ||
this.valueFormatter.willShowFormattedMixedContentProtocol(val)
? val
: trimmedValue;
}