Bug 1431573 - Part 11: Stop UI event propagation. r?gl draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Tue, 13 Mar 2018 14:31:12 +0900
changeset 766614 eeff9d24f221d0ee9664a31059c298970f511194
parent 766613 994a27eb97e27d8c011919b69d93e384f1551cac
child 766615 a9f4ad6d61d744a154859bb21975ecf80bfac84f
push id102370
push userbmo:dakatsuka@mozilla.com
push dateTue, 13 Mar 2018 06:01:02 +0000
reviewersgl
bugs1431573
milestone61.0a1
Bug 1431573 - Part 11: Stop UI event propagation. r?gl MozReview-Commit-ID: LvpSV2vsqX
devtools/client/inspector/animation/components/AnimationDetailHeader.js
devtools/client/inspector/animation/components/CurrentTimeScrubberController.js
devtools/client/inspector/animation/components/NoAnimationPanel.js
devtools/client/inspector/animation/components/PauseResumeButton.js
devtools/client/inspector/animation/components/RewindButton.js
devtools/client/inspector/animation/components/graph/SummaryGraph.js
--- a/devtools/client/inspector/animation/components/AnimationDetailHeader.js
+++ b/devtools/client/inspector/animation/components/AnimationDetailHeader.js
@@ -13,17 +13,18 @@ const { getFormattedTitle } = require(".
 class AnimationDetailHeader extends PureComponent {
   static get propTypes() {
     return {
       animation: PropTypes.object.isRequired,
       setDetailVisibility: PropTypes.func.isRequired,
     };
   }
 
-  onClick() {
+  onClick(event) {
+    event.stopPropagation();
     const { setDetailVisibility } = this.props;
     setDetailVisibility(false);
   }
 
   render() {
     const { animation } = this.props;
 
     return dom.div(
--- a/devtools/client/inspector/animation/components/CurrentTimeScrubberController.js
+++ b/devtools/client/inspector/animation/components/CurrentTimeScrubberController.js
@@ -53,45 +53,51 @@ class CurrentTimeScrubberController exte
     const { timeScale } = this.props;
 
     const thisEl = ReactDOM.findDOMNode(this);
     const offset =
       thisEl ? currentTime / timeScale.getDuration() * thisEl.clientWidth : 0;
     this.setState({ offset });
   }
 
-  onMouseDown(e) {
+  onMouseDown(event) {
+    event.stopPropagation();
     const thisEl = ReactDOM.findDOMNode(this);
     this.controllerArea = thisEl.getBoundingClientRect();
     this.listenerTarget = thisEl.closest(".animation-list-container");
     this.listenerTarget.addEventListener("mousemove", this.onMouseMove);
     this.listenerTarget.addEventListener("mouseout", this.onMouseOut);
     this.listenerTarget.addEventListener("mouseup", this.onMouseUp);
     this.listenerTarget.classList.add("active-scrubber");
 
-    this.updateAnimationsCurrentTime(e.pageX, true);
+    this.updateAnimationsCurrentTime(event.pageX, true);
   }
 
-  onMouseMove(e) {
+  onMouseMove(event) {
+    event.stopPropagation();
     this.isMouseMoved = true;
-    this.updateAnimationsCurrentTime(e.pageX);
+    this.updateAnimationsCurrentTime(event.pageX);
   }
 
-  onMouseOut(e) {
-    if (!this.listenerTarget.contains(e.relatedTarget)) {
+  onMouseOut(event) {
+    event.stopPropagation();
+
+    if (!this.listenerTarget.contains(event.relatedTarget)) {
       const endX = this.controllerArea.x + this.controllerArea.width;
-      const pageX = endX < e.pageX ? endX : e.pageX;
+      const pageX = endX < event.pageX ? endX : event.pageX;
       this.updateAnimationsCurrentTime(pageX, true);
       this.uninstallListeners();
     }
   }
 
-  onMouseUp(e) {
+  onMouseUp(event) {
+    event.stopPropagation();
+
     if (this.isMouseMoved) {
-      this.updateAnimationsCurrentTime(e.pageX, true);
+      this.updateAnimationsCurrentTime(event.pageX, true);
       this.isMouseMoved = null;
     }
 
     this.uninstallListeners();
   }
 
   uninstallListeners() {
     this.listenerTarget.removeEventListener("mousemove", this.onMouseMove);
--- a/devtools/client/inspector/animation/components/NoAnimationPanel.js
+++ b/devtools/client/inspector/animation/components/NoAnimationPanel.js
@@ -36,17 +36,20 @@ class NoAnimationPanel extends PureCompo
         null,
         L10N.getStr("panel.noAnimation")
       ),
       dom.button(
         {
           className: "animation-element-picker devtools-button" +
                      (elementPickerEnabled ? " checked" : ""),
           "data-standalone": true,
-          onClick: toggleElementPicker
+          onClick: event => {
+            event.stopPropagation();
+            toggleElementPicker();
+          }
         }
       )
     );
   }
 }
 
 const mapStateToProps = state => {
   return {
--- a/devtools/client/inspector/animation/components/PauseResumeButton.js
+++ b/devtools/client/inspector/animation/components/PauseResumeButton.js
@@ -49,27 +49,27 @@ class PauseResumeButton extends PureComp
     const targetEl = this.getKeyEventTarget();
     targetEl.removeEventListener("keydown", this.onKeyDown);
   }
 
   getKeyEventTarget() {
     return ReactDOM.findDOMNode(this).closest("#animation-container");
   }
 
-  onToggleAnimationsPlayState() {
+  onToggleAnimationsPlayState(event) {
+    event.stopPropagation();
     const { setAnimationsPlayState } = this.props;
     const { isRunning } = this.state;
 
     setAnimationsPlayState(!isRunning);
   }
 
-  onKeyDown(e) {
-    if (e.keyCode === KeyCodes.DOM_VK_SPACE) {
-      this.onToggleAnimationsPlayState();
-      e.preventDefault();
+  onKeyDown(event) {
+    if (event.keyCode === KeyCodes.DOM_VK_SPACE) {
+      this.onToggleAnimationsPlayState(event);
     }
   }
 
   updateState() {
     const { animations } = this.props;
     const isRunning = hasRunningAnimation(animations);
     this.setState({ isRunning });
   }
--- a/devtools/client/inspector/animation/components/RewindButton.js
+++ b/devtools/client/inspector/animation/components/RewindButton.js
@@ -18,16 +18,19 @@ class RewindButton extends PureComponent
   }
 
   render() {
     const { rewindAnimationsCurrentTime } = this.props;
 
     return dom.button(
       {
         className: "rewind-button devtools-button",
-        onClick: rewindAnimationsCurrentTime,
+        onClick: event => {
+          event.stopPropagation();
+          rewindAnimationsCurrentTime();
+        },
         title: getStr("timeline.rewindButtonTooltip"),
       }
     );
   }
 }
 
 module.exports = RewindButton;
--- a/devtools/client/inspector/animation/components/graph/SummaryGraph.js
+++ b/devtools/client/inspector/animation/components/graph/SummaryGraph.js
@@ -28,17 +28,18 @@ class SummaryGraph extends PureComponent
   }
 
   constructor(props) {
     super(props);
 
     this.onClick = this.onClick.bind(this);
   }
 
-  onClick() {
+  onClick(event) {
+    event.stopPropagation();
     this.props.selectAnimation(this.props.animation);
   }
 
   getTitleText(state) {
     const getTime =
       time => getFormatStr("player.timeLabel", numberWithDecimals(time / 1000, 2));
 
     let text = "";