mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
auto merge of #4002 : Manishearth/servo/activation, r=jdm
Still need to impl `Activatable` on all activatable elements. I'll probably push those changes to this PR, however they can be made separately as well.
This commit is contained in:
commit
19c69b1625
26 changed files with 636 additions and 274 deletions
65
components/script/dom/activation.rs
Normal file
65
components/script/dom/activation.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
|
use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast};
|
||||||
|
use dom::bindings::js::{JSRef, Temporary, OptionalRootable};
|
||||||
|
use dom::element::{Element, ActivationElementHelpers};
|
||||||
|
use dom::event::{Event, EventHelpers};
|
||||||
|
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
||||||
|
use dom::mouseevent::MouseEvent;
|
||||||
|
use dom::node::window_from_node;
|
||||||
|
|
||||||
|
|
||||||
|
/// Trait for elements with defined activation behavior
|
||||||
|
pub trait Activatable : Copy {
|
||||||
|
fn as_element(&self) -> Temporary<Element>;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
|
||||||
|
fn pre_click_activation(&self);
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-canceled-activation-steps
|
||||||
|
fn canceled_activation(&self);
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-post-click-activation-steps
|
||||||
|
fn activation_behavior(&self);
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#implicit-submission
|
||||||
|
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool);
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-synthetic-click-activation-steps
|
||||||
|
fn synthetic_click_activation(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
|
||||||
|
let element = self.as_element().root();
|
||||||
|
// Step 1
|
||||||
|
if element.click_in_progress() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Step 2
|
||||||
|
element.set_click_in_progress(true);
|
||||||
|
// Step 3
|
||||||
|
self.pre_click_activation();
|
||||||
|
|
||||||
|
// Step 4
|
||||||
|
// https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-synthetic-mouse-event
|
||||||
|
let win = window_from_node(*element).root();
|
||||||
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*element);
|
||||||
|
let mouse = MouseEvent::new(*win, "click".to_string(), false, false, Some(*win), 1,
|
||||||
|
0, 0, 0, 0, ctrlKey, shiftKey, altKey, metaKey,
|
||||||
|
0, None).root();
|
||||||
|
let event: JSRef<Event> = EventCast::from_ref(*mouse);
|
||||||
|
event.set_trusted(true);
|
||||||
|
target.dispatch_event_with_target(None, event).ok();
|
||||||
|
|
||||||
|
// Step 5
|
||||||
|
if event.DefaultPrevented() {
|
||||||
|
self.canceled_activation();
|
||||||
|
} else {
|
||||||
|
// post click activation
|
||||||
|
self.activation_behavior();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 6
|
||||||
|
element.set_click_in_progress(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -575,3 +575,24 @@ impl<'a, T: Reflectable> Reflectable for JSRef<'a, T> {
|
||||||
self.deref().reflector()
|
self.deref().reflector()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A trait for comparing smart pointers ignoring the lifetimes
|
||||||
|
pub trait Comparable<T> {
|
||||||
|
fn equals(&self, other: T) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b, T> Comparable<JSRef<'a, T>> for JSRef<'b, T> {
|
||||||
|
fn equals(&self, other: JSRef<'a, T>) -> bool {
|
||||||
|
self.ptr == other.ptr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b, T> Comparable<Option<JSRef<'a, T>>> for Option<JSRef<'b, T>> {
|
||||||
|
fn equals(&self, other: Option<JSRef<'a, T>>) -> bool {
|
||||||
|
match (*self, other) {
|
||||||
|
(Some(x), Some(y)) => x.ptr == y.ptr,
|
||||||
|
(None, None) => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -966,7 +966,6 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
self.ready_state.get()
|
self.ready_state.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
event_handler!(click, GetOnclick, SetOnclick)
|
global_event_handlers!()
|
||||||
event_handler!(load, GetOnload, SetOnload)
|
|
||||||
event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange)
|
event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
//! Element nodes.
|
//! Element nodes.
|
||||||
|
|
||||||
|
use dom::activation::Activatable;
|
||||||
use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpers, AttrHelpersForLayout};
|
use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpers, AttrHelpersForLayout};
|
||||||
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
|
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
|
||||||
use dom::namednodemap::NamedNodeMap;
|
use dom::namednodemap::NamedNodeMap;
|
||||||
|
@ -11,9 +12,10 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding;
|
use dom::bindings::codegen::Bindings::ElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementDerived, HTMLInputElementDerived};
|
use dom::bindings::codegen::InheritTypes::{ElementDerived, HTMLInputElementDerived, HTMLTableCellElementDerived};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTableCellElementDerived, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLInputElementCast, NodeCast, EventTargetCast, ElementCast};
|
||||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, TemporaryPushable};
|
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, TemporaryPushable};
|
||||||
use dom::bindings::js::{OptionalSettable, OptionalRootable, Root};
|
use dom::bindings::js::{OptionalSettable, OptionalRootable, Root};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
@ -24,12 +26,13 @@ use dom::domrect::DOMRect;
|
||||||
use dom::domrectlist::DOMRectList;
|
use dom::domrectlist::DOMRectList;
|
||||||
use dom::document::{Document, DocumentHelpers, LayoutDocumentHelpers};
|
use dom::document::{Document, DocumentHelpers, LayoutDocumentHelpers};
|
||||||
use dom::domtokenlist::DOMTokenList;
|
use dom::domtokenlist::DOMTokenList;
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::event::Event;
|
||||||
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId, EventTargetHelpers};
|
||||||
use dom::htmlcollection::HTMLCollection;
|
use dom::htmlcollection::HTMLCollection;
|
||||||
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
|
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
|
||||||
use dom::htmlserializer::serialize;
|
use dom::htmlserializer::serialize;
|
||||||
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers};
|
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers};
|
||||||
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node};
|
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node, CLICK_IN_PROGRESS};
|
||||||
use dom::node::{window_from_node, LayoutNodeHelpers};
|
use dom::node::{window_from_node, LayoutNodeHelpers};
|
||||||
use dom::nodelist::NodeList;
|
use dom::nodelist::NodeList;
|
||||||
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
||||||
|
@ -1184,3 +1187,92 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait ActivationElementHelpers<'a> {
|
||||||
|
fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a>;
|
||||||
|
fn click_in_progress(self) -> bool;
|
||||||
|
fn set_click_in_progress(self, click: bool);
|
||||||
|
fn nearest_activable_element(self) -> Option<Temporary<Element>>;
|
||||||
|
fn authentic_click_activation<'b>(self, event: JSRef<'b, Event>);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
|
||||||
|
fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a> {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
match node.type_id() {
|
||||||
|
ElementNodeTypeId(HTMLInputElementTypeId) => {
|
||||||
|
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
|
||||||
|
Some(element as &'a Activatable + 'a)
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn click_in_progress(self) -> bool {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
node.get_flag(CLICK_IN_PROGRESS)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_click_in_progress(self, click: bool) {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
node.set_flag(CLICK_IN_PROGRESS, click)
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#nearest-activatable-element
|
||||||
|
fn nearest_activable_element(self) -> Option<Temporary<Element>> {
|
||||||
|
match self.as_maybe_activatable() {
|
||||||
|
Some(el) => Some(Temporary::from_rooted(*el.as_element().root())),
|
||||||
|
None => {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
node.ancestors()
|
||||||
|
.filter_map(|node| ElementCast::to_ref(node))
|
||||||
|
.filter(|e| e.as_maybe_activatable().is_some()).next()
|
||||||
|
.map(|r| Temporary::from_rooted(r))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Please call this method *only* for real click events
|
||||||
|
///
|
||||||
|
/// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
||||||
|
///
|
||||||
|
/// Use an element's synthetic click activation (or handle_event) for any script-triggered clicks.
|
||||||
|
/// If the spec says otherwise, check with Manishearth first
|
||||||
|
fn authentic_click_activation<'b>(self, event: JSRef<'b, Event>) {
|
||||||
|
// Not explicitly part of the spec, however this helps enforce the invariants
|
||||||
|
// required to save state between pre-activation and post-activation
|
||||||
|
// since we cannot nest authentic clicks (unlike synthetic click activation, where
|
||||||
|
// the script can generate more click events from the handler)
|
||||||
|
assert!(!self.click_in_progress());
|
||||||
|
|
||||||
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
|
||||||
|
// Step 2 (requires canvas support)
|
||||||
|
// Step 3
|
||||||
|
self.set_click_in_progress(true);
|
||||||
|
// Step 4
|
||||||
|
let e = self.nearest_activable_element().root();
|
||||||
|
match e {
|
||||||
|
Some(el) => match el.as_maybe_activatable() {
|
||||||
|
Some(elem) => {
|
||||||
|
// Step 5-6
|
||||||
|
elem.pre_click_activation();
|
||||||
|
target.dispatch_event_with_target(None, event).ok();
|
||||||
|
if !event.DefaultPrevented() {
|
||||||
|
// post click activation
|
||||||
|
elem.activation_behavior();
|
||||||
|
} else {
|
||||||
|
elem.canceled_activation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Step 6
|
||||||
|
None => {target.dispatch_event_with_target(None, event).ok();}
|
||||||
|
},
|
||||||
|
// Step 6
|
||||||
|
None => {target.dispatch_event_with_target(None, event).ok();}
|
||||||
|
}
|
||||||
|
// Step 7
|
||||||
|
self.set_click_in_progress(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -245,3 +245,13 @@ impl Reflectable for Event {
|
||||||
&self.reflector_
|
&self.reflector_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait EventHelpers {
|
||||||
|
fn set_trusted(self, trusted: bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> EventHelpers for JSRef<'a, Event> {
|
||||||
|
fn set_trusted(self, trusted: bool) {
|
||||||
|
self.trusted.set(trusted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,14 +7,15 @@ use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::HTMLElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived};
|
||||||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLInputElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementDerived, HTMLBodyElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementDerived, HTMLBodyElementDerived};
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{Element, ElementTypeId, ElementTypeId_, HTMLElementTypeId};
|
use dom::element::{Element, ElementTypeId, ElementTypeId_, HTMLElementTypeId, ActivationElementHelpers};
|
||||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, EventTargetHelpers, NodeTargetTypeId};
|
||||||
use dom::node::{Node, ElementNodeTypeId, window_from_node};
|
use dom::node::{Node, ElementNodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
@ -74,7 +75,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
||||||
make_bool_getter!(Hidden)
|
make_bool_getter!(Hidden)
|
||||||
make_bool_setter!(SetHidden, "hidden")
|
make_bool_setter!(SetHidden, "hidden")
|
||||||
|
|
||||||
event_handler!(click, GetOnclick, SetOnclick)
|
global_event_handlers!(NoOnload)
|
||||||
|
|
||||||
fn GetOnload(self) -> Option<EventHandlerNonNull> {
|
fn GetOnload(self) -> Option<EventHandlerNonNull> {
|
||||||
if self.is_body_or_frameset() {
|
if self.is_body_or_frameset() {
|
||||||
|
@ -91,6 +92,18 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
||||||
win.SetOnload(listener)
|
win.SetOnload(listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
|
||||||
|
fn Click(self) {
|
||||||
|
let maybe_input = HTMLInputElementCast::to_ref(self);
|
||||||
|
match maybe_input {
|
||||||
|
Some(i) if i.Disabled() => return,
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||||
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27430 ?
|
||||||
|
element.as_maybe_activatable().map(|a| a.synthetic_click_activation(false, false, false, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::document::{Document, DocumentHelpers};
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::{Element, AttributeHandlers, HTMLFormElementTypeId, HTMLTextAreaElementTypeId, HTMLDataListElementTypeId};
|
use dom::element::{Element, AttributeHandlers, HTMLFormElementTypeId, HTMLTextAreaElementTypeId, HTMLDataListElementTypeId};
|
||||||
use dom::element::{HTMLInputElementTypeId, HTMLButtonElementTypeId, HTMLObjectElementTypeId, HTMLSelectElementTypeId};
|
use dom::element::{HTMLInputElementTypeId, HTMLButtonElementTypeId, HTMLObjectElementTypeId, HTMLSelectElementTypeId};
|
||||||
use dom::event::{Event, Bubbles, Cancelable};
|
use dom::event::{Event, EventHelpers, Bubbles, Cancelable};
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::htmlinputelement::HTMLInputElement;
|
use dom::htmlinputelement::HTMLInputElement;
|
||||||
|
@ -142,6 +142,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
|
||||||
let event = Event::new(Window(*win),
|
let event = Event::new(Window(*win),
|
||||||
"submit".to_string(),
|
"submit".to_string(),
|
||||||
Bubbles, Cancelable).root();
|
Bubbles, Cancelable).root();
|
||||||
|
event.set_trusted(true);
|
||||||
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
|
||||||
target.DispatchEvent(*event).ok();
|
target.DispatchEvent(*event).ok();
|
||||||
if event.DefaultPrevented() {
|
if event.DefaultPrevented() {
|
||||||
|
@ -410,7 +411,7 @@ impl<'a> FormSubmitter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FormOwner<'a> : Copy {
|
pub trait FormControl<'a> : Copy {
|
||||||
fn form_owner(self) -> Option<Temporary<HTMLFormElement>>;
|
fn form_owner(self) -> Option<Temporary<HTMLFormElement>>;
|
||||||
fn get_form_attribute(self,
|
fn get_form_attribute(self,
|
||||||
attr: &Atom,
|
attr: &Atom,
|
||||||
|
@ -423,4 +424,6 @@ pub trait FormOwner<'a> : Copy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn to_element(self) -> JSRef<'a, Element>;
|
fn to_element(self) -> JSRef<'a, Element>;
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
|
||||||
|
fn mutable(self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,28 +2,31 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom::activation::Activatable;
|
||||||
use dom::attr::{Attr, AttrValue, UIntAttrValue};
|
use dom::attr::{Attr, AttrValue, UIntAttrValue};
|
||||||
use dom::attr::AttrHelpers;
|
use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLInputElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLInputElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLFormElementCast, HTMLInputElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLFormElementCast, HTMLInputElementCast, NodeCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived, EventTargetCast};
|
||||||
use dom::bindings::codegen::InheritTypes::KeyboardEventCast;
|
use dom::bindings::codegen::InheritTypes::KeyboardEventCast;
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable, ResultRootable};
|
use dom::bindings::global::Window;
|
||||||
|
use dom::bindings::js::{Comparable, JS, JSRef, Root, Temporary, OptionalRootable};
|
||||||
|
use dom::bindings::js::{ResultRootable, RootedReference, MutNullableJS};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::document::{Document, DocumentHelpers};
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::{AttributeHandlers, Element, HTMLInputElementTypeId};
|
use dom::element::{AttributeHandlers, Element, HTMLInputElementTypeId};
|
||||||
use dom::element::RawLayoutElementHelpers;
|
use dom::element::{RawLayoutElementHelpers, ActivationElementHelpers};
|
||||||
use dom::event::Event;
|
use dom::event::{Event, Bubbles, NotCancelable, EventHelpers};
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::keyboardevent::KeyboardEvent;
|
use dom::keyboardevent::KeyboardEvent;
|
||||||
use dom::htmlformelement::{InputElement, FormOwner, HTMLFormElement, HTMLFormElementHelpers, NotFromFormSubmitMethod};
|
use dom::htmlformelement::{InputElement, FormControl, HTMLFormElement, HTMLFormElementHelpers, NotFromFormSubmitMethod};
|
||||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node};
|
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use textinput::{Single, TextInput, TriggerDefaultAction, DispatchInput, Nothing};
|
use textinput::{Single, TextInput, TriggerDefaultAction, DispatchInput, Nothing};
|
||||||
|
@ -33,6 +36,7 @@ use string_cache::Atom;
|
||||||
|
|
||||||
use std::ascii::OwnedAsciiExt;
|
use std::ascii::OwnedAsciiExt;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::default::Default;
|
||||||
|
|
||||||
const DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
const DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
||||||
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||||
|
@ -41,7 +45,9 @@ const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||||
#[deriving(PartialEq)]
|
#[deriving(PartialEq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
enum InputType {
|
enum InputType {
|
||||||
InputButton(Option<&'static str>),
|
InputSubmit,
|
||||||
|
InputReset,
|
||||||
|
InputButton,
|
||||||
InputText,
|
InputText,
|
||||||
InputFile,
|
InputFile,
|
||||||
InputImage,
|
InputImage,
|
||||||
|
@ -55,8 +61,34 @@ pub struct HTMLInputElement {
|
||||||
htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
input_type: Cell<InputType>,
|
input_type: Cell<InputType>,
|
||||||
checked: Cell<bool>,
|
checked: Cell<bool>,
|
||||||
|
indeterminate: Cell<bool>,
|
||||||
size: Cell<u32>,
|
size: Cell<u32>,
|
||||||
textinput: DOMRefCell<TextInput>,
|
textinput: DOMRefCell<TextInput>,
|
||||||
|
activation_state: DOMRefCell<InputActivationState>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[jstraceable]
|
||||||
|
#[must_root]
|
||||||
|
struct InputActivationState {
|
||||||
|
indeterminate: bool,
|
||||||
|
checked: bool,
|
||||||
|
checked_radio: MutNullableJS<HTMLInputElement>,
|
||||||
|
// In case mutability changed
|
||||||
|
was_mutable: bool,
|
||||||
|
// In case the type changed
|
||||||
|
old_type: InputType,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InputActivationState {
|
||||||
|
fn new() -> InputActivationState {
|
||||||
|
InputActivationState {
|
||||||
|
indeterminate: false,
|
||||||
|
checked: false,
|
||||||
|
checked_radio: Default::default(),
|
||||||
|
was_mutable: false,
|
||||||
|
old_type: InputText
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLInputElementDerived for EventTarget {
|
impl HTMLInputElementDerived for EventTarget {
|
||||||
|
@ -73,8 +105,10 @@ impl HTMLInputElement {
|
||||||
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, prefix, document),
|
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, prefix, document),
|
||||||
input_type: Cell::new(InputText),
|
input_type: Cell::new(InputText),
|
||||||
checked: Cell::new(false),
|
checked: Cell::new(false),
|
||||||
|
indeterminate: Cell::new(false),
|
||||||
size: Cell::new(DEFAULT_INPUT_SIZE),
|
size: Cell::new(DEFAULT_INPUT_SIZE),
|
||||||
textinput: DOMRefCell::new(TextInput::new(Single, "".to_string())),
|
textinput: DOMRefCell::new(TextInput::new(Single, "".to_string())),
|
||||||
|
activation_state: DOMRefCell::new(InputActivationState::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +144,9 @@ impl LayoutHTMLInputElementHelpers for JS<HTMLInputElement> {
|
||||||
match (*self.unsafe_get()).input_type.get() {
|
match (*self.unsafe_get()).input_type.get() {
|
||||||
InputCheckbox | InputRadio => "".to_string(),
|
InputCheckbox | InputRadio => "".to_string(),
|
||||||
InputFile | InputImage => "".to_string(),
|
InputFile | InputImage => "".to_string(),
|
||||||
InputButton(ref default) => get_raw_attr_value(self)
|
InputButton => get_raw_attr_value(self).unwrap_or_else(|| "".to_string()),
|
||||||
.or_else(|| default.map(|v| v.to_string()))
|
InputSubmit => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_SUBMIT_VALUE.to_string()),
|
||||||
.unwrap_or_else(|| "".to_string()),
|
InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_string()),
|
||||||
InputPassword => {
|
InputPassword => {
|
||||||
let raw = get_raw_textinput_value(self);
|
let raw = get_raw_textinput_value(self);
|
||||||
String::from_char(raw.char_len(), '●')
|
String::from_char(raw.char_len(), '●')
|
||||||
|
@ -149,6 +183,12 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-checked
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-checked
|
||||||
make_bool_setter!(SetChecked, "checked")
|
make_bool_setter!(SetChecked, "checked")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-readonly
|
||||||
|
make_bool_getter!(ReadOnly)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-readonly
|
||||||
|
make_bool_setter!(SetReadOnly, "readonly")
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-size
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-size
|
||||||
make_uint_getter!(Size)
|
make_uint_getter!(Size)
|
||||||
|
|
||||||
|
@ -194,7 +234,7 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
|
||||||
make_setter!(SetFormEnctype, "formenctype")
|
make_setter!(SetFormEnctype, "formenctype")
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formmethod
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formmethod
|
||||||
make_enumerated_getter!(FormMethod, "get", "post" | "dialog")
|
make_enumerated_getter!(FormMethod, "get", "post" | "dialog")
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formmethod
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formmethod
|
||||||
make_setter!(SetFormMethod, "formmethod")
|
make_setter!(SetFormMethod, "formmethod")
|
||||||
|
@ -204,34 +244,59 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formtarget
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formtarget
|
||||||
make_setter!(SetFormTarget, "formtarget")
|
make_setter!(SetFormTarget, "formtarget")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-indeterminate
|
||||||
|
fn Indeterminate(self) -> bool {
|
||||||
|
self.indeterminate.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-indeterminate
|
||||||
|
fn SetIndeterminate(self, val: bool) {
|
||||||
|
// FIXME #4079 this should change the appearance
|
||||||
|
self.indeterminate.set(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HTMLInputElementHelpers {
|
pub trait HTMLInputElementHelpers {
|
||||||
fn force_relayout(self);
|
fn force_relayout(self);
|
||||||
fn radio_group_updated(self, group: Option<&str>);
|
fn radio_group_updated(self, group: Option<&str>);
|
||||||
fn get_radio_group(self) -> Option<String>;
|
fn get_radio_group_name(self) -> Option<String>;
|
||||||
fn update_checked_state(self, checked: bool);
|
fn update_checked_state(self, checked: bool);
|
||||||
fn get_size(&self) -> u32;
|
fn get_size(&self) -> u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&str>) {
|
fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&str>) {
|
||||||
//TODO: if not in document, use root ancestor instead of document
|
//TODO: if not in document, use root ancestor instead of document
|
||||||
|
let owner = broadcaster.form_owner().root();
|
||||||
let doc = document_from_node(broadcaster).root();
|
let doc = document_from_node(broadcaster).root();
|
||||||
let radios = doc.QuerySelectorAll("input[type=\"radio\"]".to_string()).unwrap().root();
|
let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
|
||||||
let mut i = 0;
|
|
||||||
while i < radios.Length() {
|
// There is no DOM tree manipulation here, so this is safe
|
||||||
let node = radios.Item(i).unwrap().root();
|
let mut iter = unsafe {
|
||||||
let radio: JSRef<HTMLInputElement> = HTMLInputElementCast::to_ref(*node).unwrap();
|
doc_node.query_selector_iter("input[type=radio]".to_string()).unwrap()
|
||||||
if radio != broadcaster {
|
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
||||||
//TODO: determine form owner
|
.filter(|&r| in_same_group(r, owner.root_ref(), group) && broadcaster != r)
|
||||||
let other_group = radio.get_radio_group();
|
};
|
||||||
//TODO: ensure compatibility caseless match (https://html.spec.whatwg.org/multipage/infrastructure.html#compatibility-caseless)
|
for r in iter {
|
||||||
let group_matches = other_group.as_ref().map(|group| group.as_slice()) == group.as_ref().map(|&group| &*group);
|
if r.Checked() {
|
||||||
if group_matches && radio.Checked() {
|
r.SetChecked(false);
|
||||||
radio.SetChecked(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
i += 1;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn in_same_group<'a,'b>(other: JSRef<'a, HTMLInputElement>,
|
||||||
|
owner: Option<JSRef<'b, HTMLFormElement>>,
|
||||||
|
group: Option<&str>) -> bool {
|
||||||
|
let other_owner = other.form_owner().root();
|
||||||
|
let other_owner = other_owner.root_ref();
|
||||||
|
other.input_type.get() == InputRadio &&
|
||||||
|
// TODO Both a and b are in the same home subtree.
|
||||||
|
other_owner.equals(owner) &&
|
||||||
|
// TODO should be a unicode compatibility caseless match
|
||||||
|
match (other.get_radio_group_name(), group) {
|
||||||
|
(Some(ref s1), Some(s2)) => s1.as_slice() == s2,
|
||||||
|
(None, None) => true,
|
||||||
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,8 +313,7 @@ impl<'a> HTMLInputElementHelpers for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-group
|
fn get_radio_group_name(self) -> Option<String> {
|
||||||
fn get_radio_group(self) -> Option<String> {
|
|
||||||
//TODO: determine form owner
|
//TODO: determine form owner
|
||||||
let elem: JSRef<Element> = ElementCast::from_ref(self);
|
let elem: JSRef<Element> = ElementCast::from_ref(self);
|
||||||
elem.get_attribute(ns!(""), &atom!("name"))
|
elem.get_attribute(ns!(""), &atom!("name"))
|
||||||
|
@ -261,7 +325,7 @@ impl<'a> HTMLInputElementHelpers for JSRef<'a, HTMLInputElement> {
|
||||||
self.checked.set(checked);
|
self.checked.set(checked);
|
||||||
if self.input_type.get() == InputRadio && checked {
|
if self.input_type.get() == InputRadio && checked {
|
||||||
broadcast_radio_checked(self,
|
broadcast_radio_checked(self,
|
||||||
self.get_radio_group()
|
self.get_radio_group_name()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|group| group.as_slice()));
|
.map(|group| group.as_slice()));
|
||||||
}
|
}
|
||||||
|
@ -305,9 +369,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
&atom!("type") => {
|
&atom!("type") => {
|
||||||
let value = attr.value();
|
let value = attr.value();
|
||||||
self.input_type.set(match value.as_slice() {
|
self.input_type.set(match value.as_slice() {
|
||||||
"button" => InputButton(None),
|
"button" => InputButton,
|
||||||
"submit" => InputButton(Some(DEFAULT_SUBMIT_VALUE)),
|
"submit" => InputSubmit,
|
||||||
"reset" => InputButton(Some(DEFAULT_RESET_VALUE)),
|
"reset" => InputReset,
|
||||||
"file" => InputFile,
|
"file" => InputFile,
|
||||||
"radio" => InputRadio,
|
"radio" => InputRadio,
|
||||||
"checkbox" => InputCheckbox,
|
"checkbox" => InputCheckbox,
|
||||||
|
@ -315,7 +379,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
_ => InputText,
|
_ => InputText,
|
||||||
});
|
});
|
||||||
if self.input_type.get() == InputRadio {
|
if self.input_type.get() == InputRadio {
|
||||||
self.radio_group_updated(self.get_radio_group()
|
self.radio_group_updated(self.get_radio_group_name()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|group| group.as_slice()));
|
.map(|group| group.as_slice()));
|
||||||
}
|
}
|
||||||
|
@ -358,7 +422,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
&atom!("type") => {
|
&atom!("type") => {
|
||||||
if self.input_type.get() == InputRadio {
|
if self.input_type.get() == InputRadio {
|
||||||
broadcast_radio_checked(*self,
|
broadcast_radio_checked(*self,
|
||||||
self.get_radio_group()
|
self.get_radio_group_name()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|group| group.as_slice()));
|
.map(|group| group.as_slice()));
|
||||||
}
|
}
|
||||||
|
@ -419,16 +483,13 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
|
|
||||||
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
||||||
match self.input_type.get() {
|
match self.input_type.get() {
|
||||||
InputCheckbox => self.SetChecked(!self.checked.get()),
|
|
||||||
InputRadio => self.SetChecked(true),
|
InputRadio => self.SetChecked(true),
|
||||||
InputButton(Some(DEFAULT_SUBMIT_VALUE)) => {
|
|
||||||
self.form_owner().map(|o| {
|
|
||||||
o.root().submit(NotFromFormSubmitMethod, InputElement(self.clone()))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Dispatch events for non activatable inputs
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#common-input-element-events
|
||||||
|
|
||||||
//TODO: set the editing position for text inputs
|
//TODO: set the editing position for text inputs
|
||||||
|
|
||||||
let doc = document_from_node(*self).root();
|
let doc = document_from_node(*self).root();
|
||||||
|
@ -455,7 +516,7 @@ impl Reflectable for HTMLInputElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FormOwner<'a> for JSRef<'a, HTMLInputElement> {
|
impl<'a> FormControl<'a> for JSRef<'a, HTMLInputElement> {
|
||||||
// FIXME: This is wrong (https://github.com/servo/servo/issues/3553)
|
// FIXME: This is wrong (https://github.com/servo/servo/issues/3553)
|
||||||
// but we need html5ever to do it correctly
|
// but we need html5ever to do it correctly
|
||||||
fn form_owner(self) -> Option<Temporary<HTMLFormElement>> {
|
fn form_owner(self) -> Option<Temporary<HTMLFormElement>> {
|
||||||
|
@ -483,4 +544,168 @@ impl<'a> FormOwner<'a> for JSRef<'a, HTMLInputElement> {
|
||||||
fn to_element(self) -> JSRef<'a, Element> {
|
fn to_element(self) -> JSRef<'a, Element> {
|
||||||
ElementCast::from_ref(self)
|
ElementCast::from_ref(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
|
||||||
|
fn mutable(self) -> bool {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-mutable
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:concept-fe-mutable
|
||||||
|
!(self.Disabled() || self.ReadOnly())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
|
||||||
|
fn as_element(&self) -> Temporary<Element> {
|
||||||
|
Temporary::from_rooted(ElementCast::from_ref(*self))
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
|
||||||
|
fn pre_click_activation(&self) {
|
||||||
|
let mut cache = self.activation_state.borrow_mut();
|
||||||
|
let ty = self.input_type.get();
|
||||||
|
cache.old_type = ty;
|
||||||
|
cache.was_mutable = self.mutable();
|
||||||
|
if cache.was_mutable {
|
||||||
|
match ty {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#submit-button-state-(type=submit):activation-behavior
|
||||||
|
// InputSubmit => (), // No behavior defined
|
||||||
|
InputCheckbox => {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):pre-click-activation-steps
|
||||||
|
// cache current values of `checked` and `indeterminate`
|
||||||
|
// we may need to restore them later
|
||||||
|
cache.indeterminate = self.Indeterminate();
|
||||||
|
cache.checked = self.Checked();
|
||||||
|
self.SetIndeterminate(false);
|
||||||
|
self.SetChecked(!cache.checked);
|
||||||
|
},
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):pre-click-activation-steps
|
||||||
|
InputRadio => {
|
||||||
|
//TODO: if not in document, use root ancestor instead of document
|
||||||
|
let owner = self.form_owner().root();
|
||||||
|
let doc = document_from_node(*self).root();
|
||||||
|
let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
|
||||||
|
let group = self.get_radio_group_name();;
|
||||||
|
|
||||||
|
// Safe since we only manipulate the DOM tree after finding an element
|
||||||
|
let checked_member = unsafe {
|
||||||
|
doc_node.query_selector_iter("input[type=radio]".to_string()).unwrap()
|
||||||
|
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
||||||
|
.filter(|&r| in_same_group(r, owner.root_ref(),
|
||||||
|
group.as_ref().map(|gr| gr.as_slice())))
|
||||||
|
.find(|r| r.Checked())
|
||||||
|
};
|
||||||
|
cache.checked_radio.assign(checked_member);
|
||||||
|
self.SetChecked(true);
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-canceled-activation-steps
|
||||||
|
fn canceled_activation(&self) {
|
||||||
|
let cache = self.activation_state.borrow();
|
||||||
|
let ty = self.input_type.get();
|
||||||
|
if cache.old_type != ty {
|
||||||
|
// Type changed, abandon ship
|
||||||
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27414
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match ty {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#submit-button-state-(type=submit):activation-behavior
|
||||||
|
// InputSubmit => (), // No behavior defined
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):canceled-activation-steps
|
||||||
|
InputCheckbox => {
|
||||||
|
// We want to restore state only if the element had been changed in the first place
|
||||||
|
if cache.was_mutable {
|
||||||
|
self.SetIndeterminate(cache.indeterminate);
|
||||||
|
self.SetChecked(cache.checked);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):canceled-activation-steps
|
||||||
|
InputRadio => {
|
||||||
|
// We want to restore state only if the element had been changed in the first place
|
||||||
|
if cache.was_mutable {
|
||||||
|
let old_checked: Option<Root<HTMLInputElement>> = cache.checked_radio.get().root();
|
||||||
|
let name = self.get_radio_group_name();
|
||||||
|
match old_checked {
|
||||||
|
Some(o) => {
|
||||||
|
// Avoiding iterating through the whole tree here, instead
|
||||||
|
// we can check if the conditions for radio group siblings apply
|
||||||
|
if name == o.get_radio_group_name() && // TODO should be compatibility caseless
|
||||||
|
self.form_owner() == o.form_owner() &&
|
||||||
|
// TODO Both a and b are in the same home subtree
|
||||||
|
o.input_type.get() == InputRadio {
|
||||||
|
o.SetChecked(true);
|
||||||
|
} else {
|
||||||
|
self.SetChecked(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => self.SetChecked(false)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-post-click-activation-steps
|
||||||
|
fn activation_behavior(&self) {
|
||||||
|
let ty = self.input_type.get();
|
||||||
|
if self.activation_state.borrow().old_type != ty {
|
||||||
|
// Type changed, abandon ship
|
||||||
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27414
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match ty {
|
||||||
|
InputSubmit => {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#submit-button-state-(type=submit):activation-behavior
|
||||||
|
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||||
|
if self.mutable() /* and document owner is fully active */ {
|
||||||
|
self.form_owner().map(|o| {
|
||||||
|
o.root().submit(NotFromFormSubmitMethod, InputElement(self.clone()))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
InputCheckbox | InputRadio => {
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):activation-behavior
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):activation-behavior
|
||||||
|
if self.mutable() {
|
||||||
|
let win = window_from_node(*self).root();
|
||||||
|
let event = Event::new(Window(*win),
|
||||||
|
"input".to_string(),
|
||||||
|
Bubbles, NotCancelable).root();
|
||||||
|
event.set_trusted(true);
|
||||||
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
|
||||||
|
target.DispatchEvent(*event).ok();
|
||||||
|
|
||||||
|
let event = Event::new(Window(*win),
|
||||||
|
"change".to_string(),
|
||||||
|
Bubbles, NotCancelable).root();
|
||||||
|
event.set_trusted(true);
|
||||||
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
|
||||||
|
target.DispatchEvent(*event).ok();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#implicit-submission
|
||||||
|
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
|
||||||
|
let doc = document_from_node(*self).root();
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(*doc);
|
||||||
|
let owner = self.form_owner();
|
||||||
|
if owner.is_none() || ElementCast::from_ref(*self).click_in_progress() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// This is safe because we are stopping after finding the first element
|
||||||
|
// and only then performing actions which may modify the DOM tree
|
||||||
|
unsafe {
|
||||||
|
node.query_selector_iter("input[type=submit]".to_string()).unwrap()
|
||||||
|
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
||||||
|
.find(|r| r.form_owner() == owner)
|
||||||
|
.map(|s| s.synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,3 +211,19 @@ macro_rules! error_event_handler(
|
||||||
define_event_handler!(OnErrorEventHandlerNonNull, $event_type, $getter, $setter)
|
define_event_handler!(OnErrorEventHandlerNonNull, $event_type, $getter, $setter)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
|
||||||
|
// see webidls/EventHandler.webidl
|
||||||
|
// As more methods get added, just update them here.
|
||||||
|
macro_rules! global_event_handlers(
|
||||||
|
() => (
|
||||||
|
event_handler!(load, GetOnload, SetOnload)
|
||||||
|
global_event_handlers!(NoOnload)
|
||||||
|
|
||||||
|
);
|
||||||
|
(NoOnload) => (
|
||||||
|
event_handler!(click, GetOnclick, SetOnclick)
|
||||||
|
event_handler!(input, GetOninput, SetOninput)
|
||||||
|
event_handler!(change, GetOnchange, SetOnchange)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -50,7 +50,7 @@ use devtools_traits::NodeInfo;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
use servo_util::str::{DOMString, null_str_as_empty};
|
use servo_util::str::{DOMString, null_str_as_empty};
|
||||||
use style::{parse_selector_list_from_str, matches};
|
use style::{parse_selector_list_from_str, matches, SelectorList};
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime};
|
use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime};
|
||||||
use js::jsfriendapi;
|
use js::jsfriendapi;
|
||||||
|
@ -124,7 +124,7 @@ impl NodeDerived for EventTarget {
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[doc = "Flags for node items."]
|
#[doc = "Flags for node items."]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
flags NodeFlags: u8 {
|
flags NodeFlags: u16 {
|
||||||
#[doc = "Specifies whether this node is in a document."]
|
#[doc = "Specifies whether this node is in a document."]
|
||||||
const IS_IN_DOC = 0x01,
|
const IS_IN_DOC = 0x01,
|
||||||
#[doc = "Specifies whether this node is in hover state."]
|
#[doc = "Specifies whether this node is in hover state."]
|
||||||
|
@ -143,6 +143,12 @@ bitflags! {
|
||||||
#[doc = "Specifies whether this node has descendants (inclusive of itself) which \
|
#[doc = "Specifies whether this node has descendants (inclusive of itself) which \
|
||||||
have changed since the last reflow."]
|
have changed since the last reflow."]
|
||||||
const HAS_DIRTY_DESCENDANTS = 0x80,
|
const HAS_DIRTY_DESCENDANTS = 0x80,
|
||||||
|
// TODO: find a better place to keep this (#4105)
|
||||||
|
// https://critic.hoppipolla.co.uk/showcomment?chain=8873
|
||||||
|
// Perhaps using a Set in Document?
|
||||||
|
#[doc = "Specifies whether or not there is an authentic click in progress on \
|
||||||
|
this element."]
|
||||||
|
const CLICK_IN_PROGRESS = 0x100,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,6 +383,29 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct QuerySelectorIterator<'a> {
|
||||||
|
selectors: SelectorList,
|
||||||
|
iterator: TreeIterator<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> QuerySelectorIterator<'a> {
|
||||||
|
unsafe fn new(iter: TreeIterator<'a>, selectors: SelectorList) -> QuerySelectorIterator<'a> {
|
||||||
|
QuerySelectorIterator {
|
||||||
|
selectors: selectors,
|
||||||
|
iterator: iter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator<JSRef<'a, Node>> for QuerySelectorIterator<'a> {
|
||||||
|
fn next(&mut self) -> Option<JSRef<'a, Node>> {
|
||||||
|
let selectors = &self.selectors;
|
||||||
|
// TODO(cgaebel): Is it worth it to build a bloom filter here
|
||||||
|
// (instead of passing `None`)? Probably.
|
||||||
|
self.iterator.find(|node| node.is_element() && matches(selectors, node, &mut None))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait NodeHelpers<'a> {
|
pub trait NodeHelpers<'a> {
|
||||||
fn ancestors(self) -> AncestorIterator<'a>;
|
fn ancestors(self) -> AncestorIterator<'a>;
|
||||||
fn children(self) -> NodeChildrenIterator<'a>;
|
fn children(self) -> NodeChildrenIterator<'a>;
|
||||||
|
@ -449,6 +478,7 @@ pub trait NodeHelpers<'a> {
|
||||||
fn get_content_boxes(self) -> Vec<Rect<Au>>;
|
fn get_content_boxes(self) -> Vec<Rect<Au>>;
|
||||||
|
|
||||||
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
|
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
|
||||||
|
unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator<'a>>;
|
||||||
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
||||||
|
|
||||||
fn remove_self(self);
|
fn remove_self(self);
|
||||||
|
@ -719,8 +749,10 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
/// Get an iterator over all nodes which match a set of selectors
|
||||||
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
|
/// Be careful not to do anything which may manipulate the DOM tree whilst iterating, otherwise
|
||||||
|
/// the iterator may be invalidated
|
||||||
|
unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator<'a>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let nodes;
|
let nodes;
|
||||||
let root = self.ancestors().last().unwrap_or(self.clone());
|
let root = self.ancestors().last().unwrap_or(self.clone());
|
||||||
|
@ -728,17 +760,25 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Err(()) => return Err(Syntax),
|
Err(()) => return Err(Syntax),
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Ok(ref selectors) => {
|
Ok(selectors) => {
|
||||||
nodes = root.traverse_preorder().filter(
|
nodes = QuerySelectorIterator::new(root.traverse_preorder(), selectors);
|
||||||
// TODO(cgaebel): Is it worth it to build a bloom filter here
|
|
||||||
// (instead of passing `None`)? Probably.
|
|
||||||
|node| node.is_element() && matches(selectors, node, &mut None)).collect()
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
let window = window_from_node(self).root();
|
Ok(nodes)
|
||||||
Ok(NodeList::new_simple_list(*window, nodes))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
|
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
|
||||||
|
// Step 1.
|
||||||
|
unsafe {
|
||||||
|
self.query_selector_iter(selectors).map(|mut iter| {
|
||||||
|
let window = window_from_node(self).root();
|
||||||
|
NodeList::new_simple_list(*window, iter.collect())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn ancestors(self) -> AncestorIterator<'a> {
|
fn ancestors(self) -> AncestorIterator<'a> {
|
||||||
AncestorIterator {
|
AncestorIterator {
|
||||||
current: self.parent_node.get().map(|node| (*node.root()).clone()),
|
current: self.parent_node.get().map(|node| (*node.root()).clone()),
|
||||||
|
|
|
@ -23,6 +23,8 @@ typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
|
||||||
interface GlobalEventHandlers {
|
interface GlobalEventHandlers {
|
||||||
attribute EventHandler onclick;
|
attribute EventHandler onclick;
|
||||||
attribute EventHandler onload;
|
attribute EventHandler onload;
|
||||||
|
attribute EventHandler oninput;
|
||||||
|
attribute EventHandler onchange;
|
||||||
};
|
};
|
||||||
|
|
||||||
[NoInterfaceObject]
|
[NoInterfaceObject]
|
||||||
|
|
|
@ -23,7 +23,7 @@ interface HTMLElement : Element {
|
||||||
|
|
||||||
// user interaction
|
// user interaction
|
||||||
attribute boolean hidden;
|
attribute boolean hidden;
|
||||||
//void click();
|
void click();
|
||||||
// attribute long tabIndex;
|
// attribute long tabIndex;
|
||||||
//void focus();
|
//void focus();
|
||||||
//void blur();
|
//void blur();
|
||||||
|
|
|
@ -21,7 +21,7 @@ interface HTMLInputElement : HTMLElement {
|
||||||
// attribute boolean formNoValidate;
|
// attribute boolean formNoValidate;
|
||||||
attribute DOMString formTarget;
|
attribute DOMString formTarget;
|
||||||
// attribute unsigned long height;
|
// attribute unsigned long height;
|
||||||
// attribute boolean indeterminate;
|
attribute boolean indeterminate;
|
||||||
// attribute DOMString inputMode;
|
// attribute DOMString inputMode;
|
||||||
//readonly attribute HTMLElement? list;
|
//readonly attribute HTMLElement? list;
|
||||||
// attribute DOMString max;
|
// attribute DOMString max;
|
||||||
|
@ -32,7 +32,7 @@ interface HTMLInputElement : HTMLElement {
|
||||||
attribute DOMString name;
|
attribute DOMString name;
|
||||||
// attribute DOMString pattern;
|
// attribute DOMString pattern;
|
||||||
// attribute DOMString placeholder;
|
// attribute DOMString placeholder;
|
||||||
// attribute boolean readOnly;
|
attribute boolean readOnly;
|
||||||
// attribute boolean required;
|
// attribute boolean required;
|
||||||
attribute unsigned long size;
|
attribute unsigned long size;
|
||||||
// attribute DOMString src;
|
// attribute DOMString src;
|
||||||
|
|
|
@ -270,8 +270,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
self.performance.or_init(|| Performance::new(self))
|
self.performance.or_init(|| Performance::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
event_handler!(click, GetOnclick, SetOnclick)
|
global_event_handlers!()
|
||||||
event_handler!(load, GetOnload, SetOnload)
|
|
||||||
event_handler!(unload, GetOnunload, SetOnunload)
|
event_handler!(unload, GetOnunload, SetOnunload)
|
||||||
error_event_handler!(error, GetOnerror, SetOnerror)
|
error_event_handler!(error, GetOnerror, SetOnerror)
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ pub mod dom {
|
||||||
#[path="bindings/codegen/InterfaceTypes.rs"]
|
#[path="bindings/codegen/InterfaceTypes.rs"]
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
pub mod activation;
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod blob;
|
pub mod blob;
|
||||||
pub mod browsercontext;
|
pub mod browsercontext;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, Documen
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, EventCast};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, NodeCast, EventCast};
|
||||||
use dom::bindings::conversions::{FromJSValConvertible, Empty};
|
use dom::bindings::conversions::{FromJSValConvertible, Empty};
|
||||||
use dom::bindings::global;
|
use dom::bindings::global;
|
||||||
use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalRootable};
|
use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalRootable};
|
||||||
|
@ -18,8 +18,8 @@ use dom::bindings::trace::JSTraceable;
|
||||||
use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap};
|
use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap};
|
||||||
use dom::document::{Document, HTMLDocument, DocumentHelpers, FromParser};
|
use dom::document::{Document, HTMLDocument, DocumentHelpers, FromParser};
|
||||||
use dom::element::{Element, HTMLButtonElementTypeId, HTMLInputElementTypeId};
|
use dom::element::{Element, HTMLButtonElementTypeId, HTMLInputElementTypeId};
|
||||||
use dom::element::{HTMLSelectElementTypeId, HTMLTextAreaElementTypeId, HTMLOptionElementTypeId};
|
use dom::element::{HTMLSelectElementTypeId, HTMLTextAreaElementTypeId, HTMLOptionElementTypeId, ActivationElementHelpers};
|
||||||
use dom::event::{Event, Bubbles, DoesNotBubble, Cancelable, NotCancelable};
|
use dom::event::{Event, EventHelpers, Bubbles, DoesNotBubble, Cancelable, NotCancelable};
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
||||||
use dom::keyboardevent::KeyboardEvent;
|
use dom::keyboardevent::KeyboardEvent;
|
||||||
|
@ -893,9 +893,10 @@ impl ScriptTask {
|
||||||
None, props.key_code).root();
|
None, props.key_code).root();
|
||||||
let event = EventCast::from_ref(*keyevent);
|
let event = EventCast::from_ref(*keyevent);
|
||||||
let _ = target.DispatchEvent(event);
|
let _ = target.DispatchEvent(event);
|
||||||
|
let mut prevented = event.DefaultPrevented();
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys-cancelable-keys
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys-cancelable-keys
|
||||||
if state != Released && props.is_printable() && !event.DefaultPrevented() {
|
if state != Released && props.is_printable() && !prevented {
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keypress-event-order
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keypress-event-order
|
||||||
let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window),
|
let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window),
|
||||||
0, props.key.to_string(), props.code.to_string(),
|
0, props.key.to_string(), props.code.to_string(),
|
||||||
|
@ -904,9 +905,28 @@ impl ScriptTask {
|
||||||
props.char_code, 0).root();
|
props.char_code, 0).root();
|
||||||
let _ = target.DispatchEvent(EventCast::from_ref(*event));
|
let _ = target.DispatchEvent(EventCast::from_ref(*event));
|
||||||
|
|
||||||
|
let ev = EventCast::from_ref(*event);
|
||||||
|
prevented = ev.DefaultPrevented();
|
||||||
// TODO: if keypress event is canceled, prevent firing input events
|
// TODO: if keypress event is canceled, prevent firing input events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This behavior is unspecced
|
||||||
|
// We are supposed to dispatch synthetic click activation for Space and/or Return,
|
||||||
|
// however *when* we do it is up to us
|
||||||
|
// I'm dispatching it after the key event so the script has a chance to cancel it
|
||||||
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27337
|
||||||
|
match key {
|
||||||
|
Key::KeySpace if !prevented && state == Released => {
|
||||||
|
let maybe_elem: Option<JSRef<Element>> = ElementCast::to_ref(target);
|
||||||
|
maybe_elem.map(|el| el.as_maybe_activatable().map(|a| a.synthetic_click_activation(ctrl, alt, shift, meta)));
|
||||||
|
}
|
||||||
|
Key::KeyEnter if !prevented && state == Released => {
|
||||||
|
let maybe_elem: Option<JSRef<Element>> = ElementCast::to_ref(target);
|
||||||
|
maybe_elem.map(|el| el.as_maybe_activatable().map(|a| a.implicit_submission(ctrl, alt, shift, meta)));
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
|
||||||
window.flush_layout();
|
window.flush_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,8 +1038,11 @@ impl ScriptTask {
|
||||||
Event::new(global::Window(*window),
|
Event::new(global::Window(*window),
|
||||||
"click".to_string(),
|
"click".to_string(),
|
||||||
Bubbles, Cancelable).root();
|
Bubbles, Cancelable).root();
|
||||||
let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(node);
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events
|
||||||
let _ = eventtarget.dispatch_event_with_target(None, *event);
|
event.set_trusted(true);
|
||||||
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
||||||
|
let el = ElementCast::to_ref(node).unwrap(); // is_element() check already exists above
|
||||||
|
el.authentic_click_activation(*event);
|
||||||
|
|
||||||
doc.commit_focus_transaction();
|
doc.commit_focus_transaction();
|
||||||
window.flush_layout();
|
window.flush_layout();
|
||||||
|
|
31
tests/html/test-synthetic-click-activation.html
Normal file
31
tests/html/test-synthetic-click-activation.html
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
<form action="http://example.com" method="get">
|
||||||
|
<div><input type="checkbox"></div>
|
||||||
|
<div><input type="submit"><input type="reset"></div>
|
||||||
|
<div><input type="checkbox"></div>
|
||||||
|
<div><input type="checkbox" checked></div>
|
||||||
|
<div>group 1
|
||||||
|
<div><input type="radio"></div>
|
||||||
|
<div><input type="radio" checked></div>
|
||||||
|
</div>
|
||||||
|
<div>group 2
|
||||||
|
<div><input type="radio" name="a" checked></div>
|
||||||
|
<div><input type="radio" name="a"></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
Use the buttons below to shift "fake" focus and trigger click events. The first form widget is initually focused.
|
||||||
|
<br>
|
||||||
|
<button type=button id="left">Shift fake focus left</button><br>
|
||||||
|
<button type=button id="right">Shift fake focus right</button><br>
|
||||||
|
<button type=button id="click">Trigger synthetic click</button><br>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
i = 0;
|
||||||
|
tags = document.getElementsByTagName("input");
|
||||||
|
document.getElementById("left").onclick=function(){i--;}
|
||||||
|
document.getElementById("right").onclick=function(){i++;}
|
||||||
|
document.getElementById("click").onclick=function(){tags[i].click()}
|
||||||
|
</script>
|
|
@ -120,9 +120,6 @@
|
||||||
[Document interface: attribute oncanplaythrough]
|
[Document interface: attribute oncanplaythrough]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: attribute onchange]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: attribute onclose]
|
[Document interface: attribute onclose]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -174,9 +171,6 @@
|
||||||
[Document interface: attribute onfocus]
|
[Document interface: attribute onfocus]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: attribute oninput]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: attribute oninvalid]
|
[Document interface: attribute oninvalid]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -984,9 +978,6 @@
|
||||||
[HTMLElement interface: attribute itemValue]
|
[HTMLElement interface: attribute itemValue]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: operation click()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: attribute tabIndex]
|
[HTMLElement interface: attribute tabIndex]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1062,9 +1053,6 @@
|
||||||
[HTMLElement interface: attribute oncanplaythrough]
|
[HTMLElement interface: attribute oncanplaythrough]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: attribute onchange]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: attribute onclose]
|
[HTMLElement interface: attribute onclose]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1116,9 +1104,6 @@
|
||||||
[HTMLElement interface: attribute onfocus]
|
[HTMLElement interface: attribute onfocus]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: attribute oninput]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: attribute oninvalid]
|
[HTMLElement interface: attribute oninvalid]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1254,9 +1239,6 @@
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "itemValue" with the proper type (11)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "itemValue" with the proper type (11)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "click" with the proper type (13)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "tabIndex" with the proper type (14)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "tabIndex" with the proper type (14)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1332,9 +1314,6 @@
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "oncanplaythrough" with the proper type (38)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "oncanplaythrough" with the proper type (38)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onchange" with the proper type (39)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onclose" with the proper type (41)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "onclose" with the proper type (41)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1386,9 +1365,6 @@
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onfocus" with the proper type (57)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "onfocus" with the proper type (57)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "oninput" with the proper type (58)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "oninvalid" with the proper type (59)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "oninvalid" with the proper type (59)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -4800,9 +4776,6 @@
|
||||||
[HTMLInputElement interface: attribute height]
|
[HTMLInputElement interface: attribute height]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLInputElement interface: attribute indeterminate]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLInputElement interface: attribute inputMode]
|
[HTMLInputElement interface: attribute inputMode]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -4830,9 +4803,6 @@
|
||||||
[HTMLInputElement interface: attribute placeholder]
|
[HTMLInputElement interface: attribute placeholder]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLInputElement interface: attribute readOnly]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLInputElement interface: attribute required]
|
[HTMLInputElement interface: attribute required]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -4944,9 +4914,6 @@
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "height" with the proper type (15)]
|
[HTMLInputElement interface: document.createElement("input") must inherit property "height" with the proper type (15)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "indeterminate" with the proper type (16)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "inputMode" with the proper type (17)]
|
[HTMLInputElement interface: document.createElement("input") must inherit property "inputMode" with the proper type (17)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -4974,9 +4941,6 @@
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "placeholder" with the proper type (26)]
|
[HTMLInputElement interface: document.createElement("input") must inherit property "placeholder" with the proper type (26)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "readOnly" with the proper type (27)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLInputElement interface: document.createElement("input") must inherit property "required" with the proper type (28)]
|
[HTMLInputElement interface: document.createElement("input") must inherit property "required" with the proper type (28)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -7170,9 +7134,6 @@
|
||||||
[Window interface: attribute oncanplaythrough]
|
[Window interface: attribute oncanplaythrough]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Window interface: attribute onchange]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Window interface: attribute onclose]
|
[Window interface: attribute onclose]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -7221,9 +7182,6 @@
|
||||||
[Window interface: attribute onfocus]
|
[Window interface: attribute onfocus]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Window interface: attribute oninput]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Window interface: attribute oninvalid]
|
[Window interface: attribute oninvalid]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -7512,9 +7470,6 @@
|
||||||
[Window interface: window must inherit property "oncanplaythrough" with the proper type (44)]
|
[Window interface: window must inherit property "oncanplaythrough" with the proper type (44)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Window interface: window must inherit property "onchange" with the proper type (45)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Window interface: window must inherit property "onclose" with the proper type (47)]
|
[Window interface: window must inherit property "onclose" with the proper type (47)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -7563,9 +7518,6 @@
|
||||||
[Window interface: window must inherit property "onfocus" with the proper type (63)]
|
[Window interface: window must inherit property "onfocus" with the proper type (63)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Window interface: window must inherit property "oninput" with the proper type (64)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Window interface: window must inherit property "oninvalid" with the proper type (65)]
|
[Window interface: window must inherit property "oninvalid" with the proper type (65)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -9639,9 +9591,6 @@
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "oncanplaythrough" with the proper type (99)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "oncanplaythrough" with the proper type (99)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onchange" with the proper type (100)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onclose" with the proper type (102)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onclose" with the proper type (102)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -9693,9 +9642,6 @@
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onfocus" with the proper type (118)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onfocus" with the proper type (118)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "oninput" with the proper type (119)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "oninvalid" with the proper type (120)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "oninvalid" with the proper type (120)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -5925,114 +5925,6 @@
|
||||||
[input.placeholder: IDL set to object "test-valueOf" followed by IDL get]
|
[input.placeholder: IDL set to object "test-valueOf" followed by IDL get]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[input.readOnly: typeof IDL attribute]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL get with DOM attribute unset]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to "" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to " foo " followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to undefined followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to null followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to 7 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to 1.5 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to true followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to false followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to object "[object Object\]" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to NaN followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to Infinity followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to -Infinity followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to "\\0" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to object "test-toString" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to object "test-valueOf" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: setAttribute() to "readOnly" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to "" followed by hasAttribute()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to "" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to " foo " followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to undefined followed by hasAttribute()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to undefined followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to null followed by hasAttribute()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to null followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to 7 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to 1.5 followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to false followed by hasAttribute()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to object "[object Object\]" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to NaN followed by hasAttribute()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to NaN followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to Infinity followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to -Infinity followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to "\\0" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to object "test-toString" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.readOnly: IDL set to object "test-valueOf" followed by IDL get]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[input.required: typeof IDL attribute]
|
[input.required: typeof IDL attribute]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
[button.html]
|
[button.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[clicking on button should not submit a form]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[the element is barred from constraint validation]
|
[the element is barred from constraint validation]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[clicking on button should not reset other form fields]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clicking on button should not unchecked radio buttons]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clicking on button should not change its indeterminate IDL attribute]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
[checkbox.html]
|
[checkbox.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[click on mutable checkbox fires the input and change events]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[click on non-mutable checkbox doesn\'t fire the input or change event]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[pre-activation steps on unchecked checkbox]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[pre-activation steps on checked checkbox]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[canceled activation steps on unchecked checkbox]
|
[canceled activation steps on unchecked checkbox]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
[input-type-button.html]
|
[input-type-button.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[default behavior]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[label value]
|
[label value]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[mutable element\'s activation behavior is to do nothing.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[immutable element has no activation behavior.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[input-type-checkbox.html]
|
[input-type-checkbox.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[a checkbox has an indeterminate state set to false onload]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[default/on: on getting, if the element has a value attribute, it must return that attribute\'s value; otherwise, it must return the string \'on\']
|
[default/on: on getting, if the element has a value attribute, it must return that attribute\'s value; otherwise, it must return the string \'on\']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
[radio.html]
|
[radio.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
[canceled activation steps on unchecked radio]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[radio inputs with name attributes gro\xc3\xbcp2 and gro\xc3\x9cp2 belong to the same radio button group]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,6 @@
|
||||||
[\':checked\' should no longer match <input>s whose type checkbox/radio has been removed]
|
[\':checked\' should no longer match <input>s whose type checkbox/radio has been removed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[\':checked\' matches clicked checkbox and radio buttons]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,15 @@
|
||||||
[dynamically check a radio input in a radio button group]
|
[dynamically check a radio input in a radio button group]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[click on radio4 which is in the indeterminate state]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[adding a value to progress1 should put it in a determinate state]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[removing progress2\'s value should put it in an indeterminate state]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[\':progress\' also matches <input> checkbox whose indeterminate IDL is set to true]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue