Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Popover.js

Issue 2770683003: [DevTools] Fix Popover click handling. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 * @return {boolean} 80 * @return {boolean}
81 */ 81 */
82 _eventInScheduledContent(event) { 82 _eventInScheduledContent(event) {
83 return this._scheduledRequest ? this._scheduledRequest.box.contains(event.cl ientX, event.clientY) : false; 83 return this._scheduledRequest ? this._scheduledRequest.box.contains(event.cl ientX, event.clientY) : false;
84 } 84 }
85 85
86 /** 86 /**
87 * @param {!Event} event 87 * @param {!Event} event
88 */ 88 */
89 _mouseDown(event) { 89 _mouseDown(event) {
90 if (this._disableOnClick || !this._eventInScheduledContent(event)) { 90 if (this._disableOnClick) {
91 this.hidePopover(); 91 this.hidePopover();
92 } else { 92 return;
93 this._stopHidePopoverTimer();
94 this._stopShowPopoverTimer();
95 this._startShowPopoverTimer(event, 0);
96 } 93 }
94 if (this._eventInScheduledContent(event))
95 return;
96
97 this._startHidePopoverTimer(0);
98 this._stopShowPopoverTimer();
99 this._startShowPopoverTimer(event, 0);
97 } 100 }
98 101
99 /** 102 /**
100 * @param {!Event} event 103 * @param {!Event} event
101 */ 104 */
102 _mouseMove(event) { 105 _mouseMove(event) {
103 // Pretend that nothing has happened. 106 // Pretend that nothing has happened.
104 if (this._eventInScheduledContent(event)) 107 if (this._eventInScheduledContent(event))
105 return; 108 return;
106 109
107 this._startHidePopoverTimer(); 110 this._startHidePopoverTimer(this._hideTimeout);
108 this._stopShowPopoverTimer(); 111 this._stopShowPopoverTimer();
109 if (event.which && this._disableOnClick) 112 if (event.which && this._disableOnClick)
110 return; 113 return;
111 this._startShowPopoverTimer( 114 this._startShowPopoverTimer(
112 event, this.isPopoverVisible() ? Math.max(this._timeout * 0.6, this._hid eTimeout) : this._timeout); 115 event, this.isPopoverVisible() ? Math.max(this._timeout * 0.6, this._hid eTimeout) : this._timeout);
113 } 116 }
114 117
115 /** 118 /**
116 * @param {!Event} event 119 * @param {!Event} event
117 */ 120 */
118 _popoverMouseMove(event) { 121 _popoverMouseMove(event) {
119 this._stopHidePopoverTimer(); 122 this._stopHidePopoverTimer();
120 } 123 }
121 124
122 /** 125 /**
123 * @param {!UI.GlassPane} popover 126 * @param {!UI.GlassPane} popover
124 * @param {!Event} event 127 * @param {!Event} event
125 */ 128 */
126 _popoverMouseOut(popover, event) { 129 _popoverMouseOut(popover, event) {
127 if (!popover.isShowing()) 130 if (!popover.isShowing())
128 return; 131 return;
129 if (event.relatedTarget && !event.relatedTarget.isSelfOrDescendant(popover.c ontentElement)) 132 if (event.relatedTarget && !event.relatedTarget.isSelfOrDescendant(popover.c ontentElement))
130 this._startHidePopoverTimer(); 133 this._startHidePopoverTimer(this._hideTimeout);
131 } 134 }
132 135
133 /** 136 /**
134 * @param {!Event} event 137 * @param {!Event} event
135 */ 138 */
136 _mouseOut(event) { 139 _mouseOut(event) {
137 if (!this.isPopoverVisible()) 140 if (!this.isPopoverVisible())
138 return; 141 return;
139 if (!this._eventInScheduledContent(event)) 142 if (!this._eventInScheduledContent(event))
140 this._startHidePopoverTimer(); 143 this._startHidePopoverTimer(this._hideTimeout);
141 } 144 }
142 145
143 _startHidePopoverTimer() { 146 /**
144 // User has this._hideTimeout to reach the popup. 147 * @param {number} timeout
148 */
149 _startHidePopoverTimer(timeout) {
150 // User has |timeout| ms to reach the popup.
145 if (!this._hidePopoverCallback || this._hidePopoverTimer) 151 if (!this._hidePopoverCallback || this._hidePopoverTimer)
146 return; 152 return;
147 153
148 this._hidePopoverTimer = setTimeout(() => { 154 this._hidePopoverTimer = setTimeout(() => {
149 this._hidePopover(); 155 this._hidePopover();
150 delete this._hidePopoverTimer; 156 delete this._hidePopoverTimer;
151 }, this._hideTimeout); 157 }, timeout);
152 } 158 }
153 159
154 /** 160 /**
155 * @param {!Event} event 161 * @param {!Event} event
156 * @param {number} timeout 162 * @param {number} timeout
157 */ 163 */
158 _startShowPopoverTimer(event, timeout) { 164 _startShowPopoverTimer(event, timeout) {
159 this._scheduledRequest = this._getRequest.call(null, event); 165 this._scheduledRequest = this._getRequest.call(null, event);
160 if (!this._scheduledRequest) 166 if (!this._scheduledRequest)
161 return; 167 return;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 delete this._hidePopoverTimer; 247 delete this._hidePopoverTimer;
242 248
243 // We know that we reached the popup, but we might have moved over other ele ments. 249 // We know that we reached the popup, but we might have moved over other ele ments.
244 // Discard pending command. 250 // Discard pending command.
245 this._stopShowPopoverTimer(); 251 this._stopShowPopoverTimer();
246 } 252 }
247 }; 253 };
248 254
249 /** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>) , hide:(function()|undefined)}} */ 255 /** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>) , hide:(function()|undefined)}} */
250 UI.PopoverRequest; 256 UI.PopoverRequest;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698