Skip to content
Permalink
Browse files

Remove ObjectElement

  • Loading branch information...
nox committed Jan 14, 2019
1 parent 059c9f4 commit 887cc6255684864c1c5e282c30743f7126b346a1
Showing with 19 additions and 40 deletions.
  1. +19 −40 components/layout/construct.rs
@@ -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) {

0 comments on commit 887cc62

Please sign in to comment.
You can’t perform that action at this time.