diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2019-01-14 12:11:02 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2019-01-14 16:10:27 +0100 |
commit | 887cc6255684864c1c5e282c30743f7126b346a1 (patch) | |
tree | 71e4d1681bd8e9a958da595aa118082bc64d5f0c /components/layout/construct.rs | |
parent | 059c9f4f7880a747c889d0b277b68edebb58e77a (diff) | |
download | servo-887cc6255684864c1c5e282c30743f7126b346a1.tar.gz servo-887cc6255684864c1c5e282c30743f7126b346a1.zip |
Remove ObjectElement
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 8df40d5b893..21e3611f446 100644 --- a/components/layout/construct.rs +++ b/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) { |