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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 this._target.domModel.setHighlighter(null); | 144 this._target.domModel.setHighlighter(null); |
145 }, | 145 }, |
146 | 146 |
147 /** | 147 /** |
148 * @param {!WebInspector.Event} event | 148 * @param {!WebInspector.Event} event |
149 */ | 149 */ |
150 _screencastFrame: function(event) | 150 _screencastFrame: function(event) |
151 { | 151 { |
152 var metadata = /** type {PageAgent.ScreencastFrameMetadata} */(event.dat a.metadata); | 152 var metadata = /** type {PageAgent.ScreencastFrameMetadata} */(event.dat a.metadata); |
153 | 153 |
154 if (!metadata.deviceScaleFactor) { | 154 if (!metadata || !metadata.deviceScaleFactor) { |
155 console.log(event.data.data); | 155 console.error(event.data.data); |
pfeldman
2014/06/20 17:59:52
Lets remove this message.
vkuzkokov
2014/06/23 10:57:12
Done.
| |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 var base64Data = /** type {string} */(event.data.data); | 159 var base64Data = /** type {string} */(event.data.data); |
160 this._imageElement.src = "data:image/jpg;base64," + base64Data; | 160 this._imageElement.src = "data:image/jpg;base64," + base64Data; |
161 this._deviceScaleFactor = metadata.deviceScaleFactor; | 161 this._deviceScaleFactor = metadata.deviceScaleFactor; |
162 this._pageScaleFactor = metadata.pageScaleFactor; | 162 this._pageScaleFactor = metadata.pageScaleFactor; |
163 this._viewport = metadata.viewport; | 163 this._viewport = metadata.viewport; |
164 if (!this._viewport) | 164 if (!this._viewport) |
165 return; | 165 return; |
166 var offsetTop = metadata.offsetTop || 0; | 166 var offsetTop = metadata.offsetTop || 0; |
167 var offsetBottom = metadata.offsetBottom || 0; | 167 var offsetBottom = metadata.offsetBottom || 0; |
168 | 168 |
169 var screenWidthDIP = this._viewport.width * this._pageScaleFactor; | 169 // Physical device size. |
170 var screenHeightDIP = this._viewport.height * this._pageScaleFactor + of fsetTop + offsetBottom; | 170 var screenWidthDIP = Math.round(this._viewport.width * this._pageScaleFa ctor); |
171 var screenHeightDIP = Math.round(this._viewport.height * this._pageScale Factor + offsetTop + offsetBottom); | |
172 this._screenZoom = this._imageElement.naturalWidth / screenWidthDIP; | |
171 this._screenOffsetTop = offsetTop; | 173 this._screenOffsetTop = offsetTop; |
172 this._resizeViewport(screenWidthDIP, screenHeightDIP); | |
173 | 174 |
174 this._imageZoom = this._imageElement.naturalWidth ? this._canvasElement. offsetWidth / this._imageElement.naturalWidth : 1; | 175 var bordersSize = WebInspector.ScreencastView._bordersSize; |
176 this._viewportElement.classList.remove("hidden"); | |
177 this._viewportElement.style.width = this._imageElement.naturalWidth + bo rdersSize + "px"; | |
178 this._viewportElement.style.height = this._imageElement.naturalHeight + Math.floor((offsetTop + offsetBottom) * this._screenZoom) + bordersSize + "px"; | |
179 | |
180 this._imageZoom = 1;// this._imageElement.naturalWidth ? this._canvasEle ment.offsetWidth / this._imageElement.naturalWidth : 1; | |
pfeldman
2014/06/20 17:59:52
Please remove this.
pfeldman
2014/06/23 06:44:38
Note that we also need to make this work with devi
vkuzkokov
2014/06/23 10:57:12
Done.
| |
175 this.highlightDOMNode(this._highlightNode, this._highlightConfig); | 181 this.highlightDOMNode(this._highlightNode, this._highlightConfig); |
176 }, | 182 }, |
177 | 183 |
178 _isGlassPaneActive: function() | 184 _isGlassPaneActive: function() |
179 { | 185 { |
180 return !this._glassPaneElement.classList.contains("hidden"); | 186 return !this._glassPaneElement.classList.contains("hidden"); |
181 }, | 187 }, |
182 | 188 |
183 /** | 189 /** |
184 * @param {!WebInspector.Event} event | 190 * @param {!WebInspector.Event} event |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 this._glassPaneElement.classList.remove("hidden"); | 233 this._glassPaneElement.classList.remove("hidden"); |
228 } else if (this._profilerActive) { | 234 } else if (this._profilerActive) { |
229 this._glassPaneElement.textContent = WebInspector.UIString("CPU prof iler is active"); | 235 this._glassPaneElement.textContent = WebInspector.UIString("CPU prof iler is active"); |
230 this._glassPaneElement.classList.remove("hidden"); | 236 this._glassPaneElement.classList.remove("hidden"); |
231 } else { | 237 } else { |
232 this._glassPaneElement.classList.add("hidden"); | 238 this._glassPaneElement.classList.add("hidden"); |
233 } | 239 } |
234 }, | 240 }, |
235 | 241 |
236 /** | 242 /** |
237 * @param {number} screenWidthDIP | |
238 * @param {number} screenHeightDIP | |
239 */ | |
240 _resizeViewport: function(screenWidthDIP, screenHeightDIP) | |
241 { | |
242 var dimensions = this._viewportDimensions(); | |
243 this._screenZoom = Math.min(dimensions.width / screenWidthDIP, dimension s.height / screenHeightDIP); | |
244 | |
245 var bordersSize = WebInspector.ScreencastView._bordersSize; | |
246 this._viewportElement.classList.remove("hidden"); | |
247 this._viewportElement.style.width = screenWidthDIP * this._screenZoom + bordersSize + "px"; | |
248 this._viewportElement.style.height = screenHeightDIP * this._screenZoom + bordersSize + "px"; | |
249 }, | |
250 | |
251 /** | |
252 * @param {?Event} event | 243 * @param {?Event} event |
253 */ | 244 */ |
254 _handleMouseEvent: function(event) | 245 _handleMouseEvent: function(event) |
255 { | 246 { |
256 if (this._isGlassPaneActive()) { | 247 if (this._isGlassPaneActive()) { |
257 event.consume(); | 248 event.consume(); |
258 return; | 249 return; |
259 } | 250 } |
260 | 251 |
261 if (!this._viewport) | 252 if (!this._viewport) |
(...skipping 12 matching lines...) Expand all Loading... | |
274 | 265 |
275 /** | 266 /** |
276 * @param {?WebInspector.DOMNode} node | 267 * @param {?WebInspector.DOMNode} node |
277 * @this {WebInspector.ScreencastView} | 268 * @this {WebInspector.ScreencastView} |
278 */ | 269 */ |
279 function callback(node) | 270 function callback(node) |
280 { | 271 { |
281 if (!node) | 272 if (!node) |
282 return; | 273 return; |
283 if (event.type === "mousemove") | 274 if (event.type === "mousemove") |
284 node.highlight(this._inspectModeConfig); | 275 this.highlightDOMNode(node, this._inspectModeConfig); |
285 else if (event.type === "click") | 276 else if (event.type === "click") |
286 node.reveal(); | 277 node.reveal(); |
287 } | 278 } |
288 }, | 279 }, |
289 | 280 |
290 /** | 281 /** |
291 * @param {?Event} event | 282 * @param {?Event} event |
292 */ | 283 */ |
293 _handleKeyEvent: function(event) | 284 _handleKeyEvent: function(event) |
294 { | 285 { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 | 552 |
562 this._node = node; | 553 this._node = node; |
563 node.boxModel(callback.bind(this)); | 554 node.boxModel(callback.bind(this)); |
564 | 555 |
565 /** | 556 /** |
566 * @param {?DOMAgent.BoxModel} model | 557 * @param {?DOMAgent.BoxModel} model |
567 * @this {WebInspector.ScreencastView} | 558 * @this {WebInspector.ScreencastView} |
568 */ | 559 */ |
569 function callback(model) | 560 function callback(model) |
570 { | 561 { |
571 if (!model) { | 562 if (!model) { |
pfeldman
2014/06/20 17:59:52
if (!model || !this._viewport)
vkuzkokov
2014/06/23 10:57:12
Done.
| |
572 this._repaint(); | 563 this._repaint(); |
573 return; | 564 return; |
574 } | 565 } |
575 this._model = this._scaleModel(model); | 566 this._model = this._scaleModel(model); |
576 this._config = config; | 567 this._config = config; |
577 this._repaint(); | 568 this._repaint(); |
578 } | 569 } |
579 }, | 570 }, |
580 | 571 |
581 /** | 572 /** |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 this._titleElement.style.left = (boxX + 3) + "px"; | 801 this._titleElement.style.left = (boxX + 3) + "px"; |
811 }, | 802 }, |
812 | 803 |
813 /** | 804 /** |
814 * @return {!{width: number, height: number}} | 805 * @return {!{width: number, height: number}} |
815 */ | 806 */ |
816 _viewportDimensions: function() | 807 _viewportDimensions: function() |
817 { | 808 { |
818 const gutterSize = 30; | 809 const gutterSize = 30; |
819 const bordersSize = WebInspector.ScreencastView._bordersSize; | 810 const bordersSize = WebInspector.ScreencastView._bordersSize; |
820 return { width: this.element.offsetWidth - bordersSize - gutterSize, | 811 var width = Math.floor(this.element.offsetWidth - bordersSize - gutterSi ze); |
821 height: this.element.offsetHeight - bordersSize - gutterSize - WebInspector.ScreencastView._navBarHeight}; | 812 var height = Math.floor(this.element.offsetHeight - bordersSize - gutter Size - WebInspector.ScreencastView._navBarHeight); |
813 return { width: width, height: height }; | |
822 }, | 814 }, |
823 | 815 |
824 /** | 816 /** |
825 * @param {boolean} enabled | 817 * @param {boolean} enabled |
826 * @param {boolean} inspectUAShadowDOM | 818 * @param {boolean} inspectUAShadowDOM |
827 * @param {!DOMAgent.HighlightConfig} config | 819 * @param {!DOMAgent.HighlightConfig} config |
828 * @param {function(?Protocol.Error)=} callback | 820 * @param {function(?Protocol.Error)=} callback |
829 */ | 821 */ |
830 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k) | 822 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k) |
831 { | 823 { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1014 return; | 1006 return; |
1015 this._maxDisplayedProgress = progress; | 1007 this._maxDisplayedProgress = progress; |
1016 this._displayProgress(progress); | 1008 this._displayProgress(progress); |
1017 }, | 1009 }, |
1018 | 1010 |
1019 _displayProgress: function(progress) | 1011 _displayProgress: function(progress) |
1020 { | 1012 { |
1021 this._element.style.width = (100 * progress) + "%"; | 1013 this._element.style.width = (100 * progress) + "%"; |
1022 } | 1014 } |
1023 }; | 1015 }; |
OLD | NEW |