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 22 matching lines...) Expand all Loading... | |
33 * @extends {WebInspector.View} | 33 * @extends {WebInspector.View} |
34 * @implements {WebInspector.DOMNodeHighlighter} | 34 * @implements {WebInspector.DOMNodeHighlighter} |
35 */ | 35 */ |
36 WebInspector.ScreencastView = function() | 36 WebInspector.ScreencastView = function() |
37 { | 37 { |
38 WebInspector.View.call(this); | 38 WebInspector.View.call(this); |
39 this.registerRequiredCSS("screencastView.css"); | 39 this.registerRequiredCSS("screencastView.css"); |
40 | 40 |
41 this.element.addStyleClass("fill"); | 41 this.element.addStyleClass("fill"); |
42 this.element.addStyleClass("screencast"); | 42 this.element.addStyleClass("screencast"); |
43 | |
44 this._createNavigationBar(); | |
45 | |
43 this._viewportElement = this.element.createChild("div", "screencast-viewport hidden"); | 46 this._viewportElement = this.element.createChild("div", "screencast-viewport hidden"); |
44 this._canvasElement = this._viewportElement.createChild("canvas"); | 47 this._canvasElement = this._viewportElement.createChild("canvas"); |
45 this._canvasElement.tabIndex = 1; | 48 this._canvasElement.tabIndex = 1; |
46 this._canvasElement.addEventListener("mousedown", this._handleMouseEvent.bin d(this), false); | 49 this._canvasElement.addEventListener("mousedown", this._handleMouseEvent.bin d(this), false); |
47 this._canvasElement.addEventListener("mouseup", this._handleMouseEvent.bind( this), false); | 50 this._canvasElement.addEventListener("mouseup", this._handleMouseEvent.bind( this), false); |
48 this._canvasElement.addEventListener("mousemove", this._handleMouseEvent.bin d(this), false); | 51 this._canvasElement.addEventListener("mousemove", this._handleMouseEvent.bin d(this), false); |
49 this._canvasElement.addEventListener("mousewheel", this._handleMouseEvent.bi nd(this), false); | 52 this._canvasElement.addEventListener("mousewheel", this._handleMouseEvent.bi nd(this), false); |
50 this._canvasElement.addEventListener("click", this._handleMouseEvent.bind(th is), false); | 53 this._canvasElement.addEventListener("click", this._handleMouseEvent.bind(th is), false); |
51 this._canvasElement.addEventListener("contextmenu", this._handleContextMenuE vent.bind(this), false); | 54 this._canvasElement.addEventListener("contextmenu", this._handleContextMenuE vent.bind(this), false); |
52 this._canvasElement.addEventListener("keydown", this._handleKeyEvent.bind(th is), false); | 55 this._canvasElement.addEventListener("keydown", this._handleKeyEvent.bind(th is), false); |
(...skipping 14 matching lines...) Expand all Loading... | |
67 this._imageElement = new Image(); | 70 this._imageElement = new Image(); |
68 this._isCasting = false; | 71 this._isCasting = false; |
69 this._context = this._canvasElement.getContext("2d"); | 72 this._context = this._canvasElement.getContext("2d"); |
70 this._checkerboardPattern = this._createCheckerboardPattern(this._context); | 73 this._checkerboardPattern = this._createCheckerboardPattern(this._context); |
71 | 74 |
72 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.ScreencastFrame, this._screencastFrame, this); | 75 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.ScreencastFrame, this._screencastFrame, this); |
73 } | 76 } |
74 | 77 |
75 WebInspector.ScreencastView._bordersSize = 40; | 78 WebInspector.ScreencastView._bordersSize = 40; |
76 | 79 |
80 WebInspector.ScreencastView.HTTP_REGEXP = /^https?:\/\/(.+)/; | |
pfeldman
2013/09/05 11:34:13
HttpRegex
Vladislav Kaznacheev
2013/09/05 12:53:55
Renamed to _HttpRegex
On 2013/09/05 11:34:13, pfe
| |
81 | |
77 WebInspector.ScreencastView.prototype = { | 82 WebInspector.ScreencastView.prototype = { |
78 wasShown: function() | 83 wasShown: function() |
79 { | 84 { |
80 this._startCasting(); | 85 this._startCasting(); |
81 }, | 86 }, |
82 | 87 |
83 willHide: function() | 88 willHide: function() |
84 { | 89 { |
85 this._stopCasting(); | 90 this._stopCasting(); |
86 }, | 91 }, |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 | 617 |
613 pctx.fillStyle = "rgb(195, 195, 195)"; | 618 pctx.fillStyle = "rgb(195, 195, 195)"; |
614 pctx.fillRect(0, 0, size * 2, size * 2); | 619 pctx.fillRect(0, 0, size * 2, size * 2); |
615 | 620 |
616 pctx.fillStyle = "rgb(225, 225, 225)"; | 621 pctx.fillStyle = "rgb(225, 225, 225)"; |
617 pctx.fillRect(0, 0, size, size); | 622 pctx.fillRect(0, 0, size, size); |
618 pctx.fillRect(size, size, size, size); | 623 pctx.fillRect(size, size, size, size); |
619 return context.createPattern(pattern, "repeat"); | 624 return context.createPattern(pattern, "repeat"); |
620 }, | 625 }, |
621 | 626 |
627 _createNavigationBar: function() | |
628 { | |
629 this._navigationBar = this.element.createChild("div", "screencast-naviga tion"); | |
630 | |
631 this._navigationBack = this._navigationBar.createChild("button"); | |
632 this._navigationBack.textContent = "\u21E6"; // Back arrow. | |
633 this._navigationBack.disabled = true; | |
634 this._navigationBack.addEventListener("click", this._navigateToHistoryEn try.bind(this, -1), false); | |
635 | |
636 this._navigationForward = this._navigationBar.createChild("button"); | |
637 this._navigationForward.textContent = "\u21E8"; // Forward arrow. | |
638 this._navigationForward.disabled = true; | |
639 this._navigationForward.addEventListener("click", this._navigateToHistor yEntry.bind(this, 1), false); | |
640 | |
641 this._navigationReload = this._navigationBar.createChild("button"); | |
642 this._navigationReload.textContent = "\u21BB"; // Circle arrow. | |
643 this._navigationReload.addEventListener("click", this._navigateReload.bi nd(this), false); | |
644 | |
645 this._navigationUrl = this._navigationBar.createChild("input"); | |
646 this._navigationUrl.type = "text"; | |
647 this._navigationUrl.addEventListener('keyup', this._navigationUrlKeyUp.b ind(this), true); | |
648 | |
649 this._requestNavigationHistory(); | |
650 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.InspectedURLChanged, this._requestNavigationHistory, this); | |
651 }, | |
652 | |
653 _navigateToHistoryEntry: function(offset) | |
654 { | |
655 PageAgent.navigateToHistoryEntry(this._currentHistoryIndex + offset); | |
656 this._requestNavigationHistory(); | |
657 }, | |
658 | |
659 _navigateReload: function() | |
660 { | |
661 PageAgent.reload(); | |
662 }, | |
663 | |
664 _navigationUrlKeyUp: function(event) | |
665 { | |
666 if (event.keyIdentifier != 'Enter') | |
667 return; | |
668 var url = this._navigationUrl.value; | |
669 if (!url) | |
670 return; | |
671 if (!url.match(WebInspector.ScreencastView.HTTP_REGEXP)) | |
672 url = "http://" + url; | |
673 PageAgent.navigate(url); | |
674 }, | |
675 | |
676 _requestNavigationHistory: function() | |
677 { | |
678 PageAgent.getNavigationHistory(this._onNavigationHistory.bind(this)); | |
679 }, | |
680 | |
681 _onNavigationHistory: function(error, currentIndex, entries) | |
682 { | |
683 if (error) { | |
684 this._navigationBack.hidden = true; | |
685 this._navigationForward.hidden = true; | |
686 return; | |
687 } | |
688 | |
689 this._currentHistoryIndex = currentIndex; | |
690 this._navigationBack.disabled = currentIndex == 0; | |
691 this._navigationForward.disabled = currentIndex == (entries.length - 1); | |
692 | |
693 var url = entries[currentIndex].url; | |
694 var match = url.match(WebInspector.ScreencastView.HTTP_REGEXP); | |
695 if (match) | |
696 url = match[1]; | |
697 this._navigationUrl.value = url; | |
698 }, | |
699 | |
622 __proto__: WebInspector.View.prototype | 700 __proto__: WebInspector.View.prototype |
623 } | 701 } |
OLD | NEW |