OLD | NEW |
---|---|
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 this._processTimelineData(timelineData); | 414 this._processTimelineData(timelineData); |
415 return this._rawTimelineData; | 415 return this._rawTimelineData; |
416 }, | 416 }, |
417 | 417 |
418 /** | 418 /** |
419 * @param {number} startTime | 419 * @param {number} startTime |
420 * @param {number} endTime | 420 * @param {number} endTime |
421 */ | 421 */ |
422 setWindowTimes: function(startTime, endTime) | 422 setWindowTimes: function(startTime, endTime) |
423 { | 423 { |
424 this._timeWindowLeft = startTime; | 424 if (this._muteAnimation || this._timeWindowLeft === 0 || this._timeWindo wRight === Infinity) { |
425 this._timeWindowRight = endTime; | 425 // Initial setup. |
426 this.scheduleUpdate(); | 426 this._timeWindowLeft = startTime; |
427 this._timeWindowRight = endTime; | |
428 this.scheduleUpdate(); | |
429 return; | |
430 } | |
431 | |
432 if (this._cancelWindowTimesAnimation) | |
433 this._cancelWindowTimesAnimation(); | |
434 this._cancelWindowTimesAnimation = WebInspector.animateFunction(this._an imateWindowTimes.bind(this), | |
435 [{from: this._timeWindowLeft, to: startTime}, {from: this._timeWindo wRight, to: endTime}], 5, | |
436 this._animationCompleted.bind(this)); | |
427 }, | 437 }, |
428 | 438 |
429 /** | 439 /** |
440 * @param {number} startTime | |
441 * @param {number} endTime | |
442 */ | |
443 _animateWindowTimes: function(startTime, endTime) | |
444 { | |
445 this._timeWindowLeft = startTime; | |
446 this._timeWindowRight = endTime; | |
447 this.update(); | |
448 }, | |
449 | |
450 _animationCompleted: function() | |
451 { | |
452 delete this._cancelWindowTimesAnimation; | |
yurys
2014/08/08 12:40:43
this._cancelWindowTimesAnimation = null;
pfeldman
2014/08/08 12:43:11
I think we delete all the flags in other places.
| |
453 }, | |
454 | |
455 /** | |
430 * @param {!MouseEvent} event | 456 * @param {!MouseEvent} event |
431 */ | 457 */ |
432 _startCanvasDragging: function(event) | 458 _startCanvasDragging: function(event) |
433 { | 459 { |
434 if (!this._timelineData() || this._timeWindowRight === Infinity) | 460 if (!this._timelineData() || this._timeWindowRight === Infinity) |
435 return false; | 461 return false; |
436 this._isDragging = true; | 462 this._isDragging = true; |
437 this._maxDragOffset = 0; | 463 this._maxDragOffset = 0; |
438 this._dragStartPointX = event.pageX; | 464 this._dragStartPointX = event.pageX; |
439 this._dragStartPointY = event.pageY; | 465 this._dragStartPointY = event.pageY; |
440 this._dragStartScrollTop = this._vScrollElement.scrollTop; | 466 this._dragStartScrollTop = this._vScrollElement.scrollTop; |
441 this._dragStartWindowLeft = this._timeWindowLeft; | 467 this._dragStartWindowLeft = this._timeWindowLeft; |
442 this._dragStartWindowRight = this._timeWindowRight; | 468 this._dragStartWindowRight = this._timeWindowRight; |
443 this._canvas.style.cursor = ""; | 469 this._canvas.style.cursor = ""; |
444 | 470 |
445 return true; | 471 return true; |
446 }, | 472 }, |
447 | 473 |
448 /** | 474 /** |
449 * @param {!MouseEvent} event | 475 * @param {!MouseEvent} event |
450 */ | 476 */ |
451 _canvasDragging: function(event) | 477 _canvasDragging: function(event) |
452 { | 478 { |
453 var pixelShift = this._dragStartPointX - event.pageX; | 479 var pixelShift = this._dragStartPointX - event.pageX; |
480 this._dragStartPointX = event.pageX; | |
481 this._muteAnimation = true; | |
482 this._handlePanGesture(pixelShift * this._pixelToTime); | |
483 this._muteAnimation = false; | |
484 | |
454 var pixelScroll = this._dragStartPointY - event.pageY; | 485 var pixelScroll = this._dragStartPointY - event.pageY; |
455 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll; | 486 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll; |
456 var windowShift = pixelShift / this._totalPixels; | |
457 var windowTime = this._windowWidth * this._totalTime; | |
458 var timeShift = windowTime * pixelShift / this._pixelWindowWidth; | |
459 timeShift = Number.constrain( | |
460 timeShift, | |
461 this._minimumBoundary - this._dragStartWindowLeft, | |
462 this._minimumBoundary + this._totalTime - this._dragStartWindowRight | |
463 ); | |
464 var windowLeft = this._dragStartWindowLeft + timeShift; | |
465 var windowRight = this._dragStartWindowRight + timeShift; | |
466 this._flameChartDelegate.requestWindowTimes(windowLeft, windowRight); | |
467 this._maxDragOffset = Math.max(this._maxDragOffset, Math.abs(pixelShift) ); | 487 this._maxDragOffset = Math.max(this._maxDragOffset, Math.abs(pixelShift) ); |
468 }, | 488 }, |
469 | 489 |
470 _endCanvasDragging: function() | 490 _endCanvasDragging: function() |
471 { | 491 { |
472 this._isDragging = false; | 492 this._isDragging = false; |
473 }, | 493 }, |
474 | 494 |
475 /** | 495 /** |
476 * @param {!Event} event | 496 * @param {!Event} event |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 _onMouseWheel: function(e) | 553 _onMouseWheel: function(e) |
534 { | 554 { |
535 var scrollIsThere = this._totalHeight > this._offsetHeight; | 555 var scrollIsThere = this._totalHeight > this._offsetHeight; |
536 | 556 |
537 var panHorizontally = Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY) && !e.shiftKey; | 557 var panHorizontally = Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY) && !e.shiftKey; |
538 var panVertically = scrollIsThere && ((e.wheelDeltaY && !e.shiftKey) || (Math.abs(e.wheelDeltaX) === 120 && !e.shiftKey)); | 558 var panVertically = scrollIsThere && ((e.wheelDeltaY && !e.shiftKey) || (Math.abs(e.wheelDeltaX) === 120 && !e.shiftKey)); |
539 if (panVertically) { | 559 if (panVertically) { |
540 this._vScrollElement.scrollTop -= e.wheelDeltaY / 120 * this._offset Height / 8; | 560 this._vScrollElement.scrollTop -= e.wheelDeltaY / 120 * this._offset Height / 8; |
541 } else if (panHorizontally) { | 561 } else if (panHorizontally) { |
542 var shift = -e.wheelDeltaX * this._pixelToTime; | 562 var shift = -e.wheelDeltaX * this._pixelToTime; |
563 this._muteAnimation = true; | |
543 this._handlePanGesture(shift); | 564 this._handlePanGesture(shift); |
565 this._muteAnimation = false; | |
544 } else { // Zoom. | 566 } else { // Zoom. |
545 const mouseWheelZoomSpeed = 1 / 120; | 567 const mouseWheelZoomSpeed = 1 / 120; |
546 this._handleZoomGesture(Math.pow(1.2, -(e.wheelDeltaY || e.wheelDelt aX) * mouseWheelZoomSpeed) - 1); | 568 this._handleZoomGesture(Math.pow(1.2, -(e.wheelDeltaY || e.wheelDelt aX) * mouseWheelZoomSpeed) - 1); |
547 } | 569 } |
548 | 570 |
549 // Block swipe gesture. | 571 // Block swipe gesture. |
550 e.consume(true); | 572 e.consume(true); |
551 }, | 573 }, |
552 | 574 |
553 /** | 575 /** |
554 * @param {!Event} e | 576 * @param {!Event} e |
555 */ | 577 */ |
556 _onKeyDown: function(e) | 578 _onKeyDown: function(e) |
557 { | 579 { |
558 var multiplier = e.shiftKey ? 4 : 1; | 580 var zoomMultiplier = e.shiftKey ? 0.8 : 0.3; |
581 var panMultiplier = e.shiftKey ? 320 : 80; | |
559 if (e.keyCode === "A".charCodeAt(0)) { | 582 if (e.keyCode === "A".charCodeAt(0)) { |
560 this._handlePanGesture(-20 * this._pixelToTime * multiplier); | 583 this._handlePanGesture(-panMultiplier * this._pixelToTime); |
561 e.consume(true); | 584 e.consume(true); |
562 } else if (e.keyCode === "D".charCodeAt(0)) { | 585 } else if (e.keyCode === "D".charCodeAt(0)) { |
563 this._handlePanGesture(20 * this._pixelToTime * multiplier); | 586 this._handlePanGesture(panMultiplier * this._pixelToTime); |
564 e.consume(true); | 587 e.consume(true); |
565 } else if (e.keyCode === "W".charCodeAt(0)) { | 588 } else if (e.keyCode === "W".charCodeAt(0)) { |
566 this._handleZoomGesture(-0.2 * multiplier); | 589 this._handleZoomGesture(-zoomMultiplier); |
567 e.consume(true); | 590 e.consume(true); |
568 } else if (e.keyCode === "S".charCodeAt(0)) { | 591 } else if (e.keyCode === "S".charCodeAt(0)) { |
569 this._handleZoomGesture(0.2 * multiplier); | 592 this._handleZoomGesture(zoomMultiplier); |
570 e.consume(true); | 593 e.consume(true); |
571 } | 594 } |
572 }, | 595 }, |
573 | 596 |
574 /** | 597 /** |
575 * @param {number} zoom | 598 * @param {number} zoom |
576 */ | 599 */ |
577 _handleZoomGesture: function(zoom) | 600 _handleZoomGesture: function(zoom) |
578 { | 601 { |
579 var bounds = this._windowForGesture(); | 602 var bounds = this._windowForGesture(); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 _updateScrollBar: function() | 1134 _updateScrollBar: function() |
1112 { | 1135 { |
1113 var showScroll = this._totalHeight > this._offsetHeight; | 1136 var showScroll = this._totalHeight > this._offsetHeight; |
1114 this._vScrollElement.classList.toggle("hidden", !showScroll); | 1137 this._vScrollElement.classList.toggle("hidden", !showScroll); |
1115 this._offsetWidth = this.element.offsetWidth - (WebInspector.isMac() ? 0 : this._vScrollElement.offsetWidth); | 1138 this._offsetWidth = this.element.offsetWidth - (WebInspector.isMac() ? 0 : this._vScrollElement.offsetWidth); |
1116 this._offsetHeight = this.element.offsetHeight; | 1139 this._offsetHeight = this.element.offsetHeight; |
1117 }, | 1140 }, |
1118 | 1141 |
1119 scheduleUpdate: function() | 1142 scheduleUpdate: function() |
1120 { | 1143 { |
1121 if (this._updateTimerId) | 1144 if (this._updateTimerId || this._cancelWindowTimesAnimation) |
1122 return; | 1145 return; |
1123 this._updateTimerId = requestAnimationFrame(this.update.bind(this)); | 1146 this._updateTimerId = requestAnimationFrame(this.update.bind(this)); |
1124 }, | 1147 }, |
1125 | 1148 |
1126 update: function() | 1149 update: function() |
1127 { | 1150 { |
1128 this._updateTimerId = 0; | 1151 this._updateTimerId = 0; |
1129 if (!this._timelineData()) | 1152 if (!this._timelineData()) |
1130 return; | 1153 return; |
1131 this._resetCanvas(); | 1154 this._resetCanvas(); |
1132 this._updateBoundaries(); | 1155 this._updateBoundaries(); |
1133 this._calculator._updateBoundaries(this); | 1156 this._calculator._updateBoundaries(this); |
1134 this._draw(this._offsetWidth, this._offsetHeight); | 1157 this._draw(this._offsetWidth, this._offsetHeight); |
1135 }, | 1158 }, |
1136 | 1159 |
1137 reset: function() | 1160 reset: function() |
1138 { | 1161 { |
1139 this._highlightedMarkerIndex = -1; | 1162 this._highlightedMarkerIndex = -1; |
1140 this._highlightedEntryIndex = -1; | 1163 this._highlightedEntryIndex = -1; |
1141 this._selectedEntryIndex = -1; | 1164 this._selectedEntryIndex = -1; |
1142 this._textWidth = {}; | 1165 this._textWidth = {}; |
1143 this.update(); | 1166 this.update(); |
1144 }, | 1167 }, |
1145 | 1168 |
1146 __proto__: WebInspector.HBox.prototype | 1169 __proto__: WebInspector.HBox.prototype |
1147 } | 1170 } |
OLD | NEW |