diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-10-31 10:05:45 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-10-31 10:05:45 +0530 |
commit | 521a87180a85709f8f704df33537f79bd131bf71 (patch) | |
tree | 4cac4c0dc50a40f9fa31b745f3ada54e1ee293d9 /components/script/dom/htmlinputelement.rs | |
parent | 7512aa69c034767cfb41206180bec50b020b2b0f (diff) | |
parent | 79ac365a68333072d80c41c05e56effbe1335f3d (diff) | |
download | servo-521a87180a85709f8f704df33537f79bd131bf71.tar.gz servo-521a87180a85709f8f704df33537f79bd131bf71.zip |
Auto merge of #8162 - bholley:centralize_event_states, r=pcwalton
Centralize event states in rust-selectors
This still needs a rev bump on rust-selectors once https://github.com/servo/rust-selectors/pull/55 gets merged.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8162)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlinputelement.rs')
-rw-r--r-- | components/script/dom/htmlinputelement.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index b82f96aed63..1adfc56b304 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -15,7 +15,7 @@ use dom::bindings::conversions::Castable; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, LayoutJS, Root, RootedReference}; use dom::document::Document; -use dom::element::{AttributeMutation, Element, IN_ENABLED_STATE, RawLayoutElementHelpers}; +use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; @@ -27,6 +27,7 @@ use dom::node::{Node, NodeDamage}; use dom::node::{document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use msg::constellation_msg::ConstellationChan; +use selectors::states::*; use std::borrow::ToOwned; use std::cell::Cell; use string_cache::Atom; @@ -57,10 +58,8 @@ enum InputType { pub struct HTMLInputElement { htmlelement: HTMLElement, input_type: Cell<InputType>, - checked: Cell<bool>, checked_changed: Cell<bool>, placeholder: DOMRefCell<DOMString>, - indeterminate: Cell<bool>, value_changed: Cell<bool>, size: Cell<u32>, #[ignore_heap_size_of = "#7193"] @@ -111,9 +110,7 @@ impl HTMLInputElement { HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, localName, prefix, document), input_type: Cell::new(InputType::InputText), - checked: Cell::new(false), placeholder: DOMRefCell::new("".to_owned()), - indeterminate: Cell::new(false), checked_changed: Cell::new(false), value_changed: Cell::new(false), size: Cell::new(DEFAULT_INPUT_SIZE), @@ -204,13 +201,13 @@ impl RawLayoutHTMLInputElementHelpers for HTMLInputElement { #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn get_checked_state_for_layout(&self) -> bool { - self.checked.get() + self.Checked() } #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn get_indeterminate_state_for_layout(&self) -> bool { - self.indeterminate.get() + self.Indeterminate() } #[allow(unrooted_must_root)] @@ -240,7 +237,7 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-input-checked fn Checked(&self) -> bool { - self.checked.get() + self.upcast::<Element>().get_state().contains(IN_CHECKED_STATE) } // https://html.spec.whatwg.org/multipage/#dom-input-checked @@ -329,12 +326,12 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate fn Indeterminate(&self) -> bool { - self.indeterminate.get() + self.upcast::<Element>().get_state().contains(IN_INDETERMINATE_STATE) } // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate fn SetIndeterminate(&self, val: bool) { - self.indeterminate.set(val) + self.upcast::<Element>().set_state(IN_INDETERMINATE_STATE, val) } } @@ -443,7 +440,7 @@ impl HTMLInputElement { } fn update_checked_state(&self, checked: bool, dirty: bool) { - self.checked.set(checked); + self.upcast::<Element>().set_state(IN_CHECKED_STATE, checked); if dirty { self.checked_changed.set(true); @@ -459,7 +456,7 @@ impl HTMLInputElement { } pub fn get_indeterminate_state(&self) -> bool { - self.indeterminate.get() + self.Indeterminate() } // https://html.spec.whatwg.org/multipage/#concept-fe-mutable |