mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8260 - martiansideofthemoon:my-code-fix, r=Manishearth
Implementing activation behavior for <label> Attempt to resolve #8179 @Manishearth , could you give me some resources having more information about what each function in `Activatable` does? The code compiles on my machine but I guess a lot more is needed <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8260) <!-- Reviewable:end -->
This commit is contained in:
commit
53d8f04ac4
2 changed files with 42 additions and 0 deletions
|
@ -43,6 +43,7 @@ use dom::htmlfieldsetelement::HTMLFieldSetElement;
|
|||
use dom::htmlfontelement::HTMLFontElement;
|
||||
use dom::htmliframeelement::HTMLIFrameElement;
|
||||
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
|
||||
use dom::htmllabelelement::HTMLLabelElement;
|
||||
use dom::htmllegendelement::HTMLLegendElement;
|
||||
use dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementLayoutHelpers};
|
||||
|
@ -1719,6 +1720,10 @@ impl Element {
|
|||
let element = self.downcast::<HTMLAnchorElement>().unwrap();
|
||||
Some(element as &Activatable)
|
||||
},
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLabelElement)) => {
|
||||
let element = self.downcast::<HTMLLabelElement>().unwrap();
|
||||
Some(element as &Activatable)
|
||||
},
|
||||
_ => {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* 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::activation::Activatable;
|
||||
use dom::attr::AttrValue;
|
||||
use dom::bindings::codegen::Bindings::HTMLLabelElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods;
|
||||
|
@ -9,6 +10,8 @@ use dom::bindings::conversions::Castable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::event::Event;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlformelement::{FormControl, HTMLFormElement};
|
||||
use dom::node::{document_from_node, Node};
|
||||
|
@ -40,6 +43,40 @@ impl HTMLLabelElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl Activatable for HTMLLabelElement {
|
||||
fn as_element(&self) -> &Element {
|
||||
self.upcast::<Element>()
|
||||
}
|
||||
|
||||
fn is_instance_activatable(&self) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
|
||||
// https://html.spec.whatwg.org/multipage/#the-button-element:activation-behavior
|
||||
fn pre_click_activation(&self) {
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#run-canceled-activation-steps
|
||||
fn canceled_activation(&self) {
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
|
||||
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) {
|
||||
self.upcast::<Element>()
|
||||
.as_maybe_activatable()
|
||||
.map(|a| a.synthetic_click_activation(false, false, false, false));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#implicit-submission
|
||||
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
|
||||
//FIXME: Investigate and implement implicit submission for label elements
|
||||
// Issue filed at https://github.com/servo/servo/issues/8263
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
impl HTMLLabelElementMethods for HTMLLabelElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-fae-form
|
||||
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue