Bug 1871745 - Keep exposing chrome-only properties on CSS2Properties. r=peterv

So that chrome code can keep setting -moz-user-focus via script, for
example.

Differential Revision: https://phabricator.services.mozilla.com/D197295
This commit is contained in:
Emilio Cobos Álvarez 2023-12-28 17:45:50 +00:00
parent 61474d6767
commit cd214fc2d8
4 changed files with 30 additions and 21 deletions

View File

@ -10051,13 +10051,10 @@ var FirefoxViewHandler = {
this.button?.setAttribute("aria-pressed", selected);
this._recordViewIfTabSelected();
this._onTabForegrounded();
if (e.target == this.tab) {
// If Fx View is opened, add temporary style to make first available tab focusable
gBrowser.visibleTabs[0].style["-moz-user-focus"] = "normal";
} else {
// When Fx View is closed, remove temporary -moz-user-focus style from first available tab
gBrowser.visibleTabs[0].style.removeProperty("-moz-user-focus");
}
// If Fx View is opened, add temporary style to make first available tab focusable
// When Fx View is closed, remove temporary -moz-user-focus style from first available tab
gBrowser.visibleTabs[0].style.MozUserFocus =
e.target == this.tab ? "normal" : "";
break;
case "TabClose":
this.tab = null;

View File

@ -382,11 +382,12 @@ class Configuration(DescriptorProvider):
def filterExtendedAttributes(extendedAttributes):
# These are the extended attributes that we allow to have
# different values among all atributes that use the same
# different values among all attributes that use the same
# template.
ignoredAttributes = {
"BindingTemplate",
"BindingAlias",
"ChromeOnly",
"Pure",
"Pref",
"Func",

View File

@ -23,9 +23,6 @@ def generate(output, idlFilename, dataFile):
propsData = runpy.run_path(dataFile)["data"]
props = ""
for p in propsData.values():
if "Internal" in p.flags:
continue
# Skip properties which aren't valid in style rules.
if "Style" not in p.rules:
continue
@ -46,6 +43,7 @@ def generate(output, idlFilename, dataFile):
]
if p.pref != "":
assert "Internal" not in p.flags
# BackdropFilter is a special case where we want WebIDL to check
# a function instead of checking the pref directly.
if p.method == "BackdropFilter":
@ -54,6 +52,10 @@ def generate(output, idlFilename, dataFile):
# see bug 1861828, 1865332, 1860424, 1864970, 1865332, 1869119.
elif p.method not in ["MozTransform", "MozTransformOrigin"]:
extendedAttrs.append('Pref="%s"' % p.pref)
elif "EnabledInUASheetsAndChrome" in p.flags:
extendedAttrs.append("ChromeOnly")
elif "Internal" in p.flags:
continue
def add_extra_accessors(p):
prop = p.method

View File

@ -4,26 +4,30 @@
<iframe></iframe>
<iframe srcdoc="Foo"></iframe>
<script>
const NON_CONTENT_ACCESSIBLE_PROPERTIES = [
"-x-span",
"-x-lang",
"-x-text-scale",
const CHROME_ONLY_PROPERTIES = [
"-moz-window-input-region-margin",
"-moz-window-shadow",
"-moz-window-opacity",
"-moz-window-transform",
"-moz-window-transform-origin",
"-moz-default-appearance",
"-moz-user-focus",
];
const UA_ONLY_PROPERTIES = [
"-x-span",
"-x-lang",
"-x-text-scale",
"-moz-control-character-visibility",
"-moz-top-layer",
"-moz-script-level",
"-moz-math-display",
"-moz-math-variant",
"-moz-font-smoothing-background-color",
"-moz-min-font-size-ratio",
"-moz-default-appearance",
"-moz-inert",
"-moz-control-character-visibility",
"-moz-min-font-size-ratio",
// TODO: This should ideally be in CHROME_ONLY_PROPERTIES, but due to how
// [Pref] and [ChromeOnly] interact in WebIDL, the former wins.
"-moz-context-properties",
"-moz-user-focus",
];
function testInWin(win) {
@ -36,9 +40,14 @@ function testInWin(win) {
sheet.textContent = `div { color: initial }`;
assert_equals(sheet.sheet.cssRules[0].style.length, 1, `sanity: ${doc.documentURI}`);
for (const prop of NON_CONTENT_ACCESSIBLE_PROPERTIES) {
for (const prop of CHROME_ONLY_PROPERTIES.concat(UA_ONLY_PROPERTIES)) {
sheet.textContent = `div { ${prop}: initial }`;
let block = sheet.sheet.cssRules[0].style;
assert_false(prop in block, `${prop} shouldn't be exposed in CSS2Properties`);
let isUAOnly = UA_ONLY_PROPERTIES.includes(prop);
assert_equals(prop in SpecialPowers.wrap(block), !isUAOnly, `${prop} should be exposed to chrome code if needed`);
assert_equals(
block.length,
0,