Closed Bug 2051196 Opened 21 days ago Closed 19 days ago

Add a global [hidden] { display: none !important } rule instead of :not([hidden]) display guards

Categories

(Toolkit :: Themes, task)

task

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: dao, Assigned: dao)

References

Details

Attachments

(1 file)

[hidden] is implemented as a low-priority presentation attribute (see the comment in layout/style/res/html.css), so any author rule setting display silently overrides it. To work around this, a lot of chrome/in-content CSS guards display-setting rules with :not([hidden]) (e.g. foo:not([hidden]) { display: flex }) so the element still hides when the hidden attribute is set.

Add a single [hidden] { display: none !important } rule to the two base stylesheets -- global-shared.css (chrome, via global.css) and in-content/common-shared.css (in-content pages, via in-content/common.css) -- so callers can set a display type unconditionally, and drop the redundant :not([hidden]) guards.

Notes:

  • Rules that intentionally re-show a [hidden] element via display need !important to keep winning: findbar[hidden] (slide transition), treecol[hidden] in xul.css (column collapse), and setting-control[hidden]:has(> moz-message-bar).
  • Guards are kept where the base rule can't reach: shadow-DOM widgets, the newtab/activity-stream bundle, browser/fxr/*, and mixed-coverage sheets injected into content docs or shadow roots (urlbar view sheets via the smartbar, feature-callout sheets).
  • Structural :not([hidden]) uses (sibling/descendant combinators) are untouched.

[hidden] is implemented as a low-priority presentation attribute (see the
comment in layout/style/res/html.css), so any author rule setting display
silently overrides it. A lot of chrome/in-content CSS therefore guards
display-setting rules with :not([hidden]) so the element still hides when the
hidden attribute is set.

Add a single [hidden] { display: none !important } rule to the two base
stylesheets -- global-shared.css (chrome) and in-content/common-shared.css
(in-content pages) -- so callers can set a display type unconditionally, and
drop the redundant :not([hidden]) guards.

Rules that intentionally re-show a [hidden] element via display keep working
via !important: findbar[hidden] (slide transition), treecol[hidden] in xul.css
(column collapse), and setting-control[hidden]:has(> moz-message-bar). Guards are
kept where the base rule can't reach: shadow-DOM widgets, the
newtab/activity-stream bundle, browser/fxr/*, and mixed-coverage sheets injected
into content documents or shadow roots (urlbar view sheets via the smartbar,
feature-callout sheets). Structural :not([hidden]) uses (sibling/descendant
combinators) are untouched.

Assignee: nobody → dao+bmo
Status: NEW → ASSIGNED
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f37be02e7cb9 https://hg.mozilla.org/integration/autoland/rev/e09a46c71ae9 Add a global [hidden] { display: none !important } rule instead of :not([hidden]) display guards r=desktop-theme-reviewers,emilio
Pushed by pstanciu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ee5fc2e1ef8c https://hg.mozilla.org/integration/autoland/rev/d9c618e38c09 Revert "Bug 2051196 - Add a global [hidden] { display: none !important } rule instead of :not([hidden]) display guards r=desktop-theme-reviewers,emilio" for causing mochitests failures @ browser_webconsole_location_logpoint_debugger_link.js

Backed out for causing mochitests failures @ browser_webconsole_location_logpoint_debugger_link.js

Flags: needinfo?(dao+bmo)
Flags: needinfo?(dao+bmo)
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/759f86dd9ecd https://hg.mozilla.org/integration/autoland/rev/39415a20dbc4 Add a global [hidden] { display: none !important } rule instead of :not([hidden]) display guards r=desktop-theme-reviewers,emilio
Status: ASSIGNED → RESOLVED
Closed: 19 days ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch
Blocks: 2039272
Duplicate of this bug: 1964412
Regressions: 2054149
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: