aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-11-29 04:42:41 -0700
committerbors-servo <metajack+bors@gmail.com>2014-11-29 04:42:41 -0700
commit9541dcdee271d83834af12c756932697ab0ef5dc (patch)
treef4b07ecda2c8ae6f3c0046edfc677e05668537a3 /components/script
parentb87d98e468d6c405dd02625e3e223e2412db8610 (diff)
parentfab09a51379eb9bdc5e7362cc7714b62e9135744 (diff)
downloadservo-9541dcdee271d83834af12c756932697ab0ef5dc.tar.gz
servo-9541dcdee271d83834af12c756932697ab0ef5dc.zip
auto merge of #4149 : aakashjain/servo/MovingElementGetters, r=Manishearth
Moved all getters from Element to ElementHelpers. Existing ElementHelpers getters `get_namespace` and `get_local_name` were replaced by `namespace` and `local_name`. Callers were updated accordingly. Also the getters are no longer inlined. 3 of the getters needed to be added to RawLayoutElementHelpers as well, to accomodate existing calls directly from Element objects.
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/element.rs81
-rw-r--r--components/script/dom/htmlfieldsetelement.rs2
-rw-r--r--components/script/dom/htmloptionelement.rs2
-rw-r--r--components/script/dom/namednodemap.rs2
-rw-r--r--components/script/parse/html.rs4
5 files changed, 49 insertions, 42 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 79ecfe93743..d3b5b1946aa 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -182,36 +182,6 @@ impl Element {
Node::reflect_node(box Element::new_inherited(ElementTypeId_, local_name, namespace, prefix, document),
document, ElementBinding::Wrap)
}
-
- #[inline]
- pub fn local_name<'a>(&'a self) -> &'a Atom {
- &self.local_name
- }
-
- #[inline]
- pub fn namespace<'a>(&'a self) -> &'a Namespace {
- &self.namespace
- }
-
- #[inline]
- pub fn prefix<'a>(&'a self) -> &'a Option<DOMString> {
- &self.prefix
- }
-
- #[inline]
- pub fn attrs(&self) -> Ref<Vec<JS<Attr>>> {
- self.attrs.borrow()
- }
-
- #[inline]
- pub fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
- self.attrs.borrow_mut()
- }
-
- #[inline]
- pub fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>> {
- &self.style_attribute
- }
}
pub trait RawLayoutElementHelpers {
@@ -225,6 +195,9 @@ pub trait RawLayoutElementHelpers {
-> LengthOrPercentageOrAuto;
unsafe fn get_integer_attribute_for_layout(&self, integer_attribute: IntegerAttribute)
-> Option<i32>;
+ fn local_name<'a>(&'a self) -> &'a Atom;
+ fn namespace<'a>(&'a self) -> &'a Namespace;
+ fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>>;
}
#[inline]
@@ -336,6 +309,20 @@ impl RawLayoutElementHelpers for Element {
}
}
}
+
+ // Getters used in components/layout/wrapper.rs
+
+ fn local_name<'a>(&'a self) -> &'a Atom {
+ &self.local_name
+ }
+
+ fn namespace<'a>(&'a self) -> &'a Namespace {
+ &self.namespace
+ }
+
+ fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>> {
+ &self.style_attribute
+ }
}
pub trait LayoutElementHelpers {
@@ -361,8 +348,12 @@ impl LayoutElementHelpers for JS<Element> {
pub trait ElementHelpers<'a> {
fn html_element_in_html_document(self) -> bool;
- fn get_local_name(self) -> &'a Atom;
- fn get_namespace(self) -> &'a Namespace;
+ fn local_name(self) -> &'a Atom;
+ fn namespace(self) -> &'a Namespace;
+ fn prefix(self) -> &'a Option<DOMString>;
+ fn attrs(&self) -> Ref<Vec<JS<Attr>>>;
+ fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>>;
+ fn style_attribute(self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>>;
fn summarize(self) -> Vec<AttrInfo>;
fn is_void(self) -> bool;
}
@@ -373,14 +364,30 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
self.namespace == ns!(HTML) && node.is_in_html_doc()
}
- fn get_local_name(self) -> &'a Atom {
+ fn local_name(self) -> &'a Atom {
&self.extended_deref().local_name
}
- fn get_namespace(self) -> &'a Namespace {
+ fn namespace(self) -> &'a Namespace {
&self.extended_deref().namespace
}
+ fn prefix(self) -> &'a Option<DOMString> {
+ &self.extended_deref().prefix
+ }
+
+ fn attrs(&self) -> Ref<Vec<JS<Attr>>> {
+ self.extended_deref().attrs.borrow()
+ }
+
+ fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
+ self.extended_deref().attrs.borrow_mut()
+ }
+
+ fn style_attribute(self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>> {
+ &self.extended_deref().style_attribute
+ }
+
fn summarize(self) -> Vec<AttrInfo> {
let attrs = self.Attributes().root();
let mut i = 0;
@@ -393,7 +400,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
summarized
}
- fn is_void(self) -> bool {
+ fn is_void(self) -> bool {
if self.namespace != ns!(HTML) {
return false
}
@@ -1116,7 +1123,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_local_name<'a, T: ElementHelpers<'a>>(this: T) -> &'a Atom {
- this.get_local_name()
+ this.local_name()
}
get_local_name(self)
@@ -1125,7 +1132,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_namespace<'a, T: ElementHelpers<'a>>(this: T) -> &'a Namespace {
- this.get_namespace()
+ this.namespace()
}
get_namespace(self)
diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs
index 689f9b498dc..1dfdaa063b9 100644
--- a/components/script/dom/htmlfieldsetelement.rs
+++ b/components/script/dom/htmlfieldsetelement.rs
@@ -11,7 +11,7 @@ use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLLegendElementDer
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::Document;
-use dom::element::{AttributeHandlers, Element, HTMLFieldSetElementTypeId, HTMLButtonElementTypeId};
+use dom::element::{AttributeHandlers, Element, ElementHelpers, HTMLFieldSetElementTypeId, HTMLButtonElementTypeId};
use dom::element::{HTMLInputElementTypeId, HTMLSelectElementTypeId, HTMLTextAreaElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::{HTMLCollection, CollectionFilter};
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index eabda88f4f8..c97b32c906e 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -15,7 +15,7 @@ use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector};
use dom::characterdata::CharacterData;
use dom::document::Document;
-use dom::element::{AttributeHandlers, Element, HTMLOptionElementTypeId};
+use dom::element::{AttributeHandlers, Element, ElementHelpers, HTMLOptionElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId};
diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs
index 1bfe7034198..220a2009a99 100644
--- a/components/script/dom/namednodemap.rs
+++ b/components/script/dom/namednodemap.rs
@@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::global;
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
-use dom::element::Element;
+use dom::element::{Element, ElementHelpers};
use dom::window::Window;
#[dom_struct]
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs
index 7e199fad1d3..53a54e11f66 100644
--- a/components/script/parse/html.rs
+++ b/components/script/parse/html.rs
@@ -98,8 +98,8 @@ impl<'a> TreeSink<TrustedNodeAddress> for servohtmlparser::Sink {
let elem: JSRef<Element> = ElementCast::to_ref(*node)
.expect("tried to get name of non-Element in HTML parsing");
QualName {
- ns: elem.get_namespace().clone(),
- local: elem.get_local_name().clone(),
+ ns: elem.namespace().clone(),
+ local: elem.local_name().clone(),
}
}