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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/perf_ui/TimelineOverviewPane.js

Issue 2675833002: DevTools: simplify TimelineOverview interface, move windowTimes()/windowBoundaries() to pane (Closed)
Patch Set: also always assume leftPadding to be 0 Created 3 years, 10 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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 */ 209 */
210 function process() { 210 function process() {
211 this._update(); 211 this._update();
212 return Promise.resolve(); 212 return Promise.resolve();
213 } 213 }
214 } 214 }
215 215
216 _update() { 216 _update() {
217 if (!this.isShowing()) 217 if (!this.isShowing())
218 return; 218 return;
219 this._overviewCalculator.setDisplayWindow(this._overviewGrid.clientWidth()); 219 this._overviewCalculator.setDisplayWidth(this._overviewGrid.clientWidth());
220 for (var i = 0; i < this._overviewControls.length; ++i) 220 for (var i = 0; i < this._overviewControls.length; ++i)
221 this._overviewControls[i].update(); 221 this._overviewControls[i].update();
222 this._overviewGrid.updateDividers(this._overviewCalculator); 222 this._overviewGrid.updateDividers(this._overviewCalculator);
223 this._updateMarkers(); 223 this._updateMarkers();
224 this._updateWindow(); 224 this._updateWindow();
225 } 225 }
226 226
227 /** 227 /**
228 * @param {!Map<number, !Element>} markers 228 * @param {!Map<number, !Element>} markers
229 */ 229 */
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 /** 278 /**
279 * @param {!Common.Event} event 279 * @param {!Common.Event} event
280 */ 280 */
281 _onWindowChanged(event) { 281 _onWindowChanged(event) {
282 if (this._muteOnWindowChanged) 282 if (this._muteOnWindowChanged)
283 return; 283 return;
284 // Always use first control as a time converter. 284 // Always use first control as a time converter.
285 if (!this._overviewControls.length) 285 if (!this._overviewControls.length)
286 return; 286 return;
287 var windowTimes = 287
288 this._overviewControls[0].windowTimes(this._overviewGrid.windowLeft(), t his._overviewGrid.windowRight()); 288 var absoluteMin = this._overviewCalculator.minimumBoundary();
289 var timeSpan = this._overviewCalculator.maximumBoundary() - absoluteMin;
290 var windowTimes = {
291 startTime: absoluteMin + timeSpan * this._overviewGrid.windowLeft(),
292 endTime: absoluteMin + timeSpan * this._overviewGrid.windowRight()
293 };
289 this._windowStartTime = windowTimes.startTime; 294 this._windowStartTime = windowTimes.startTime;
290 this._windowEndTime = windowTimes.endTime; 295 this._windowEndTime = windowTimes.endTime;
291 this.dispatchEventToListeners(PerfUI.TimelineOverviewPane.Events.WindowChang ed, windowTimes); 296 this.dispatchEventToListeners(PerfUI.TimelineOverviewPane.Events.WindowChang ed, windowTimes);
292 } 297 }
293 298
294 /** 299 /**
295 * @param {number} startTime 300 * @param {number} startTime
296 * @param {number} endTime 301 * @param {number} endTime
297 */ 302 */
298 requestWindowTimes(startTime, endTime) { 303 requestWindowTimes(startTime, endTime) {
299 if (startTime === this._windowStartTime && endTime === this._windowEndTime) 304 if (startTime === this._windowStartTime && endTime === this._windowEndTime)
300 return; 305 return;
301 this._windowStartTime = startTime; 306 this._windowStartTime = startTime;
302 this._windowEndTime = endTime; 307 this._windowEndTime = endTime;
303 this._updateWindow(); 308 this._updateWindow();
304 this.dispatchEventToListeners( 309 this.dispatchEventToListeners(
305 PerfUI.TimelineOverviewPane.Events.WindowChanged, {startTime: startTime, endTime: endTime}); 310 PerfUI.TimelineOverviewPane.Events.WindowChanged, {startTime: startTime, endTime: endTime});
306 } 311 }
307 312
308 _updateWindow() { 313 _updateWindow() {
309 if (!this._overviewControls.length) 314 if (!this._overviewControls.length)
310 return; 315 return;
311 var windowBoundaries = this._overviewControls[0].windowBoundaries(this._wind owStartTime, this._windowEndTime); 316
317 var absoluteMin = this._overviewCalculator.minimumBoundary();
318 var timeSpan = this._overviewCalculator.maximumBoundary() - absoluteMin;
319 var haveRecords = absoluteMin > 0;
320 var left = haveRecords && this._windowStartTime ? Math.min((this._windowStar tTime - absoluteMin) / timeSpan, 1) : 0;
321 var right = haveRecords && this._windowEndTime < Infinity ? (this._windowEnd Time - absoluteMin) / timeSpan : 1;
312 this._muteOnWindowChanged = true; 322 this._muteOnWindowChanged = true;
313 this._overviewGrid.setWindow(windowBoundaries.left, windowBoundaries.right); 323 this._overviewGrid.setWindow(left, right);
314 this._muteOnWindowChanged = false; 324 this._muteOnWindowChanged = false;
315 } 325 }
316 }; 326 };
317 327
318 /** @enum {symbol} */ 328 /** @enum {symbol} */
319 PerfUI.TimelineOverviewPane.Events = { 329 PerfUI.TimelineOverviewPane.Events = {
320 WindowChanged: Symbol('WindowChanged') 330 WindowChanged: Symbol('WindowChanged')
321 }; 331 };
322 332
323 /** 333 /**
(...skipping 13 matching lines...) Expand all
337 PerfUI.TimelineOverviewCalculator = class { 347 PerfUI.TimelineOverviewCalculator = class {
338 constructor() { 348 constructor() {
339 this.reset(); 349 this.reset();
340 } 350 }
341 351
342 /** 352 /**
343 * @override 353 * @override
344 * @return {number} 354 * @return {number}
345 */ 355 */
346 paddingLeft() { 356 paddingLeft() {
347 return this._paddingLeft; 357 return 0;
348 } 358 }
349 359
350 /** 360 /**
351 * @override 361 * @override
352 * @param {number} time 362 * @param {number} time
353 * @return {number} 363 * @return {number}
354 */ 364 */
355 computePosition(time) { 365 computePosition(time) {
356 return (time - this._minimumBoundary) / this.boundarySpan() * this._workingA rea + this._paddingLeft; 366 return (time - this._minimumBoundary) / this.boundarySpan() * this._workingA rea;
357 } 367 }
358 368
359 /** 369 /**
360 * @param {number} position 370 * @param {number} position
361 * @return {number} 371 * @return {number}
362 */ 372 */
363 positionToTime(position) { 373 positionToTime(position) {
364 return (position - this._paddingLeft) / this._workingArea * this.boundarySpa n() + this._minimumBoundary; 374 return position / this._workingArea * this.boundarySpan() + this._minimumBou ndary;
365 } 375 }
366 376
367 /** 377 /**
368 * @param {number} minimumBoundary 378 * @param {number} minimumBoundary
369 * @param {number} maximumBoundary 379 * @param {number} maximumBoundary
370 */ 380 */
371 setBounds(minimumBoundary, maximumBoundary) { 381 setBounds(minimumBoundary, maximumBoundary) {
372 this._minimumBoundary = minimumBoundary; 382 this._minimumBoundary = minimumBoundary;
373 this._maximumBoundary = maximumBoundary; 383 this._maximumBoundary = maximumBoundary;
374 } 384 }
375 385
376 /** 386 /**
377 * @param {number} clientWidth 387 * @param {number} clientWidth
378 * @param {number=} paddingLeft
379 */ 388 */
380 setDisplayWindow(clientWidth, paddingLeft) { 389 setDisplayWidth(clientWidth) {
381 this._paddingLeft = paddingLeft || 0; 390 this._workingArea = clientWidth;
382 this._workingArea = clientWidth - this._paddingLeft;
383 } 391 }
384 392
385 reset() { 393 reset() {
386 this.setBounds(0, 100); 394 this.setBounds(0, 100);
387 } 395 }
388 396
389 /** 397 /**
390 * @override 398 * @override
391 * @param {number} value 399 * @param {number} value
392 * @param {number=} precision 400 * @param {number=} precision
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 * @param {number} x 459 * @param {number} x
452 * @return {!Promise<?Element>} 460 * @return {!Promise<?Element>}
453 */ 461 */
454 popoverElementPromise(x) {}, 462 popoverElementPromise(x) {},
455 463
456 /** 464 /**
457 * @param {!Event} event 465 * @param {!Event} event
458 * @return {boolean} 466 * @return {boolean}
459 */ 467 */
460 onClick(event) {}, 468 onClick(event) {},
461
462 /**
463 * @param {number} windowLeft
464 * @param {number} windowRight
465 * @return {!{startTime: number, endTime: number}}
466 */
467 windowTimes(windowLeft, windowRight) {},
468
469 /**
470 * @param {number} startTime
471 * @param {number} endTime
472 * @return {!{left: number, right: number}}
473 */
474 windowBoundaries(startTime, endTime) {},
475 }; 469 };
476 470
477 /** 471 /**
478 * @implements {PerfUI.TimelineOverview} 472 * @implements {PerfUI.TimelineOverview}
479 * @unrestricted 473 * @unrestricted
480 */ 474 */
481 PerfUI.TimelineOverviewBase = class extends UI.VBox { 475 PerfUI.TimelineOverviewBase = class extends UI.VBox {
482 constructor() { 476 constructor() {
483 super(); 477 super();
484 /** @type {?PerfUI.TimelineOverviewCalculator} */ 478 /** @type {?PerfUI.TimelineOverviewCalculator} */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 542
549 /** 543 /**
550 * @override 544 * @override
551 * @param {!Event} event 545 * @param {!Event} event
552 * @return {boolean} 546 * @return {boolean}
553 */ 547 */
554 onClick(event) { 548 onClick(event) {
555 return false; 549 return false;
556 } 550 }
557 551
558 /**
559 * @override
560 * @param {number} windowLeft
561 * @param {number} windowRight
562 * @return {!{startTime: number, endTime: number}}
563 */
564 windowTimes(windowLeft, windowRight) {
565 var absoluteMin = this._calculator.minimumBoundary();
566 var timeSpan = this._calculator.maximumBoundary() - absoluteMin;
567 return {startTime: absoluteMin + timeSpan * windowLeft, endTime: absoluteMin + timeSpan * windowRight};
568 }
569
570 /**
571 * @override
572 * @param {number} startTime
573 * @param {number} endTime
574 * @return {!{left: number, right: number}}
575 */
576 windowBoundaries(startTime, endTime) {
577 var absoluteMin = this._calculator.minimumBoundary();
578 var timeSpan = this._calculator.maximumBoundary() - absoluteMin;
579 var haveRecords = absoluteMin > 0;
580 return {
581 left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / time Span, 1) : 0,
582 right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeS pan : 1
583 };
584 }
585
586 resetCanvas() { 552 resetCanvas() {
587 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; 553 this._canvas.width = this.element.clientWidth * window.devicePixelRatio;
588 this._canvas.height = this.element.clientHeight * window.devicePixelRatio; 554 this._canvas.height = this.element.clientHeight * window.devicePixelRatio;
589 } 555 }
590 }; 556 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698