Auto merge of #17821 - bzbarsky:pseudo-prop-restrictions, r=emilio

Implement restrictions on which properties apply to which pseudo-elements

::first-line, ::first-letter, and ::placeholder don't allow all properties to apply to them.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1382786

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because they're Gecko-only for the moment, and Gecko has tests.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17821)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-21 12:15:50 -07:00 committed by GitHub
commit 4bf8e4413e
14 changed files with 132 additions and 8 deletions

View file

@ -10,6 +10,8 @@
use cssparser::{ToCss, serialize_identifier}; use cssparser::{ToCss, serialize_identifier};
use gecko_bindings::structs::{self, CSSPseudoElementType}; use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::{PropertyFlags, APPLIES_TO_FIRST_LETTER, APPLIES_TO_FIRST_LINE};
use properties::APPLIES_TO_PLACEHOLDER;
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl}; use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt; use std::fmt;
use string_cache::Atom; use string_cache::Atom;
@ -119,4 +121,15 @@ impl PseudoElement {
_ => self.clone(), _ => self.clone(),
} }
} }
/// Property flag that properties must have to apply to this pseudo-element.
#[inline]
pub fn property_restriction(&self) -> Option<PropertyFlags> {
match *self {
PseudoElement::FirstLetter => Some(APPLIES_TO_FIRST_LETTER),
PseudoElement::FirstLine => Some(APPLIES_TO_FIRST_LINE),
PseudoElement::Placeholder => Some(APPLIES_TO_PLACEHOLDER),
_ => None,
}
}
} }

View file

@ -12,7 +12,8 @@ ${helpers.predefined_type("background-color", "Color",
spec="https://drafts.csswg.org/css-backgrounds/#background-color", spec="https://drafts.csswg.org/css-backgrounds/#background-color",
animation_value_type="IntermediateColor", animation_value_type="IntermediateColor",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
allow_quirks=True)} allow_quirks=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.predefined_type("background-image", "ImageLayer", ${helpers.predefined_type("background-image", "ImageLayer",
initial_value="Either::First(None_)", initial_value="Either::First(None_)",
@ -21,7 +22,8 @@ ${helpers.predefined_type("background-image", "ImageLayer",
vector="True", vector="True",
animation_value_type="discrete", animation_value_type="discrete",
has_uncacheable_values="True" if product == "gecko" else "False", has_uncacheable_values="True" if product == "gecko" else "False",
ignored_when_colors_disabled="True")} ignored_when_colors_disabled="True",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
% for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]: % for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]:
${helpers.predefined_type( ${helpers.predefined_type(
@ -32,11 +34,13 @@ ${helpers.predefined_type("background-image", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis, spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis,
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
vector=True, vector=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
)} )}
% endfor % endfor
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete" <%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat"> spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -138,7 +142,8 @@ ${helpers.single_keyword("background-attachment",
vector=True, vector=True,
gecko_constant_prefix="NS_STYLE_IMAGELAYER_ATTACHMENT", gecko_constant_prefix="NS_STYLE_IMAGELAYER_ATTACHMENT",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-attachment", spec="https://drafts.csswg.org/css-backgrounds/#the-background-attachment",
animation_value_type="discrete")} animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.single_keyword("background-clip", ${helpers.single_keyword("background-clip",
"border-box padding-box content-box", "border-box padding-box content-box",
@ -146,14 +151,16 @@ ${helpers.single_keyword("background-clip",
vector=True, extra_prefixes="webkit", vector=True, extra_prefixes="webkit",
gecko_enum_prefix="StyleGeometryBox", gecko_enum_prefix="StyleGeometryBox",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-clip", spec="https://drafts.csswg.org/css-backgrounds/#the-background-clip",
animation_value_type="discrete")} animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.single_keyword("background-origin", ${helpers.single_keyword("background-origin",
"padding-box border-box content-box", "padding-box border-box content-box",
vector=True, extra_prefixes="webkit", vector=True, extra_prefixes="webkit",
gecko_enum_prefix="StyleGeometryBox", gecko_enum_prefix="StyleGeometryBox",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-origin", spec="https://drafts.csswg.org/css-backgrounds/#the-background-origin",
animation_value_type="discrete")} animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.predefined_type("background-size", "BackgroundSize", ${helpers.predefined_type("background-size", "BackgroundSize",
initial_value="computed::LengthOrPercentageOrAuto::Auto.into()", initial_value="computed::LengthOrPercentageOrAuto::Auto.into()",
@ -161,6 +168,7 @@ ${helpers.predefined_type("background-size", "BackgroundSize",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-size", spec="https://drafts.csswg.org/css-backgrounds/#the-background-size",
vector=True, vector=True,
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
extra_prefixes="webkit")} extra_prefixes="webkit")}
// https://drafts.fxtf.org/compositing/#background-blend-mode // https://drafts.fxtf.org/compositing/#background-blend-mode
@ -170,4 +178,5 @@ ${helpers.single_keyword("background-blend-mode",
saturation color luminosity""", saturation color luminosity""",
gecko_constant_prefix="NS_STYLE_BLEND", gecko_constant_prefix="NS_STYLE_BLEND",
vector=True, products="gecko", animation_value_type="discrete", vector=True, products="gecko", animation_value_type="discrete",
spec="https://drafts.fxtf.org/compositing/#background-blend-mode")} spec="https://drafts.fxtf.org/compositing/#background-blend-mode",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}

View file

@ -27,12 +27,14 @@
animation_value_type="IntermediateColor", animation_value_type="IntermediateColor",
logical=is_logical, logical=is_logical,
allow_quirks=not is_logical, allow_quirks=not is_logical,
flags="APPLIES_TO_FIRST_LETTER",
ignored_when_colors_disabled=True)} ignored_when_colors_disabled=True)}
${helpers.predefined_type("border-%s-style" % side_name, "BorderStyle", ${helpers.predefined_type("border-%s-style" % side_name, "BorderStyle",
"specified::BorderStyle::none", "specified::BorderStyle::none",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"), alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"),
spec=maybe_logical_spec(side, "style"), spec=maybe_logical_spec(side, "style"),
flags="APPLIES_TO_FIRST_LETTER",
animation_value_type="discrete" if not is_logical else "none", animation_value_type="discrete" if not is_logical else "none",
logical=is_logical)} logical=is_logical)}
@ -44,6 +46,7 @@
spec=maybe_logical_spec(side, "width"), spec=maybe_logical_spec(side, "width"),
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
logical=is_logical, logical=is_logical,
flags="APPLIES_TO_FIRST_LETTER",
allow_quirks=not is_logical)} allow_quirks=not is_logical)}
% endfor % endfor
@ -58,6 +61,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
"parse", extra_prefixes="webkit", "parse", extra_prefixes="webkit",
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner, spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,
boxed=True, boxed=True,
flags="APPLIES_TO_FIRST_LETTER",
animation_value_type="ComputedValue")} animation_value_type="ComputedValue")}
% endfor % endfor
@ -67,6 +71,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
<%helpers:longhand name="-moz-border-${side}-colors" animation_value_type="discrete" <%helpers:longhand name="-moz-border-${side}-colors" animation_value_type="discrete"
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-*-colors)" spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-*-colors)"
products="gecko" products="gecko"
flags="APPLIES_TO_FIRST_LETTER"
ignored_when_colors_disabled="True"> ignored_when_colors_disabled="True">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -206,6 +211,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
vector=False, vector=False,
animation_value_type="discrete", animation_value_type="discrete",
has_uncacheable_values=False, has_uncacheable_values=False,
flags="APPLIES_TO_FIRST_LETTER",
boxed="True")} boxed="True")}
${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
@ -214,9 +220,11 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
initial_specified_value="specified::LengthOrNumber::zero().into()", initial_specified_value="specified::LengthOrNumber::zero().into()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)} boxed=True)}
<%helpers:longhand name="border-image-repeat" animation_value_type="discrete" <%helpers:longhand name="border-image-repeat" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER"
spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat">
use style_traits::ToCss; use style_traits::ToCss;
@ -278,6 +286,7 @@ ${helpers.predefined_type("border-image-width", "BorderImageWidth",
initial_specified_value="specified::BorderImageSideWidth::one().into()", initial_specified_value="specified::BorderImageSideWidth::one().into()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)} boxed=True)}
${helpers.predefined_type("border-image-slice", "BorderImageSlice", ${helpers.predefined_type("border-image-slice", "BorderImageSlice",
@ -285,6 +294,7 @@ ${helpers.predefined_type("border-image-slice", "BorderImageSlice",
initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage::new(1.)).into()", initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage::new(1.)).into()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice", spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)} boxed=True)}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]

View file

@ -10,10 +10,14 @@
gecko_name="Display") %> gecko_name="Display") %>
// TODO(SimonSapin): don't parse `inline-table`, since we don't support it // TODO(SimonSapin): don't parse `inline-table`, since we don't support it
//
// We allow "display" to apply to placeholders because we need to make the
// placeholder pseudo-element an inline-block in the UA stylesheet in Gecko.
<%helpers:longhand name="display" <%helpers:longhand name="display"
need_clone="True" need_clone="True"
animation_value_type="discrete" animation_value_type="discrete"
custom_cascade="${product == 'servo'}" custom_cascade="${product == 'servo'}"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-display/#propdef-display"> spec="https://drafts.csswg.org/css-display/#propdef-display">
<% <%
values = """inline block inline-block values = """inline block inline-block
@ -216,6 +220,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
gecko_inexhaustive="True" gecko_inexhaustive="True"
gecko_ffi_name="mFloat" gecko_ffi_name="mFloat"
gecko_pref_ident="float_" gecko_pref_ident="float_"
flags="APPLIES_TO_FIRST_LETTER"
spec="https://drafts.csswg.org/css-box/#propdef-float"> spec="https://drafts.csswg.org/css-box/#propdef-float">
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
@ -306,6 +311,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="vertical-align" animation_value_type="ComputedValue" <%helpers:longhand name="vertical-align" animation_value_type="ComputedValue"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align"> spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -432,6 +438,7 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
${helpers.single_keyword("overflow-clip-box", "padding-box content-box", ${helpers.single_keyword("overflow-clip-box", "padding-box content-box",
products="gecko", animation_value_type="discrete", internal=True, products="gecko", animation_value_type="discrete", internal=True,
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \ spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")} may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
@ -445,10 +452,12 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
extra_gecko_values="-moz-hidden-unscrollable", extra_gecko_values="-moz-hidden-unscrollable",
custom_consts=overflow_custom_consts, custom_consts=overflow_custom_consts,
gecko_constant_prefix="NS_STYLE_OVERFLOW", gecko_constant_prefix="NS_STYLE_OVERFLOW",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x")} spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x")}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
<%helpers:longhand name="overflow-y" need_clone="True" animation_value_type="discrete" <%helpers:longhand name="overflow-y" need_clone="True" animation_value_type="discrete"
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y"> spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y">
pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value}; pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value};
</%helpers:longhand> </%helpers:longhand>
@ -1618,10 +1627,15 @@ ${helpers.single_keyword("page-break-inside",
// CSS Basic User Interface Module Level 3 // CSS Basic User Interface Module Level 3
// http://dev.w3.org/csswg/css-ui // http://dev.w3.org/csswg/css-ui
// FIXME support logical values `block` and `inline` (https://drafts.csswg.org/css-logical-props/#resize) // FIXME support logical values `block` and `inline` (https://drafts.csswg.org/css-logical-props/#resize)
//
// This is APPLIES_TO_PLACEHOLDER so we can override, in the UA sheet, the
// 'resize' property we'd inherit from textarea otherwise. Basically, just
// makes the UA rules easier to write.
${helpers.single_keyword("resize", ${helpers.single_keyword("resize",
"none both horizontal vertical", "none both horizontal vertical",
products="gecko", products="gecko",
spec="https://drafts.csswg.org/css-ui/#propdef-resize", spec="https://drafts.csswg.org/css-ui/#propdef-resize",
flags="APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -1888,6 +1902,7 @@ ${helpers.predefined_type("shape-outside", "basic_shape::FloatAreaShape",
"generics::basic_shape::ShapeSource::None", "generics::basic_shape::ShapeSource::None",
products="gecko", boxed="True", products="gecko", boxed="True",
animation_value_type="none", animation_value_type="none",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property")} spec="https://drafts.csswg.org/css-shapes/#shape-outside-property")}
<%helpers:longhand name="touch-action" <%helpers:longhand name="touch-action"

View file

@ -11,6 +11,7 @@
<%helpers:longhand name="color" need_clone="True" <%helpers:longhand name="color" need_clone="True"
animation_value_type="IntermediateRGBA" animation_value_type="IntermediateRGBA"
ignored_when_colors_disabled="True" ignored_when_colors_disabled="True"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-color/#color"> spec="https://drafts.csswg.org/css-color/#color">
use cssparser::RGBA; use cssparser::RGBA;
use values::specified::{AllowQuirks, Color}; use values::specified::{AllowQuirks, Color};

View file

@ -11,7 +11,7 @@ ${helpers.predefined_type("opacity",
"Opacity", "Opacity",
"1.0", "1.0",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="CREATES_STACKING_CONTEXT", flags="CREATES_STACKING_CONTEXT APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-color/#opacity")} spec="https://drafts.csswg.org/css-color/#opacity")}
${helpers.predefined_type( ${helpers.predefined_type(
@ -22,6 +22,7 @@ ${helpers.predefined_type(
animation_value_type="AnimatedBoxShadowList", animation_value_type="AnimatedBoxShadowList",
extra_prefixes="webkit", extra_prefixes="webkit",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-backgrounds/#box-shadow", spec="https://drafts.csswg.org/css-backgrounds/#box-shadow",
)} )}

View file

@ -69,6 +69,7 @@ macro_rules! impl_gecko_keyword_conversions {
</%def> </%def>
<%helpers:longhand name="font-family" animation_value_type="discrete" need_index="True" boxed="${product == 'gecko'}" <%helpers:longhand name="font-family" animation_value_type="discrete" need_index="True" boxed="${product == 'gecko'}"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-family">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use self::computed_value::{FontFamily, FamilyName}; use self::computed_value::{FontFamily, FamilyName};
@ -379,6 +380,7 @@ ${helpers.single_keyword_system("font-style",
gecko_constant_prefix="NS_FONT_STYLE", gecko_constant_prefix="NS_FONT_STYLE",
gecko_ffi_name="mFont.style", gecko_ffi_name="mFont.style",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style", spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -395,9 +397,11 @@ ${helpers.single_keyword_system("font-variant-caps",
gecko_ffi_name="mFont.variantCaps", gecko_ffi_name="mFont.variantCaps",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps",
custom_consts=font_variant_caps_custom_consts, custom_consts=font_variant_caps_custom_consts,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
<%helpers:longhand name="font-weight" need_clone="True" animation_value_type="ComputedValue" <%helpers:longhand name="font-weight" need_clone="True" animation_value_type="ComputedValue"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
@ -559,6 +563,7 @@ ${helpers.single_keyword_system("font-variant-caps",
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="font-size" need_clone="True" animation_value_type="ComputedValue" <%helpers:longhand name="font-size" need_clone="True" animation_value_type="ComputedValue"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size">
use app_units::Au; use app_units::Au;
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
@ -1020,6 +1025,7 @@ ${helpers.single_keyword_system("font-variant-caps",
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand products="gecko" name="font-size-adjust" animation_value_type="ComputedValue" <%helpers:longhand products="gecko" name="font-size-adjust" animation_value_type="ComputedValue"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
@ -1141,6 +1147,7 @@ ${helpers.single_keyword_system("font-variant-caps",
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand products="gecko" name="font-synthesis" animation_value_type="discrete" <%helpers:longhand products="gecko" name="font-synthesis" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -1238,6 +1245,7 @@ ${helpers.single_keyword_system("font-stretch",
gecko_constant_prefix="NS_FONT_STRETCH", gecko_constant_prefix="NS_FONT_STRETCH",
cast_type='i16', cast_type='i16',
spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch", spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="ComputedValue")} animation_value_type="ComputedValue")}
${helpers.single_keyword_system("font-kerning", ${helpers.single_keyword_system("font-kerning",
@ -1246,9 +1254,11 @@ ${helpers.single_keyword_system("font-kerning",
gecko_ffi_name="mFont.kerning", gecko_ffi_name="mFont.kerning",
gecko_constant_prefix="NS_FONT_KERNING", gecko_constant_prefix="NS_FONT_KERNING",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning", spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
<%helpers:longhand name="font-variant-alternates" products="gecko" animation_value_type="none" <%helpers:longhand name="font-variant-alternates" products="gecko" animation_value_type="none"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
@ -1458,6 +1468,7 @@ macro_rules! exclusive_value {
} }
<%helpers:longhand name="font-variant-east-asian" products="gecko" animation_value_type="discrete" <%helpers:longhand name="font-variant-east-asian" products="gecko" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
@ -1603,6 +1614,7 @@ macro_rules! exclusive_value {
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete" <%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
@ -1762,6 +1774,7 @@ macro_rules! exclusive_value {
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete" <%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
@ -1915,10 +1928,12 @@ ${helpers.single_keyword_system("font-variant-position",
gecko_ffi_name="mFont.variantPosition", gecko_ffi_name="mFont.variantPosition",
gecko_constant_prefix="NS_FONT_VARIANT_POSITION", gecko_constant_prefix="NS_FONT_VARIANT_POSITION",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="discrete" <%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="discrete"
extra_prefixes="moz" boxed="True" extra_prefixes="moz" boxed="True"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use values::generics::FontSettings; use values::generics::FontSettings;
@ -1961,6 +1976,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
""" """
%> %>
<%helpers:longhand name="font-variation-settings" products="gecko" animation_value_type="none" <%helpers:longhand name="font-variation-settings" products="gecko" animation_value_type="none"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="${variation_spec}"> spec="${variation_spec}">
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::generics::FontSettings; use values::generics::FontSettings;
@ -1991,6 +2007,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
<%helpers:longhand name="font-language-override" products="gecko" animation_value_type="discrete" <%helpers:longhand name="font-language-override" products="gecko" animation_value_type="discrete"
extra_prefixes="moz" boxed="True" extra_prefixes="moz" boxed="True"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override"> spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
@ -2550,6 +2567,7 @@ ${helpers.single_keyword("-moz-osx-font-smoothing",
gecko_ffi_name="mFont.smoothing", gecko_ffi_name="mFont.smoothing",
products="gecko", products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} animation_value_type="discrete")}
${helpers.predefined_type("-moz-min-font-size-ratio", ${helpers.predefined_type("-moz-min-font-size-ratio",

View file

@ -10,6 +10,7 @@ ${helpers.predefined_type("line-height",
"LineHeight", "LineHeight",
"computed::LineHeight::normal()", "computed::LineHeight::normal()",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height")} spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height")}
// CSS Text Module Level 3 // CSS Text Module Level 3
@ -19,6 +20,7 @@ ${helpers.single_keyword("text-transform",
"none capitalize uppercase lowercase", "none capitalize uppercase lowercase",
extra_gecko_values="full-width", extra_gecko_values="full-width",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-text-transform")} spec="https://drafts.csswg.org/css-text/#propdef-text-transform")}
${helpers.single_keyword("hyphens", "manual none auto", ${helpers.single_keyword("hyphens", "manual none auto",
@ -66,6 +68,7 @@ ${helpers.single_keyword("word-break",
gecko_enum_prefix="StyleTextJustify" gecko_enum_prefix="StyleTextJustify"
gecko_inexhaustive="True" gecko_inexhaustive="True"
animation_value_type="discrete" animation_value_type="discrete"
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-text-justify"> spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -109,6 +112,7 @@ ${helpers.single_keyword("text-align-last",
// TODO make this a shorthand and implement text-align-last/text-align-all // TODO make this a shorthand and implement text-align-last/text-align-all
<%helpers:longhand name="text-align" animation_value_type="discrete" <%helpers:longhand name="text-align" animation_value_type="discrete"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-text/#propdef-text-align"> spec="https://drafts.csswg.org/css-text/#propdef-text-align">
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
@ -267,12 +271,14 @@ ${helpers.predefined_type("letter-spacing",
"LetterSpacing", "LetterSpacing",
"computed::LetterSpacing::normal()", "computed::LetterSpacing::normal()",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing")} spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing")}
${helpers.predefined_type("word-spacing", ${helpers.predefined_type("word-spacing",
"WordSpacing", "WordSpacing",
"computed::WordSpacing::normal()", "computed::WordSpacing::normal()",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-word-spacing")} spec="https://drafts.csswg.org/css-text/#propdef-word-spacing")}
<%helpers:longhand name="-servo-text-decorations-in-effect" <%helpers:longhand name="-servo-text-decorations-in-effect"
@ -367,6 +373,9 @@ ${helpers.predefined_type("word-spacing",
needs_conversion="True" needs_conversion="True"
gecko_inexhaustive="True" gecko_inexhaustive="True"
animation_value_type="discrete" animation_value_type="discrete"
// Only allowed for UA sheets, which set it
// !important.
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-text/#propdef-white-space"> spec="https://drafts.csswg.org/css-text/#propdef-white-space">
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -414,6 +423,7 @@ ${helpers.predefined_type(
vector=True, vector=True,
animation_value_type="AnimatedTextShadowList", animation_value_type="AnimatedTextShadowList",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property", spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property",
)} )}
@ -718,6 +728,7 @@ ${helpers.predefined_type(
"computed_value::T::currentcolor()", "computed_value::T::currentcolor()",
products="gecko", animation_value_type="IntermediateColor", products="gecko", animation_value_type="IntermediateColor",
need_clone=True, ignored_when_colors_disabled=True, need_clone=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color")} spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color")}
${helpers.predefined_type( ${helpers.predefined_type(
@ -726,6 +737,7 @@ ${helpers.predefined_type(
initial_specified_value="specified::Color::currentcolor()", initial_specified_value="specified::Color::currentcolor()",
products="gecko", animation_value_type="IntermediateColor", products="gecko", animation_value_type="IntermediateColor",
need_clone=True, ignored_when_colors_disabled=True, need_clone=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")} spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
${helpers.predefined_type("-webkit-text-stroke-width", ${helpers.predefined_type("-webkit-text-stroke-width",
@ -734,6 +746,7 @@ ${helpers.predefined_type("-webkit-text-stroke-width",
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())", initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
computed_type="::app_units::Au", computed_type="::app_units::Au",
products="gecko", products="gecko",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
animation_value_type="none")} animation_value_type="none")}

View file

@ -17,5 +17,6 @@
alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"), alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"),
allow_quirks=not side[1], allow_quirks=not side[1],
animation_value_type="ComputedValue", logical = side[1], spec = spec, animation_value_type="ComputedValue", logical = side[1], spec = spec,
flags="APPLIES_TO_FIRST_LETTER",
allowed_in_page_rule=True)} allowed_in_page_rule=True)}
% endfor % endfor

View file

@ -6,6 +6,8 @@
<% from data import ALL_SIDES, maybe_moz_logical_alias %> <% from data import ALL_SIDES, maybe_moz_logical_alias %>
<% data.new_style_struct("Padding", inherited=False) %> <% data.new_style_struct("Padding", inherited=False) %>
// APPLIES_TO_PLACEHOLDER so we can set it in UA stylesheets. But we use a
// !important value there, so pages can't set it.
% for side in ALL_SIDES: % for side in ALL_SIDES:
<% <%
spec = "https://drafts.csswg.org/css-box/#propdef-padding-%s" % side[0] spec = "https://drafts.csswg.org/css-box/#propdef-padding-%s" % side[0]
@ -19,5 +21,6 @@
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
logical = side[1], logical = side[1],
spec = spec, spec = spec,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_PLACEHOLDER",
allow_quirks=not side[1])} allow_quirks=not side[1])}
% endfor % endfor

View file

@ -152,6 +152,7 @@
// TODO(pcwalton): SVG-only values. // TODO(pcwalton): SVG-only values.
${helpers.single_keyword("pointer-events", "auto none", animation_value_type="discrete", ${helpers.single_keyword("pointer-events", "auto none", animation_value_type="discrete",
extra_gecko_values="visiblepainted visiblefill visiblestroke visible painted fill stroke all", extra_gecko_values="visiblepainted visiblefill visiblestroke visible painted fill stroke all",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty")} spec="https://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty")}
${helpers.single_keyword("-moz-user-input", "auto none enabled disabled", ${helpers.single_keyword("-moz-user-input", "auto none enabled disabled",

View file

@ -13,6 +13,7 @@
Method("has_line_through", "bool")]) %> Method("has_line_through", "bool")]) %>
<%helpers:longhand name="text-overflow" animation_value_type="discrete" boxed="True" <%helpers:longhand name="text-overflow" animation_value_type="discrete" boxed="True"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow"> spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -142,6 +143,7 @@ ${helpers.single_keyword("unicode-bidi",
custom_cascade="${product == 'servo'}" custom_cascade="${product == 'servo'}"
need_clone=True need_clone=True
animation_value_type="discrete" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -262,6 +264,7 @@ ${helpers.single_keyword("text-decoration-style",
"solid double dotted dashed wavy -moz-none", "solid double dotted dashed wavy -moz-none",
products="gecko", products="gecko",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style")} spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style")}
${helpers.predefined_type( ${helpers.predefined_type(
@ -271,6 +274,7 @@ ${helpers.predefined_type(
products="gecko", products="gecko",
animation_value_type="IntermediateColor", animation_value_type="IntermediateColor",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color")} spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color")}
${helpers.predefined_type( ${helpers.predefined_type(
@ -280,4 +284,5 @@ ${helpers.predefined_type(
initial_specified_value="specified::InitialLetter::normal()", initial_specified_value="specified::InitialLetter::normal()",
animation_value_type="discrete", animation_value_type="discrete",
products="gecko", products="gecko",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")} spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")}

View file

@ -442,6 +442,12 @@ bitflags! {
const ABSPOS_CB = 1 << 2, const ABSPOS_CB = 1 << 2,
/// This shorthand property is an alias of another property. /// This shorthand property is an alias of another property.
const SHORTHAND_ALIAS_PROPERTY = 1 << 3, const SHORTHAND_ALIAS_PROPERTY = 1 << 3,
/// This longhand property applies to ::first-letter.
const APPLIES_TO_FIRST_LETTER = 1 << 4,
/// This longhand property applies to ::first-line.
const APPLIES_TO_FIRST_LINE = 1 << 5,
/// This longhand property applies to ::placeholder.
const APPLIES_TO_PLACEHOLDER = 1 << 6,
} }
} }
@ -2866,11 +2872,26 @@ pub fn cascade(
&[] &[]
}; };
let node_importance = node.importance(); let node_importance = node.importance();
let property_restriction = pseudo.and_then(|p| p.property_restriction());
declarations declarations
.iter() .iter()
// Yield declarations later in source order (with more precedence) first. // Yield declarations later in source order (with more precedence) first.
.rev() .rev()
.filter_map(move |&(ref declaration, declaration_importance)| { .filter_map(move |&(ref declaration, declaration_importance)| {
if let Some(property_restriction) = property_restriction {
// declaration.id() is either a longhand or a custom
// property. Custom properties are always allowed, but
// longhands are only allowed if they have our
// property_restriction flag set.
if let PropertyDeclarationId::Longhand(id) = declaration.id() {
if !id.flags().contains(property_restriction) {
return None
}
}
}
if declaration_importance == node_importance { if declaration_importance == node_importance {
Some((declaration, cascade_level)) Some((declaration, cascade_level))
} else { } else {

View file

@ -13,6 +13,7 @@ use dom::{OpaqueNode, TElement, TNode};
use element_state::ElementState; use element_state::ElementState;
use fnv::FnvHashMap; use fnv::FnvHashMap;
use invalidation::element::element_wrapper::ElementSnapshot; use invalidation::element::element_wrapper::ElementSnapshot;
use properties::PropertyFlags;
use selector_parser::{AttrValue as SelectorAttrValue, ElementExt, PseudoElementCascadeType, SelectorParser}; use selector_parser::{AttrValue as SelectorAttrValue, ElementExt, PseudoElementCascadeType, SelectorParser};
use selectors::Element; use selectors::Element;
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity}; use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
@ -39,6 +40,12 @@ pub enum PseudoElement {
Before, Before,
Selection, Selection,
// If/when :first-letter is added, update is_first_letter accordingly. // If/when :first-letter is added, update is_first_letter accordingly.
// If/when ::first-letter, ::first-line, or ::placeholder are added, adjust
// our property_restriction implementation to do property filtering for
// them. Also, make sure the UA sheet has the !important rules some of the
// APPLIES_TO_PLACEHOLDER properties expect!
// Non-eager pseudos. // Non-eager pseudos.
DetailsSummary, DetailsSummary,
DetailsContent, DetailsContent,
@ -169,6 +176,12 @@ impl PseudoElement {
/// Stub, only Gecko needs this /// Stub, only Gecko needs this
pub fn pseudo_info(&self) { () } pub fn pseudo_info(&self) { () }
/// Property flag that properties must have to apply to this pseudo-element.
#[inline]
pub fn property_restriction(&self) -> Option<PropertyFlags> {
None
}
} }
/// The type used for storing pseudo-class string arguments. /// The type used for storing pseudo-class string arguments.