aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/properties
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-11 23:05:37 -0500
committerGitHub <noreply@github.com>2020-02-11 23:05:37 -0500
commit6d6d16f7f492e6346f0391e352015226a4444806 (patch)
treed991c986a7f83be25157934e93c248ea86ee4b00 /components/style/properties
parentbaac1e2c69d3b6e840ced2be4b5e03bb39bd40d5 (diff)
parentd1f8d576f83714fe674a36c5b718341c236312e6 (diff)
downloadservo-6d6d16f7f492e6346f0391e352015226a4444806.tar.gz
servo-6d6d16f7f492e6346f0391e352015226a4444806.zip
Auto merge of #25717 - emilio:gecko-sync, r=emilio,nox
style: Sync changes from mozilla-central. See individual commits for details. https://bugzilla.mozilla.org/show_bug.cgi?id=1614394
Diffstat (limited to 'components/style/properties')
-rw-r--r--components/style/properties/cascade.rs131
-rw-r--r--components/style/properties/computed_value_flags.rs29
-rw-r--r--components/style/properties/declaration_block.rs19
-rw-r--r--components/style/properties/gecko.mako.rs362
-rw-r--r--components/style/properties/helpers.mako.rs3
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs2
-rw-r--r--components/style/properties/longhands/box.mako.rs8
-rw-r--r--components/style/properties/longhands/column.mako.rs17
-rw-r--r--components/style/properties/longhands/inherited_box.mako.rs3
-rw-r--r--components/style/properties/longhands/inherited_svg.mako.rs2
-rw-r--r--components/style/properties/longhands/inherited_table.mako.rs2
-rw-r--r--components/style/properties/longhands/inherited_text.mako.rs4
-rw-r--r--components/style/properties/longhands/position.mako.rs2
-rw-r--r--components/style/properties/longhands/svg.mako.rs1
-rw-r--r--components/style/properties/longhands/table.mako.rs1
-rw-r--r--components/style/properties/properties.mako.rs39
-rw-r--r--components/style/properties/shorthands/column.mako.rs5
17 files changed, 178 insertions, 452 deletions
diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs
index dd87916cf7d..50029da8479 100644
--- a/components/style/properties/cascade.rs
+++ b/components/style/properties/cascade.rs
@@ -25,7 +25,7 @@ use smallvec::SmallVec;
use std::borrow::Cow;
use std::cell::RefCell;
use crate::style_adjuster::StyleAdjuster;
-use crate::values::computed;
+use crate::values::{computed, specified};
/// We split the cascade in two phases: 'early' properties, and 'late'
/// properties.
@@ -250,7 +250,7 @@ where
let custom_properties = {
let mut builder = CustomPropertiesBuilder::new(
inherited_style.custom_properties(),
- device.environment(),
+ device,
);
for (declaration, origin) in iter_declarations() {
@@ -263,8 +263,11 @@ where
builder.build()
};
+
+ let is_root_element =
+ pseudo.is_none() && element.map_or(false, |e| e.is_root());
+
let mut context = computed::Context {
- is_root_element: pseudo.is_none() && element.map_or(false, |e| e.is_root()),
// We'd really like to own the rules here to avoid refcount traffic, but
// animation's usage of `apply_declarations` make this tricky. See bug
// 1375525.
@@ -275,6 +278,7 @@ where
pseudo,
Some(rules.clone()),
custom_properties,
+ is_root_element,
),
cached_system_font: None,
in_media_query: false,
@@ -333,27 +337,37 @@ where
context.builder.build()
}
-fn should_ignore_declaration_when_ignoring_document_colors(
- device: &Device,
+/// How should a declaration behave when ignoring document colors?
+enum DeclarationApplication {
+ /// We should apply the declaration.
+ Apply,
+ /// We should ignore the declaration.
+ Ignore,
+ /// We should apply the following declaration, only if any other declaration
+ /// hasn't set it before.
+ ApplyUnlessOverriden(PropertyDeclaration),
+}
+
+fn application_when_ignoring_colors(
+ builder: &StyleBuilder,
longhand_id: LonghandId,
origin: Origin,
- pseudo: Option<&PseudoElement>,
- declaration: &mut Cow<PropertyDeclaration>,
-) -> bool {
+ declaration: &PropertyDeclaration,
+) -> DeclarationApplication {
if !longhand_id.ignored_when_document_colors_disabled() {
- return false;
+ return DeclarationApplication::Apply;
}
let is_ua_or_user_rule = matches!(origin, Origin::User | Origin::UserAgent);
if is_ua_or_user_rule {
- return false;
+ return DeclarationApplication::Apply;
}
// Don't override background-color on ::-moz-color-swatch. It is set as an
// author style (via the style attribute), but it's pretty important for it
// to show up for obvious reasons :)
- if pseudo.map_or(false, |p| p.is_color_swatch()) && longhand_id == LonghandId::BackgroundColor {
- return false;
+ if builder.pseudo.map_or(false, |p| p.is_color_swatch()) && longhand_id == LonghandId::BackgroundColor {
+ return DeclarationApplication::Apply;
}
// Treat background-color a bit differently. If the specified color is
@@ -365,26 +379,41 @@ fn should_ignore_declaration_when_ignoring_document_colors(
// a background image, if we're ignoring document colors).
// Here we check backplate status to decide if ignoring background-image
// is the right decision.
- {
- let background_color = match **declaration {
- PropertyDeclaration::BackgroundColor(ref color) => color,
- // In the future, if/when we remove the backplate pref, we can remove this
- // special case along with the 'ignored_when_colors_disabled=True' mako line
- // for the "background-image" property.
- #[cfg(feature = "gecko")]
- PropertyDeclaration::BackgroundImage(..) => return !static_prefs::pref!("browser.display.permit_backplate"),
- _ => return true,
- };
-
- if background_color.is_transparent() {
- return false;
+ match *declaration {
+ PropertyDeclaration::BackgroundColor(ref color) => {
+ if color.is_transparent() {
+ return DeclarationApplication::Apply;
+ }
+ let color = builder.device.default_background_color();
+ DeclarationApplication::ApplyUnlessOverriden(
+ PropertyDeclaration::BackgroundColor(color.into())
+ )
}
+ PropertyDeclaration::Color(ref color) => {
+ if color.0.is_transparent() {
+ return DeclarationApplication::Apply;
+ }
+ if builder.get_parent_inherited_text().clone_color().alpha != 0 {
+ return DeclarationApplication::Ignore;
+ }
+ let color = builder.device.default_color();
+ DeclarationApplication::ApplyUnlessOverriden(
+ PropertyDeclaration::Color(specified::ColorPropertyValue(color.into()))
+ )
+ },
+ // In the future, if/when we remove the backplate pref, we can remove this
+ // special case along with the 'ignored_when_colors_disabled=True' mako line
+ // for the "background-image" property.
+ #[cfg(feature = "gecko")]
+ PropertyDeclaration::BackgroundImage(..) => {
+ if static_prefs::pref!("browser.display.permit_backplate") {
+ DeclarationApplication::Apply
+ } else {
+ DeclarationApplication::Ignore
+ }
+ },
+ _ => DeclarationApplication::Ignore,
}
-
- let color = device.default_background_color();
- *declaration.to_mut() = PropertyDeclaration::BackgroundColor(color.into());
-
- false
}
struct Cascade<'a, 'b: 'a> {
@@ -424,7 +453,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
declaration.id,
self.context.builder.custom_properties.as_ref(),
self.context.quirks_mode,
- self.context.device().environment(),
+ self.context.device(),
))
}
@@ -461,6 +490,8 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
);
let ignore_colors = !self.context.builder.device.use_document_colors();
+ let mut declarations_to_apply_unless_overriden =
+ SmallVec::<[PropertyDeclaration; 2]>::new();
for (declaration, origin) in declarations {
let declaration_id = declaration.id();
@@ -502,21 +533,25 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
continue;
}
- let mut declaration = self.substitute_variables_if_needed(declaration);
+ let declaration = self.substitute_variables_if_needed(declaration);
- // When document colors are disabled, skip properties that are
- // marked as ignored in that mode, unless they come from a UA or
- // user style sheet.
+ // When document colors are disabled, do special handling of
+ // properties that are marked as ignored in that mode.
if ignore_colors {
- let should_ignore = should_ignore_declaration_when_ignoring_document_colors(
- self.context.builder.device,
+ let application = application_when_ignoring_colors(
+ &self.context.builder,
longhand_id,
origin,
- self.context.builder.pseudo,
- &mut declaration,
+ &declaration,
);
- if should_ignore {
- continue;
+
+ match application {
+ DeclarationApplication::Ignore => continue,
+ DeclarationApplication::Apply => {},
+ DeclarationApplication::ApplyUnlessOverriden(decl) => {
+ declarations_to_apply_unless_overriden.push(decl);
+ continue;
+ }
}
}
@@ -554,6 +589,20 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
self.apply_declaration(longhand_id, &*declaration);
}
+ if ignore_colors {
+ for declaration in declarations_to_apply_unless_overriden.iter() {
+ let longhand_id = match declaration.id() {
+ PropertyDeclarationId::Longhand(id) => id,
+ PropertyDeclarationId::Custom(..) => unreachable!(),
+ };
+ debug_assert!(!longhand_id.is_logical());
+ if self.seen.contains(longhand_id) {
+ continue;
+ }
+ self.apply_declaration(longhand_id, declaration);
+ }
+ }
+
if Phase::is_early() {
self.fixup_font_stuff();
self.compute_writing_mode();
diff --git a/components/style/properties/computed_value_flags.rs b/components/style/properties/computed_value_flags.rs
index a86f8a4da3a..4363f3f36e9 100644
--- a/components/style/properties/computed_value_flags.rs
+++ b/components/style/properties/computed_value_flags.rs
@@ -11,6 +11,7 @@ bitflags! {
/// anonymous boxes, see StyleBuilder::for_inheritance and its callsites.
/// If we ever want to add some flags that shouldn't inherit for them,
/// we might want to add a function to handle this.
+ #[repr(C)]
pub struct ComputedValueFlags: u16 {
/// Whether the style or any of the ancestors has a text-decoration-line
/// property that should get propagated to descendants.
@@ -63,6 +64,9 @@ bitflags! {
///
/// Only used in Servo.
const CAN_BE_FRAGMENTED = 1 << 10;
+
+ /// Whether this style is the style of the document element.
+ const IS_ROOT_ELEMENT_STYLE = 1 << 11;
}
}
@@ -71,9 +75,9 @@ impl ComputedValueFlags {
#[inline]
fn inherited_flags() -> Self {
ComputedValueFlags::IS_RELEVANT_LINK_VISITED |
- ComputedValueFlags::CAN_BE_FRAGMENTED |
- ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE |
- ComputedValueFlags::HAS_TEXT_DECORATION_LINES
+ ComputedValueFlags::CAN_BE_FRAGMENTED |
+ ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE |
+ ComputedValueFlags::HAS_TEXT_DECORATION_LINES
}
/// Flags that may be propagated to descendants.
@@ -97,22 +101,3 @@ impl ComputedValueFlags {
self & Self::maybe_inherited_flags()
}
}
-
-/// Asserts that the relevant servo and Gecko representations match.
-#[cfg(feature = "gecko")]
-#[inline]
-pub fn assert_match() {
- use crate::gecko_bindings::structs;
- macro_rules! assert_bit {
- ($rust:ident, $cpp:ident) => {
- debug_assert_eq!(ComputedValueFlags::$rust.bits, structs::$cpp);
- }
- }
-
- assert_bit!(HAS_TEXT_DECORATION_LINES, ComputedStyleBit_HasTextDecorationLines);
- assert_bit!(IS_IN_PSEUDO_ELEMENT_SUBTREE, ComputedStyleBit_HasPseudoElementData);
- assert_bit!(SHOULD_SUPPRESS_LINEBREAK, ComputedStyleBit_SuppressLineBreak);
- assert_bit!(IS_TEXT_COMBINED, ComputedStyleBit_IsTextCombined);
- assert_bit!(IS_RELEVANT_LINK_VISITED, ComputedStyleBit_RelevantLinkVisited);
- assert_bit!(DEPENDS_ON_FONT_METRICS, ComputedStyleBit_DependsOnFontMetrics);
-}
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index 90dec0a47d7..53b483887ce 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -8,7 +8,7 @@
use super::*;
use crate::context::QuirksMode;
-use crate::custom_properties::{CssEnvironment, CustomPropertiesBuilder};
+use crate::custom_properties::CustomPropertiesBuilder;
use crate::error_reporting::{ContextualParseError, ParseErrorReporter};
use crate::parser::ParserContext;
use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
@@ -778,6 +778,7 @@ impl PropertyDeclarationBlock {
dest: &mut CssStringWriter,
computed_values: Option<&ComputedValues>,
custom_properties_block: Option<&PropertyDeclarationBlock>,
+ device: &Device,
) -> fmt::Result {
if let Ok(shorthand) = property.as_shorthand() {
return self.shorthand_to_css(shorthand, dest);
@@ -790,19 +791,13 @@ impl PropertyDeclarationBlock {
None => return Err(fmt::Error),
};
- // TODO(emilio): When we implement any environment variable without
- // hard-coding the values we're going to need to get something
- // meaningful out of here... All this code path is so terribly hacky
- // ;_;.
- let env = CssEnvironment;
-
let custom_properties = if let Some(cv) = computed_values {
// If there are extra custom properties for this declaration block,
// factor them in too.
if let Some(block) = custom_properties_block {
// FIXME(emilio): This is not super-efficient here, and all this
// feels like a hack anyway...
- block.cascade_custom_properties(cv.custom_properties(), &env)
+ block.cascade_custom_properties(cv.custom_properties(), device)
} else {
cv.custom_properties().cloned()
}
@@ -825,7 +820,7 @@ impl PropertyDeclarationBlock {
declaration.id,
custom_properties.as_ref(),
QuirksMode::NoQuirks,
- &env,
+ device,
)
.to_css(dest)
},
@@ -873,7 +868,7 @@ impl PropertyDeclarationBlock {
) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> {
self.cascade_custom_properties(
context.style().custom_properties(),
- context.device().environment(),
+ context.device(),
)
}
@@ -883,9 +878,9 @@ impl PropertyDeclarationBlock {
fn cascade_custom_properties(
&self,
inherited_custom_properties: Option<&Arc<crate::custom_properties::CustomPropertiesMap>>,
- environment: &CssEnvironment,
+ device: &Device,
) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> {
- let mut builder = CustomPropertiesBuilder::new(inherited_custom_properties, environment);
+ let mut builder = CustomPropertiesBuilder::new(inherited_custom_properties, device);
for declaration in self.normal_declaration_iter() {
if let PropertyDeclaration::Custom(ref declaration) = *declaration {
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 14262e7a074..6cfb4c859b4 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -12,6 +12,7 @@
use crate::Atom;
use app_units::Au;
+use crate::computed_value_flags::*;
use crate::custom_properties::CustomPropertiesMap;
use crate::gecko_bindings::bindings;
% for style_struct in data.style_structs:
@@ -24,28 +25,20 @@ use crate::gecko_bindings::bindings::Gecko_CopyCounterStyle;
use crate::gecko_bindings::bindings::Gecko_CopyCursorArrayFrom;
use crate::gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
use crate::gecko_bindings::bindings::Gecko_CopyImageValueFrom;
-use crate::gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
use crate::gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
-use crate::gecko_bindings::bindings::Gecko_SetCursorArrayLength;
-use crate::gecko_bindings::bindings::Gecko_SetCursorImageValue;
use crate::gecko_bindings::bindings::Gecko_nsStyleFont_SetLang;
use crate::gecko_bindings::bindings::Gecko_nsStyleFont_CopyLangFrom;
-use crate::gecko_bindings::bindings::Gecko_SetListStyleImageNone;
-use crate::gecko_bindings::bindings::Gecko_SetListStyleImageImageValue;
use crate::gecko_bindings::bindings::Gecko_SetNullImageValue;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::nsCSSPropertyID;
use crate::gecko_bindings::structs::mozilla::PseudoStyleType;
-use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::gecko::values::round_border_to_device_pixels;
use crate::logical_geometry::WritingMode;
use crate::media_queries::Device;
-use crate::properties::computed_value_flags::*;
use crate::properties::longhands;
use crate::rule_tree::StrongRuleNode;
use crate::selector_parser::PseudoElement;
use servo_arc::{Arc, RawOffsetArc, UniqueArc};
-use std::marker::PhantomData;
use std::mem::{forget, MaybeUninit};
use std::{cmp, ops, ptr};
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
@@ -55,8 +48,6 @@ use crate::values::computed::BorderStyle;
use crate::values::computed::font::FontSize;
use crate::values::generics::column::ColumnCount;
use crate::values::generics::image::ImageLayer;
-use crate::values::generics::transform::TransformStyle;
-use crate::values::generics::url::UrlOrNone;
pub mod style_structs {
@@ -959,48 +950,16 @@ fn static_assert() {
<% skip_position_longhands = " ".join(x.ident for x in SIDES) %>
<%self:impl_trait style_struct_name="Position"
- skip_longhands="${skip_position_longhands}
- align-content justify-content align-self
- justify-self align-items justify-items
- grid-auto-flow">
+ skip_longhands="${skip_position_longhands} grid-auto-flow">
% for side in SIDES:
<% impl_split_style_coord(side.ident, "mOffset", side.index) %>
% endfor
-
- % for kind in ["align", "justify"]:
- ${impl_simple_type_with_conversion(kind + "_content")}
- ${impl_simple_type_with_conversion(kind + "_self")}
- % endfor
- ${impl_simple_type_with_conversion("align_items")}
-
- pub fn set_justify_items(&mut self, v: longhands::justify_items::computed_value::T) {
- self.gecko.mSpecifiedJustifyItems = v.specified.into();
- self.set_computed_justify_items(v.computed);
- }
-
+ ${impl_simple_type_with_conversion("grid_auto_flow")}
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert_ne!(v.0, crate::values::specified::align::AlignFlags::LEGACY);
- self.gecko.mJustifyItems = v.into();
+ self.gecko.mJustifyItems.computed = v;
}
- pub fn reset_justify_items(&mut self, reset_style: &Self) {
- self.gecko.mJustifyItems = reset_style.gecko.mJustifyItems;
- self.gecko.mSpecifiedJustifyItems = reset_style.gecko.mSpecifiedJustifyItems;
- }
-
- pub fn copy_justify_items_from(&mut self, other: &Self) {
- self.gecko.mJustifyItems = other.gecko.mJustifyItems;
- self.gecko.mSpecifiedJustifyItems = other.gecko.mJustifyItems;
- }
-
- pub fn clone_justify_items(&self) -> longhands::justify_items::computed_value::T {
- longhands::justify_items::computed_value::T {
- computed: self.gecko.mJustifyItems.into(),
- specified: self.gecko.mSpecifiedJustifyItems.into(),
- }
- }
-
- ${impl_simple_type_with_conversion("grid_auto_flow")}
</%self:impl_trait>
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
@@ -1507,7 +1466,7 @@ fn static_assert() {
animation-iteration-count animation-timing-function
clear transition-duration transition-delay
transition-timing-function transition-property
- transform-style shape-outside -webkit-line-clamp""" %>
+ shape-outside -webkit-line-clamp""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
#[inline]
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
@@ -1664,25 +1623,6 @@ fn static_assert() {
self.copy_transition_property_from(other)
}
- // Hand-written because the Mako helpers transform `Preserve3d` into `PRESERVE3D`.
- pub fn set_transform_style(&mut self, v: TransformStyle) {
- self.gecko.mTransformStyle = match v {
- TransformStyle::Flat => structs::NS_STYLE_TRANSFORM_STYLE_FLAT as u8,
- TransformStyle::Preserve3d => structs::NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D as u8,
- };
- }
-
- // Hand-written because the Mako helpers transform `Preserve3d` into `PRESERVE3D`.
- pub fn clone_transform_style(&self) -> TransformStyle {
- match self.gecko.mTransformStyle as u32 {
- structs::NS_STYLE_TRANSFORM_STYLE_FLAT => TransformStyle::Flat,
- structs::NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D => TransformStyle::Preserve3d,
- _ => panic!("illegal transform style"),
- }
- }
-
- ${impl_simple_copy('transform_style', 'mTransformStyle')}
-
${impl_transition_count('property', 'Property')}
pub fn animations_equals(&self, other: &Self) -> bool {
@@ -2162,57 +2102,20 @@ fn static_assert() {
<% impl_simple_image_array_property("blend_mode", "background", "mImage", "mBlendMode", "Background") %>
</%self:impl_trait>
-<%self:impl_trait style_struct_name="List"
- skip_longhands="list-style-image list-style-type">
-
- pub fn set_list_style_image(&mut self, image: longhands::list_style_image::computed_value::T) {
- match image {
- UrlOrNone::None => {
- unsafe {
- Gecko_SetListStyleImageNone(&mut *self.gecko);
- }
- }
- UrlOrNone::Url(ref url) => {
- unsafe {
- Gecko_SetListStyleImageImageValue(&mut *self.gecko, url);
- }
- }
- }
- }
-
- pub fn copy_list_style_image_from(&mut self, other: &Self) {
- unsafe { Gecko_CopyListStyleImageFrom(&mut *self.gecko, &*other.gecko); }
- }
-
- pub fn reset_list_style_image(&mut self, other: &Self) {
- self.copy_list_style_image_from(other)
- }
-
- pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
- if self.gecko.mListStyleImage.mRawPtr.is_null() {
- return UrlOrNone::None;
- }
-
- unsafe {
- let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
- UrlOrNone::Url(ComputedImageUrl::from_image_request(gecko_image_request))
- }
- }
-
+<%self:impl_trait style_struct_name="List" skip_longhands="list-style-type">
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T) {
- use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToName;
- use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToString;
use nsstring::{nsACString, nsCStr};
use self::longhands::list_style_type::computed_value::T;
match v {
T::None => unsafe {
- Gecko_SetCounterStyleToName(&mut self.gecko.mCounterStyle,
- atom!("none").into_addrefed());
+ bindings::Gecko_SetCounterStyleToNone(&mut self.gecko.mCounterStyle)
}
T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle),
T::String(s) => unsafe {
- Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle,
- &nsCStr::from(&s) as &nsACString)
+ bindings::Gecko_SetCounterStyleToString(
+ &mut self.gecko.mCounterStyle,
+ &nsCStr::from(&s) as &nsACString,
+ )
}
}
}
@@ -2488,14 +2391,11 @@ clip-path
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
self.gecko.mCursor = v.keyword;
unsafe {
- Gecko_SetCursorArrayLength(&mut *self.gecko, v.images.len());
+ bindings::Gecko_SetCursorArrayCapacity(&mut *self.gecko, v.images.len());
}
for i in 0..v.images.len() {
unsafe {
- Gecko_SetCursorImageValue(
- &mut self.gecko.mCursorImages[i],
- &v.images[i].url
- );
+ bindings::Gecko_AppendCursorImage(&mut *self.gecko, &v.images[i].url);
}
match v.images[i].hotspot {
@@ -2528,10 +2428,7 @@ clip-path
let keyword = self.gecko.mCursor;
let images = self.gecko.mCursorImages.iter().map(|gecko_cursor_image| {
- let url = unsafe {
- let gecko_image_request = gecko_cursor_image.mImage.mRawPtr.as_ref().unwrap();
- ComputedImageUrl::from_image_request(&gecko_image_request)
- };
+ let url = gecko_cursor_image.mImage.clone();
let hotspot =
if gecko_cursor_image.mHaveHotspot {
@@ -2580,236 +2477,9 @@ clip-path
${impl_simple('column_rule_style', 'mColumnRuleStyle')}
</%self:impl_trait>
-<%self:impl_trait style_struct_name="Counters" skip_longhands="content">
+<%self:impl_trait style_struct_name="Counters">
pub fn ineffective_content_property(&self) -> bool {
- self.gecko.mContents.is_empty()
- }
-
- pub fn set_content(&mut self, v: longhands::content::computed_value::T) {
- use crate::values::CustomIdent;
- use crate::values::generics::counters::{Content, ContentItem};
- use crate::values::generics::CounterStyle;
- use crate::gecko_bindings::structs::nsStyleContentData;
- use crate::gecko_bindings::structs::nsStyleContentAttr;
- use crate::gecko_bindings::structs::StyleContentType;
- use crate::gecko_bindings::bindings::Gecko_ClearAndResizeStyleContents;
-
- // Converts a string as utf16, and returns an owned, zero-terminated raw buffer.
- fn as_utf16_and_forget(s: &str) -> *mut u16 {
- use std::mem;
- let mut vec = s.encode_utf16().collect::<Vec<_>>();
- vec.push(0u16);
- let ptr = vec.as_mut_ptr();
- mem::forget(vec);
- ptr
- }
-
- fn set_counter_function(
- data: &mut nsStyleContentData,
- content_type: StyleContentType,
- name: CustomIdent,
- sep: &str,
- style: CounterStyle,
- ) {
- debug_assert!(content_type == StyleContentType::Counter ||
- content_type == StyleContentType::Counters);
- let counter_func = unsafe {
- bindings::Gecko_SetCounterFunction(data, content_type).as_mut().unwrap()
- };
- counter_func.mIdent.set_move(unsafe {
- RefPtr::from_addrefed(name.0.into_addrefed())
- });
- if content_type == StyleContentType::Counters {
- counter_func.mSeparator.assign_str(sep);
- }
- style.to_gecko_value(&mut counter_func.mCounterStyle);
- }
-
- match v {
- Content::None |
- Content::Normal => {
- // Ensure destructors run, otherwise we could leak.
- if !self.gecko.mContents.is_empty() {
- unsafe {
- Gecko_ClearAndResizeStyleContents(&mut *self.gecko, 0);
- }
- }
- },
- Content::MozAltContent => {
- unsafe {
- Gecko_ClearAndResizeStyleContents(&mut *self.gecko, 1);
- *self.gecko.mContents[0].mContent.mString.as_mut() = ptr::null_mut();
- }
- self.gecko.mContents[0].mType = StyleContentType::AltContent;
- },
- Content::Items(items) => {
- unsafe {
- Gecko_ClearAndResizeStyleContents(&mut *self.gecko,
- items.len() as u32);
- }
- for (i, item) in items.into_vec().into_iter().enumerate() {
- // NB: Gecko compares the mString value if type is not image
- // or URI independently of whatever gets there. In the quote
- // cases, they set it to null, so do the same here.
- unsafe {
- *self.gecko.mContents[i].mContent.mString.as_mut() = ptr::null_mut();
- }
- match item {
- ContentItem::String(ref value) => {
- self.gecko.mContents[i].mType = StyleContentType::String;
- unsafe {
- // NB: we share allocators, so doing this is fine.
- *self.gecko.mContents[i].mContent.mString.as_mut() =
- as_utf16_and_forget(&value);
- }
- }
- ContentItem::Attr(ref attr) => {
- self.gecko.mContents[i].mType = StyleContentType::Attr;
- unsafe {
- // NB: we share allocators, so doing this is fine.
- let maybe_ns = attr.namespace.clone();
- let attr_struct = Box::new(nsStyleContentAttr {
- mName: structs::RefPtr {
- mRawPtr: attr.attribute.clone().into_addrefed(),
- _phantom_0: PhantomData,
- },
- mNamespaceURL: structs::RefPtr {
- mRawPtr: maybe_ns.map_or(ptr::null_mut(), |x| (x.1).0.into_addrefed()),
- _phantom_0: PhantomData,
- },
- });
- *self.gecko.mContents[i].mContent.mAttr.as_mut() =
- Box::into_raw(attr_struct);
- }
- }
- ContentItem::OpenQuote
- => self.gecko.mContents[i].mType = StyleContentType::OpenQuote,
- ContentItem::CloseQuote
- => self.gecko.mContents[i].mType = StyleContentType::CloseQuote,
- ContentItem::NoOpenQuote
- => self.gecko.mContents[i].mType = StyleContentType::NoOpenQuote,
- ContentItem::NoCloseQuote
- => self.gecko.mContents[i].mType = StyleContentType::NoCloseQuote,
- ContentItem::Counter(name, style) => {
- set_counter_function(
- &mut self.gecko.mContents[i],
- StyleContentType::Counter,
- name,
- "",
- style,
- );
- }
- ContentItem::Counters(name, sep, style) => {
- set_counter_function(
- &mut self.gecko.mContents[i],
- StyleContentType::Counters,
- name,
- &sep,
- style,
- );
- }
- ContentItem::Url(ref url) => {
- unsafe {
- bindings::Gecko_SetContentDataImageValue(
- &mut self.gecko.mContents[i],
- url,
- )
- }
- }
- }
- }
- }
- }
- }
-
- pub fn copy_content_from(&mut self, other: &Self) {
- use crate::gecko_bindings::bindings::Gecko_CopyStyleContentsFrom;
- unsafe {
- Gecko_CopyStyleContentsFrom(&mut *self.gecko, &*other.gecko)
- }
- }
-
- pub fn reset_content(&mut self, other: &Self) {
- self.copy_content_from(other)
- }
-
- pub fn clone_content(&self) -> longhands::content::computed_value::T {
- use {Atom, Namespace};
- use crate::gecko::conversions::string_from_chars_pointer;
- use crate::gecko_bindings::structs::StyleContentType;
- use crate::values::generics::counters::{Content, ContentItem};
- use crate::values::{CustomIdent, Either};
- use crate::values::generics::CounterStyle;
- use crate::values::specified::Attr;
-
- if self.gecko.mContents.is_empty() {
- return Content::None;
- }
-
- if self.gecko.mContents.len() == 1 &&
- self.gecko.mContents[0].mType == StyleContentType::AltContent {
- return Content::MozAltContent;
- }
-
- Content::Items(
- self.gecko.mContents.iter().map(|gecko_content| {
- match gecko_content.mType {
- StyleContentType::OpenQuote => ContentItem::OpenQuote,
- StyleContentType::CloseQuote => ContentItem::CloseQuote,
- StyleContentType::NoOpenQuote => ContentItem::NoOpenQuote,
- StyleContentType::NoCloseQuote => ContentItem::NoCloseQuote,
- StyleContentType::String => {
- let gecko_chars = unsafe { gecko_content.mContent.mString.as_ref() };
- let string = unsafe { string_from_chars_pointer(*gecko_chars) };
- ContentItem::String(string.into_boxed_str())
- },
- StyleContentType::Attr => {
- let (namespace, attribute) = unsafe {
- let s = &**gecko_content.mContent.mAttr.as_ref();
- let ns = if s.mNamespaceURL.mRawPtr.is_null() {
- None
- } else {
- // FIXME(bholley): We don't have any way to get the prefix here. :-(
- let prefix = atom!("");
- Some((prefix, Namespace(Atom::from_raw(s.mNamespaceURL.mRawPtr))))
- };
- (ns, Atom::from_raw(s.mName.mRawPtr))
- };
- ContentItem::Attr(Attr { namespace, attribute })
- },
- StyleContentType::Counter | StyleContentType::Counters => {
- let gecko_function =
- unsafe { &**gecko_content.mContent.mCounters.as_ref() };
- let ident = CustomIdent(unsafe {
- Atom::from_raw(gecko_function.mIdent.mRawPtr)
- });
- let style =
- CounterStyle::from_gecko_value(&gecko_function.mCounterStyle);
- let style = match style {
- Either::First(counter_style) => counter_style,
- Either::Second(_) =>
- unreachable!("counter function shouldn't have single string type"),
- };
- if gecko_content.mType == StyleContentType::Counter {
- ContentItem::Counter(ident, style)
- } else {
- let separator = gecko_function.mSeparator.to_string();
- ContentItem::Counters(ident, separator.into_boxed_str(), style)
- }
- },
- StyleContentType::Image => {
- unsafe {
- let gecko_image_request =
- &**gecko_content.mContent.mImage.as_ref();
- ContentItem::Url(
- ComputedImageUrl::from_image_request(gecko_image_request)
- )
- }
- },
- _ => panic!("Found unexpected value in style struct for content property"),
- }
- }).collect::<Vec<_>>().into_boxed_slice()
- )
+ !self.gecko.mContent.is_items()
}
</%self:impl_trait>
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index 4d3895440d5..7a25b2569ea 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -563,6 +563,7 @@
Copy,
Debug,
Eq,
+ FromPrimitive,
Hash,
MallocSizeOf,
Parse,
@@ -762,7 +763,7 @@
% endif
pub mod computed_value {
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
- #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
+ #[derive(Clone, Copy, Debug, Eq, FromPrimitive, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
% if not extra_specified:
#[derive(Parse, SpecifiedValueInfo, ToComputedValue, ToShmem)]
% endif
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index c81e186a129..84f843ec728 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -507,7 +507,7 @@ impl AnimationValue {
declaration.id,
custom_properties,
context.quirks_mode,
- context.device().environment(),
+ context.device(),
)
};
return AnimationValue::from_declaration(
diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index fba2fac66dc..90c8dc539d8 100644
--- a/components/style/properties/longhands/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -47,6 +47,7 @@ ${helpers.single_keyword(
values="static absolute relative fixed ${'sticky' if engine in ['gecko', 'servo-2013'] else ''}"
engines="gecko servo-2013 servo-2020"
animation_value_type="discrete"
+ gecko_enum_prefix="StylePositionProperty"
flags="CREATES_STACKING_CONTEXT ABSPOS_CB"
spec="https://drafts.csswg.org/css-position/#position-property"
servo_restyle_damage="rebuild_and_reflow"
@@ -452,6 +453,7 @@ ${helpers.single_keyword(
engines="gecko",
spec="https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior",
animation_value_type="discrete",
+ gecko_enum_prefix="StyleScrollBehavior",
)}
${helpers.predefined_type(
@@ -472,13 +474,15 @@ ${helpers.predefined_type(
animation_value_type="discrete",
)}
-% for axis in ["x", "y"]:
+% for (axis, logical) in ALL_AXES:
${helpers.predefined_type(
"overscroll-behavior-" + axis,
"OverscrollBehavior",
"computed::OverscrollBehavior::Auto",
engines="gecko",
needs_context=False,
+ logical_group="overscroll-behavior",
+ logical=logical,
gecko_pref="layout.css.overscroll-behavior.enabled",
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties",
animation_value_type="discrete",
@@ -589,7 +593,7 @@ ${helpers.single_keyword(
${helpers.predefined_type(
"transform-style",
"TransformStyle",
- "computed::TransformStyle::" + ("Flat" if engine == "gecko" else "Auto"),
+ "computed::TransformStyle::Flat",
engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
spec="https://drafts.csswg.org/css-transforms-2/#transform-style-property",
diff --git a/components/style/properties/longhands/column.mako.rs b/components/style/properties/longhands/column.mako.rs
index 8b49679abf7..1974e82d137 100644
--- a/components/style/properties/longhands/column.mako.rs
+++ b/components/style/properties/longhands/column.mako.rs
@@ -13,7 +13,7 @@ ${helpers.predefined_type(
engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_specified_value="specified::length::NonNegativeLengthOrAuto::auto()",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
animation_value_type="NonNegativeLengthOrAuto",
servo_2013_pref="layout.columns.enabled",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-width",
@@ -29,7 +29,7 @@ ${helpers.predefined_type(
initial_specified_value="specified::ColumnCount::auto()",
servo_2013_pref="layout.columns.enabled",
animation_value_type="AnimatedColumnCount",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-count",
servo_restyle_damage="rebuild_and_reflow",
)}
@@ -38,7 +38,7 @@ ${helpers.single_keyword(
"column-fill",
"balance auto",
engines="gecko",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
animation_value_type="discrete",
gecko_enum_prefix="StyleColumnFill",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill",
@@ -53,7 +53,7 @@ ${helpers.predefined_type(
computed_type="crate::values::computed::NonNegativeLength",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width",
animation_value_type="NonNegativeLength",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
)}
// https://drafts.csswg.org/css-multicol-1/#crc
@@ -64,22 +64,19 @@ ${helpers.predefined_type(
engines="gecko",
initial_specified_value="specified::Color::currentcolor()",
animation_value_type="AnimatedColor",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
ignored_when_colors_disabled=True,
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color",
)}
-// FIXME: Remove enabled_in="ua" once column-span is enabled on nightly (bug 1423383).
${helpers.single_keyword(
"column-span",
"none all",
engines="gecko",
animation_value_type="discrete",
gecko_enum_prefix="StyleColumnSpan",
- gecko_pref="layout.css.column-span.enabled",
- enabled_in="ua",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-span",
- extra_prefixes="moz:layout.css.column-span.enabled",
+ extra_prefixes="moz:layout.css.prefixes.columns",
)}
${helpers.predefined_type(
@@ -89,7 +86,7 @@ ${helpers.predefined_type(
engines="gecko",
needs_context=False,
initial_specified_value="specified::BorderStyle::None",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-style",
)}
diff --git a/components/style/properties/longhands/inherited_box.mako.rs b/components/style/properties/longhands/inherited_box.mako.rs
index 78c2e6023ee..e8f3a0a45d9 100644
--- a/components/style/properties/longhands/inherited_box.mako.rs
+++ b/components/style/properties/longhands/inherited_box.mako.rs
@@ -43,7 +43,7 @@ ${helpers.single_keyword(
servo_2020_pref="layout.2020.unimplemented",
animation_value_type="none",
spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction",
- needs_conversion=True,
+ gecko_enum_prefix="StyleDirection",
servo_restyle_damage="rebuild_and_reflow",
)}
@@ -78,6 +78,7 @@ ${helpers.single_keyword(
extra_servo_2013_values="pixelated",
extra_servo_2020_values="pixelated",
gecko_aliases="-moz-crisp-edges=crisp-edges",
+ gecko_enum_prefix="StyleImageRendering",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-images/#propdef-image-rendering",
)}
diff --git a/components/style/properties/longhands/inherited_svg.mako.rs b/components/style/properties/longhands/inherited_svg.mako.rs
index 1d75df08bd8..1839f90d6e6 100644
--- a/components/style/properties/longhands/inherited_svg.mako.rs
+++ b/components/style/properties/longhands/inherited_svg.mako.rs
@@ -17,6 +17,7 @@ ${helpers.single_keyword(
engines="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/css-inline-3/#propdef-dominant-baseline",
+ gecko_enum_prefix="StyleDominantBaseline",
)}
${helpers.single_keyword(
@@ -118,6 +119,7 @@ ${helpers.single_keyword(
engines="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/painting.html#StrokeLinejoinProperty",
+ gecko_enum_prefix = "StyleStrokeLinejoin",
)}
${helpers.predefined_type(
diff --git a/components/style/properties/longhands/inherited_table.mako.rs b/components/style/properties/longhands/inherited_table.mako.rs
index 06b42e802b6..488fe5d2659 100644
--- a/components/style/properties/longhands/inherited_table.mako.rs
+++ b/components/style/properties/longhands/inherited_table.mako.rs
@@ -20,7 +20,7 @@ ${helpers.single_keyword(
"empty-cells",
"show hide",
engines="gecko servo-2013",
- gecko_constant_prefix="NS_STYLE_TABLE_EMPTY_CELLS",
+ gecko_enum_prefix="StyleEmptyCells",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-tables/#propdef-empty-cells",
servo_restyle_damage="rebuild_and_reflow",
diff --git a/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs
index 9784e2529e9..f01bedb177e 100644
--- a/components/style/properties/longhands/inherited_text.mako.rs
+++ b/components/style/properties/longhands/inherited_text.mako.rs
@@ -382,8 +382,8 @@ ${helpers.single_keyword(
// text underline offset
${helpers.predefined_type(
"text-underline-offset",
- "TextDecorationLength",
- "generics::text::GenericTextDecorationLength::Auto",
+ "LengthPercentageOrAuto",
+ "computed::LengthPercentageOrAuto::auto()",
engines="gecko",
animation_value_type="ComputedValue",
gecko_pref="layout.css.text-underline-offset.enabled",
diff --git a/components/style/properties/longhands/position.mako.rs b/components/style/properties/longhands/position.mako.rs
index d974a0f5915..5e3cbf1324c 100644
--- a/components/style/properties/longhands/position.mako.rs
+++ b/components/style/properties/longhands/position.mako.rs
@@ -398,7 +398,7 @@ ${helpers.predefined_type(
"computed::length::NonNegativeLengthPercentageOrNormal::normal()",
engines="gecko servo-2013",
alias="grid-column-gap" if engine == "gecko" else "",
- extra_prefixes="moz",
+ extra_prefixes="moz:layout.css.prefixes.columns",
servo_2013_pref="layout.columns.enabled",
spec="https://drafts.csswg.org/css-align-3/#propdef-column-gap",
animation_value_type="NonNegativeLengthPercentageOrNormal",
diff --git a/components/style/properties/longhands/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs
index f25cbb8e019..724c38b2d1b 100644
--- a/components/style/properties/longhands/svg.mako.rs
+++ b/components/style/properties/longhands/svg.mako.rs
@@ -69,6 +69,7 @@ ${helpers.single_keyword(
"mask-type",
"luminance alpha",
engines="gecko",
+ gecko_enum_prefix="StyleMaskType",
animation_value_type="discrete",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type",
)}
diff --git a/components/style/properties/longhands/table.mako.rs b/components/style/properties/longhands/table.mako.rs
index 0564942fc0a..104c28b8e04 100644
--- a/components/style/properties/longhands/table.mako.rs
+++ b/components/style/properties/longhands/table.mako.rs
@@ -12,6 +12,7 @@ ${helpers.single_keyword(
engines="gecko servo-2013",
gecko_ffi_name="mLayoutStrategy",
animation_value_type="discrete",
+ gecko_enum_prefix="StyleTableLayout",
spec="https://drafts.csswg.org/css-tables/#propdef-table-layout",
servo_restyle_damage="reflow",
)}
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 30a03f79290..d3e61867518 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -28,6 +28,7 @@ use crate::context::QuirksMode;
#[cfg(feature = "servo")] use crate::computed_values;
use crate::logical_geometry::WritingMode;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
+use crate::computed_value_flags::*;
use crate::media_queries::Device;
use crate::parser::ParserContext;
use crate::properties::longhands::system_font::SystemFont;
@@ -45,7 +46,6 @@ use crate::values::computed::NonNegativeLength;
use crate::values::serialize_atom_name;
use crate::rule_tree::StrongRuleNode;
use crate::Zero;
-use self::computed_value_flags::*;
use crate::str::{CssString, CssStringBorrow, CssStringWriter};
use std::cell::Cell;
@@ -58,8 +58,6 @@ pub use self::cascade::*;
import os.path
%>
-#[path="${repr(os.path.join(os.path.dirname(__file__), 'computed_value_flags.rs'))[1:-1]}"]
-pub mod computed_value_flags;
#[path="${repr(os.path.join(os.path.dirname(__file__), 'declaration_block.rs'))[1:-1]}"]
pub mod declaration_block;
#[path="${repr(os.path.join(os.path.dirname(__file__), 'cascade.rs'))[1:-1]}"]
@@ -1584,7 +1582,7 @@ impl UnparsedValue {
longhand_id: LonghandId,
custom_properties: Option<<&Arc<crate::custom_properties::CustomPropertiesMap>>,
quirks_mode: QuirksMode,
- environment: &::custom_properties::CssEnvironment,
+ device: &Device,
) -> PropertyDeclaration {
let invalid_at_computed_value_time = || {
let keyword = if longhand_id.inherited() {
@@ -1602,7 +1600,7 @@ impl UnparsedValue {
&self.css,
self.first_token_type,
custom_properties,
- environment,
+ device,
) {
Ok(css) => css,
Err(..) => return invalid_at_computed_value_time(),
@@ -1803,8 +1801,11 @@ impl ToCss for PropertyId {
}
/// The counted unknown property list which is used for css use counters.
+///
+/// FIXME: This should be just #[repr(u8)], but can't be because of ABI issues,
+/// see https://bugs.llvm.org/show_bug.cgi?id=44228.
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, PartialEq)]
-#[repr(u8)]
+#[repr(u32)]
pub enum CountedUnknownProperty {
% for prop in data.counted_unknown_properties:
/// ${prop.name}
@@ -2894,9 +2895,18 @@ pub struct ComputedValues {
/// We maintain this distinction in servo to reduce the amount of special
/// casing.
inner: ComputedValuesInner,
+
+ /// The pseudo-element that we're using.
+ pseudo: Option<PseudoElement>,
}
impl ComputedValues {
+ /// Returns the pseudo-element that this style represents.
+ #[cfg(feature = "servo")]
+ pub fn pseudo(&self) -> Option<<&PseudoElement> {
+ self.pseudo.as_ref()
+ }
+
/// Returns whether this style's display value is equal to contents.
pub fn is_display_contents(&self) -> bool {
self.get_box().clone_display().is_contents()
@@ -2999,7 +3009,7 @@ impl ComputedValues {
impl ComputedValues {
/// Create a new refcounted `ComputedValues`
pub fn new(
- _: Option<<&PseudoElement>,
+ pseudo: Option<<&PseudoElement>,
custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
flags: ComputedValueFlags,
@@ -3019,7 +3029,8 @@ impl ComputedValues {
% for style_struct in data.active_style_structs():
${style_struct.ident},
% endfor
- }
+ },
+ pseudo: pseudo.cloned(),
})
}
@@ -3433,6 +3444,9 @@ pub struct StyleBuilder<'a> {
/// `StyleAdjuster` did any work.
modified_reset: bool,
+ /// Whether this is the style for the root element.
+ pub is_root_element: bool,
+
/// The writing mode flags.
///
/// TODO(emilio): Make private.
@@ -3459,6 +3473,7 @@ impl<'a> StyleBuilder<'a> {
pseudo: Option<<&'a PseudoElement>,
rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
+ is_root_element: bool,
) -> Self {
debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some());
#[cfg(feature = "gecko")]
@@ -3480,6 +3495,7 @@ impl<'a> StyleBuilder<'a> {
pseudo,
rules,
modified_reset: false,
+ is_root_element,
custom_properties,
writing_mode: inherited_style.writing_mode,
flags: Cell::new(flags),
@@ -3518,6 +3534,7 @@ impl<'a> StyleBuilder<'a> {
reset_style,
pseudo: None,
modified_reset: false,
+ is_root_element: false,
rules: None,
custom_properties: style_to_derive_from.custom_properties().cloned(),
writing_mode: style_to_derive_from.writing_mode,
@@ -3645,6 +3662,7 @@ impl<'a> StyleBuilder<'a> {
pseudo,
/* rules = */ None,
parent.and_then(|p| p.custom_properties().cloned()),
+ /* is_root_element = */ false,
);
ret.visited_style = visited_style;
ret
@@ -3827,9 +3845,9 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
#[allow(missing_docs)]
mod lazy_static_module {
use crate::logical_geometry::WritingMode;
+ use crate::computed_value_flags::ComputedValueFlags;
use servo_arc::Arc;
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
- use super::computed_value_flags::ComputedValueFlags;
lazy_static! {
/// The initial values for all style structs as defined by the specification.
@@ -3859,7 +3877,8 @@ mod lazy_static_module {
rules: None,
visited_style: None,
flags: ComputedValueFlags::empty(),
- }
+ },
+ pseudo: None,
};
}
}
diff --git a/components/style/properties/shorthands/column.mako.rs b/components/style/properties/shorthands/column.mako.rs
index f9612fd6c0c..d5e385faa4c 100644
--- a/components/style/properties/shorthands/column.mako.rs
+++ b/components/style/properties/shorthands/column.mako.rs
@@ -9,7 +9,8 @@
sub_properties="column-width column-count"
servo_2013_pref="layout.columns.enabled",
derive_serialize="True"
- extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
+ extra_prefixes="moz:layout.css.prefixes.columns"
+ spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
use crate::properties::longhands::{column_count, column_width};
pub fn parse_value<'i, 't>(
@@ -59,7 +60,7 @@
<%helpers:shorthand
name="column-rule"
engines="gecko"
- extra_prefixes="moz"
+ extra_prefixes="moz:layout.css.prefixes.columns"
sub_properties="column-rule-width column-rule-style column-rule-color"
derive_serialize="True"
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule"