mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make LayoutElementHelpers methods take self
This commit is contained in:
parent
9b2debe678
commit
467913acdb
1 changed files with 26 additions and 26 deletions
|
@ -622,12 +622,12 @@ impl RawLayoutElementHelpers for Element {
|
||||||
|
|
||||||
pub trait LayoutElementHelpers<'dom> {
|
pub trait LayoutElementHelpers<'dom> {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
unsafe fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]>;
|
unsafe fn get_classes_for_layout(self) -> Option<&'static [Atom]>;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, _: &mut V)
|
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(self, _: &mut V)
|
||||||
where
|
where
|
||||||
V: Push<ApplicableDeclarationBlock>;
|
V: Push<ApplicableDeclarationBlock>;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -635,24 +635,24 @@ pub trait LayoutElementHelpers<'dom> {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_rowspan(self) -> u32;
|
unsafe fn get_rowspan(self) -> u32;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn is_html_element(&self) -> bool;
|
unsafe fn is_html_element(self) -> bool;
|
||||||
fn id_attribute(&self) -> *const Option<Atom>;
|
fn id_attribute(self) -> *const Option<Atom>;
|
||||||
fn style_attribute(&self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>>;
|
fn style_attribute(self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>>;
|
||||||
fn local_name(&self) -> &LocalName;
|
fn local_name(self) -> &'dom LocalName;
|
||||||
fn namespace(&self) -> &Namespace;
|
fn namespace(self) -> &'dom Namespace;
|
||||||
fn get_lang_for_layout(&self) -> String;
|
fn get_lang_for_layout(self) -> String;
|
||||||
fn get_state_for_layout(&self) -> ElementState;
|
fn get_state_for_layout(self) -> ElementState;
|
||||||
fn insert_selector_flags(&self, flags: ElementSelectorFlags);
|
fn insert_selector_flags(self, flags: ElementSelectorFlags);
|
||||||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool;
|
||||||
/// The shadow root this element is a host of.
|
/// The shadow root this element is a host of.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
unsafe fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
||||||
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class")).map_or(
|
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class")).map_or(
|
||||||
false,
|
false,
|
||||||
|attr| {
|
|attr| {
|
||||||
|
@ -666,13 +666,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]> {
|
unsafe fn get_classes_for_layout(self) -> Option<&'static [Atom]> {
|
||||||
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class"))
|
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class"))
|
||||||
.map(|attr| attr.value_tokens_forever().unwrap())
|
.map(|attr| attr.value_tokens_forever().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(self, hints: &mut V)
|
||||||
where
|
where
|
||||||
V: Push<ApplicableDeclarationBlock>,
|
V: Push<ApplicableDeclarationBlock>,
|
||||||
{
|
{
|
||||||
|
@ -1019,32 +1019,32 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn is_html_element(&self) -> bool {
|
unsafe fn is_html_element(self) -> bool {
|
||||||
(*self.unsafe_get()).namespace == ns!(html)
|
(*self.unsafe_get()).namespace == ns!(html)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn id_attribute(&self) -> *const Option<Atom> {
|
fn id_attribute(self) -> *const Option<Atom> {
|
||||||
unsafe { (*self.unsafe_get()).id_attribute.borrow_for_layout() }
|
unsafe { (*self.unsafe_get()).id_attribute.borrow_for_layout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn style_attribute(&self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
fn style_attribute(self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
||||||
unsafe { (*self.unsafe_get()).style_attribute.borrow_for_layout() }
|
unsafe { (*self.unsafe_get()).style_attribute.borrow_for_layout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn local_name(&self) -> &LocalName {
|
fn local_name(self) -> &'dom LocalName {
|
||||||
unsafe { &(*self.unsafe_get()).local_name }
|
unsafe { &(*self.unsafe_get()).local_name }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn namespace(&self) -> &Namespace {
|
fn namespace(self) -> &'dom Namespace {
|
||||||
unsafe { &(*self.unsafe_get()).namespace }
|
unsafe { &(*self.unsafe_get()).namespace }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn get_lang_for_layout(&self) -> String {
|
fn get_lang_for_layout(self) -> String {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut current_node = Some(self.upcast::<Node>());
|
let mut current_node = Some(self.upcast::<Node>());
|
||||||
while let Some(node) = current_node {
|
while let Some(node) = current_node {
|
||||||
|
@ -1073,13 +1073,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn get_state_for_layout(&self) -> ElementState {
|
fn get_state_for_layout(self) -> ElementState {
|
||||||
unsafe { (*self.unsafe_get()).state.get() }
|
unsafe { (*self.unsafe_get()).state.get() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn insert_selector_flags(&self, flags: ElementSelectorFlags) {
|
fn insert_selector_flags(self, flags: ElementSelectorFlags) {
|
||||||
debug_assert!(thread_state::get().is_layout());
|
debug_assert!(thread_state::get().is_layout());
|
||||||
unsafe {
|
unsafe {
|
||||||
let f = &(*self.unsafe_get()).selector_flags;
|
let f = &(*self.unsafe_get()).selector_flags;
|
||||||
|
@ -1089,13 +1089,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool {
|
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool {
|
||||||
unsafe { (*self.unsafe_get()).selector_flags.get().contains(flags) }
|
unsafe { (*self.unsafe_get()).selector_flags.get().contains(flags) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||||
(*self.unsafe_get())
|
(*self.unsafe_get())
|
||||||
.rare_data_for_layout()
|
.rare_data_for_layout()
|
||||||
.as_ref()?
|
.as_ref()?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue