diff options
author | Ali Sabil <ali.sabil@gmail.com> | 2015-08-07 12:33:06 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-09-13 23:55:40 +0200 |
commit | 2e9d8a76d15d478b90fffb235ace1293ed329231 (patch) | |
tree | f5defe61b193b74651f801b663eb8d3d8ef3a749 | |
parent | ea655ada10cca75423dc5380ee26779e09c26883 (diff) | |
download | servo-2e9d8a76d15d478b90fffb235ace1293ed329231.tar.gz servo-2e9d8a76d15d478b90fffb235ace1293ed329231.zip |
Use cached element ID in LayoutElement::get_id
-rw-r--r-- | components/layout/wrapper.rs | 2 | ||||
-rw-r--r-- | components/script/dom/element.rs | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index d346e97a40e..28e57417c84 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -487,7 +487,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> { #[inline] fn get_id(&self) -> Option<Atom> { unsafe { - (*self.element.unsafe_get()).get_attr_atom_for_layout(&ns!(""), &atom!("id")) + (*self.element.id_attribute()).clone() } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 0ca9c3c3f90..bedce2ed975 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -494,6 +494,7 @@ pub trait LayoutElementHelpers { unsafe fn html_element_in_html_document_for_layout(&self) -> bool; #[allow(unsafe_code)] unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool; + fn id_attribute(&self) -> *const Option<Atom>; fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock>; fn local_name(&self) -> &Atom; fn namespace(&self) -> &Namespace; @@ -518,6 +519,13 @@ impl LayoutElementHelpers for LayoutJS<Element> { } #[allow(unsafe_code)] + fn id_attribute(&self) -> *const Option<Atom> { + unsafe { + (*self.unsafe_get()).id_attribute.borrow_for_layout() + } + } + + #[allow(unsafe_code)] fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock> { unsafe { (*self.unsafe_get()).style_attribute.borrow_for_layout() |