mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
style: Fix Gecko and Servo builds, and appease tidy.
This commit is contained in:
parent
f9ce3a9da2
commit
ff41f82720
16 changed files with 155 additions and 78 deletions
|
@ -294,7 +294,9 @@ mod bindings {
|
||||||
fn generate_structs() {
|
fn generate_structs() {
|
||||||
let builder = Builder::get_initial_builder()
|
let builder = Builder::get_initial_builder()
|
||||||
.enable_cxx_namespaces()
|
.enable_cxx_namespaces()
|
||||||
.with_codegen_config(CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS);
|
.with_codegen_config(
|
||||||
|
CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS,
|
||||||
|
);
|
||||||
let mut fixups = vec![];
|
let mut fixups = vec![];
|
||||||
let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap())
|
let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap())
|
||||||
.handle_common(&mut fixups)
|
.handle_common(&mut fixups)
|
||||||
|
|
|
@ -9,25 +9,25 @@
|
||||||
#![allow(non_snake_case, missing_docs)]
|
#![allow(non_snake_case, missing_docs)]
|
||||||
|
|
||||||
use crate::gecko::url::CssUrlData;
|
use crate::gecko::url::CssUrlData;
|
||||||
|
use crate::gecko_bindings::structs::RawServoAnimationValue;
|
||||||
use crate::gecko_bindings::structs::RawServoCounterStyleRule;
|
use crate::gecko_bindings::structs::RawServoCounterStyleRule;
|
||||||
|
use crate::gecko_bindings::structs::RawServoCssUrlData;
|
||||||
|
use crate::gecko_bindings::structs::RawServoDeclarationBlock;
|
||||||
|
use crate::gecko_bindings::structs::RawServoFontFaceRule;
|
||||||
use crate::gecko_bindings::structs::RawServoFontFeatureValuesRule;
|
use crate::gecko_bindings::structs::RawServoFontFeatureValuesRule;
|
||||||
use crate::gecko_bindings::structs::RawServoImportRule;
|
use crate::gecko_bindings::structs::RawServoImportRule;
|
||||||
use crate::gecko_bindings::structs::RawServoKeyframe;
|
use crate::gecko_bindings::structs::RawServoKeyframe;
|
||||||
use crate::gecko_bindings::structs::RawServoKeyframesRule;
|
use crate::gecko_bindings::structs::RawServoKeyframesRule;
|
||||||
|
use crate::gecko_bindings::structs::RawServoMediaList;
|
||||||
use crate::gecko_bindings::structs::RawServoMediaRule;
|
use crate::gecko_bindings::structs::RawServoMediaRule;
|
||||||
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
|
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
|
||||||
use crate::gecko_bindings::structs::RawServoNamespaceRule;
|
use crate::gecko_bindings::structs::RawServoNamespaceRule;
|
||||||
use crate::gecko_bindings::structs::RawServoPageRule;
|
use crate::gecko_bindings::structs::RawServoPageRule;
|
||||||
use crate::gecko_bindings::structs::RawServoSupportsRule;
|
|
||||||
use crate::gecko_bindings::structs::ServoCssRules;
|
|
||||||
use crate::gecko_bindings::structs::RawServoAnimationValue;
|
|
||||||
use crate::gecko_bindings::structs::RawServoCssUrlData;
|
|
||||||
use crate::gecko_bindings::structs::RawServoDeclarationBlock;
|
|
||||||
use crate::gecko_bindings::structs::RawServoFontFaceRule;
|
|
||||||
use crate::gecko_bindings::structs::RawServoMediaList;
|
|
||||||
use crate::gecko_bindings::structs::RawServoQuotes;
|
use crate::gecko_bindings::structs::RawServoQuotes;
|
||||||
use crate::gecko_bindings::structs::RawServoStyleRule;
|
use crate::gecko_bindings::structs::RawServoStyleRule;
|
||||||
use crate::gecko_bindings::structs::RawServoStyleSheetContents;
|
use crate::gecko_bindings::structs::RawServoStyleSheetContents;
|
||||||
|
use crate::gecko_bindings::structs::RawServoSupportsRule;
|
||||||
|
use crate::gecko_bindings::structs::ServoCssRules;
|
||||||
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
|
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
|
||||||
use crate::media_queries::MediaList;
|
use crate::media_queries::MediaList;
|
||||||
use crate::properties::animated_properties::AnimationValue;
|
use crate::properties::animated_properties::AnimationValue;
|
||||||
|
|
|
@ -1011,10 +1011,9 @@ impl<'a> From<&'a Matrix4x4Components> for Matrix3D {
|
||||||
impl From<Matrix3D> for Matrix4x4Components {
|
impl From<Matrix3D> for Matrix4x4Components {
|
||||||
fn from(matrix: Matrix3D) -> Self {
|
fn from(matrix: Matrix3D) -> Self {
|
||||||
[
|
[
|
||||||
matrix.m11, matrix.m12, matrix.m13, matrix.m14, matrix.m21,
|
matrix.m11, matrix.m12, matrix.m13, matrix.m14, matrix.m21, matrix.m22, matrix.m23,
|
||||||
matrix.m22, matrix.m23, matrix.m24, matrix.m31, matrix.m32,
|
matrix.m24, matrix.m31, matrix.m32, matrix.m33, matrix.m34, matrix.m41, matrix.m42,
|
||||||
matrix.m33, matrix.m34, matrix.m41, matrix.m42, matrix.m43,
|
matrix.m43, matrix.m44,
|
||||||
matrix.m44,
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,10 @@ impl ::selectors::parser::PseudoElement for PseudoElement {
|
||||||
fn valid_after_slotted(&self) -> bool {
|
fn valid_after_slotted(&self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
*self,
|
*self,
|
||||||
PseudoElement::Before | PseudoElement::After | PseudoElement::Marker | PseudoElement::Placeholder
|
PseudoElement::Before |
|
||||||
|
PseudoElement::After |
|
||||||
|
PseudoElement::Marker |
|
||||||
|
PseudoElement::Placeholder
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +112,12 @@ impl PseudoElement {
|
||||||
*self == PseudoElement::After
|
*self == PseudoElement::After
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether this pseudo-element is the ::marker pseudo.
|
||||||
|
#[inline]
|
||||||
|
pub fn is_marker(&self) -> bool {
|
||||||
|
*self == PseudoElement::Marker
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether this pseudo-element is ::first-letter.
|
/// Whether this pseudo-element is ::first-letter.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_first_letter(&self) -> bool {
|
pub fn is_first_letter(&self) -> bool {
|
||||||
|
|
|
@ -53,7 +53,9 @@ use crate::gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
|
||||||
use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
|
use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
|
||||||
use crate::gecko_bindings::structs::NODE_NEEDS_FRAME;
|
use crate::gecko_bindings::structs::NODE_NEEDS_FRAME;
|
||||||
use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
|
use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
|
||||||
use crate::gecko_bindings::structs::{Element as RawGeckoElement, nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding};
|
use crate::gecko_bindings::structs::{
|
||||||
|
nsINode as RawGeckoNode, nsXBLBinding as RawGeckoXBLBinding, Element as RawGeckoElement,
|
||||||
|
};
|
||||||
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
|
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
|
||||||
use crate::global_style_data::GLOBAL_STYLE_DATA;
|
use crate::global_style_data::GLOBAL_STYLE_DATA;
|
||||||
use crate::hash::FxHashMap;
|
use crate::hash::FxHashMap;
|
||||||
|
@ -321,7 +323,11 @@ impl<'ln> GeckoNode<'ln> {
|
||||||
// `flattened_tree_parent`.
|
// `flattened_tree_parent`.
|
||||||
if self.flattened_tree_parent_is_parent() {
|
if self.flattened_tree_parent_is_parent() {
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).as_ref().map(GeckoNode) },
|
unsafe {
|
||||||
|
bindings::Gecko_GetFlattenedTreeParentNode(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoNode)
|
||||||
|
},
|
||||||
self.parent_node(),
|
self.parent_node(),
|
||||||
"Fast path stopped holding!"
|
"Fast path stopped holding!"
|
||||||
);
|
);
|
||||||
|
@ -331,7 +337,11 @@ impl<'ln> GeckoNode<'ln> {
|
||||||
|
|
||||||
// NOTE(emilio): If this call is too expensive, we could manually
|
// NOTE(emilio): If this call is too expensive, we could manually
|
||||||
// inline more aggressively.
|
// inline more aggressively.
|
||||||
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).as_ref().map(GeckoNode) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetFlattenedTreeParentNode(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoNode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -381,7 +391,11 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prev_sibling(&self) -> Option<Self> {
|
fn prev_sibling(&self) -> Option<Self> {
|
||||||
unsafe { bindings::Gecko_GetPreviousSibling(self.0).as_ref().map(GeckoNode) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetPreviousSibling(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoNode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -498,7 +512,9 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> {
|
||||||
// however we can't express this easily with bindgen, and it would
|
// however we can't express this easily with bindgen, and it would
|
||||||
// introduce functions with two input lifetimes into bindgen,
|
// introduce functions with two input lifetimes into bindgen,
|
||||||
// which would be out of scope for elision.
|
// which would be out of scope for elision.
|
||||||
bindings::Gecko_GetNextStyleChild(&mut *(it as *mut _)).as_ref().map(GeckoNode)
|
bindings::Gecko_GetNextStyleChild(&mut *(it as *mut _))
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoNode)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,7 +721,11 @@ impl<'le> GeckoElement<'le> {
|
||||||
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
|
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
|
||||||
// where the binding parent is stored in a member variable
|
// where the binding parent is stored in a member variable
|
||||||
// rather than in slots. So just get it through FFI for now.
|
// rather than in slots. So just get it through FFI for now.
|
||||||
unsafe { bindings::Gecko_GetBindingParent(self.0).as_ref().map(GeckoElement) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetBindingParent(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoElement)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let binding_parent = unsafe { self.non_xul_xbl_binding_parent_raw_content().as_ref() }
|
let binding_parent = unsafe { self.non_xul_xbl_binding_parent_raw_content().as_ref() }
|
||||||
.map(GeckoNode::from_content)
|
.map(GeckoNode::from_content)
|
||||||
|
@ -713,7 +733,11 @@ impl<'le> GeckoElement<'le> {
|
||||||
|
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
binding_parent ==
|
binding_parent ==
|
||||||
unsafe { bindings::Gecko_GetBindingParent(self.0).as_ref().map(GeckoElement) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetBindingParent(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoElement)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
binding_parent
|
binding_parent
|
||||||
}
|
}
|
||||||
|
@ -773,7 +797,11 @@ impl<'le> GeckoElement<'le> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { bindings::Gecko_GetBeforeOrAfterPseudo(self.0, is_before).as_ref().map(GeckoElement) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetBeforeOrAfterPseudo(self.0, is_before)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoElement)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -795,11 +823,7 @@ impl<'le> GeckoElement<'le> {
|
||||||
/// animation.
|
/// animation.
|
||||||
///
|
///
|
||||||
/// Also this function schedules style flush.
|
/// Also this function schedules style flush.
|
||||||
pub unsafe fn note_explicit_hints(
|
pub unsafe fn note_explicit_hints(&self, restyle_hint: RestyleHint, change_hint: nsChangeHint) {
|
||||||
&self,
|
|
||||||
restyle_hint: RestyleHint,
|
|
||||||
change_hint: nsChangeHint,
|
|
||||||
) {
|
|
||||||
use crate::gecko::restyle_damage::GeckoRestyleDamage;
|
use crate::gecko::restyle_damage::GeckoRestyleDamage;
|
||||||
|
|
||||||
let damage = GeckoRestyleDamage::new(change_hint);
|
let damage = GeckoRestyleDamage::new(change_hint);
|
||||||
|
@ -1042,13 +1066,10 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
|
||||||
let style = context.style();
|
let style = context.style();
|
||||||
|
|
||||||
let (wm, font) = match base_size {
|
let (wm, font) = match base_size {
|
||||||
FontBaseSize::CurrentStyle => {
|
FontBaseSize::CurrentStyle => (style.writing_mode, style.get_font()),
|
||||||
(style.writing_mode, style.get_font())
|
|
||||||
},
|
|
||||||
// These are only used for font-size computation, and the first is
|
// These are only used for font-size computation, and the first is
|
||||||
// really dubious...
|
// really dubious...
|
||||||
FontBaseSize::InheritedStyleButStripEmUnits |
|
FontBaseSize::InheritedStyleButStripEmUnits | FontBaseSize::InheritedStyle => {
|
||||||
FontBaseSize::InheritedStyle => {
|
|
||||||
(*style.inherited_writing_mode(), style.get_parent_font())
|
(*style.inherited_writing_mode(), style.get_parent_font())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1142,7 +1163,11 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { bindings::Gecko_GetMarkerPseudo(self.0).as_ref().map(GeckoElement) }
|
unsafe {
|
||||||
|
bindings::Gecko_GetMarkerPseudo(self.0)
|
||||||
|
.as_ref()
|
||||||
|
.map(GeckoElement)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1555,10 +1580,12 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
// should destroy all CSS animations in display:none subtree.
|
// should destroy all CSS animations in display:none subtree.
|
||||||
let computed_data = self.borrow_data();
|
let computed_data = self.borrow_data();
|
||||||
let computed_values = computed_data.as_ref().map(|d| d.styles.primary());
|
let computed_values = computed_data.as_ref().map(|d| d.styles.primary());
|
||||||
let before_change_values =
|
let before_change_values = before_change_style
|
||||||
before_change_style.as_ref().map_or(ptr::null(), |x| x.as_gecko_computed_style());
|
.as_ref()
|
||||||
let computed_values_opt =
|
.map_or(ptr::null(), |x| x.as_gecko_computed_style());
|
||||||
computed_values.as_ref().map_or(ptr::null(), |x| x.as_gecko_computed_style());
|
let computed_values_opt = computed_values
|
||||||
|
.as_ref()
|
||||||
|
.map_or(ptr::null(), |x| x.as_gecko_computed_style());
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_UpdateAnimations(
|
Gecko_UpdateAnimations(
|
||||||
self.0,
|
self.0,
|
||||||
|
@ -1834,7 +1861,8 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
hints.push(SVG_TEXT_DISABLE_ZOOM_RULE.clone());
|
hints.push(SVG_TEXT_DISABLE_ZOOM_RULE.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0).as_ref() };
|
let declarations =
|
||||||
|
unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0).as_ref() };
|
||||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||||
declarations.and_then(|s| s.as_arc_opt());
|
declarations.and_then(|s| s.as_arc_opt());
|
||||||
if let Some(decl) = declarations {
|
if let Some(decl) = declarations {
|
||||||
|
@ -1884,7 +1912,8 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
.state()
|
.state()
|
||||||
.intersects(NonTSPseudoClass::Active.state_flag());
|
.intersects(NonTSPseudoClass::Active.state_flag());
|
||||||
if active {
|
if active {
|
||||||
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0).as_ref() };
|
let declarations =
|
||||||
|
unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0).as_ref() };
|
||||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||||
declarations.and_then(|s| s.as_arc_opt());
|
declarations.and_then(|s| s.as_arc_opt());
|
||||||
if let Some(decl) = declarations {
|
if let Some(decl) = declarations {
|
||||||
|
|
|
@ -11,7 +11,6 @@ use crate::parallel::STYLE_THREAD_STACK_SIZE_KB;
|
||||||
use crate::shared_lock::SharedRwLock;
|
use crate::shared_lock::SharedRwLock;
|
||||||
use crate::thread_state;
|
use crate::thread_state;
|
||||||
use rayon;
|
use rayon;
|
||||||
use servo_config::pref;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
/// Global style data
|
/// Global style data
|
||||||
|
@ -67,6 +66,7 @@ lazy_static! {
|
||||||
Ok(num) => num,
|
Ok(num) => num,
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
_ => {
|
_ => {
|
||||||
|
use servo_config::pref;
|
||||||
// We always set this pref on startup, before layout or script
|
// We always set this pref on startup, before layout or script
|
||||||
// have had a chance of accessing (and thus creating) the
|
// have had a chance of accessing (and thus creating) the
|
||||||
// thread-pool.
|
// thread-pool.
|
||||||
|
|
|
@ -41,4 +41,5 @@ ${helpers.predefined_type(
|
||||||
animation_value_type="discrete",
|
animation_value_type="discrete",
|
||||||
spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-set",
|
spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-set",
|
||||||
servo_restyle_damage="rebuild_and_reflow",
|
servo_restyle_damage="rebuild_and_reflow",
|
||||||
|
products="gecko",
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2759,7 +2759,7 @@ pub struct ComputedValuesInner {
|
||||||
pub writing_mode: WritingMode,
|
pub writing_mode: WritingMode,
|
||||||
|
|
||||||
/// A set of flags we use to store misc information regarding this style.
|
/// A set of flags we use to store misc information regarding this style.
|
||||||
flags: ComputedValueFlags,
|
pub flags: ComputedValueFlags,
|
||||||
|
|
||||||
/// The rule node representing the ordered list of rules matched for this
|
/// The rule node representing the ordered list of rules matched for this
|
||||||
/// node. Can be None for default values and text nodes. This is
|
/// node. Can be None for default values and text nodes. This is
|
||||||
|
@ -3719,8 +3719,8 @@ mod lazy_static_module {
|
||||||
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
|
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
|
||||||
use super::computed_value_flags::ComputedValueFlags;
|
use super::computed_value_flags::ComputedValueFlags;
|
||||||
|
|
||||||
/// The initial values for all style structs as defined by the specification.
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
/// The initial values for all style structs as defined by the specification.
|
||||||
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
|
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
|
||||||
inner: ComputedValuesInner {
|
inner: ComputedValuesInner {
|
||||||
% for style_struct in data.active_style_structs():
|
% for style_struct in data.active_style_structs():
|
||||||
|
@ -3744,7 +3744,7 @@ mod lazy_static_module {
|
||||||
writing_mode: WritingMode::empty(),
|
writing_mode: WritingMode::empty(),
|
||||||
rules: None,
|
rules: None,
|
||||||
visited_style: None,
|
visited_style: None,
|
||||||
flags: Cell::new(ComputedValueFlags::empty()),
|
flags: ComputedValueFlags::empty(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,12 @@ impl PseudoElement {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether this pseudo-element is the ::marker pseudo.
|
||||||
|
#[inline]
|
||||||
|
pub fn is_marker(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether this pseudo-element is the ::before pseudo.
|
/// Whether this pseudo-element is the ::before pseudo.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_before(&self) -> bool {
|
pub fn is_before(&self) -> bool {
|
||||||
|
|
|
@ -180,7 +180,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
where
|
where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
{
|
{
|
||||||
use crate::selector_parser::PseudoElement;
|
|
||||||
use crate::computed_values::list_style_position::T as ListStylePosition;
|
use crate::computed_values::list_style_position::T as ListStylePosition;
|
||||||
|
|
||||||
let mut blockify = false;
|
let mut blockify = false;
|
||||||
|
@ -205,8 +204,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
|
|
||||||
blockify_if!(self.style.floated());
|
blockify_if!(self.style.floated());
|
||||||
blockify_if!(self.style.out_of_flow_positioned());
|
blockify_if!(self.style.out_of_flow_positioned());
|
||||||
blockify_if!(self.style.pseudo == Some(&PseudoElement::Marker) &&
|
blockify_if!(
|
||||||
self.style.get_parent_list().clone_list_style_position() == ListStylePosition::Outside);
|
self.style.pseudo.map_or(false, |p| p.is_marker()) &&
|
||||||
|
self.style.get_parent_list().clone_list_style_position() ==
|
||||||
|
ListStylePosition::Outside
|
||||||
|
);
|
||||||
|
|
||||||
if !blockify {
|
if !blockify {
|
||||||
return;
|
return;
|
||||||
|
@ -232,11 +234,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
.clone_text_decoration_line()
|
.clone_text_decoration_line()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
self.style.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
|
self.style
|
||||||
|
.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.style.is_pseudo_element() {
|
if self.style.is_pseudo_element() {
|
||||||
self.style.add_flags(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE);
|
self.style
|
||||||
|
.add_flags(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
@ -302,7 +306,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
.get_parent_flags()
|
.get_parent_flags()
|
||||||
.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK)
|
.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK)
|
||||||
{
|
{
|
||||||
self.style.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
self.style
|
||||||
|
.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +593,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
let self_display = self.style.get_box().clone_display();
|
let self_display = self.style.get_box().clone_display();
|
||||||
// Check whether line break should be suppressed for this element.
|
// Check whether line break should be suppressed for this element.
|
||||||
if self.should_suppress_linebreak(layout_parent_style) {
|
if self.should_suppress_linebreak(layout_parent_style) {
|
||||||
self.style.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
self.style
|
||||||
|
.add_flags(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
|
||||||
// Inlinify the display type if allowed.
|
// Inlinify the display type if allowed.
|
||||||
if !self.skip_item_display_fixup(element) {
|
if !self.skip_item_display_fixup(element) {
|
||||||
let inline_display = self_display.inlinify();
|
let inline_display = self_display.inlinify();
|
||||||
|
@ -646,10 +652,12 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if element.unwrap().is_visited_link() {
|
if element.unwrap().is_visited_link() {
|
||||||
self.style.add_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
|
self.style
|
||||||
|
.add_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
|
||||||
} else {
|
} else {
|
||||||
// Need to remove to handle unvisited link inside visited.
|
// Need to remove to handle unvisited link inside visited.
|
||||||
self.style.remove_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
|
self.style
|
||||||
|
.remove_flags(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,9 +733,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
E: TElement,
|
E: TElement,
|
||||||
{
|
{
|
||||||
use crate::properties::longhands::counter_increment::computed_value::T as ComputedIncrement;
|
use crate::properties::longhands::counter_increment::computed_value::T as ComputedIncrement;
|
||||||
use crate::values::CustomIdent;
|
use crate::values::generics::counters::CounterPair;
|
||||||
use crate::values::generics::counters::{CounterPair};
|
|
||||||
use crate::values::specified::list::MozListReversed;
|
use crate::values::specified::list::MozListReversed;
|
||||||
|
use crate::values::CustomIdent;
|
||||||
|
|
||||||
if self.style.get_box().clone_display() != Display::ListItem {
|
if self.style.get_box().clone_display() != Display::ListItem {
|
||||||
return;
|
return;
|
||||||
|
@ -752,8 +760,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
name: CustomIdent(atom!("list-item")),
|
name: CustomIdent(atom!("list-item")),
|
||||||
value: increment,
|
value: increment,
|
||||||
};
|
};
|
||||||
let increments = increments.iter().cloned().chain(std::iter::once(list_increment));
|
let increments = increments
|
||||||
self.style.mutate_counters().set_counter_increment(ComputedIncrement::new(increments.collect()));
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.chain(std::iter::once(list_increment));
|
||||||
|
self.style
|
||||||
|
.mutate_counters()
|
||||||
|
.set_counter_increment(ComputedIncrement::new(increments.collect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adjusts the style to account for various fixups that don't fit naturally
|
/// Adjusts the style to account for various fixups that don't fit naturally
|
||||||
|
|
|
@ -27,7 +27,6 @@ use cssparser::CowRcStr;
|
||||||
use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
|
use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
|
||||||
use euclid::TypedSize2D;
|
use euclid::TypedSize2D;
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
use servo_config::pref;
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
@ -39,6 +38,7 @@ use style_traits::{CssWriter, ParseError, PinchZoomFactor, StyleParseErrorKind,
|
||||||
/// Whether parsing and processing of `@viewport` rules is enabled.
|
/// Whether parsing and processing of `@viewport` rules is enabled.
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub fn enabled() -> bool {
|
pub fn enabled() -> bool {
|
||||||
|
use servo_config::pref;
|
||||||
pref!(layout.viewport.enabled)
|
pref!(layout.viewport.enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,9 +190,7 @@ impl FontFamily {
|
||||||
/// Get default font family as `serif` which is a generic font-family
|
/// Get default font family as `serif` which is a generic font-family
|
||||||
pub fn serif() -> Self {
|
pub fn serif() -> Self {
|
||||||
FontFamily {
|
FontFamily {
|
||||||
families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(
|
families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(atom!("serif"))])),
|
||||||
atom!("serif"),
|
|
||||||
)])),
|
|
||||||
is_system_font: false,
|
is_system_font: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +202,9 @@ impl MallocSizeOf for FontFamily {
|
||||||
// SharedFontList objects are generally shared from the pointer
|
// SharedFontList objects are generally shared from the pointer
|
||||||
// stored in the specified value. So only count this if the
|
// stored in the specified value. So only count this if the
|
||||||
// SharedFontList is unshared.
|
// SharedFontList is unshared.
|
||||||
unsafe { bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(self.families.0.get()) }
|
unsafe {
|
||||||
|
bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(self.families.0.get())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
|
|
||||||
pub use crate::values::specified::TextAlignKeyword as TextAlign;
|
pub use crate::values::specified::TextAlignKeyword as TextAlign;
|
||||||
pub use crate::values::specified::{TextEmphasisPosition, TextDecorationLine};
|
|
||||||
pub use crate::values::specified::{OverflowWrap, WordBreak};
|
pub use crate::values::specified::{OverflowWrap, WordBreak};
|
||||||
|
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
||||||
|
|
||||||
/// A computed value for the `initial-letter` property.
|
/// A computed value for the `initial-letter` property.
|
||||||
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
|
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
|
||||||
|
|
|
@ -135,7 +135,9 @@ impl FontRelativeLength {
|
||||||
base_size: FontBaseSize,
|
base_size: FontBaseSize,
|
||||||
orientation: FontMetricsOrientation,
|
orientation: FontMetricsOrientation,
|
||||||
) -> FontMetrics {
|
) -> FontMetrics {
|
||||||
context.font_metrics_provider.query(context, base_size, orientation)
|
context
|
||||||
|
.font_metrics_provider
|
||||||
|
.query(context, base_size, orientation)
|
||||||
}
|
}
|
||||||
|
|
||||||
let reference_font_size = base_size.resolve(context);
|
let reference_font_size = base_size.resolve(context);
|
||||||
|
@ -160,13 +162,12 @@ impl FontRelativeLength {
|
||||||
if context.for_non_inherited_property.is_some() {
|
if context.for_non_inherited_property.is_some() {
|
||||||
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
||||||
}
|
}
|
||||||
context.builder.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
|
context
|
||||||
|
.builder
|
||||||
|
.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
|
||||||
// The x-height is an intrinsically horizontal metric.
|
// The x-height is an intrinsically horizontal metric.
|
||||||
let metrics = query_font_metrics(
|
let metrics =
|
||||||
context,
|
query_font_metrics(context, base_size, FontMetricsOrientation::Horizontal);
|
||||||
base_size,
|
|
||||||
FontMetricsOrientation::Horizontal
|
|
||||||
);
|
|
||||||
let reference_size = metrics.x_height.unwrap_or_else(|| {
|
let reference_size = metrics.x_height.unwrap_or_else(|| {
|
||||||
// https://drafts.csswg.org/css-values/#ex
|
// https://drafts.csswg.org/css-values/#ex
|
||||||
//
|
//
|
||||||
|
@ -182,7 +183,9 @@ impl FontRelativeLength {
|
||||||
if context.for_non_inherited_property.is_some() {
|
if context.for_non_inherited_property.is_some() {
|
||||||
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
||||||
}
|
}
|
||||||
context.builder.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
|
context
|
||||||
|
.builder
|
||||||
|
.add_flags(ComputedValueFlags::DEPENDS_ON_FONT_METRICS);
|
||||||
// https://drafts.csswg.org/css-values/#ch:
|
// https://drafts.csswg.org/css-values/#ch:
|
||||||
//
|
//
|
||||||
// Equal to the used advance measure of the “0” (ZERO,
|
// Equal to the used advance measure of the “0” (ZERO,
|
||||||
|
@ -190,11 +193,8 @@ impl FontRelativeLength {
|
||||||
// measure of a glyph is its advance width or height,
|
// measure of a glyph is its advance width or height,
|
||||||
// whichever is in the inline axis of the element.)
|
// whichever is in the inline axis of the element.)
|
||||||
//
|
//
|
||||||
let metrics = query_font_metrics(
|
let metrics =
|
||||||
context,
|
query_font_metrics(context, base_size, FontMetricsOrientation::MatchContext);
|
||||||
base_size,
|
|
||||||
FontMetricsOrientation::MatchContext,
|
|
||||||
);
|
|
||||||
let reference_size = metrics.zero_advance_measure.unwrap_or_else(|| {
|
let reference_size = metrics.zero_advance_measure.unwrap_or_else(|| {
|
||||||
// https://drafts.csswg.org/css-values/#ch
|
// https://drafts.csswg.org/css-values/#ch
|
||||||
//
|
//
|
||||||
|
|
|
@ -125,7 +125,19 @@ impl Parse for Quotes {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specified and computed `-moz-list-reversed` property (for UA sheets only).
|
/// Specified and computed `-moz-list-reversed` property (for UA sheets only).
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
Hash,
|
||||||
|
MallocSizeOf,
|
||||||
|
Parse,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum MozListReversed {
|
pub enum MozListReversed {
|
||||||
/// the initial value
|
/// the initial value
|
||||||
|
|
|
@ -282,7 +282,6 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Parse for TextDecorationLine {
|
impl Parse for TextDecorationLine {
|
||||||
/// none | [ underline || overline || line-through || blink ]
|
/// none | [ underline || overline || line-through || blink ]
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
|
@ -318,7 +317,7 @@ impl Parse for TextDecorationLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.contains(flag) {
|
if result.contains(flag) {
|
||||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.insert(flag)
|
result.insert(flag)
|
||||||
|
@ -341,6 +340,13 @@ impl ToCss for TextDecorationLine {
|
||||||
return dest.write_str("none");
|
return dest.write_str("none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
{
|
||||||
|
if *self == TextDecorationLine::COLOR_OVERRIDE {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut writer = SequenceWriter::new(dest, " ");
|
let mut writer = SequenceWriter::new(dest, " ");
|
||||||
let mut any = false;
|
let mut any = false;
|
||||||
|
|
||||||
|
@ -358,7 +364,7 @@ impl ToCss for TextDecorationLine {
|
||||||
maybe_write!(LINE_THROUGH => "line-through");
|
maybe_write!(LINE_THROUGH => "line-through");
|
||||||
maybe_write!(BLINK => "blink");
|
maybe_write!(BLINK => "blink");
|
||||||
|
|
||||||
debug_assert!(any || *self == TextDecorationLine::COLOR_OVERRIDE);
|
debug_assert!(any);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue