mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Inline ObjectElement::get_type_and_data into the consumers.
The usage here doesn't quite work without the lifetimes.
This commit is contained in:
parent
b1878bd925
commit
7c4dcaa677
1 changed files with 8 additions and 12 deletions
|
@ -1674,10 +1674,7 @@ impl<'ln, ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNo
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Methods for interacting with HTMLObjectElement nodes
|
/// Methods for interacting with HTMLObjectElement nodes
|
||||||
trait ObjectElement<'a> {
|
trait ObjectElement {
|
||||||
/// Returns None if this node is not matching attributes.
|
|
||||||
fn get_type_and_data(&self) -> (Option<&'a str>, Option<&'a str>);
|
|
||||||
|
|
||||||
/// Returns true if this node has object data that is correct uri.
|
/// Returns true if this node has object data that is correct uri.
|
||||||
fn has_object_data(&self) -> bool;
|
fn has_object_data(&self) -> bool;
|
||||||
|
|
||||||
|
@ -1685,21 +1682,20 @@ trait ObjectElement<'a> {
|
||||||
fn object_data(&self) -> Option<Url>;
|
fn object_data(&self) -> Option<Url>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ln, N> ObjectElement<'ln> for N where N: ThreadSafeLayoutNode<'ln> {
|
impl<'ln, N> ObjectElement for N where N: ThreadSafeLayoutNode<'ln> {
|
||||||
fn get_type_and_data(&self) -> (Option<&'ln str>, Option<&'ln str>) {
|
|
||||||
let elem = self.as_element();
|
|
||||||
(elem.get_attr(&ns!(), &atom!("type")), elem.get_attr(&ns!(), &atom!("data")))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn has_object_data(&self) -> bool {
|
fn has_object_data(&self) -> bool {
|
||||||
match self.get_type_and_data() {
|
let elem = self.as_element();
|
||||||
|
let type_and_data = (elem.get_attr(&ns!(), &atom!("type")), elem.get_attr(&ns!(), &atom!("data")));
|
||||||
|
match type_and_data {
|
||||||
(None, Some(uri)) => is_image_data(uri),
|
(None, Some(uri)) => is_image_data(uri),
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_data(&self) -> Option<Url> {
|
fn object_data(&self) -> Option<Url> {
|
||||||
match self.get_type_and_data() {
|
let elem = self.as_element();
|
||||||
|
let type_and_data = (elem.get_attr(&ns!(), &atom!("type")), elem.get_attr(&ns!(), &atom!("data")));
|
||||||
|
match type_and_data {
|
||||||
(None, Some(uri)) if is_image_data(uri) => Url::parse(uri).ok(),
|
(None, Some(uri)) if is_image_data(uri) => Url::parse(uri).ok(),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue