mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove ObjectElement
This commit is contained in:
parent
059c9f4f78
commit
887cc62556
1 changed files with 19 additions and 40 deletions
|
@ -419,8 +419,17 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
SpecificFragmentInfo::Media(Box::new(MediaFragmentInfo::new(data)))
|
||||
},
|
||||
Some(LayoutNodeType::Element(LayoutElementType::HTMLObjectElement)) => {
|
||||
let elem = node.as_element().unwrap();
|
||||
let type_and_data = (
|
||||
elem.get_attr(&ns!(), &local_name!("type")),
|
||||
elem.get_attr(&ns!(), &local_name!("data")),
|
||||
);
|
||||
let object_data = match type_and_data {
|
||||
(None, Some(uri)) if is_image_data(uri) => ServoUrl::parse(uri).ok(),
|
||||
_ => None,
|
||||
};
|
||||
let image_info = Box::new(ImageFragmentInfo::new(
|
||||
node.object_data(),
|
||||
object_data,
|
||||
None,
|
||||
node,
|
||||
&self.layout_context,
|
||||
|
@ -1976,7 +1985,15 @@ where
|
|||
Some(LayoutNodeType::Element(LayoutElementType::HTMLCanvasElement)) |
|
||||
Some(LayoutNodeType::Element(LayoutElementType::SVGSVGElement)) => true,
|
||||
Some(LayoutNodeType::Element(LayoutElementType::HTMLObjectElement)) => {
|
||||
self.has_object_data()
|
||||
let elem = self.as_element().unwrap();
|
||||
let type_and_data = (
|
||||
elem.get_attr(&ns!(), &local_name!("type")),
|
||||
elem.get_attr(&ns!(), &local_name!("data")),
|
||||
);
|
||||
match type_and_data {
|
||||
(None, Some(uri)) => is_image_data(uri),
|
||||
_ => false,
|
||||
}
|
||||
},
|
||||
Some(LayoutNodeType::Element(_)) => false,
|
||||
None => self.get_pseudo_element_type().is_replaced_content(),
|
||||
|
@ -2007,44 +2024,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Methods for interacting with HTMLObjectElement nodes
|
||||
trait ObjectElement {
|
||||
/// Returns true if this node has object data that is correct uri.
|
||||
fn has_object_data(&self) -> bool;
|
||||
|
||||
/// Returns the "data" attribute value parsed as a URL
|
||||
fn object_data(&self) -> Option<ServoUrl>;
|
||||
}
|
||||
|
||||
impl<N> ObjectElement for N
|
||||
where
|
||||
N: ThreadSafeLayoutNode,
|
||||
{
|
||||
fn has_object_data(&self) -> bool {
|
||||
let elem = self.as_element().unwrap();
|
||||
let type_and_data = (
|
||||
elem.get_attr(&ns!(), &local_name!("type")),
|
||||
elem.get_attr(&ns!(), &local_name!("data")),
|
||||
);
|
||||
match type_and_data {
|
||||
(None, Some(uri)) => is_image_data(uri),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn object_data(&self) -> Option<ServoUrl> {
|
||||
let elem = self.as_element().unwrap();
|
||||
let type_and_data = (
|
||||
elem.get_attr(&ns!(), &local_name!("type")),
|
||||
elem.get_attr(&ns!(), &local_name!("data")),
|
||||
);
|
||||
match type_and_data {
|
||||
(None, Some(uri)) if is_image_data(uri) => ServoUrl::parse(uri).ok(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FlowRef {
|
||||
/// Adds a new flow as a child of this flow. Fails if this flow is marked as a leaf.
|
||||
fn add_new_child(&mut self, mut new_child: FlowRef) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue