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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 var timeSpan = this._rangeSelectionEnd - this._rangeSelectionStart; | 674 var timeSpan = this._rangeSelectionEnd - this._rangeSelectionStart; |
675 this._selectedTimeSpanLabel.textContent = Number.preciseMillisToString(t
imeSpan, 2); | 675 this._selectedTimeSpanLabel.textContent = Number.preciseMillisToString(t
imeSpan, 2); |
676 }, | 676 }, |
677 | 677 |
678 /** | 678 /** |
679 * @param {!Event} event | 679 * @param {!Event} event |
680 */ | 680 */ |
681 _onMouseMove: function(event) | 681 _onMouseMove: function(event) |
682 { | 682 { |
683 this._lastMouseOffsetX = event.offsetX; | 683 this._lastMouseOffsetX = event.offsetX; |
| 684 this._lastMouseOffsetY = event.offsetY; |
684 | 685 |
685 if (!this._enabled()) | 686 if (!this._enabled()) |
686 return; | 687 return; |
687 | 688 |
688 if (this._isDragging) | 689 if (this._isDragging) |
689 return; | 690 return; |
690 | 691 |
691 var inDividersBar = event.offsetY < WebInspector.FlameChart.DividersBarH
eight; | 692 var inDividersBar = event.offsetY < WebInspector.FlameChart.DividersBarH
eight; |
692 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(event.offsetX) : -1; | 693 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(event.offsetX) : -1; |
693 this._updateMarkerHighlight(); | 694 this._updateMarkerHighlight(); |
694 this._entryInfo.style.left = event.offsetX + "px"; | 695 this._showHighlight(); |
695 this._entryInfo.style.top = event.offsetY + "px"; | |
696 | |
697 this._highlightEntry(this._coordinatesToEntryIndex(event.offsetX, event.
offsetY)); | |
698 }, | 696 }, |
699 | 697 |
700 _onMouseOut: function() | 698 _onMouseOut: function() |
701 { | 699 { |
702 this._highlightEntry(-1); | 700 this._hideHighlight(); |
703 }, | 701 }, |
704 | 702 |
705 /** | 703 _showHighlight: function() |
706 * @param {number} entryIndex | |
707 */ | |
708 _highlightEntry: function(entryIndex) | |
709 { | 704 { |
710 if (this._highlightedEntryIndex === entryIndex) | 705 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, t
his._lastMouseOffsetY); |
| 706 if (entryIndex === -1) { |
| 707 this._hideHighlight(); |
711 return; | 708 return; |
712 | 709 } |
713 if (entryIndex === -1 || !this._dataProvider.canJumpToEntry(entryIndex)) | 710 if (entryIndex !== this._highlightedEntryIndex) { |
714 this._canvas.style.cursor = "default"; | 711 this._entryInfo.removeChildren(); |
715 else | 712 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(entry
Index); |
716 this._canvas.style.cursor = "pointer"; | |
717 | |
718 this._highlightedEntryIndex = entryIndex; | |
719 | |
720 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); | |
721 this._entryInfo.removeChildren(); | |
722 | |
723 if (this._highlightedEntryIndex === -1) | |
724 return; | |
725 | |
726 if (!this._isDragging) { | |
727 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(this.
_highlightedEntryIndex); | |
728 if (entryInfo) | 713 if (entryInfo) |
729 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); | 714 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); |
730 } | 715 } |
| 716 var mouseX = this._lastMouseOffsetX; |
| 717 var mouseY = this._lastMouseOffsetY; |
| 718 var parentWidth = this._entryInfo.parentElement.clientWidth; |
| 719 var parentHeight = this._entryInfo.parentElement.clientHeight; |
| 720 var infoWidth = this._entryInfo.clientWidth; |
| 721 var infoHeight = this._entryInfo.clientHeight; |
| 722 var /** @const */ offsetX = 10; |
| 723 var /** @const */ offsetY = 6; |
| 724 var x; |
| 725 var y; |
| 726 for (var quadrant = 0; quadrant < 4; ++quadrant) { |
| 727 var dx = quadrant & 2 ? -offsetX - infoWidth : offsetX; |
| 728 var dy = quadrant & 1 ? -offsetY - infoHeight : offsetY; |
| 729 x = Number.constrain(mouseX + dx, 0, parentWidth - infoWidth); |
| 730 y = Number.constrain(mouseY + dy, 0, parentHeight - infoHeight); |
| 731 if (x >= mouseX || mouseX >= x + infoWidth || y >= mouseY || mouseY
>= y + infoHeight) |
| 732 break; |
| 733 } |
| 734 this._entryInfo.style.left = x + "px"; |
| 735 this._entryInfo.style.top = y + "px"; |
| 736 if (this._highlightedEntryIndex === entryIndex) |
| 737 return; |
| 738 this._highlightedEntryIndex = entryIndex; |
| 739 this._canvas.style.cursor = this._dataProvider.canJumpToEntry(entryIndex
) ? "pointer" : "default"; |
| 740 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 741 }, |
| 742 |
| 743 _hideHighlight: function() |
| 744 { |
| 745 this._entryInfo.removeChildren(); |
| 746 this._canvas.style.cursor = "default"; |
| 747 this._highlightedEntryIndex = -1; |
| 748 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
731 }, | 749 }, |
732 | 750 |
733 _onClick: function() | 751 _onClick: function() |
734 { | 752 { |
735 this.focus(); | 753 this.focus(); |
736 // onClick comes after dragStart and dragEnd events. | 754 // onClick comes after dragStart and dragEnd events. |
737 // So if there was drag (mouse move) in the middle of that events | 755 // So if there was drag (mouse move) in the middle of that events |
738 // we skip the click. Otherwise we jump to the sources. | 756 // we skip the click. Otherwise we jump to the sources. |
739 const clickThreshold = 5; | 757 const clickThreshold = 5; |
740 if (this._maxDragOffset() > clickThreshold) | 758 if (this._maxDragOffset() > clickThreshold) |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 this.update(); | 1562 this.update(); |
1545 }, | 1563 }, |
1546 | 1564 |
1547 _enabled: function() | 1565 _enabled: function() |
1548 { | 1566 { |
1549 return this._rawTimelineDataLength !== 0; | 1567 return this._rawTimelineDataLength !== 0; |
1550 }, | 1568 }, |
1551 | 1569 |
1552 __proto__: WebInspector.HBox.prototype | 1570 __proto__: WebInspector.HBox.prototype |
1553 } | 1571 } |
OLD | NEW |