| 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.OverlayModel.Highlighter} | 31 * @implements {SDK.DOMNodeHighlighter} |
| 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); | |
| 43 this._resourceTreeModel = screenCaptureModel.target().model(SDK.ResourceTree
Model); | 42 this._resourceTreeModel = screenCaptureModel.target().model(SDK.ResourceTree
Model); |
| 44 this._networkManager = screenCaptureModel.target().model(SDK.NetworkManager)
; | 43 this._networkManager = screenCaptureModel.target().model(SDK.NetworkManager)
; |
| 45 this._inputModel = screenCaptureModel.target().model(Screencast.InputModel); | 44 this._inputModel = screenCaptureModel.target().model(Screencast.InputModel); |
| 46 | 45 |
| 47 this.setMinimumSize(150, 150); | 46 this.setMinimumSize(150, 150); |
| 48 this.registerRequiredCSS('screencast/screencastView.css'); | 47 this.registerRequiredCSS('screencast/screencastView.css'); |
| 49 } | 48 } |
| 50 | 49 |
| 51 initialize() { | 50 initialize() { |
| 52 this.element.classList.add('screencast'); | 51 this.element.classList.add('screencast'); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return; | 123 return; |
| 125 } | 124 } |
| 126 dimensions.width *= window.devicePixelRatio; | 125 dimensions.width *= window.devicePixelRatio; |
| 127 dimensions.height *= window.devicePixelRatio; | 126 dimensions.height *= window.devicePixelRatio; |
| 128 // Note: startScreencast width and height are expected to be integers so mus
t be floored. | 127 // Note: startScreencast width and height are expected to be integers so mus
t be floored. |
| 129 this._screenCaptureModel.startScreencast( | 128 this._screenCaptureModel.startScreencast( |
| 130 'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)), | 129 'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)), |
| 131 Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, t
his._screencastFrame.bind(this), | 130 Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, t
his._screencastFrame.bind(this), |
| 132 this._screencastVisibilityChanged.bind(this)); | 131 this._screencastVisibilityChanged.bind(this)); |
| 133 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(true); | 132 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(true); |
| 134 if (this._overlayModel) | 133 if (this._domModel) |
| 135 this._overlayModel.setHighlighter(this); | 134 this._domModel.setHighlighter(this); |
| 136 } | 135 } |
| 137 | 136 |
| 138 _stopCasting() { | 137 _stopCasting() { |
| 139 if (!this._isCasting) | 138 if (!this._isCasting) |
| 140 return; | 139 return; |
| 141 this._isCasting = false; | 140 this._isCasting = false; |
| 142 this._screenCaptureModel.stopScreencast(); | 141 this._screenCaptureModel.stopScreencast(); |
| 143 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(false); | 142 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(false); |
| 144 if (this._overlayModel) | 143 if (this._domModel) |
| 145 this._overlayModel.setHighlighter(null); | 144 this._domModel.setHighlighter(null); |
| 146 } | 145 } |
| 147 | 146 |
| 148 /** | 147 /** |
| 149 * @param {string} base64Data | 148 * @param {string} base64Data |
| 150 * @param {!Protocol.Page.ScreencastFrameMetadata} metadata | 149 * @param {!Protocol.Page.ScreencastFrameMetadata} metadata |
| 151 */ | 150 */ |
| 152 _screencastFrame(base64Data, metadata) { | 151 _screencastFrame(base64Data, metadata) { |
| 153 this._imageElement.onload = () => { | 152 this._imageElement.onload = () => { |
| 154 this._pageScaleFactor = metadata.pageScaleFactor; | 153 this._pageScaleFactor = metadata.pageScaleFactor; |
| 155 this._screenOffsetTop = metadata.offsetTop; | 154 this._screenOffsetTop = metadata.offsetTop; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 238 |
| 240 /** | 239 /** |
| 241 * @param {?SDK.DOMNode} node | 240 * @param {?SDK.DOMNode} node |
| 242 * @this {Screencast.ScreencastView} | 241 * @this {Screencast.ScreencastView} |
| 243 */ | 242 */ |
| 244 function callback(node) { | 243 function callback(node) { |
| 245 if (!node) | 244 if (!node) |
| 246 return; | 245 return; |
| 247 if (event.type === 'mousemove') { | 246 if (event.type === 'mousemove') { |
| 248 this.highlightDOMNode(node, this._inspectModeConfig); | 247 this.highlightDOMNode(node, this._inspectModeConfig); |
| 249 this._domModel.overlayModel().nodeHighlightRequested(node.id); | 248 this._domModel.nodeHighlightRequested(node.id); |
| 250 } else if (event.type === 'click') { | 249 } else if (event.type === 'click') { |
| 251 Common.Revealer.reveal(node); | 250 Common.Revealer.reveal(node); |
| 252 } | 251 } |
| 253 } | 252 } |
| 254 } | 253 } |
| 255 | 254 |
| 256 /** | 255 /** |
| 257 * @param {!Event} event | 256 * @param {!Event} event |
| 258 */ | 257 */ |
| 259 _handleKeyEvent(event) { | 258 _handleKeyEvent(event) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 delete this._deferredCasting; | 309 delete this._deferredCasting; |
| 311 } | 310 } |
| 312 | 311 |
| 313 this._stopCasting(); | 312 this._stopCasting(); |
| 314 this._deferredCasting = setTimeout(this._startCasting.bind(this), 100); | 313 this._deferredCasting = setTimeout(this._startCasting.bind(this), 100); |
| 315 } | 314 } |
| 316 | 315 |
| 317 /** | 316 /** |
| 318 * @override | 317 * @override |
| 319 * @param {?SDK.DOMNode} node | 318 * @param {?SDK.DOMNode} node |
| 320 * @param {?Protocol.Overlay.HighlightConfig} config | 319 * @param {?Protocol.DOM.HighlightConfig} config |
| 321 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | 320 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId |
| 322 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | 321 * @param {!Protocol.Runtime.RemoteObjectId=} objectId |
| 323 */ | 322 */ |
| 324 highlightDOMNode(node, config, backendNodeId, objectId) { | 323 highlightDOMNode(node, config, backendNodeId, objectId) { |
| 325 this._highlightNode = node; | 324 this._highlightNode = node; |
| 326 this._highlightConfig = config; | 325 this._highlightConfig = config; |
| 327 if (!node) { | 326 if (!node) { |
| 328 this._model = null; | 327 this._model = null; |
| 329 this._config = null; | 328 this._config = null; |
| 330 this._node = null; | 329 this._node = null; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 _viewportDimensions() { | 562 _viewportDimensions() { |
| 564 const gutterSize = 30; | 563 const gutterSize = 30; |
| 565 const bordersSize = Screencast.ScreencastView._bordersSize; | 564 const bordersSize = Screencast.ScreencastView._bordersSize; |
| 566 var width = this.element.offsetWidth - bordersSize - gutterSize; | 565 var width = this.element.offsetWidth - bordersSize - gutterSize; |
| 567 var height = this.element.offsetHeight - bordersSize - gutterSize - Screenca
st.ScreencastView._navBarHeight; | 566 var height = this.element.offsetHeight - bordersSize - gutterSize - Screenca
st.ScreencastView._navBarHeight; |
| 568 return {width: width, height: height}; | 567 return {width: width, height: height}; |
| 569 } | 568 } |
| 570 | 569 |
| 571 /** | 570 /** |
| 572 * @override | 571 * @override |
| 573 * @param {!Protocol.Overlay.InspectMode} mode | 572 * @param {!Protocol.DOM.InspectMode} mode |
| 574 * @param {!Protocol.Overlay.HighlightConfig} config | 573 * @param {!Protocol.DOM.HighlightConfig} config |
| 575 * @return {!Promise} | 574 * @param {function(?Protocol.Error)=} callback |
| 576 */ | 575 */ |
| 577 setInspectMode(mode, config) { | 576 setInspectMode(mode, config, callback) { |
| 578 this._inspectModeConfig = mode !== Protocol.Overlay.InspectMode.None ? confi
g : null; | 577 this._inspectModeConfig = mode !== Protocol.DOM.InspectMode.None ? config :
null; |
| 579 return Promise.resolve(); | 578 if (callback) |
| 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 |