mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
Generate ::before and ::after content from attr() for layout 2020
This commit is contained in:
parent
bc66948f7c
commit
5b2d6c81b2
5 changed files with 29 additions and 14 deletions
|
@ -21,6 +21,7 @@ euclid = "0.20"
|
|||
fnv = "1.0"
|
||||
gfx = {path = "../gfx"}
|
||||
gfx_traits = {path = "../gfx_traits"}
|
||||
html5ever = "0.25"
|
||||
ipc-channel = "0.14"
|
||||
libc = "0.2"
|
||||
msg = {path = "../msg"}
|
||||
|
|
|
@ -9,8 +9,11 @@ use crate::replaced::ReplacedContent;
|
|||
use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside};
|
||||
use crate::wrapper::GetRawData;
|
||||
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
|
||||
use html5ever::LocalName;
|
||||
use net_traits::image::base::Image as NetImage;
|
||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use script_layout_interface::wrapper_traits::{
|
||||
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||
};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use std::marker::PhantomData as marker;
|
||||
use std::sync::Arc;
|
||||
|
@ -253,24 +256,23 @@ fn pseudo_element_style<'dom, Node>(
|
|||
where
|
||||
Node: NodeExt<'dom>,
|
||||
{
|
||||
if let Some(pseudo_element) = match which {
|
||||
match which {
|
||||
WhichPseudoElement::Before => element.to_threadsafe().get_before_pseudo(),
|
||||
WhichPseudoElement::After => element.to_threadsafe().get_after_pseudo(),
|
||||
} {
|
||||
}
|
||||
.and_then(|pseudo_element| {
|
||||
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>(
|
||||
pseudo_element_style: &ComputedValues,
|
||||
_element: Node,
|
||||
element: Node,
|
||||
_context: &LayoutContext,
|
||||
) -> Vec<PseudoElementContentItem>
|
||||
where
|
||||
|
@ -282,14 +284,25 @@ where
|
|||
for item in items.iter() {
|
||||
match item {
|
||||
ContentItem::String(s) => {
|
||||
vec.push(PseudoElementContentItem::Text(s.to_string()))
|
||||
vec.push(PseudoElementContentItem::Text(s.to_string()));
|
||||
},
|
||||
_ => unimplemented!(),
|
||||
ContentItem::Attr(attr) => {
|
||||
let element = element
|
||||
.to_threadsafe()
|
||||
.as_element()
|
||||
.expect("Expected an element");
|
||||
let attr_val = element
|
||||
.get_attr(&attr.namespace_url, &LocalName::from(&*attr.attribute));
|
||||
vec.push(PseudoElementContentItem::Text(
|
||||
attr_val.map_or("".to_string(), |s| s.to_string()),
|
||||
));
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
vec
|
||||
},
|
||||
_ => vec![],
|
||||
Content::Normal | Content::None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue