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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/OverviewGrid.js

Issue 2553043003: [DevTools] Remove methods on Common.Event. (Closed)
Patch Set: rebased Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 * @param {symbol} eventType 103 * @param {symbol} eventType
104 * @param {function(!Common.Event)} listener 104 * @param {function(!Common.Event)} listener
105 * @param {!Object=} thisObject 105 * @param {!Object=} thisObject
106 * @return {!Common.EventTarget.EventDescriptor} 106 * @return {!Common.EventTarget.EventDescriptor}
107 */ 107 */
108 addEventListener(eventType, listener, thisObject) { 108 addEventListener(eventType, listener, thisObject) {
109 return this._window.addEventListener(eventType, listener, thisObject); 109 return this._window.addEventListener(eventType, listener, thisObject);
110 } 110 }
111 111
112 /** 112 /**
113 * @param {?function(!Event):boolean} clickHandler
114 */
115 setClickHandler(clickHandler) {
116 this._window.setClickHandler(clickHandler);
117 }
118
119 /**
113 * @param {number} zoomFactor 120 * @param {number} zoomFactor
114 * @param {number} referencePoint 121 * @param {number} referencePoint
115 */ 122 */
116 zoom(zoomFactor, referencePoint) { 123 zoom(zoomFactor, referencePoint) {
117 this._window._zoom(zoomFactor, referencePoint); 124 this._window._zoom(zoomFactor, referencePoint);
118 } 125 }
119 126
120 /** 127 /**
121 * @param {boolean} enabled 128 * @param {boolean} enabled
122 */ 129 */
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 185 }
179 186
180 /** 187 /**
181 * @param {boolean} enabled 188 * @param {boolean} enabled
182 */ 189 */
183 setEnabled(enabled) { 190 setEnabled(enabled) {
184 this._enabled = enabled; 191 this._enabled = enabled;
185 } 192 }
186 193
187 /** 194 /**
195 * @param {?function(!Event):boolean} clickHandler
196 */
197 setClickHandler(clickHandler) {
198 this._clickHandler = clickHandler;
199 }
200
201 /**
188 * @param {!Event} event 202 * @param {!Event} event
189 */ 203 */
190 _resizerElementStartDragging(event) { 204 _resizerElementStartDragging(event) {
191 if (!this._enabled) 205 if (!this._enabled)
192 return false; 206 return false;
193 this._resizerParentOffsetLeft = event.pageX - event.offsetX - event.target.o ffsetLeft; 207 this._resizerParentOffsetLeft = event.pageX - event.offsetX - event.target.o ffsetLeft;
194 event.stopPropagation(); 208 event.stopPropagation();
195 return true; 209 return true;
196 } 210 }
197 211
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 247 }
234 248
235 /** 249 /**
236 * @param {!Event} event 250 * @param {!Event} event
237 */ 251 */
238 _endWindowSelectorDragging(event) { 252 _endWindowSelectorDragging(event) {
239 var window = this._overviewWindowSelector._close(event.x - this._offsetLeft) ; 253 var window = this._overviewWindowSelector._close(event.x - this._offsetLeft) ;
240 delete this._overviewWindowSelector; 254 delete this._overviewWindowSelector;
241 var clickThreshold = 3; 255 var clickThreshold = 3;
242 if (window.end - window.start < clickThreshold) { 256 if (window.end - window.start < clickThreshold) {
243 if (this.dispatchEventToListeners(UI.OverviewGrid.Events.Click, event)) 257 if (this._clickHandler && this._clickHandler.call(null, event))
244 return; 258 return;
245 var middle = window.end; 259 var middle = window.end;
246 window.start = Math.max(0, middle - UI.OverviewGrid.MinSelectableSize / 2) ; 260 window.start = Math.max(0, middle - UI.OverviewGrid.MinSelectableSize / 2) ;
247 window.end = Math.min(this._parentElement.clientWidth, middle + UI.Overvie wGrid.MinSelectableSize / 2); 261 window.end = Math.min(this._parentElement.clientWidth, middle + UI.Overvie wGrid.MinSelectableSize / 2);
248 } else if (window.end - window.start < UI.OverviewGrid.MinSelectableSize) { 262 } else if (window.end - window.start < UI.OverviewGrid.MinSelectableSize) {
249 if (this._parentElement.clientWidth - window.end > UI.OverviewGrid.MinSele ctableSize) 263 if (this._parentElement.clientWidth - window.end > UI.OverviewGrid.MinSele ctableSize)
250 window.end = window.start + UI.OverviewGrid.MinSelectableSize; 264 window.end = window.start + UI.OverviewGrid.MinSelectableSize;
251 else 265 else
252 window.start = window.end - UI.OverviewGrid.MinSelectableSize; 266 window.start = window.end - UI.OverviewGrid.MinSelectableSize;
253 } 267 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 left = Number.constrain(left, 0, 1 - newWindowSize); 412 left = Number.constrain(left, 0, 1 - newWindowSize);
399 413
400 right = reference + (right - reference) * factor; 414 right = reference + (right - reference) * factor;
401 right = Number.constrain(right, newWindowSize, 1); 415 right = Number.constrain(right, newWindowSize, 1);
402 this._setWindow(left, right); 416 this._setWindow(left, right);
403 } 417 }
404 }; 418 };
405 419
406 /** @enum {symbol} */ 420 /** @enum {symbol} */
407 UI.OverviewGrid.Events = { 421 UI.OverviewGrid.Events = {
408 WindowChanged: Symbol('WindowChanged'), 422 WindowChanged: Symbol('WindowChanged')
409 Click: Symbol('Click')
410 }; 423 };
411 424
412 /** 425 /**
413 * @unrestricted 426 * @unrestricted
414 */ 427 */
415 UI.OverviewGrid.WindowSelector = class { 428 UI.OverviewGrid.WindowSelector = class {
416 constructor(parent, position) { 429 constructor(parent, position) {
417 this._startPosition = position; 430 this._startPosition = position;
418 this._width = parent.offsetWidth; 431 this._width = parent.offsetWidth;
419 this._windowSelector = createElement('div'); 432 this._windowSelector = createElement('div');
(...skipping 14 matching lines...) Expand all
434 position = Math.max(0, Math.min(position, this._width)); 447 position = Math.max(0, Math.min(position, this._width));
435 if (position < this._startPosition) { 448 if (position < this._startPosition) {
436 this._windowSelector.style.left = position + 'px'; 449 this._windowSelector.style.left = position + 'px';
437 this._windowSelector.style.right = this._width - this._startPosition + 'px '; 450 this._windowSelector.style.right = this._width - this._startPosition + 'px ';
438 } else { 451 } else {
439 this._windowSelector.style.left = this._startPosition + 'px'; 452 this._windowSelector.style.left = this._startPosition + 'px';
440 this._windowSelector.style.right = this._width - position + 'px'; 453 this._windowSelector.style.right = this._width - position + 'px';
441 } 454 }
442 } 455 }
443 }; 456 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698