New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate ::before and ::after content for layout_2020 #25817
Changes from 1 commit
32d8a1e
bc66948
5b2d6c8
1cdd66a
60fd1e0
File filter...
Jump to…
Generate ::before and ::after string content for layout 2020
- Loading branch information
| @@ -17,8 +17,10 @@ use std::sync::Arc; | ||||||
| use style::dom::{OpaqueNode, TNode}; | ||||||
| use style::properties::ComputedValues; | ||||||
| use style::selector_parser::PseudoElement; | ||||||
| use style::values::generics::counters::Content; | ||||||
| use style::values::generics::counters::ContentItem; | ||||||
|
|
||||||
| #[derive(Clone, Copy)] | ||||||
| #[derive(Clone, Copy, Debug)] | ||||||
| pub enum WhichPseudoElement { | ||||||
| Before, | ||||||
| After, | ||||||
| @@ -244,29 +246,51 @@ impl NonReplacedContents { | ||||||
| } | ||||||
|
|
||||||
| fn pseudo_element_style<'dom, Node>( | ||||||
| _which: WhichPseudoElement, | ||||||
| _element: Node, | ||||||
| _context: &LayoutContext, | ||||||
| which: WhichPseudoElement, | ||||||
| element: Node, | ||||||
| context: &LayoutContext, | ||||||
| ) -> Option<ServoArc<ComputedValues>> | ||||||
| where | ||||||
| Node: NodeExt<'dom>, | ||||||
| { | ||||||
| // FIXME: run the cascade, then return None for `content: normal` or `content: none` | ||||||
| // https://drafts.csswg.org/css2/generate.html#content | ||||||
| None | ||||||
| if let Some(pseudo_element) = match which { | ||||||
| WhichPseudoElement::Before => element.to_threadsafe().get_before_pseudo(), | ||||||
| WhichPseudoElement::After => element.to_threadsafe().get_after_pseudo(), | ||||||
| } { | ||||||
| let style = pseudo_element.style(context.shared_context()); | ||||||
| if style.ineffective_content_property() { | ||||||
| None | ||||||
| } else { | ||||||
| Some(style) | ||||||
| } | ||||||
| } else { | ||||||
| None | ||||||
| } | ||||||
|
This conversation was marked as resolved
by SimonSapin
Comment on lines
+266
to
+268
|
||||||
| } | ||||||
|
|
||||||
| fn generate_pseudo_element_content<'dom, Node>( | ||||||
| _pseudo_element_style: &ComputedValues, | ||||||
| pseudo_element_style: &ComputedValues, | ||||||
| _element: Node, | ||||||
| _context: &LayoutContext, | ||||||
| ) -> Vec<PseudoElementContentItem> | ||||||
| where | ||||||
| Node: NodeExt<'dom>, | ||||||
| { | ||||||
| let _ = PseudoElementContentItem::Text; | ||||||
| let _ = PseudoElementContentItem::Replaced; | ||||||
| unimplemented!() | ||||||
| match &pseudo_element_style.get_counters().content { | ||||||
| Content::Items(ref items) => { | ||||||
| let mut vec = vec![]; | ||||||
| for item in items.iter() { | ||||||
| match item { | ||||||
| ContentItem::String(s) => { | ||||||
| vec.push(PseudoElementContentItem::Text(s.to_string())) | ||||||
| }, | ||||||
| _ => unimplemented!(), | ||||||
|
This conversation was marked as resolved
by SimonSapin
SimonSapin
Member
|
||||||
| } | ||||||
| } | ||||||
| vec | ||||||
| }, | ||||||
| _ => vec![], | ||||||
|
This conversation was marked as resolved
by SimonSapin
SimonSapin
Member
|
||||||
| _ => vec![], | |
| Content::Normal | Content::None => unreachable!(), |
Here however this function should not be called with these values (because pseudo_element_style returned Option::None), so panicking is appropriate since it indicates a bug.
Nit: does this
if let…elselook better as.and_then(|| {…})?