Skip to content

Commit

Permalink
Bug 1809568 - Part 1: Implement parsing for baseline-source. r=emilio
Browse files Browse the repository at this point in the history
  • Loading branch information
dshin-moz committed May 15, 2023
1 parent 0c64bc4 commit f33a180
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 107 deletions.
1 change: 1 addition & 0 deletions devtools/server/actors/animation-type-longhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
"background-image",
"background-origin",
"background-repeat",
"baseline-source",
"border-bottom-style",
"border-collapse",
"border-image-repeat",
Expand Down
18 changes: 18 additions & 0 deletions devtools/shared/css/generated/properties-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,7 @@ exports.CSS_PROPERTIES = {
"float",
"clear",
"vertical-align",
"baseline-source",
"overflow-clip-box-inline",
"overflow-clip-box-block",
"overflow-x",
Expand Down Expand Up @@ -4016,6 +4017,23 @@ exports.CSS_PROPERTIES = {
"unset"
]
},
"baseline-source": {
"isInherited": false,
"subproperties": [
"baseline-source"
],
"supports": [],
"values": [
"auto",
"first",
"inherit",
"initial",
"last",
"revert",
"revert-layer",
"unset"
]
},
"block-size": {
"isInherited": false,
"subproperties": [
Expand Down
1 change: 1 addition & 0 deletions layout/style/ServoBindings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ cbindgen-types = [
{ gecko = "StyleLockedMediaList", servo = "crate::gecko::arc_types::LockedMediaList" },
{ gecko = "StyleLockedImportRule", servo = "crate::gecko::arc_types::LockedImportRule" },
{ gecko = "StyleLockedFontFaceRule", servo = "crate::gecko::arc_types::LockedFontFaceRule" },
{ gecko = "StyleBaselineSource", servo = "crate::values::computed::BaselineSource" },
]

mapped-generic-types = [
Expand Down
5 changes: 4 additions & 1 deletion layout/style/nsStyleStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,7 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
mPerspectiveOrigin(Position::FromPercentage(0.5f)),
mVerticalAlign(
StyleVerticalAlign::Keyword(StyleVerticalAlignKeyword::Baseline)),
mBaselineSource(StyleBaselineSource::Auto),
mWebkitLineClamp(0),
mShapeMargin(LengthPercentage::Zero()),
mShapeOutside(StyleShapeOutside::None()) {
Expand Down Expand Up @@ -2284,6 +2285,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
mChildPerspective(aSource.mChildPerspective),
mPerspectiveOrigin(aSource.mPerspectiveOrigin),
mVerticalAlign(aSource.mVerticalAlign),
mBaselineSource(aSource.mBaselineSource),
mWebkitLineClamp(aSource.mWebkitLineClamp),
mShapeImageThreshold(aSource.mShapeImageThreshold),
mShapeMargin(aSource.mShapeMargin),
Expand Down Expand Up @@ -2520,7 +2522,8 @@ nsChangeHint nsStyleDisplay::CalcDifference(
}

if (mWebkitLineClamp != aNewData.mWebkitLineClamp ||
mVerticalAlign != aNewData.mVerticalAlign) {
mVerticalAlign != aNewData.mVerticalAlign ||
mBaselineSource != aNewData.mBaselineSource) {
// XXX Can this just be AllReflowHints + RepaintFrame, and be included in
// the block below?
hint |= NS_STYLE_HINT_REFLOW;
Expand Down
1 change: 1 addition & 0 deletions layout/style/nsStyleStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
mozilla::Position mPerspectiveOrigin;

mozilla::StyleVerticalAlign mVerticalAlign;
mozilla::StyleBaselineSource mBaselineSource;

mozilla::StyleLineClamp mWebkitLineClamp;

Expand Down
11 changes: 11 additions & 0 deletions layout/style/test/property_database.js
Original file line number Diff line number Diff line change
Expand Up @@ -8418,6 +8418,17 @@ var gCSSProperties = {
invalid_values: [],
quirks_values: { "5": "5px" },
},
"baseline-source": {
domProp: "baselineSource",
inherited: false,
type: CSS_TYPE_LONGHAND,
applies_to_first_letter: true,
applies_to_first_line: true,
applies_to_placeholder: true,
initial_values: ["auto"],
other_values: ["first", "last"],
invalid_values: [],
},
visibility: {
domProp: "visibility",
inherited: true,
Expand Down
5 changes: 5 additions & 0 deletions servo/components/style/properties/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ def specified_is_copy(self):
"AlignSelf",
"Appearance",
"AspectRatio",
"BaselineSource",
"BreakBetween",
"BreakWithin",
"BackgroundRepeat",
Expand Down Expand Up @@ -809,6 +810,8 @@ def first_letter(data):
"-webkit-text-fill-color",
"-webkit-text-stroke-color",
"vertical-align",
# Will become shorthand of vertical-align (Bug 1830771)
"baseline-source",
"line-height",
# Kinda like css-backgrounds?
"background-blend-mode",
Expand Down Expand Up @@ -842,6 +845,8 @@ def first_line(data):
"-webkit-text-fill-color",
"-webkit-text-stroke-color",
"vertical-align",
# Will become shorthand of vertical-align (Bug 1830771)
"baseline-source",
"line-height",
# Kinda like css-backgrounds?
"background-blend-mode",
Expand Down
10 changes: 10 additions & 0 deletions servo/components/style/properties/longhands/box.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ ${helpers.predefined_type(
servo_restyle_damage = "reflow",
)}

${helpers.predefined_type(
"baseline-source",
"BaselineSource",
"computed::BaselineSource::Auto",
engines="gecko servo-2013",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-inline-3/#baseline-source",
servo_restyle_damage = "reflow",
)}

// CSS 2.1, Section 11 - Visual effects

${helpers.single_keyword(
Expand Down
8 changes: 4 additions & 4 deletions servo/components/style/values/computed/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use crate::values::generics::box_::{
use crate::values::specified::box_ as specified;

pub use crate::values::specified::box_::{
Appearance, BreakBetween, BreakWithin, Clear as SpecifiedClear, Contain, ContainerName,
ContainerType, ContentVisibility, Display, Float as SpecifiedFloat, Overflow, OverflowAnchor,
OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop,
ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, WillChange,
Appearance, BaselineSource, BreakBetween, BreakWithin, Clear as SpecifiedClear, Contain,
ContainerName, ContainerType, ContentVisibility, Display, Float as SpecifiedFloat, Overflow,
OverflowAnchor, OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis,
ScrollSnapStop, ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, WillChange,
};

/// A computed value for the `vertical-align` property.
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/values/computed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, S
pub use self::box_::{
ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop, ScrollSnapStrictness, ScrollSnapType,
};
pub use self::box_::{TouchAction, VerticalAlign, WillChange};
pub use self::box_::{BaselineSource, TouchAction, VerticalAlign, WillChange};
pub use self::color::{
Color, ColorOrAuto, ColorPropertyValue, ColorScheme, ForcedColorAdjust, PrintColorAdjust,
};
Expand Down
47 changes: 43 additions & 4 deletions servo/components/style/values/specified/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::parser::{Parse, ParserContext};
use crate::properties::{LonghandId, PropertyDeclarationId, PropertyId};
use crate::values::generics::box_::{
GenericLineClamp, GenericPerspective, GenericContainIntrinsicSize, GenericVerticalAlign,
GenericContainIntrinsicSize, GenericLineClamp, GenericPerspective, GenericVerticalAlign,
VerticalAlignKeyword,
};
use crate::values::specified::length::{LengthPercentage, NonNegativeLength};
Expand Down Expand Up @@ -636,6 +636,33 @@ impl Parse for VerticalAlign {
}
}

/// A specified value for the `baseline-source` property.
/// https://drafts.csswg.org/css-inline-3/#baseline-source
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToShmem,
ToComputedValue,
ToResolvedValue,
)]
#[repr(u8)]
pub enum BaselineSource {
/// `Last` for `inline-block`, `First` otherwise.
Auto,
/// Use first baseline for alignment.
First,
/// Use last baseline for alignment.
Last,
}

/// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
Expand Down Expand Up @@ -1203,7 +1230,20 @@ pub enum ContentVisibility {
Visible,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToCss, Parse, ToResolvedValue, ToShmem)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
MallocSizeOf,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
Parse,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
#[allow(missing_docs)]
/// https://drafts.csswg.org/css-contain-3/#container-type
Expand Down Expand Up @@ -1264,8 +1304,7 @@ impl ContainerName {
if !for_query && first.eq_ignore_ascii_case("none") {
return Ok(Self::none());
}
const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] =
&["none", "not", "or", "and"];
const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] = &["none", "not", "or", "and"];
idents.push(CustomIdent::from_ident(
location,
first,
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/values/specified/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use self::box_::{Contain, Display};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType};
pub use self::box_::{TouchAction, VerticalAlign, WillChange};
pub use self::box_::{BaselineSource, TouchAction, VerticalAlign, WillChange};
pub use self::color::{
Color, ColorOrAuto, ColorPropertyValue, ColorScheme, ForcedColorAdjust, PrintColorAdjust,
};
Expand Down
1 change: 1 addition & 0 deletions servo/ports/geckolib/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ include = [
"Position",
"PositionOrAuto",
"BackgroundSize",
"BaselineSource",
"BorderImageSlice",
"BorderSpacing",
"BorderRadius",
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,79 +1,5 @@
[baseline-source-no-interpolation.html]
[CSS Transitions: property <baseline-source> from [initial\] to [last\] at (0.5) should be [last\]]
expected: FAIL

[CSS Transitions: property <baseline-source> from [initial\] to [last\] at (0.6) should be [last\]]
expected: FAIL

[CSS Transitions: property <baseline-source> from [initial\] to [last\] at (1) should be [last\]]
expected: FAIL

[CSS Transitions: property <baseline-source> from [initial\] to [last\] at (1.5) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (-0.3) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (0) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (0.3) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (0.5) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (0.6) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (1) should be [last\]]
expected: FAIL

[CSS Transitions with transition: all: property <baseline-source> from [initial\] to [last\] at (1.5) should be [last\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (-0.3) should be [initial\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (0) should be [initial\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (0.3) should be [initial\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (0.5) should be [last\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (0.6) should be [last\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (1) should be [last\]]
expected: FAIL

[CSS Animations: property <baseline-source> from [initial\] to [last\] at (1.5) should be [last\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (-0.3) should be [initial\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (0) should be [initial\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (0.3) should be [initial\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (0.5) should be [last\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (0.6) should be [last\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (1) should be [last\]]
expected: FAIL

[Web Animations: property <baseline-source> from [initial\] to [last\] at (1.5) should be [last\]]
expected: FAIL

bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1805727
[CSS Transitions: property <baseline-source> from [initial\] to [last\] at (0) should be [initial\]]
expected: FAIL

Expand Down

This file was deleted.

0 comments on commit f33a180

Please sign in to comment.