aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/construct.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r--components/layout/construct.rs59
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) {