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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 this._target.emulationAgent().setTouchEmulationEnabled(false); | 141 this._target.emulationAgent().setTouchEmulationEnabled(false); |
142 this._domModel.setHighlighter(null); | 142 this._domModel.setHighlighter(null); |
143 } | 143 } |
144 | 144 |
145 /** | 145 /** |
146 * @param {!Common.Event} event | 146 * @param {!Common.Event} event |
147 */ | 147 */ |
148 _screencastFrame(event) { | 148 _screencastFrame(event) { |
149 var metadata = /** type {Protocol.Page.ScreencastFrameMetadata} */ (event.da
ta.metadata); | 149 var metadata = /** type {Protocol.Page.ScreencastFrameMetadata} */ (event.da
ta.metadata); |
150 var base64Data = /** type {string} */ (event.data.data); | 150 var base64Data = /** type {string} */ (event.data.data); |
| 151 this._imageElement.onload = () => { |
| 152 this._pageScaleFactor = metadata.pageScaleFactor; |
| 153 this._screenOffsetTop = metadata.offsetTop; |
| 154 this._scrollOffsetX = metadata.scrollOffsetX; |
| 155 this._scrollOffsetY = metadata.scrollOffsetY; |
| 156 |
| 157 var deviceSizeRatio = metadata.deviceHeight / metadata.deviceWidth; |
| 158 var dimensionsCSS = this._viewportDimensions(); |
| 159 |
| 160 this._imageZoom = Math.min( |
| 161 dimensionsCSS.width / this._imageElement.naturalWidth, |
| 162 dimensionsCSS.height / (this._imageElement.naturalWidth * deviceSizeRa
tio)); |
| 163 this._viewportElement.classList.remove('hidden'); |
| 164 var bordersSize = Screencast.ScreencastView._bordersSize; |
| 165 if (this._imageZoom < 1.01 / window.devicePixelRatio) |
| 166 this._imageZoom = 1 / window.devicePixelRatio; |
| 167 this._screenZoom = this._imageElement.naturalWidth * this._imageZoom / met
adata.deviceWidth; |
| 168 this._viewportElement.style.width = metadata.deviceWidth * this._screenZoo
m + bordersSize + 'px'; |
| 169 this._viewportElement.style.height = metadata.deviceHeight * this._screenZ
oom + bordersSize + 'px'; |
| 170 |
| 171 this.highlightDOMNode(this._highlightNode, this._highlightConfig); |
| 172 }; |
151 this._imageElement.src = 'data:image/jpg;base64,' + base64Data; | 173 this._imageElement.src = 'data:image/jpg;base64,' + base64Data; |
152 this._pageScaleFactor = metadata.pageScaleFactor; | |
153 this._screenOffsetTop = metadata.offsetTop; | |
154 this._scrollOffsetX = metadata.scrollOffsetX; | |
155 this._scrollOffsetY = metadata.scrollOffsetY; | |
156 | |
157 var deviceSizeRatio = metadata.deviceHeight / metadata.deviceWidth; | |
158 var dimensionsCSS = this._viewportDimensions(); | |
159 | |
160 this._imageZoom = Math.min( | |
161 dimensionsCSS.width / this._imageElement.naturalWidth, | |
162 dimensionsCSS.height / (this._imageElement.naturalWidth * deviceSizeRati
o)); | |
163 this._viewportElement.classList.remove('hidden'); | |
164 var bordersSize = Screencast.ScreencastView._bordersSize; | |
165 if (this._imageZoom < 1.01 / window.devicePixelRatio) | |
166 this._imageZoom = 1 / window.devicePixelRatio; | |
167 this._screenZoom = this._imageElement.naturalWidth * this._imageZoom / metad
ata.deviceWidth; | |
168 this._viewportElement.style.width = metadata.deviceWidth * this._screenZoom
+ bordersSize + 'px'; | |
169 this._viewportElement.style.height = metadata.deviceHeight * this._screenZoo
m + bordersSize + 'px'; | |
170 | |
171 this.highlightDOMNode(this._highlightNode, this._highlightConfig); | |
172 } | 174 } |
173 | 175 |
174 _isGlassPaneActive() { | 176 _isGlassPaneActive() { |
175 return !this._glassPaneElement.classList.contains('hidden'); | 177 return !this._glassPaneElement.classList.contains('hidden'); |
176 } | 178 } |
177 | 179 |
178 /** | 180 /** |
179 * @param {!Common.Event} event | 181 * @param {!Common.Event} event |
180 */ | 182 */ |
181 _screencastVisibilityChanged(event) { | 183 _screencastVisibilityChanged(event) { |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 if (this._maxDisplayedProgress >= progress) | 863 if (this._maxDisplayedProgress >= progress) |
862 return; | 864 return; |
863 this._maxDisplayedProgress = progress; | 865 this._maxDisplayedProgress = progress; |
864 this._displayProgress(progress); | 866 this._displayProgress(progress); |
865 } | 867 } |
866 | 868 |
867 _displayProgress(progress) { | 869 _displayProgress(progress) { |
868 this._element.style.width = (100 * progress) + '%'; | 870 this._element.style.width = (100 * progress) + '%'; |
869 } | 871 } |
870 }; | 872 }; |
OLD | NEW |