mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Generate ::before and ::after string content for layout 2020
This commit is contained in:
parent
32d8a1efbb
commit
bc66948f7c
2 changed files with 35 additions and 12 deletions
|
@ -17,8 +17,10 @@ use std::sync::Arc;
|
||||||
use style::dom::{OpaqueNode, TNode};
|
use style::dom::{OpaqueNode, TNode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::selector_parser::PseudoElement;
|
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 {
|
pub enum WhichPseudoElement {
|
||||||
Before,
|
Before,
|
||||||
After,
|
After,
|
||||||
|
@ -244,29 +246,51 @@ impl NonReplacedContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pseudo_element_style<'dom, Node>(
|
fn pseudo_element_style<'dom, Node>(
|
||||||
_which: WhichPseudoElement,
|
which: WhichPseudoElement,
|
||||||
_element: Node,
|
element: Node,
|
||||||
_context: &LayoutContext,
|
context: &LayoutContext,
|
||||||
) -> Option<ServoArc<ComputedValues>>
|
) -> Option<ServoArc<ComputedValues>>
|
||||||
where
|
where
|
||||||
Node: NodeExt<'dom>,
|
Node: NodeExt<'dom>,
|
||||||
{
|
{
|
||||||
// FIXME: run the cascade, then return None for `content: normal` or `content: none`
|
if let Some(pseudo_element) = match which {
|
||||||
// https://drafts.csswg.org/css2/generate.html#content
|
WhichPseudoElement::Before => element.to_threadsafe().get_before_pseudo(),
|
||||||
None
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_pseudo_element_content<'dom, Node>(
|
fn generate_pseudo_element_content<'dom, Node>(
|
||||||
_pseudo_element_style: &ComputedValues,
|
pseudo_element_style: &ComputedValues,
|
||||||
_element: Node,
|
_element: Node,
|
||||||
_context: &LayoutContext,
|
_context: &LayoutContext,
|
||||||
) -> Vec<PseudoElementContentItem>
|
) -> Vec<PseudoElementContentItem>
|
||||||
where
|
where
|
||||||
Node: NodeExt<'dom>,
|
Node: NodeExt<'dom>,
|
||||||
{
|
{
|
||||||
let _ = PseudoElementContentItem::Text;
|
match &pseudo_element_style.get_counters().content {
|
||||||
let _ = PseudoElementContentItem::Replaced;
|
Content::Items(ref items) => {
|
||||||
unimplemented!()
|
let mut vec = vec![];
|
||||||
|
for item in items.iter() {
|
||||||
|
match item {
|
||||||
|
ContentItem::String(s) => {
|
||||||
|
vec.push(PseudoElementContentItem::Text(s.to_string()))
|
||||||
|
},
|
||||||
|
_ => unimplemented!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec
|
||||||
|
},
|
||||||
|
_ => vec![],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BoxSlot<'dom> {
|
pub struct BoxSlot<'dom> {
|
||||||
|
|
|
@ -11,7 +11,6 @@ ${helpers.predefined_type(
|
||||||
"Content",
|
"Content",
|
||||||
"computed::Content::normal()",
|
"computed::Content::normal()",
|
||||||
engines="gecko servo-2013 servo-2020",
|
engines="gecko servo-2013 servo-2020",
|
||||||
servo_2020_pref="layout.2020.unimplemented",
|
|
||||||
initial_specified_value="specified::Content::normal()",
|
initial_specified_value="specified::Content::normal()",
|
||||||
animation_value_type="discrete",
|
animation_value_type="discrete",
|
||||||
spec="https://drafts.csswg.org/css-content/#propdef-content",
|
spec="https://drafts.csswg.org/css-content/#propdef-content",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue