| 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._HttpRegex = /^https?:\/\/(.+)/; |
| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 618 |
| 614 pctx.fillStyle = "rgb(195, 195, 195)"; | 619 pctx.fillStyle = "rgb(195, 195, 195)"; |
| 615 pctx.fillRect(0, 0, size * 2, size * 2); | 620 pctx.fillRect(0, 0, size * 2, size * 2); |
| 616 | 621 |
| 617 pctx.fillStyle = "rgb(225, 225, 225)"; | 622 pctx.fillStyle = "rgb(225, 225, 225)"; |
| 618 pctx.fillRect(0, 0, size, size); | 623 pctx.fillRect(0, 0, size, size); |
| 619 pctx.fillRect(size, size, size, size); | 624 pctx.fillRect(size, size, size, size); |
| 620 return context.createPattern(pattern, "repeat"); | 625 return context.createPattern(pattern, "repeat"); |
| 621 }, | 626 }, |
| 622 | 627 |
| 628 _createNavigationBar: function() |
| 629 { |
| 630 this._navigationBar = this.element.createChild("div", "screencast-naviga
tion"); |
| 631 |
| 632 this._navigationBack = this._navigationBar.createChild("button", "back")
; |
| 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", "for
ward"); |
| 637 this._navigationForward.disabled = true; |
| 638 this._navigationForward.addEventListener("click", this._navigateToHistor
yEntry.bind(this, 1), false); |
| 639 |
| 640 this._navigationReload = this._navigationBar.createChild("button", "relo
ad"); |
| 641 this._navigationReload.addEventListener("click", this._navigateReload.bi
nd(this), false); |
| 642 |
| 643 this._navigationUrl = this._navigationBar.createChild("input"); |
| 644 this._navigationUrl.type = "text"; |
| 645 this._navigationUrl.addEventListener('keyup', this._navigationUrlKeyUp.b
ind(this), true); |
| 646 |
| 647 this._requestNavigationHistory(); |
| 648 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.InspectedURLChanged, this._requestNavigationHistory, this); |
| 649 }, |
| 650 |
| 651 _navigateToHistoryEntry: function(offset) |
| 652 { |
| 653 var newIndex = this._historyIndex + offset; |
| 654 if (newIndex < 0 || newIndex >= this._historyEntries.length) |
| 655 return; |
| 656 PageAgent.navigateToHistoryEntry(this._historyEntries[newIndex].id); |
| 657 this._requestNavigationHistory(); |
| 658 }, |
| 659 |
| 660 _navigateReload: function() |
| 661 { |
| 662 PageAgent.reload(); |
| 663 }, |
| 664 |
| 665 _navigationUrlKeyUp: function(event) |
| 666 { |
| 667 if (event.keyIdentifier != 'Enter') |
| 668 return; |
| 669 var url = this._navigationUrl.value; |
| 670 if (!url) |
| 671 return; |
| 672 if (!url.match(WebInspector.ScreencastView._HttpRegex)) |
| 673 url = "http://" + url; |
| 674 PageAgent.navigate(url); |
| 675 }, |
| 676 |
| 677 _requestNavigationHistory: function() |
| 678 { |
| 679 PageAgent.getNavigationHistory(this._onNavigationHistory.bind(this)); |
| 680 }, |
| 681 |
| 682 _onNavigationHistory: function(error, currentIndex, entries) |
| 683 { |
| 684 if (error) |
| 685 return; |
| 686 |
| 687 this._historyIndex = currentIndex; |
| 688 this._historyEntries = entries; |
| 689 |
| 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._HttpRegex); |
| 695 if (match) |
| 696 url = match[1]; |
| 697 this._navigationUrl.value = url; |
| 698 }, |
| 699 |
| 623 __proto__: WebInspector.View.prototype | 700 __proto__: WebInspector.View.prototype |
| 624 } | 701 } |
| OLD | NEW |