Corey Farwell 2016-04-10 22:06:29 -04:00
parent 3b376bb319
commit 11a3ce1257
9 changed files with 29 additions and 29 deletions

View file

@ -903,7 +903,7 @@ impl Document {
for element in new_target.upcast::<Node>() for element in new_target.upcast::<Node>()
.inclusive_ancestors() .inclusive_ancestors()
.filter_map(Root::downcast::<Element>) { .filter_map(Root::downcast::<Element>) {
if element.get_hover_state() { if element.hover_state() {
break; break;
} }
@ -1774,7 +1774,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut(); let mut map = self.modified_elements.borrow_mut();
let snapshot = map.entry(JS::from_ref(el)).or_insert(ElementSnapshot::new()); let snapshot = map.entry(JS::from_ref(el)).or_insert(ElementSnapshot::new());
if snapshot.state.is_none() { if snapshot.state.is_none() {
snapshot.state = Some(el.get_state()); snapshot.state = Some(el.state());
} }
} }
@ -1802,7 +1802,7 @@ impl Element {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement))
if self.get_disabled_state() => true, if self.disabled_state() => true,
_ => false, _ => false,
} }
} }

View file

@ -791,7 +791,7 @@ impl Element {
} }
} }
pub fn get_root_element(&self) -> Root<Element> { pub fn root_element(&self) -> Root<Element> {
if self.node.is_in_doc() { if self.node.is_in_doc() {
self.upcast::<Node>() self.upcast::<Node>()
.owner_doc() .owner_doc()
@ -864,7 +864,7 @@ impl Element {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => {
self.get_disabled_state() self.disabled_state()
} }
// TODO: // TODO:
// an optgroup element that has a disabled attribute // an optgroup element that has a disabled attribute
@ -1874,7 +1874,7 @@ impl<'a> ::selectors::Element for Root<Element> {
NonTSPseudoClass::Disabled | NonTSPseudoClass::Disabled |
NonTSPseudoClass::Checked | NonTSPseudoClass::Checked |
NonTSPseudoClass::Indeterminate => NonTSPseudoClass::Indeterminate =>
Element::get_state(self).contains(pseudo_class.state_flag()), Element::state(self).contains(pseudo_class.state_flag()),
} }
} }
@ -2077,7 +2077,7 @@ impl Element {
self.set_click_in_progress(false); self.set_click_in_progress(false);
} }
pub fn get_state(&self) -> ElementState { pub fn state(&self) -> ElementState {
self.state.get() self.state.get()
} }
@ -2096,7 +2096,7 @@ impl Element {
self.state.set(state); self.state.set(state);
} }
pub fn get_active_state(&self) -> bool { pub fn active_state(&self) -> bool {
self.state.get().contains(IN_ACTIVE_STATE) self.state.get().contains(IN_ACTIVE_STATE)
} }
@ -2104,7 +2104,7 @@ impl Element {
self.set_state(IN_ACTIVE_STATE, value) self.set_state(IN_ACTIVE_STATE, value)
} }
pub fn get_focus_state(&self) -> bool { pub fn focus_state(&self) -> bool {
self.state.get().contains(IN_FOCUS_STATE) self.state.get().contains(IN_FOCUS_STATE)
} }
@ -2113,7 +2113,7 @@ impl Element {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
} }
pub fn get_hover_state(&self) -> bool { pub fn hover_state(&self) -> bool {
self.state.get().contains(IN_HOVER_STATE) self.state.get().contains(IN_HOVER_STATE)
} }
@ -2121,7 +2121,7 @@ impl Element {
self.set_state(IN_HOVER_STATE, value) self.set_state(IN_HOVER_STATE, value)
} }
pub fn get_enabled_state(&self) -> bool { pub fn enabled_state(&self) -> bool {
self.state.get().contains(IN_ENABLED_STATE) self.state.get().contains(IN_ENABLED_STATE)
} }
@ -2129,7 +2129,7 @@ impl Element {
self.set_state(IN_ENABLED_STATE, value) self.set_state(IN_ENABLED_STATE, value)
} }
pub fn get_disabled_state(&self) -> bool { pub fn disabled_state(&self) -> bool {
self.state.get().contains(IN_DISABLED_STATE) self.state.get().contains(IN_DISABLED_STATE)
} }
@ -2141,7 +2141,7 @@ impl Element {
impl Element { impl Element {
pub fn check_ancestors_disabled_state_for_form_control(&self) { pub fn check_ancestors_disabled_state_for_form_control(&self) {
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();
if self.get_disabled_state() { if self.disabled_state() {
return; return;
} }
for ancestor in node.ancestors() { for ancestor in node.ancestors() {
@ -2150,7 +2150,7 @@ impl Element {
if !ancestor.is::<HTMLFieldSetElement>() { if !ancestor.is::<HTMLFieldSetElement>() {
continue; continue;
} }
if !ancestor.downcast::<Element>().unwrap().get_disabled_state() { if !ancestor.downcast::<Element>().unwrap().disabled_state() {
continue; continue;
} }
if ancestor.is_parent_of(node) { if ancestor.is_parent_of(node) {
@ -2175,13 +2175,13 @@ impl Element {
} }
pub fn check_parent_disabled_state_for_option(&self) { pub fn check_parent_disabled_state_for_option(&self) {
if self.get_disabled_state() { if self.disabled_state() {
return; return;
} }
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();
if let Some(ref parent) = node.GetParentNode() { if let Some(ref parent) = node.GetParentNode() {
if parent.is::<HTMLOptGroupElement>() && if parent.is::<HTMLOptGroupElement>() &&
parent.downcast::<Element>().unwrap().get_disabled_state() { parent.downcast::<Element>().unwrap().disabled_state() {
self.set_disabled_state(true); self.set_disabled_state(true);
self.set_enabled_state(false); self.set_enabled_state(false);
} }

View file

@ -213,7 +213,7 @@ impl Activatable for HTMLButtonElement {
fn is_instance_activatable(&self) -> bool { fn is_instance_activatable(&self) -> bool {
//https://html.spec.whatwg.org/multipage/#the-button-element //https://html.spec.whatwg.org/multipage/#the-button-element
!self.upcast::<Element>().get_disabled_state() !self.upcast::<Element>().disabled_state()
} }
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps // https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps

View file

@ -200,7 +200,7 @@ impl HTMLElementMethods for HTMLElement {
// https://html.spec.whatwg.org/multipage/#dom-click // https://html.spec.whatwg.org/multipage/#dom-click
fn Click(&self) { fn Click(&self) {
if !self.upcast::<Element>().get_disabled_state() { if !self.upcast::<Element>().disabled_state() {
synthetic_click_activation(self.upcast::<Element>(), synthetic_click_activation(self.upcast::<Element>(),
false, false,
false, false,
@ -223,7 +223,7 @@ impl HTMLElementMethods for HTMLElement {
// https://html.spec.whatwg.org/multipage/#dom-blur // https://html.spec.whatwg.org/multipage/#dom-blur
fn Blur(&self) { fn Blur(&self) {
// TODO: Run the unfocusing steps. // TODO: Run the unfocusing steps.
if !self.upcast::<Element>().get_focus_state() { if !self.upcast::<Element>().focus_state() {
return; return;
} }
// https://html.spec.whatwg.org/multipage/#unfocusing-steps // https://html.spec.whatwg.org/multipage/#unfocusing-steps
@ -449,7 +449,7 @@ impl HTMLElement {
}; };
// Traverse entire tree for <label> elements with `for` attribute matching `id` // Traverse entire tree for <label> elements with `for` attribute matching `id`
let root_element = element.get_root_element(); let root_element = element.root_element();
let root_node = root_element.upcast::<Node>(); let root_node = root_element.upcast::<Node>();
let children = root_node.traverse_preorder() let children = root_node.traverse_preorder()
.filter_map(Root::downcast::<Element>) .filter_map(Root::downcast::<Element>)

View file

@ -400,7 +400,7 @@ impl HTMLFormElement {
for child in node.traverse_preorder() { for child in node.traverse_preorder() {
// Step 3.1: The field element is disabled. // Step 3.1: The field element is disabled.
match child.downcast::<Element>() { match child.downcast::<Element>() {
Some(el) if !el.get_disabled_state() => (), Some(el) if !el.disabled_state() => (),
_ => continue, _ => continue,
} }

View file

@ -272,7 +272,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)] #[allow(unsafe_code)]
unsafe fn get_selection_for_layout(self) -> Option<Range<isize>> { unsafe fn get_selection_for_layout(self) -> Option<Range<isize>> {
if !(*self.unsafe_get()).upcast::<Element>().get_focus_state() { if !(*self.unsafe_get()).upcast::<Element>().focus_state() {
return None; return None;
} }
@ -324,7 +324,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-checked // https://html.spec.whatwg.org/multipage/#dom-input-checked
fn Checked(&self) -> bool { fn Checked(&self) -> bool {
self.upcast::<Element>().get_state().contains(IN_CHECKED_STATE) self.upcast::<Element>().state().contains(IN_CHECKED_STATE)
} }
// https://html.spec.whatwg.org/multipage/#dom-input-checked // https://html.spec.whatwg.org/multipage/#dom-input-checked
@ -466,7 +466,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
fn Indeterminate(&self) -> bool { fn Indeterminate(&self) -> bool {
self.upcast::<Element>().get_state().contains(IN_INDETERMINATE_STATE) self.upcast::<Element>().state().contains(IN_INDETERMINATE_STATE)
} }
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
@ -663,7 +663,7 @@ impl HTMLInputElement {
fn mutable(&self) -> bool { fn mutable(&self) -> bool {
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-fe-mutable // https://html.spec.whatwg.org/multipage/#the-input-element:concept-fe-mutable
// https://html.spec.whatwg.org/multipage/#the-readonly-attribute:concept-fe-mutable // https://html.spec.whatwg.org/multipage/#the-readonly-attribute:concept-fe-mutable
!(self.upcast::<Element>().get_disabled_state() || self.ReadOnly()) !(self.upcast::<Element>().disabled_state() || self.ReadOnly())
} }
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control // https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control

View file

@ -67,7 +67,7 @@ impl HTMLSelectElement {
last_selected = Some(Root::from_ref(opt.r())); last_selected = Some(Root::from_ref(opt.r()));
} }
let element = opt.upcast::<Element>(); let element = opt.upcast::<Element>();
if first_enabled.is_none() && !element.get_disabled_state() { if first_enabled.is_none() && !element.disabled_state() {
first_enabled = Some(Root::from_ref(opt.r())); first_enabled = Some(Root::from_ref(opt.r()));
} }
} }
@ -90,7 +90,7 @@ impl HTMLSelectElement {
} }
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) { for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
let element = opt.upcast::<Element>(); let element = opt.upcast::<Element>();
if opt.Selected() && element.get_enabled_state() { if opt.Selected() && element.enabled_state() {
data_set.push(FormDatum { data_set.push(FormDatum {
ty: self.Type(), ty: self.Type(),
name: self.Name(), name: self.Name(),

View file

@ -64,7 +64,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)] #[allow(unsafe_code)]
unsafe fn get_absolute_selection_for_layout(self) -> Option<Range<usize>> { unsafe fn get_absolute_selection_for_layout(self) -> Option<Range<usize>> {
if (*self.unsafe_get()).upcast::<Element>().get_focus_state() { if (*self.unsafe_get()).upcast::<Element>().focus_state() {
Some((*self.unsafe_get()).textinput.borrow_for_layout() Some((*self.unsafe_get()).textinput.borrow_for_layout()
.get_absolute_selection_range()) .get_absolute_selection_range())
} else { } else {

View file

@ -295,7 +295,7 @@ pub fn handle_is_enabled(page: &Rc<Page>,
reply.send(match find_node_by_unique_id(page, pipeline, element_id) { reply.send(match find_node_by_unique_id(page, pipeline, element_id) {
Some(ref node) => { Some(ref node) => {
match node.downcast::<Element>() { match node.downcast::<Element>() {
Some(elem) => Ok(elem.get_enabled_state()), Some(elem) => Ok(elem.enabled_state()),
None => Err(()) None => Err(())
} }
}, },