| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 * @return {number} | 440 * @return {number} |
| 441 */ | 441 */ |
| 442 boundarySpan: function() | 442 boundarySpan: function() |
| 443 { | 443 { |
| 444 return this._maximumBoundaries - this._minimumBoundaries; | 444 return this._maximumBoundaries - this._minimumBoundaries; |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 WebInspector.FlameChart.prototype = { | 448 WebInspector.FlameChart.prototype = { |
| 449 /** | 449 /** |
| 450 * @override |
| 451 */ |
| 452 willHide: function() |
| 453 { |
| 454 this.hideHighlight(); |
| 455 }, |
| 456 |
| 457 /** |
| 450 * @param {number} entryIndex | 458 * @param {number} entryIndex |
| 451 */ | 459 */ |
| 452 highlightEntry: function(entryIndex) | 460 highlightEntry: function(entryIndex) |
| 453 { | 461 { |
| 454 this._entryInfo.removeChildren(); | 462 if (this._highlightedEntryIndex === entryIndex) |
| 455 this._innerHighlightEntry(entryIndex); | 463 return; |
| 464 this._highlightedEntryIndex = entryIndex; |
| 465 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 456 }, | 466 }, |
| 457 | 467 |
| 458 hideHighlight: function() | 468 hideHighlight: function() |
| 459 { | 469 { |
| 460 this._entryInfo.removeChildren(); | 470 this._entryInfo.removeChildren(); |
| 461 this._canvas.style.cursor = "default"; | 471 this._canvas.style.cursor = "default"; |
| 462 this._highlightedEntryIndex = -1; | 472 this._highlightedEntryIndex = -1; |
| 463 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); | 473 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 464 }, | 474 }, |
| 465 | 475 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 { | 542 { |
| 533 if (this._muteAnimation || this._timeWindowLeft === 0 || this._timeWindo
wRight === Infinity || (startTime === 0 && endTime === Infinity) || (startTime =
== Infinity && endTime === Infinity)) { | 543 if (this._muteAnimation || this._timeWindowLeft === 0 || this._timeWindo
wRight === Infinity || (startTime === 0 && endTime === Infinity) || (startTime =
== Infinity && endTime === Infinity)) { |
| 534 // Initial setup. | 544 // Initial setup. |
| 535 this._timeWindowLeft = startTime; | 545 this._timeWindowLeft = startTime; |
| 536 this._timeWindowRight = endTime; | 546 this._timeWindowRight = endTime; |
| 537 this.scheduleUpdate(); | 547 this.scheduleUpdate(); |
| 538 return; | 548 return; |
| 539 } | 549 } |
| 540 | 550 |
| 541 this._cancelAnimation(); | 551 this._cancelAnimation(); |
| 552 this._updateHighlight(); |
| 542 this._cancelWindowTimesAnimation = WebInspector.animateFunction(this.ele
ment.window(), this._animateWindowTimes.bind(this), | 553 this._cancelWindowTimesAnimation = WebInspector.animateFunction(this.ele
ment.window(), this._animateWindowTimes.bind(this), |
| 543 [{from: this._timeWindowLeft, to: startTime}, {from: this._timeWindo
wRight, to: endTime}], 5, | 554 [{from: this._timeWindowLeft, to: startTime}, {from: this._timeWindo
wRight, to: endTime}], 5, |
| 544 this._animationCompleted.bind(this)); | 555 this._animationCompleted.bind(this)); |
| 545 this._pendingAnimationTimeLeft = startTime; | 556 this._pendingAnimationTimeLeft = startTime; |
| 546 this._pendingAnimationTimeRight = endTime; | 557 this._pendingAnimationTimeRight = endTime; |
| 547 }, | 558 }, |
| 548 | 559 |
| 549 /** | 560 /** |
| 550 * @param {number} startTime | 561 * @param {number} startTime |
| 551 * @param {number} endTime | 562 * @param {number} endTime |
| 552 */ | 563 */ |
| 553 _animateWindowTimes: function(startTime, endTime) | 564 _animateWindowTimes: function(startTime, endTime) |
| 554 { | 565 { |
| 555 this._timeWindowLeft = startTime; | 566 this._timeWindowLeft = startTime; |
| 556 this._timeWindowRight = endTime; | 567 this._timeWindowRight = endTime; |
| 568 this._updateHighlight(); |
| 557 this.update(); | 569 this.update(); |
| 558 }, | 570 }, |
| 559 | 571 |
| 560 _animationCompleted: function() | 572 _animationCompleted: function() |
| 561 { | 573 { |
| 562 delete this._cancelWindowTimesAnimation; | 574 delete this._cancelWindowTimesAnimation; |
| 575 this._updateHighlight(); |
| 563 }, | 576 }, |
| 564 | 577 |
| 565 /** | 578 /** |
| 566 * @param {!MouseEvent} event | 579 * @param {!MouseEvent} event |
| 567 */ | 580 */ |
| 568 _initMaxDragOffset: function(event) | 581 _initMaxDragOffset: function(event) |
| 569 { | 582 { |
| 570 this._maxDragOffsetSquared = 0; | 583 this._maxDragOffsetSquared = 0; |
| 571 this._dragStartX = event.pageX; | 584 this._dragStartX = event.pageX; |
| 572 this._dragStartY = event.pageY; | 585 this._dragStartY = event.pageY; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 602 if (!this._timelineData() || this._timeWindowRight === Infinity) | 615 if (!this._timelineData() || this._timeWindowRight === Infinity) |
| 603 return false; | 616 return false; |
| 604 this._isDragging = true; | 617 this._isDragging = true; |
| 605 this._initMaxDragOffset(event); | 618 this._initMaxDragOffset(event); |
| 606 this._dragStartPointX = event.pageX; | 619 this._dragStartPointX = event.pageX; |
| 607 this._dragStartPointY = event.pageY; | 620 this._dragStartPointY = event.pageY; |
| 608 this._dragStartScrollTop = this._vScrollElement.scrollTop; | 621 this._dragStartScrollTop = this._vScrollElement.scrollTop; |
| 609 this._dragStartWindowLeft = this._timeWindowLeft; | 622 this._dragStartWindowLeft = this._timeWindowLeft; |
| 610 this._dragStartWindowRight = this._timeWindowRight; | 623 this._dragStartWindowRight = this._timeWindowRight; |
| 611 this._canvas.style.cursor = ""; | 624 this._canvas.style.cursor = ""; |
| 625 this.hideHighlight(); |
| 612 return true; | 626 return true; |
| 613 }, | 627 }, |
| 614 | 628 |
| 615 /** | 629 /** |
| 616 * @param {!MouseEvent} event | 630 * @param {!MouseEvent} event |
| 617 */ | 631 */ |
| 618 _canvasDragging: function(event) | 632 _canvasDragging: function(event) |
| 619 { | 633 { |
| 620 var pixelShift = this._dragStartPointX - event.pageX; | 634 var pixelShift = this._dragStartPointX - event.pageX; |
| 621 this._dragStartPointX = event.pageX; | 635 this._dragStartPointX = event.pageX; |
| 622 this._muteAnimation = true; | 636 this._muteAnimation = true; |
| 623 this._handlePanGesture(pixelShift * this._pixelToTime); | 637 this._handlePanGesture(pixelShift * this._pixelToTime); |
| 624 this._muteAnimation = false; | 638 this._muteAnimation = false; |
| 625 | 639 |
| 626 var pixelScroll = this._dragStartPointY - event.pageY; | 640 var pixelScroll = this._dragStartPointY - event.pageY; |
| 627 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll; | 641 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll; |
| 628 this._updateMaxDragOffset(event); | 642 this._updateMaxDragOffset(event); |
| 629 }, | 643 }, |
| 630 | 644 |
| 631 _endCanvasDragging: function() | 645 _endCanvasDragging: function() |
| 632 { | 646 { |
| 633 this._isDragging = false; | 647 this._isDragging = false; |
| 648 this._updateHighlight(); |
| 634 }, | 649 }, |
| 635 | 650 |
| 636 /** | 651 /** |
| 637 * @param {!MouseEvent} event | 652 * @param {!MouseEvent} event |
| 638 * @return {boolean} | 653 * @return {boolean} |
| 639 */ | 654 */ |
| 640 _startRangeSelection: function(event) | 655 _startRangeSelection: function(event) |
| 641 { | 656 { |
| 642 if (!event.shiftKey) | 657 if (!event.shiftKey) |
| 643 return false; | 658 return false; |
| 644 this._isDragging = true; | 659 this._isDragging = true; |
| 645 this._initMaxDragOffset(event); | 660 this._initMaxDragOffset(event); |
| 646 this._selectionOffsetShiftX = event.offsetX - event.pageX; | 661 this._selectionOffsetShiftX = event.offsetX - event.pageX; |
| 647 this._selectionOffsetShiftY = event.offsetY - event.pageY; | 662 this._selectionOffsetShiftY = event.offsetY - event.pageY; |
| 648 this._selectionStartX = event.offsetX; | 663 this._selectionStartX = event.offsetX; |
| 649 var style = this._selectionOverlay.style; | 664 var style = this._selectionOverlay.style; |
| 650 style.left = this._selectionStartX + "px"; | 665 style.left = this._selectionStartX + "px"; |
| 651 style.width = "1px"; | 666 style.width = "1px"; |
| 652 this._selectedTimeSpanLabel.textContent = ""; | 667 this._selectedTimeSpanLabel.textContent = ""; |
| 653 this._selectionOverlay.classList.remove("hidden"); | 668 this._selectionOverlay.classList.remove("hidden"); |
| 669 this.hideHighlight(); |
| 654 return true; | 670 return true; |
| 655 }, | 671 }, |
| 656 | 672 |
| 657 _endRangeSelection: function() | 673 _endRangeSelection: function() |
| 658 { | 674 { |
| 659 this._isDragging = false; | 675 this._isDragging = false; |
| 660 this._flameChartDelegate.endRangeSelection(); | 676 this._flameChartDelegate.endRangeSelection(); |
| 677 this._updateHighlight(); |
| 661 }, | 678 }, |
| 662 | 679 |
| 663 _hideRangeSelection: function() | 680 _hideRangeSelection: function() |
| 664 { | 681 { |
| 665 this._selectionOverlay.classList.add("hidden"); | 682 this._selectionOverlay.classList.add("hidden"); |
| 666 }, | 683 }, |
| 667 | 684 |
| 668 /** | 685 /** |
| 669 * @param {!MouseEvent} event | 686 * @param {!MouseEvent} event |
| 670 */ | 687 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 692 this._selectedTimeSpanLabel.textContent = Number.preciseMillisToString(t
imeSpan, 2); | 709 this._selectedTimeSpanLabel.textContent = Number.preciseMillisToString(t
imeSpan, 2); |
| 693 }, | 710 }, |
| 694 | 711 |
| 695 /** | 712 /** |
| 696 * @param {!Event} event | 713 * @param {!Event} event |
| 697 */ | 714 */ |
| 698 _onMouseMove: function(event) | 715 _onMouseMove: function(event) |
| 699 { | 716 { |
| 700 this._lastMouseOffsetX = event.offsetX; | 717 this._lastMouseOffsetX = event.offsetX; |
| 701 this._lastMouseOffsetY = event.offsetY; | 718 this._lastMouseOffsetY = event.offsetY; |
| 702 | |
| 703 if (!this._enabled()) | 719 if (!this._enabled()) |
| 704 return; | 720 return; |
| 705 | |
| 706 if (this._isDragging) | 721 if (this._isDragging) |
| 707 return; | 722 return; |
| 723 this._updateHighlight(); |
| 724 }, |
| 708 | 725 |
| 709 var inDividersBar = event.offsetY < WebInspector.FlameChart.DividersBarH
eight; | 726 _updateHighlight: function() |
| 710 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(event.offsetX) : -1; | 727 { |
| 728 var inDividersBar = this._lastMouseOffsetY < WebInspector.FlameChart.Div
idersBarHeight; |
| 729 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(this._lastMouseOffsetX) : -1; |
| 711 this._updateMarkerHighlight(); | 730 this._updateMarkerHighlight(); |
| 712 | 731 |
| 713 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, t
his._lastMouseOffsetY); | 732 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, t
his._lastMouseOffsetY); |
| 714 if (entryIndex === -1) { | 733 if (entryIndex === -1) { |
| 715 this.hideHighlight(); | 734 this.hideHighlight(); |
| 716 return; | 735 return; |
| 717 } | 736 } |
| 718 this._updateEntryInfo(entryIndex); | 737 this._updatePopover(entryIndex); |
| 719 | |
| 720 this._canvas.style.cursor = this._dataProvider.canJumpToEntry(entryIndex
) ? "pointer" : "default"; | 738 this._canvas.style.cursor = this._dataProvider.canJumpToEntry(entryIndex
) ? "pointer" : "default"; |
| 721 this._innerHighlightEntry(entryIndex); | 739 this.highlightEntry(entryIndex); |
| 722 }, | 740 }, |
| 723 | 741 |
| 724 _onMouseOut: function() | 742 _onMouseOut: function() |
| 725 { | 743 { |
| 744 this._lastMouseOffsetX = -1; |
| 745 this._lastMouseOffsetY = -1; |
| 726 this.hideHighlight(); | 746 this.hideHighlight(); |
| 727 }, | 747 }, |
| 728 | 748 |
| 729 /** | 749 /** |
| 730 * @param {number} entryIndex | 750 * @param {number} entryIndex |
| 731 */ | 751 */ |
| 732 _updateEntryInfo: function(entryIndex) | 752 _updatePopover: function(entryIndex) |
| 733 { | 753 { |
| 734 if (entryIndex !== this._highlightedEntryIndex) { | 754 if (entryIndex !== this._highlightedEntryIndex) { |
| 735 this._entryInfo.removeChildren(); | 755 this._entryInfo.removeChildren(); |
| 736 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(entry
Index); | 756 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(entry
Index); |
| 737 if (entryInfo) | 757 if (entryInfo) |
| 738 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); | 758 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); |
| 739 } | 759 } |
| 740 var mouseX = this._lastMouseOffsetX; | 760 var mouseX = this._lastMouseOffsetX; |
| 741 var mouseY = this._lastMouseOffsetY; | 761 var mouseY = this._lastMouseOffsetY; |
| 742 var parentWidth = this._entryInfo.parentElement.clientWidth; | 762 var parentWidth = this._entryInfo.parentElement.clientWidth; |
| 743 var parentHeight = this._entryInfo.parentElement.clientHeight; | 763 var parentHeight = this._entryInfo.parentElement.clientHeight; |
| 744 var infoWidth = this._entryInfo.clientWidth; | 764 var infoWidth = this._entryInfo.clientWidth; |
| 745 var infoHeight = this._entryInfo.clientHeight; | 765 var infoHeight = this._entryInfo.clientHeight; |
| 746 var /** @const */ offsetX = 10; | 766 var /** @const */ offsetX = 10; |
| 747 var /** @const */ offsetY = 6; | 767 var /** @const */ offsetY = 6; |
| 748 var x; | 768 var x; |
| 749 var y; | 769 var y; |
| 750 for (var quadrant = 0; quadrant < 4; ++quadrant) { | 770 for (var quadrant = 0; quadrant < 4; ++quadrant) { |
| 751 var dx = quadrant & 2 ? -offsetX - infoWidth : offsetX; | 771 var dx = quadrant & 2 ? -offsetX - infoWidth : offsetX; |
| 752 var dy = quadrant & 1 ? -offsetY - infoHeight : offsetY; | 772 var dy = quadrant & 1 ? -offsetY - infoHeight : offsetY; |
| 753 x = Number.constrain(mouseX + dx, 0, parentWidth - infoWidth); | 773 x = Number.constrain(mouseX + dx, 0, parentWidth - infoWidth); |
| 754 y = Number.constrain(mouseY + dy, 0, parentHeight - infoHeight); | 774 y = Number.constrain(mouseY + dy, 0, parentHeight - infoHeight); |
| 755 if (x >= mouseX || mouseX >= x + infoWidth || y >= mouseY || mouseY
>= y + infoHeight) | 775 if (x >= mouseX || mouseX >= x + infoWidth || y >= mouseY || mouseY
>= y + infoHeight) |
| 756 break; | 776 break; |
| 757 } | 777 } |
| 758 this._entryInfo.style.left = x + "px"; | 778 this._entryInfo.style.left = x + "px"; |
| 759 this._entryInfo.style.top = y + "px"; | 779 this._entryInfo.style.top = y + "px"; |
| 760 }, | 780 }, |
| 761 | 781 |
| 762 /** | |
| 763 * @param {number} entryIndex | |
| 764 */ | |
| 765 _innerHighlightEntry: function(entryIndex) | |
| 766 { | |
| 767 if (this._highlightedEntryIndex === entryIndex) | |
| 768 return; | |
| 769 this._highlightedEntryIndex = entryIndex; | |
| 770 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); | |
| 771 }, | |
| 772 | |
| 773 _onClick: function() | 782 _onClick: function() |
| 774 { | 783 { |
| 775 this.focus(); | 784 this.focus(); |
| 776 // onClick comes after dragStart and dragEnd events. | 785 // onClick comes after dragStart and dragEnd events. |
| 777 // So if there was drag (mouse move) in the middle of that events | 786 // So if there was drag (mouse move) in the middle of that events |
| 778 // we skip the click. Otherwise we jump to the sources. | 787 // we skip the click. Otherwise we jump to the sources. |
| 779 const clickThreshold = 5; | 788 const clickThreshold = 5; |
| 780 if (this._maxDragOffset() > clickThreshold) | 789 if (this._maxDragOffset() > clickThreshold) |
| 781 return; | 790 return; |
| 782 this._hideRangeSelection(); | 791 this._hideRangeSelection(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._minimumBoundary; | 977 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._minimumBoundary; |
| 969 }, | 978 }, |
| 970 | 979 |
| 971 /** | 980 /** |
| 972 * @param {number} x | 981 * @param {number} x |
| 973 * @param {number} y | 982 * @param {number} y |
| 974 * @return {number} | 983 * @return {number} |
| 975 */ | 984 */ |
| 976 _coordinatesToEntryIndex: function(x, y) | 985 _coordinatesToEntryIndex: function(x, y) |
| 977 { | 986 { |
| 987 if (x < 0 || y < 0) |
| 988 return -1; |
| 978 y += this._scrollTop; | 989 y += this._scrollTop; |
| 979 var timelineData = this._timelineData(); | 990 var timelineData = this._timelineData(); |
| 980 if (!timelineData) | 991 if (!timelineData) |
| 981 return -1; | 992 return -1; |
| 982 var cursorTime = this._cursorTime(x); | 993 var cursorTime = this._cursorTime(x); |
| 983 var cursorLevel; | 994 var cursorLevel; |
| 984 var offsetFromLevel; | 995 var offsetFromLevel; |
| 985 if (this._isTopDown) { | 996 if (this._isTopDown) { |
| 986 cursorLevel = Math.floor((y - WebInspector.FlameChart.DividersBarHei
ght) / this._barHeight); | 997 cursorLevel = Math.floor((y - WebInspector.FlameChart.DividersBarHei
ght) / this._barHeight); |
| 987 offsetFromLevel = y - WebInspector.FlameChart.DividersBarHeight - cu
rsorLevel * this._barHeight; | 998 offsetFromLevel = y - WebInspector.FlameChart.DividersBarHeight - cu
rsorLevel * this._barHeight; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 | 1576 |
| 1566 update: function() | 1577 update: function() |
| 1567 { | 1578 { |
| 1568 this._updateTimerId = 0; | 1579 this._updateTimerId = 0; |
| 1569 if (!this._timelineData()) | 1580 if (!this._timelineData()) |
| 1570 return; | 1581 return; |
| 1571 this._resetCanvas(); | 1582 this._resetCanvas(); |
| 1572 this._updateBoundaries(); | 1583 this._updateBoundaries(); |
| 1573 this._calculator._updateBoundaries(this); | 1584 this._calculator._updateBoundaries(this); |
| 1574 this._draw(this._offsetWidth, this._offsetHeight); | 1585 this._draw(this._offsetWidth, this._offsetHeight); |
| 1586 if (!this._isDragging) |
| 1587 this._updateHighlight(); |
| 1575 }, | 1588 }, |
| 1576 | 1589 |
| 1577 reset: function() | 1590 reset: function() |
| 1578 { | 1591 { |
| 1579 this._vScrollElement.scrollTop = 0; | 1592 this._vScrollElement.scrollTop = 0; |
| 1580 this._highlightedMarkerIndex = -1; | 1593 this._highlightedMarkerIndex = -1; |
| 1581 this._highlightedEntryIndex = -1; | 1594 this._highlightedEntryIndex = -1; |
| 1582 this._selectedEntryIndex = -1; | 1595 this._selectedEntryIndex = -1; |
| 1583 this._textWidth = {}; | 1596 this._textWidth = {}; |
| 1584 this.update(); | 1597 this.update(); |
| 1585 }, | 1598 }, |
| 1586 | 1599 |
| 1587 _enabled: function() | 1600 _enabled: function() |
| 1588 { | 1601 { |
| 1589 return this._rawTimelineDataLength !== 0; | 1602 return this._rawTimelineDataLength !== 0; |
| 1590 }, | 1603 }, |
| 1591 | 1604 |
| 1592 __proto__: WebInspector.HBox.prototype | 1605 __proto__: WebInspector.HBox.prototype |
| 1593 } | 1606 } |
| OLD | NEW |