mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move the state getters to LayoutElementHelpers.
This commit is contained in:
parent
849eb7837a
commit
487eef88e3
2 changed files with 28 additions and 31 deletions
|
@ -469,16 +469,12 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_checked_state(&self) -> bool {
|
fn get_checked_state(&self) -> bool {
|
||||||
unsafe {
|
self.element.get_checked_state_for_layout()
|
||||||
(*self.element.unsafe_get()).get_checked_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_indeterminate_state(&self) -> bool {
|
fn get_indeterminate_state(&self) -> bool {
|
||||||
unsafe {
|
self.element.get_indeterminate_state_for_layout()
|
||||||
(*self.element.unsafe_get()).get_indeterminate_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -177,8 +177,6 @@ pub trait RawLayoutElementHelpers {
|
||||||
|
|
||||||
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 V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
||||||
unsafe fn get_checked_state_for_layout(&self) -> bool;
|
|
||||||
unsafe fn get_indeterminate_state_for_layout(&self) -> bool;
|
|
||||||
unsafe fn get_unsigned_integer_attribute_for_layout(&self, attribute: UnsignedIntegerAttribute)
|
unsafe fn get_unsigned_integer_attribute_for_layout(&self, attribute: UnsignedIntegerAttribute)
|
||||||
-> Option<u32>;
|
-> Option<u32>;
|
||||||
}
|
}
|
||||||
|
@ -457,29 +455,6 @@ impl RawLayoutElementHelpers for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
unsafe fn get_checked_state_for_layout(&self) -> bool {
|
|
||||||
// TODO option and menuitem can also have a checked state.
|
|
||||||
if !self.is_htmlinputelement() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
let this: &HTMLInputElement = mem::transmute(self);
|
|
||||||
this.get_checked_state_for_layout()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
unsafe fn get_indeterminate_state_for_layout(&self) -> bool {
|
|
||||||
// TODO progress elements can also be matched with :indeterminate
|
|
||||||
if !self.is_htmlinputelement() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
let this: &HTMLInputElement = mem::transmute(self);
|
|
||||||
this.get_indeterminate_state_for_layout()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsafe fn get_unsigned_integer_attribute_for_layout(&self,
|
unsafe fn get_unsigned_integer_attribute_for_layout(&self,
|
||||||
attribute: UnsignedIntegerAttribute)
|
attribute: UnsignedIntegerAttribute)
|
||||||
-> Option<u32> {
|
-> Option<u32> {
|
||||||
|
@ -506,6 +481,8 @@ pub trait LayoutElementHelpers {
|
||||||
fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock>;
|
fn style_attribute(&self) -> *const Option<PropertyDeclarationBlock>;
|
||||||
fn local_name<'a>(&'a self) -> &'a Atom;
|
fn local_name<'a>(&'a self) -> &'a Atom;
|
||||||
fn namespace<'a>(&'a self) -> &'a Namespace;
|
fn namespace<'a>(&'a self) -> &'a Namespace;
|
||||||
|
fn get_checked_state_for_layout(&self) -> bool;
|
||||||
|
fn get_indeterminate_state_for_layout(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutElementHelpers for LayoutJS<Element> {
|
impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
|
@ -544,6 +521,30 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
&(*self.unsafe_get()).namespace
|
&(*self.unsafe_get()).namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
fn get_checked_state_for_layout(&self) -> bool {
|
||||||
|
// TODO option and menuitem can also have a checked state.
|
||||||
|
match HTMLInputElementCast::to_layout_js(self) {
|
||||||
|
Some(input) => unsafe {
|
||||||
|
(*input.unsafe_get()).get_checked_state_for_layout()
|
||||||
|
},
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
fn get_indeterminate_state_for_layout(&self) -> bool {
|
||||||
|
// TODO progress elements can also be matched with :indeterminate
|
||||||
|
match HTMLInputElementCast::to_layout_js(self) {
|
||||||
|
Some(input) => unsafe {
|
||||||
|
(*input.unsafe_get()).get_indeterminate_state_for_layout()
|
||||||
|
},
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue