diff options
author | Anthony Ramine <nox@nox.paris> | 2020-03-31 18:02:02 +0200 |
---|---|---|
committer | Anthony Ramine <nox@nox.paris> | 2020-03-31 18:02:02 +0200 |
commit | 3b504148d5d4fef9f651e73df90ad8c9e9fb09a5 (patch) | |
tree | e08a8cfa752d48644e835cf012a011dae4c23719 | |
parent | fb1ff3f097c0c8a994c9e7c4bb72c3ba5b64492d (diff) | |
download | servo-3b504148d5d4fef9f651e73df90ad8c9e9fb09a5.tar.gz servo-3b504148d5d4fef9f651e73df90ad8c9e9fb09a5.zip |
Move around some code in the element
The intent is to merge the two layout helper traits together
so I'm moving them around to make later diffs more readable.
-rw-r--r-- | components/script/dom/element.rs | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 7d167bf2574..3acbd647107 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -550,21 +550,6 @@ impl Element { } } -#[allow(unsafe_code)] -pub trait RawLayoutElementHelpers { - unsafe fn get_attr_for_layout<'a>( - &'a self, - namespace: &Namespace, - name: &LocalName, - ) -> Option<&'a AttrValue>; - unsafe fn get_attr_val_for_layout<'a>( - &'a self, - namespace: &Namespace, - name: &LocalName, - ) -> Option<&'a str>; - unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue>; -} - #[inline] #[allow(unsafe_code)] pub unsafe fn get_attr_for_layout<'dom>( @@ -583,43 +568,6 @@ pub unsafe fn get_attr_for_layout<'dom>( .map(|attr| attr.to_layout()) } -#[allow(unsafe_code)] -impl RawLayoutElementHelpers for Element { - #[inline] - unsafe fn get_attr_for_layout<'a>( - &'a self, - namespace: &Namespace, - name: &LocalName, - ) -> Option<&'a AttrValue> { - get_attr_for_layout(self, namespace, name).map(|attr| attr.value()) - } - - #[inline] - unsafe fn get_attr_val_for_layout<'a>( - &'a self, - namespace: &Namespace, - name: &LocalName, - ) -> Option<&'a str> { - get_attr_for_layout(self, namespace, name).map(|attr| attr.as_str()) - } - - #[inline] - unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue> { - let attrs = self.attrs.borrow_for_layout(); - attrs - .iter() - .filter_map(|attr| { - let attr = attr.to_layout(); - if name == attr.local_name() { - Some(attr.value()) - } else { - None - } - }) - .collect() - } -} - pub trait LayoutElementHelpers<'dom> { #[allow(unsafe_code)] unsafe fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool; @@ -649,6 +597,21 @@ pub trait LayoutElementHelpers<'dom> { unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>; } +#[allow(unsafe_code)] +pub trait RawLayoutElementHelpers { + unsafe fn get_attr_for_layout<'a>( + &'a self, + namespace: &Namespace, + name: &LocalName, + ) -> Option<&'a AttrValue>; + unsafe fn get_attr_val_for_layout<'a>( + &'a self, + namespace: &Namespace, + name: &LocalName, + ) -> Option<&'a str>; + unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue>; +} + impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> { #[allow(unsafe_code)] #[inline] @@ -1105,6 +1068,43 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> { } } +#[allow(unsafe_code)] +impl RawLayoutElementHelpers for Element { + #[inline] + unsafe fn get_attr_for_layout<'a>( + &'a self, + namespace: &Namespace, + name: &LocalName, + ) -> Option<&'a AttrValue> { + get_attr_for_layout(self, namespace, name).map(|attr| attr.value()) + } + + #[inline] + unsafe fn get_attr_val_for_layout<'a>( + &'a self, + namespace: &Namespace, + name: &LocalName, + ) -> Option<&'a str> { + get_attr_for_layout(self, namespace, name).map(|attr| attr.as_str()) + } + + #[inline] + unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue> { + let attrs = self.attrs.borrow_for_layout(); + attrs + .iter() + .filter_map(|attr| { + let attr = attr.to_layout(); + if name == attr.local_name() { + Some(attr.value()) + } else { + None + } + }) + .collect() + } +} + impl Element { pub fn is_html_element(&self) -> bool { self.namespace == ns!(html) |