diff options
author | bors-servo <metajack+bors@gmail.com> | 2014-12-16 15:03:49 -0700 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2014-12-16 15:03:49 -0700 |
commit | 5951056973fc0e08e70224214740a274ca8ef20f (patch) | |
tree | a8007d81bb3377bd6803f0b589ed1c69ad3463dd /components/script/dom/element.rs | |
parent | b6a593650bcc33e4188153d135e9a2781a488f96 (diff) | |
parent | e4963869d3820d47865cf5d67a8c13f547061f5e (diff) | |
download | servo-5951056973fc0e08e70224214740a274ca8ef20f.tar.gz servo-5951056973fc0e08e70224214740a274ca8ef20f.zip |
auto merge of #4133 : mttr/servo/form_resetting, r=jdm
We can reset `<input type=text>` fields! I wish I could've done something with checkboxes, but unfortunately, that's it for now.
In addition to that, this PR implements `HTMLInputAttribute.defaultValue`, updates wpt-test to expect passing tests as a result of that implementation, and fixes an index error crash with text inputs.
edit: also includes an html example where one may lazily watch form resets in action: ` tests/html/form_reset_handsfree.html`
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index c3c0b9fcb28..a8beed315fe 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -35,7 +35,7 @@ use dom::event::Event; use dom::eventtarget::{EventTarget, NodeTargetTypeId, EventTargetHelpers}; use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementHelpers}; use dom::htmlcollection::HTMLCollection; -use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers}; +use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers, HTMLInputElementHelpers}; use dom::htmlserializer::serialize; use dom::htmltableelement::{HTMLTableElement, HTMLTableElementHelpers}; use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers}; @@ -212,6 +212,7 @@ pub trait RawLayoutElementHelpers { unsafe fn get_integer_attribute_for_layout(&self, integer_attribute: IntegerAttribute) -> Option<i32>; 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) -> Option<u32>; unsafe fn get_simple_color_attribute_for_layout(&self, attribute: SimpleColorAttribute) @@ -352,6 +353,18 @@ impl RawLayoutElementHelpers for Element { 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, attribute: UnsignedIntegerAttribute) -> Option<u32> { @@ -1289,6 +1302,12 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> { None => false, } } + fn get_indeterminate_state(self) -> bool { + match HTMLInputElementCast::to_ref(self) { + Some(input) => input.get_indeterminate_state(), + None => false, + } + } fn has_class(self, name: &Atom) -> bool { // FIXME(zwarich): Remove this when UFCS lands and there is a better way // of disambiguating methods. |