mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Use cached element ID in LayoutElement::get_id
This commit is contained in:
parent
ea655ada10
commit
2e9d8a76d1
2 changed files with 9 additions and 1 deletions
|
@ -487,7 +487,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_id(&self) -> Option<Atom> {
|
fn get_id(&self) -> Option<Atom> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.element.unsafe_get()).get_attr_atom_for_layout(&ns!(""), &atom!("id"))
|
(*self.element.id_attribute()).clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,7 @@ pub trait LayoutElementHelpers {
|
||||||
unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
|
unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool;
|
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 style_attribute(&self) -> *const Option<PropertyDeclarationBlock>;
|
||||||
fn local_name(&self) -> &Atom;
|
fn local_name(&self) -> &Atom;
|
||||||
fn namespace(&self) -> &Namespace;
|
fn namespace(&self) -> &Namespace;
|
||||||
|
@ -517,6 +518,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some()
|
get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
fn id_attribute(&self) -> *const Option<Atom> {
|
||||||
|
unsafe {
|
||||||
|
(*self.unsafe_get()).id_attribute.borrow_for_layout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock> {
|
fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue