| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {SDK.DOMNodeHighlighter} | 31 * @implements {SDK.OverlayModel.Highlighter} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Screencast.ScreencastView = class extends UI.VBox { | 34 Screencast.ScreencastView = class extends UI.VBox { |
| 35 /** | 35 /** |
| 36 * @param {!SDK.ScreenCaptureModel} screenCaptureModel | 36 * @param {!SDK.ScreenCaptureModel} screenCaptureModel |
| 37 */ | 37 */ |
| 38 constructor(screenCaptureModel) { | 38 constructor(screenCaptureModel) { |
| 39 super(); | 39 super(); |
| 40 this._screenCaptureModel = screenCaptureModel; | 40 this._screenCaptureModel = screenCaptureModel; |
| 41 this._domModel = screenCaptureModel.target().model(SDK.DOMModel); | 41 this._domModel = screenCaptureModel.target().model(SDK.DOMModel); |
| 42 this._overlayModel = screenCaptureModel.target().model(SDK.OverlayModel); |
| 42 this._resourceTreeModel = screenCaptureModel.target().model(SDK.ResourceTree
Model); | 43 this._resourceTreeModel = screenCaptureModel.target().model(SDK.ResourceTree
Model); |
| 43 this._networkManager = screenCaptureModel.target().model(SDK.NetworkManager)
; | 44 this._networkManager = screenCaptureModel.target().model(SDK.NetworkManager)
; |
| 44 this._inputModel = screenCaptureModel.target().model(Screencast.InputModel); | 45 this._inputModel = screenCaptureModel.target().model(Screencast.InputModel); |
| 45 | 46 |
| 46 this.setMinimumSize(150, 150); | 47 this.setMinimumSize(150, 150); |
| 47 this.registerRequiredCSS('screencast/screencastView.css'); | 48 this.registerRequiredCSS('screencast/screencastView.css'); |
| 48 } | 49 } |
| 49 | 50 |
| 50 initialize() { | 51 initialize() { |
| 51 this.element.classList.add('screencast'); | 52 this.element.classList.add('screencast'); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return; | 124 return; |
| 124 } | 125 } |
| 125 dimensions.width *= window.devicePixelRatio; | 126 dimensions.width *= window.devicePixelRatio; |
| 126 dimensions.height *= window.devicePixelRatio; | 127 dimensions.height *= window.devicePixelRatio; |
| 127 // Note: startScreencast width and height are expected to be integers so mus
t be floored. | 128 // Note: startScreencast width and height are expected to be integers so mus
t be floored. |
| 128 this._screenCaptureModel.startScreencast( | 129 this._screenCaptureModel.startScreencast( |
| 129 'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)), | 130 'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)), |
| 130 Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, t
his._screencastFrame.bind(this), | 131 Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, t
his._screencastFrame.bind(this), |
| 131 this._screencastVisibilityChanged.bind(this)); | 132 this._screencastVisibilityChanged.bind(this)); |
| 132 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(true); | 133 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(true); |
| 133 if (this._domModel) | 134 if (this._overlayModel) |
| 134 this._domModel.setHighlighter(this); | 135 this._overlayModel.setHighlighter(this); |
| 135 } | 136 } |
| 136 | 137 |
| 137 _stopCasting() { | 138 _stopCasting() { |
| 138 if (!this._isCasting) | 139 if (!this._isCasting) |
| 139 return; | 140 return; |
| 140 this._isCasting = false; | 141 this._isCasting = false; |
| 141 this._screenCaptureModel.stopScreencast(); | 142 this._screenCaptureModel.stopScreencast(); |
| 142 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(false); | 143 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(false); |
| 143 if (this._domModel) | 144 if (this._overlayModel) |
| 144 this._domModel.setHighlighter(null); | 145 this._overlayModel.setHighlighter(null); |
| 145 } | 146 } |
| 146 | 147 |
| 147 /** | 148 /** |
| 148 * @param {string} base64Data | 149 * @param {string} base64Data |
| 149 * @param {!Protocol.Page.ScreencastFrameMetadata} metadata | 150 * @param {!Protocol.Page.ScreencastFrameMetadata} metadata |
| 150 */ | 151 */ |
| 151 _screencastFrame(base64Data, metadata) { | 152 _screencastFrame(base64Data, metadata) { |
| 152 this._imageElement.onload = () => { | 153 this._imageElement.onload = () => { |
| 153 this._pageScaleFactor = metadata.pageScaleFactor; | 154 this._pageScaleFactor = metadata.pageScaleFactor; |
| 154 this._screenOffsetTop = metadata.offsetTop; | 155 this._screenOffsetTop = metadata.offsetTop; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 239 |
| 239 /** | 240 /** |
| 240 * @param {?SDK.DOMNode} node | 241 * @param {?SDK.DOMNode} node |
| 241 * @this {Screencast.ScreencastView} | 242 * @this {Screencast.ScreencastView} |
| 242 */ | 243 */ |
| 243 function callback(node) { | 244 function callback(node) { |
| 244 if (!node) | 245 if (!node) |
| 245 return; | 246 return; |
| 246 if (event.type === 'mousemove') { | 247 if (event.type === 'mousemove') { |
| 247 this.highlightDOMNode(node, this._inspectModeConfig); | 248 this.highlightDOMNode(node, this._inspectModeConfig); |
| 248 this._domModel.nodeHighlightRequested(node.id); | 249 this._domModel.overlayModel().nodeHighlightRequested(node.id); |
| 249 } else if (event.type === 'click') { | 250 } else if (event.type === 'click') { |
| 250 Common.Revealer.reveal(node); | 251 Common.Revealer.reveal(node); |
| 251 } | 252 } |
| 252 } | 253 } |
| 253 } | 254 } |
| 254 | 255 |
| 255 /** | 256 /** |
| 256 * @param {!Event} event | 257 * @param {!Event} event |
| 257 */ | 258 */ |
| 258 _handleKeyEvent(event) { | 259 _handleKeyEvent(event) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 delete this._deferredCasting; | 310 delete this._deferredCasting; |
| 310 } | 311 } |
| 311 | 312 |
| 312 this._stopCasting(); | 313 this._stopCasting(); |
| 313 this._deferredCasting = setTimeout(this._startCasting.bind(this), 100); | 314 this._deferredCasting = setTimeout(this._startCasting.bind(this), 100); |
| 314 } | 315 } |
| 315 | 316 |
| 316 /** | 317 /** |
| 317 * @override | 318 * @override |
| 318 * @param {?SDK.DOMNode} node | 319 * @param {?SDK.DOMNode} node |
| 319 * @param {?Protocol.DOM.HighlightConfig} config | 320 * @param {?Protocol.Overlay.HighlightConfig} config |
| 320 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | 321 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId |
| 321 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | 322 * @param {!Protocol.Runtime.RemoteObjectId=} objectId |
| 322 */ | 323 */ |
| 323 highlightDOMNode(node, config, backendNodeId, objectId) { | 324 highlightDOMNode(node, config, backendNodeId, objectId) { |
| 324 this._highlightNode = node; | 325 this._highlightNode = node; |
| 325 this._highlightConfig = config; | 326 this._highlightConfig = config; |
| 326 if (!node) { | 327 if (!node) { |
| 327 this._model = null; | 328 this._model = null; |
| 328 this._config = null; | 329 this._config = null; |
| 329 this._node = null; | 330 this._node = null; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 _viewportDimensions() { | 563 _viewportDimensions() { |
| 563 const gutterSize = 30; | 564 const gutterSize = 30; |
| 564 const bordersSize = Screencast.ScreencastView._bordersSize; | 565 const bordersSize = Screencast.ScreencastView._bordersSize; |
| 565 var width = this.element.offsetWidth - bordersSize - gutterSize; | 566 var width = this.element.offsetWidth - bordersSize - gutterSize; |
| 566 var height = this.element.offsetHeight - bordersSize - gutterSize - Screenca
st.ScreencastView._navBarHeight; | 567 var height = this.element.offsetHeight - bordersSize - gutterSize - Screenca
st.ScreencastView._navBarHeight; |
| 567 return {width: width, height: height}; | 568 return {width: width, height: height}; |
| 568 } | 569 } |
| 569 | 570 |
| 570 /** | 571 /** |
| 571 * @override | 572 * @override |
| 572 * @param {!Protocol.DOM.InspectMode} mode | 573 * @param {!Protocol.Overlay.InspectMode} mode |
| 573 * @param {!Protocol.DOM.HighlightConfig} config | 574 * @param {!Protocol.Overlay.HighlightConfig} config |
| 574 * @param {function(?Protocol.Error)=} callback | 575 * @return {!Promise} |
| 575 */ | 576 */ |
| 576 setInspectMode(mode, config, callback) { | 577 setInspectMode(mode, config) { |
| 577 this._inspectModeConfig = mode !== Protocol.DOM.InspectMode.None ? config :
null; | 578 this._inspectModeConfig = mode !== Protocol.DOM.InspectMode.None ? config :
null; |
| 578 if (callback) | 579 return Promise.resolve(); |
| 579 callback(null); | |
| 580 } | 580 } |
| 581 | 581 |
| 582 /** | 582 /** |
| 583 * @override | 583 * @override |
| 584 * @param {!Protocol.Page.FrameId} frameId | 584 * @param {!Protocol.Page.FrameId} frameId |
| 585 */ | 585 */ |
| 586 highlightFrame(frameId) { | 586 highlightFrame(frameId) { |
| 587 } | 587 } |
| 588 | 588 |
| 589 /** | 589 /** |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 if (this._maxDisplayedProgress >= progress) | 767 if (this._maxDisplayedProgress >= progress) |
| 768 return; | 768 return; |
| 769 this._maxDisplayedProgress = progress; | 769 this._maxDisplayedProgress = progress; |
| 770 this._displayProgress(progress); | 770 this._displayProgress(progress); |
| 771 } | 771 } |
| 772 | 772 |
| 773 _displayProgress(progress) { | 773 _displayProgress(progress) { |
| 774 this._element.style.width = (100 * progress) + '%'; | 774 this._element.style.width = (100 * progress) + '%'; |
| 775 } | 775 } |
| 776 }; | 776 }; |
| OLD | NEW |