mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Add some new Servo-specific pseudo-classes for anonymous flows.
This allows us to remove `modify_style_for_anonymous_table_object`.
This commit is contained in:
parent
92b7189f31
commit
93e41ba4aa
2 changed files with 89 additions and 1 deletions
|
@ -271,6 +271,33 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the style for an anonymous box of the given type.
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
pub fn style_for_anonymous_box(&self,
|
||||||
|
pseudo: &PseudoElement,
|
||||||
|
parent_style: &Arc<ComputedValues>)
|
||||||
|
-> Arc<ComputedValues> {
|
||||||
|
// For most (but not all) pseudo-elements, we inherit all values from the parent.
|
||||||
|
let inherit_all = match *pseudo {
|
||||||
|
PseudoElement::ServoInputText => false,
|
||||||
|
PseudoElement::ServoAnonymousBlock |
|
||||||
|
PseudoElement::ServoAnonymousTable |
|
||||||
|
PseudoElement::ServoAnonymousTableCell |
|
||||||
|
PseudoElement::ServoAnonymousTableRow |
|
||||||
|
PseudoElement::ServoAnonymousTableWrapper |
|
||||||
|
PseudoElement::ServoTableWrapper => true,
|
||||||
|
PseudoElement::Before |
|
||||||
|
PseudoElement::After |
|
||||||
|
PseudoElement::Selection |
|
||||||
|
PseudoElement::DetailsSummary |
|
||||||
|
PseudoElement::DetailsContent => {
|
||||||
|
unreachable!("That pseudo doesn't represent an anonymous box!")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), inherit_all)
|
||||||
|
.expect("style_for_anonymous_box(): No precomputed values for that pseudo!")
|
||||||
|
}
|
||||||
|
|
||||||
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
||||||
element: &E,
|
element: &E,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
|
|
|
@ -13,6 +13,7 @@ use selectors::parser::{AttrSelector, ParserContext, SelectorImpl};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use string_cache::{Atom, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
|
|
||||||
|
/// NB: If you add to this list, be sure to update `each_pseudo_element` too.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub enum PseudoElement {
|
pub enum PseudoElement {
|
||||||
|
@ -22,6 +23,12 @@ pub enum PseudoElement {
|
||||||
DetailsSummary,
|
DetailsSummary,
|
||||||
DetailsContent,
|
DetailsContent,
|
||||||
ServoInputText,
|
ServoInputText,
|
||||||
|
ServoTableWrapper,
|
||||||
|
ServoAnonymousTableWrapper,
|
||||||
|
ServoAnonymousTable,
|
||||||
|
ServoAnonymousTableRow,
|
||||||
|
ServoAnonymousTableCell,
|
||||||
|
ServoAnonymousBlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for PseudoElement {
|
impl ToCss for PseudoElement {
|
||||||
|
@ -34,6 +41,12 @@ impl ToCss for PseudoElement {
|
||||||
DetailsSummary => "::-servo-details-summary",
|
DetailsSummary => "::-servo-details-summary",
|
||||||
DetailsContent => "::-servo-details-content",
|
DetailsContent => "::-servo-details-content",
|
||||||
ServoInputText => "::-servo-input-text",
|
ServoInputText => "::-servo-input-text",
|
||||||
|
ServoTableWrapper => "::-servo-table-wrapper",
|
||||||
|
ServoAnonymousTableWrapper => "::-servo-anonymous-table-wrapper",
|
||||||
|
ServoAnonymousTable => "::-servo-anonymous-table",
|
||||||
|
ServoAnonymousTableRow => "::-servo-anonymous-table-row",
|
||||||
|
ServoAnonymousTableCell => "::-servo-anonymous-table-cell",
|
||||||
|
ServoAnonymousBlock => "::-servo-anonymous-block",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +70,13 @@ impl PseudoElement {
|
||||||
PseudoElement::Selection => PseudoElementCascadeType::Eager,
|
PseudoElement::Selection => PseudoElementCascadeType::Eager,
|
||||||
PseudoElement::DetailsSummary => PseudoElementCascadeType::Lazy,
|
PseudoElement::DetailsSummary => PseudoElementCascadeType::Lazy,
|
||||||
PseudoElement::DetailsContent |
|
PseudoElement::DetailsContent |
|
||||||
PseudoElement::ServoInputText => PseudoElementCascadeType::Precomputed,
|
PseudoElement::ServoInputText |
|
||||||
|
PseudoElement::ServoTableWrapper |
|
||||||
|
PseudoElement::ServoAnonymousTableWrapper |
|
||||||
|
PseudoElement::ServoAnonymousTable |
|
||||||
|
PseudoElement::ServoAnonymousTableRow |
|
||||||
|
PseudoElement::ServoAnonymousTableCell |
|
||||||
|
PseudoElement::ServoAnonymousBlock => PseudoElementCascadeType::Precomputed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +229,42 @@ impl SelectorImpl for ServoSelectorImpl {
|
||||||
}
|
}
|
||||||
ServoInputText
|
ServoInputText
|
||||||
},
|
},
|
||||||
|
"-servo-table-wrapper" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoTableWrapper
|
||||||
|
},
|
||||||
|
"-servo-anonymous-table-wrapper" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoAnonymousTableWrapper
|
||||||
|
},
|
||||||
|
"-servo-anonymous-table" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoAnonymousTable
|
||||||
|
},
|
||||||
|
"-servo-anonymous-table-row" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoAnonymousTableRow
|
||||||
|
},
|
||||||
|
"-servo-anonymous-table-cell" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoAnonymousTableCell
|
||||||
|
},
|
||||||
|
"-servo-anonymous-block" => {
|
||||||
|
if !context.in_user_agent_stylesheet {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
ServoAnonymousBlock
|
||||||
|
},
|
||||||
_ => return Err(())
|
_ => return Err(())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,6 +287,12 @@ impl ServoSelectorImpl {
|
||||||
fun(PseudoElement::DetailsSummary);
|
fun(PseudoElement::DetailsSummary);
|
||||||
fun(PseudoElement::Selection);
|
fun(PseudoElement::Selection);
|
||||||
fun(PseudoElement::ServoInputText);
|
fun(PseudoElement::ServoInputText);
|
||||||
|
fun(PseudoElement::ServoTableWrapper);
|
||||||
|
fun(PseudoElement::ServoAnonymousTableWrapper);
|
||||||
|
fun(PseudoElement::ServoAnonymousTable);
|
||||||
|
fun(PseudoElement::ServoAnonymousTableRow);
|
||||||
|
fun(PseudoElement::ServoAnonymousTableCell);
|
||||||
|
fun(PseudoElement::ServoAnonymousBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue