servo: Merge #10019 - Fix htmllabelelement click to activate correct element (from rebstar6:htmllabelclick); r=jdm
authorRebecca <rebstar6@gmail.com>
Wed, 30 Mar 2016 05:11:30 +0500
changeset 338354 4a7c8433295741905016865e1915d53950f5eea2
parent 338353 9f556c5fbc05a4e2fe7a957e47a64a41ab87e0cd
child 338355 a8c8c83985e146697640859b99c4a53941f5c390
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
servo: Merge #10019 - Fix htmllabelelement click to activate correct element (from rebstar6:htmllabelclick); r=jdm Address https://github.com/servo/servo/issues/9928 Pass on label click to the label element's labeled control Source-Repo: https://github.com/servo/servo Source-Revision: 80d903a89725db081913f82515dc492ef711b829
servo/components/script/dom/htmlinputelement.rs
servo/components/script/dom/htmllabelelement.rs
--- a/servo/components/script/dom/htmlinputelement.rs
+++ b/servo/components/script/dom/htmlinputelement.rs
@@ -857,20 +857,16 @@ impl VirtualMethods for HTMLInputElement
     }
 
     fn handle_event(&self, event: &Event) {
         if let Some(s) = self.super_type() {
             s.handle_event(event);
         }
 
         if event.type_() == atom!("click") && !event.DefaultPrevented() {
-            if let InputType::InputRadio = self.input_type.get() {
-                self.update_checked_state(true, true);
-            }
-
             // TODO: Dispatch events for non activatable inputs
             // https://html.spec.whatwg.org/multipage/#common-input-element-events
 
             //TODO: set the editing position for text inputs
 
             document_from_node(self).request_focus(self.upcast());
         } else if event.type_() == atom!("keydown") && !event.DefaultPrevented() &&
             (self.input_type.get() == InputType::InputText ||
--- a/servo/components/script/dom/htmllabelelement.rs
+++ b/servo/components/script/dom/htmllabelelement.rs
@@ -58,22 +58,25 @@ impl Activatable for HTMLLabelElement {
     }
 
     // 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) {
-        synthetic_click_activation(self.upcast::<Element>(),
-                                   false,
-                                   false,
-                                   false,
-                                   false,
-                                   ActivationSource::NotFromClick);
+        if let Some(e) = self.GetControl() {
+            let elem = e.upcast::<Element>();
+            synthetic_click_activation(elem,
+                                       false,
+                                       false,
+                                       false,
+                                       false,
+                                       ActivationSource::NotFromClick);
+        }
     }
 
     // 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
     }