| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 Emulation.DeviceModeView = class extends UI.VBox { | 7 Emulation.DeviceModeView = class extends UI.VBox { |
| 8 constructor() { | 8 constructor() { |
| 9 super(true); | 9 super(true); |
| 10 this.setMinimumSize(150, 150); | 10 this.setMinimumSize(150, 150); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 UI.ResizerWidget.Events.ResizeUpdate, this._onResizeUpdate.bind(this, wi
dthFactor, heightFactor)); | 125 UI.ResizerWidget.Events.ResizeUpdate, this._onResizeUpdate.bind(this, wi
dthFactor, heightFactor)); |
| 126 resizer.addEventListener(UI.ResizerWidget.Events.ResizeEnd, this._onResizeEn
d, this); | 126 resizer.addEventListener(UI.ResizerWidget.Events.ResizeEnd, this._onResizeEn
d, this); |
| 127 return resizer; | 127 return resizer; |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @param {!Common.Event} event | 131 * @param {!Common.Event} event |
| 132 */ | 132 */ |
| 133 _onResizeStart(event) { | 133 _onResizeStart(event) { |
| 134 this._slowPositionStart = null; | 134 this._slowPositionStart = null; |
| 135 /** @type {!Size} */ | 135 /** @type {!UI.Size} */ |
| 136 this._resizeStart = this._model.screenRect().size(); | 136 this._resizeStart = this._model.screenRect().size(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * @param {number} widthFactor | 140 * @param {number} widthFactor |
| 141 * @param {number} heightFactor | 141 * @param {number} heightFactor |
| 142 * @param {!Common.Event} event | 142 * @param {!Common.Event} event |
| 143 */ | 143 */ |
| 144 _onResizeUpdate(widthFactor, heightFactor, event) { | 144 _onResizeUpdate(widthFactor, heightFactor, event) { |
| 145 if (event.data.shiftKey !== !!this._slowPositionStart) | 145 if (event.data.shiftKey !== !!this._slowPositionStart) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 175 * @param {!Common.Event} event | 175 * @param {!Common.Event} event |
| 176 */ | 176 */ |
| 177 _onResizeEnd(event) { | 177 _onResizeEnd(event) { |
| 178 delete this._resizeStart; | 178 delete this._resizeStart; |
| 179 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ResizedViewInResponsive
Mode); | 179 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ResizedViewInResponsive
Mode); |
| 180 } | 180 } |
| 181 | 181 |
| 182 _updateUI() { | 182 _updateUI() { |
| 183 /** | 183 /** |
| 184 * @param {!Element} element | 184 * @param {!Element} element |
| 185 * @param {!Common.Rect} rect | 185 * @param {!UI.Rect} rect |
| 186 */ | 186 */ |
| 187 function applyRect(element, rect) { | 187 function applyRect(element, rect) { |
| 188 element.style.left = rect.left + 'px'; | 188 element.style.left = rect.left + 'px'; |
| 189 element.style.top = rect.top + 'px'; | 189 element.style.top = rect.top + 'px'; |
| 190 element.style.width = rect.width + 'px'; | 190 element.style.width = rect.width + 'px'; |
| 191 element.style.height = rect.height + 'px'; | 191 element.style.height = rect.height + 'px'; |
| 192 } | 192 } |
| 193 | 193 |
| 194 if (!this.isShowing()) | 194 if (!this.isShowing()) |
| 195 return; | 195 return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 * @param {!Element} element | 303 * @param {!Element} element |
| 304 * @param {boolean} success | 304 * @param {boolean} success |
| 305 */ | 305 */ |
| 306 _onImageLoaded(element, success) { | 306 _onImageLoaded(element, success) { |
| 307 element.classList.toggle('hidden', !success); | 307 element.classList.toggle('hidden', !success); |
| 308 } | 308 } |
| 309 | 309 |
| 310 _contentAreaResized() { | 310 _contentAreaResized() { |
| 311 var zoomFactor = UI.zoomManager.zoomFactor(); | 311 var zoomFactor = UI.zoomManager.zoomFactor(); |
| 312 var rect = this._contentArea.getBoundingClientRect(); | 312 var rect = this._contentArea.getBoundingClientRect(); |
| 313 var availableSize = new Size(Math.max(rect.width * zoomFactor, 1), Math.max(
rect.height * zoomFactor, 1)); | 313 var availableSize = new UI.Size(Math.max(rect.width * zoomFactor, 1), Math.m
ax(rect.height * zoomFactor, 1)); |
| 314 var preferredSize = new Size( | 314 var preferredSize = new UI.Size( |
| 315 Math.max((rect.width - 2 * this._handleWidth) * zoomFactor, 1), | 315 Math.max((rect.width - 2 * this._handleWidth) * zoomFactor, 1), |
| 316 Math.max((rect.height - this._handleHeight) * zoomFactor, 1)); | 316 Math.max((rect.height - this._handleHeight) * zoomFactor, 1)); |
| 317 this._model.setAvailableSize(availableSize, preferredSize); | 317 this._model.setAvailableSize(availableSize, preferredSize); |
| 318 } | 318 } |
| 319 | 319 |
| 320 _measureHandles() { | 320 _measureHandles() { |
| 321 var hidden = this._rightResizerElement.classList.contains('hidden'); | 321 var hidden = this._rightResizerElement.classList.contains('hidden'); |
| 322 this._rightResizerElement.classList.toggle('hidden', false); | 322 this._rightResizerElement.classList.toggle('hidden', false); |
| 323 this._bottomResizerElement.classList.toggle('hidden', false); | 323 this._bottomResizerElement.classList.toggle('hidden', false); |
| 324 this._handleWidth = this._rightResizerElement.offsetWidth; | 324 this._handleWidth = this._rightResizerElement.offsetWidth; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 captureScreenshot() { | 362 captureScreenshot() { |
| 363 var mainTarget = SDK.targetManager.mainTarget(); | 363 var mainTarget = SDK.targetManager.mainTarget(); |
| 364 if (!mainTarget) | 364 if (!mainTarget) |
| 365 return; | 365 return; |
| 366 SDK.DOMModel.muteHighlight(); | 366 SDK.DOMModel.muteHighlight(); |
| 367 | 367 |
| 368 var zoomFactor = UI.zoomManager.zoomFactor(); | 368 var zoomFactor = UI.zoomManager.zoomFactor(); |
| 369 var rect = this._contentArea.getBoundingClientRect(); | 369 var rect = this._contentArea.getBoundingClientRect(); |
| 370 var availableSize = new Size(Math.max(rect.width * zoomFactor, 1), Math.max(
rect.height * zoomFactor, 1)); | 370 var availableSize = new UI.Size(Math.max(rect.width * zoomFactor, 1), Math.m
ax(rect.height * zoomFactor, 1)); |
| 371 var outlineVisible = this._model.deviceOutlineSetting().get(); | 371 var outlineVisible = this._model.deviceOutlineSetting().get(); |
| 372 | 372 |
| 373 if (availableSize.width < this._model.screenRect().width || | 373 if (availableSize.width < this._model.screenRect().width || |
| 374 availableSize.height < this._model.screenRect().height) { | 374 availableSize.height < this._model.screenRect().height) { |
| 375 UI.inspectorView.minimize(); | 375 UI.inspectorView.minimize(); |
| 376 this._model.deviceOutlineSetting().set(false); | 376 this._model.deviceOutlineSetting().set(false); |
| 377 } | 377 } |
| 378 | 378 |
| 379 mainTarget.pageAgent().captureScreenshot(screenshotCaptured.bind(this)); | 379 mainTarget.pageAgent().captureScreenshot(screenshotCaptured.bind(this)); |
| 380 | 380 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 var promise = Promise.resolve(); | 414 var promise = Promise.resolve(); |
| 415 if (this._model.outlineImage()) | 415 if (this._model.outlineImage()) |
| 416 promise = promise.then(paintImage.bind(null, this._model.outlineImage(),
outlineRect)); | 416 promise = promise.then(paintImage.bind(null, this._model.outlineImage(),
outlineRect)); |
| 417 promise = promise.then(drawBorder); | 417 promise = promise.then(drawBorder); |
| 418 if (this._model.screenImage()) | 418 if (this._model.screenImage()) |
| 419 promise = promise.then(paintImage.bind(null, this._model.screenImage(),
screenRect)); | 419 promise = promise.then(paintImage.bind(null, this._model.screenImage(),
screenRect)); |
| 420 promise.then(paintScreenshot.bind(this)); | 420 promise.then(paintScreenshot.bind(this)); |
| 421 | 421 |
| 422 /** | 422 /** |
| 423 * @param {string} src | 423 * @param {string} src |
| 424 * @param {!Common.Rect} rect | 424 * @param {!UI.Rect} rect |
| 425 * @return {!Promise<undefined>} | 425 * @return {!Promise<undefined>} |
| 426 */ | 426 */ |
| 427 function paintImage(src, rect) { | 427 function paintImage(src, rect) { |
| 428 var callback; | 428 var callback; |
| 429 var promise = new Promise(fulfill => callback = fulfill); | 429 var promise = new Promise(fulfill => callback = fulfill); |
| 430 var image = new Image(); | 430 var image = new Image(); |
| 431 image.crossOrigin = 'Anonymous'; | 431 image.crossOrigin = 'Anonymous'; |
| 432 image.srcset = src; | 432 image.srcset = src; |
| 433 image.onload = onImageLoad; | 433 image.onload = onImageLoad; |
| 434 image.onerror = callback; | 434 image.onerror = callback; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 return Promise.resolve(); | 565 return Promise.resolve(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 /** | 568 /** |
| 569 * @param {number} size | 569 * @param {number} size |
| 570 */ | 570 */ |
| 571 _onMarkerClick(size) { | 571 _onMarkerClick(size) { |
| 572 this._applyCallback.call(null, size); | 572 this._applyCallback.call(null, size); |
| 573 } | 573 } |
| 574 }; | 574 }; |
| OLD | NEW |