Bug 1901374: Implement field-sizing parsing r=emilio

This change adds a new layout.css.field-sizing.enabled pref that controls the availability of the field-sizing CSS property.

With the pref enabled this property now parses according to the spec.

Spec: https://drafts.csswg.org/css-ui/#field-sizing

Differential Revision: https://phabricator.services.mozilla.com/D212983
This commit is contained in:
Luke Warlow 2024-06-11 12:00:50 +00:00
parent cb9b1adfc3
commit 9cadf878d9
12 changed files with 82 additions and 15 deletions

View File

@ -16512,6 +16512,23 @@ use.counter.css.page:
send_in_pings:
- use-counters
css_field_sizing:
type: counter
description: >
Whether a page used the CSS property field-sizing.
Compare against `use.counter.top_level_content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
css_flex_direction:
type: counter
description: >
@ -28448,6 +28465,23 @@ use.counter.css.doc:
send_in_pings:
- use-counters
css_field_sizing:
type: counter
description: >
Whether a document used the CSS property field-sizing.
Compare against `use.counter.content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
css_flex_direction:
type: counter
description: >

View File

@ -139,6 +139,7 @@ rusty-enums = [
"mozilla::StyleListStylePosition",
"mozilla::StylePointerEvents",
"mozilla::StyleScrollbarWidth",
"mozilla::StyleFieldSizing",
"mozilla::StyleWhiteSpaceCollapse",
"mozilla::StyleTextWrapMode",
"mozilla::StyleTextRendering",

View File

@ -130,6 +130,12 @@ enum class StyleScrollbarWidth : uint8_t {
None,
};
// field-sizing
enum class StyleFieldSizing : bool {
Fixed,
Content,
};
// Shape source type
enum class StyleShapeSourceType : uint8_t {
None,

View File

@ -3113,7 +3113,8 @@ nsStyleUIReset::nsStyleUIReset()
nsStyleAutoArray<StyleViewTimeline>::WITH_SINGLE_INITIAL_ELEMENT),
mViewTimelineNameCount(1),
mViewTimelineAxisCount(1),
mViewTimelineInsetCount(1) {
mViewTimelineInsetCount(1),
mFieldSizing(StyleFieldSizing::Fixed) {
MOZ_COUNT_CTOR(nsStyleUIReset);
}
@ -3152,7 +3153,8 @@ nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
mViewTimelines(aSource.mViewTimelines.Clone()),
mViewTimelineNameCount(aSource.mViewTimelineNameCount),
mViewTimelineAxisCount(aSource.mViewTimelineAxisCount),
mViewTimelineInsetCount(aSource.mViewTimelineInsetCount) {
mViewTimelineInsetCount(aSource.mViewTimelineInsetCount),
mFieldSizing(aSource.mFieldSizing) {
MOZ_COUNT_CTOR(nsStyleUIReset);
}
@ -3166,6 +3168,9 @@ nsChangeHint nsStyleUIReset::CalcDifference(
if (mMozSubtreeHiddenOnlyVisually != aNewData.mMozSubtreeHiddenOnlyVisually) {
hint |= nsChangeHint_RepaintFrame;
}
if (mFieldSizing != aNewData.mFieldSizing) {
hint |= nsChangeHint_NeutralChange;
}
if (mScrollbarWidth != aNewData.mScrollbarWidth) {
// For scrollbar-width change, we need some special handling similar
// to overflow properties. Specifically, we may need to reconstruct

View File

@ -1737,6 +1737,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset {
uint32_t mViewTimelineNameCount;
uint32_t mViewTimelineAxisCount;
uint32_t mViewTimelineInsetCount;
mozilla::StyleFieldSizing mFieldSizing;
};
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUI {

View File

@ -12,6 +12,7 @@ prefs = [
"layout.css.basic-shape-xywh.enabled=true",
"layout.css.transform-box-content-stroke.enabled=true",
"layout.css.transition-behavior.enabled=true",
"layout.css.field-sizing.enabled=true",
]
support-files = [
"animation_utils.js",

View File

@ -14319,6 +14319,19 @@ if (IsCSSPropertyPrefEnabled("layout.css.transition-behavior.enabled")) {
}
}
if (IsCSSPropertyPrefEnabled("layout.css.field-sizing.enabled")) {
Object.assign(gCSSProperties, {
"field-sizing": {
domProp: "fieldSizing",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: ["fixed"],
other_values: ["content"],
invalid_values: ["none", "auto"],
},
});
}
// Copy aliased properties' fields from their alias targets. Keep this logic
// at the bottom of this file to ensure all the aliased properties are
// processed.

View File

@ -9547,6 +9547,12 @@
value: false
mirror: always
# field-sizing CSS property
- name: layout.css.field-sizing.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# Whether supports() conditions in @import is enabled
- name: layout.css.import-supports.enabled
type: RelaxedAtomicBool

View File

@ -432,3 +432,14 @@ ${helpers.predefined_type(
rule_types_allowed=DEFAULT_RULES_EXCEPT_KEYFRAME,
affects="",
)}
${helpers.single_keyword(
"field-sizing",
"fixed content",
engines="gecko",
gecko_enum_prefix="StyleFieldSizing",
animation_value_type="discrete",
gecko_pref="layout.css.field-sizing.enabled",
spec="https://drafts.csswg.org/css-ui/#field-sizing",
affects="layout",
)}

View File

@ -1 +1 @@
prefs: [intl.icu4x.segmenter.enabled:true]
prefs: [intl.icu4x.segmenter.enabled:true,layout.css.field-sizing.enabled:true]

View File

@ -1,6 +0,0 @@
[field-sizing-computed.html]
[Property field-sizing value 'fixed']
expected: FAIL
[Property field-sizing value 'content']
expected: FAIL

View File

@ -1,6 +0,0 @@
[field-sizing-valid.html]
[e.style['field-sizing'\] = "fixed" should set the property value]
expected: FAIL
[e.style['field-sizing'\] = "content" should set the property value]
expected: FAIL