Chromium Code Reviews| 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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Emulation.DeviceModeModel = class { | 8 Emulation.DeviceModeModel = class { |
| 9 /** | 9 /** |
| 10 * @param {function()} updateCallback | 10 * @param {function()} updateCallback |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 } | 266 } |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * @return {boolean} | 269 * @return {boolean} |
| 270 */ | 270 */ |
| 271 isFullHeight() { | 271 isFullHeight() { |
| 272 return !this._heightSetting.get(); | 272 return !this._heightSetting.get(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * @return {boolean} | |
| 277 */ | |
| 278 isMobile() { | |
| 279 if (this._device && this._device.mobile()) | |
| 280 return true; | |
| 281 return false; | |
|
dgozman
2017/01/12 21:49:35
Note this is incorrect for responsive mode.
ahmetemirercin
2017/01/13 01:49:23
Done.
| |
| 282 } | |
| 283 | |
| 284 /** | |
| 276 * @return {!Common.Setting} | 285 * @return {!Common.Setting} |
| 277 */ | 286 */ |
| 278 scaleSetting() { | 287 scaleSetting() { |
| 279 return this._scaleSetting; | 288 return this._scaleSetting; |
| 280 } | 289 } |
| 281 | 290 |
| 282 /** | 291 /** |
| 283 * @return {!Common.Setting} | 292 * @return {!Common.Setting} |
| 284 */ | 293 */ |
| 285 uaSetting() { | 294 uaSetting() { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 outline, | 524 outline, |
| 516 scale, | 525 scale, |
| 517 deviceScaleFactor, | 526 deviceScaleFactor, |
| 518 mobile, | 527 mobile, |
| 519 screenOrientation, | 528 screenOrientation, |
| 520 resetPageScaleFactor) { | 529 resetPageScaleFactor) { |
| 521 screenSize.width = Math.max(1, Math.floor(screenSize.width)); | 530 screenSize.width = Math.max(1, Math.floor(screenSize.width)); |
| 522 screenSize.height = Math.max(1, Math.floor(screenSize.height)); | 531 screenSize.height = Math.max(1, Math.floor(screenSize.height)); |
| 523 | 532 |
| 524 var pageWidth = screenSize.width - insets.left - insets.right; | 533 var pageWidth = screenSize.width - insets.left - insets.right; |
| 534 this._emulatedPageWidth = pageWidth * scale; | |
|
dgozman
2017/01/12 21:49:35
Use Size instead of width+height.
ahmetemirercin
2017/01/13 01:49:23
Done.
| |
| 535 | |
| 525 var pageHeight = screenSize.height - insets.top - insets.bottom; | 536 var pageHeight = screenSize.height - insets.top - insets.bottom; |
| 537 this._emulatedPageHeight = pageHeight * scale; | |
| 526 | 538 |
| 527 var positionX = insets.left; | 539 var positionX = insets.left; |
| 528 var positionY = insets.top; | 540 var positionY = insets.top; |
| 529 var screenOrientationAngle = screenOrientation === 'landscapePrimary' ? 90 : 0; | 541 var screenOrientationAngle = screenOrientation === 'landscapePrimary' ? 90 : 0; |
| 530 | 542 |
| 531 this._appliedDeviceSize = screenSize; | 543 this._appliedDeviceSize = screenSize; |
| 532 this._appliedDeviceScaleFactor = deviceScaleFactor || window.devicePixelRati o; | 544 this._appliedDeviceScaleFactor = deviceScaleFactor || window.devicePixelRati o; |
| 533 this._screenRect = new Common.Rect( | 545 this._screenRect = new Common.Rect( |
| 534 Math.max(0, (this._availableSize.width - screenSize.width * scale) / 2), outline.top * scale, | 546 Math.max(0, (this._availableSize.width - screenSize.width * scale) / 2), outline.top * scale, |
| 535 screenSize.width * scale, screenSize.height * scale); | 547 screenSize.width * scale, screenSize.height * scale); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 if (screenOrientation) | 601 if (screenOrientation) |
| 590 params.screenOrientation = {type: screenOrientation, angle: screenOrie ntationAngle}; | 602 params.screenOrientation = {type: screenOrientation, angle: screenOrie ntationAngle}; |
| 591 setDevicePromise = this._target.emulationAgent().invoke_setDeviceMetrics Override( | 603 setDevicePromise = this._target.emulationAgent().invoke_setDeviceMetrics Override( |
| 592 params, this._deviceMetricsOverrideAppliedForTest.bind(this)); | 604 params, this._deviceMetricsOverrideAppliedForTest.bind(this)); |
| 593 } | 605 } |
| 594 allPromises.push(setDevicePromise); | 606 allPromises.push(setDevicePromise); |
| 595 return Promise.all(allPromises); | 607 return Promise.all(allPromises); |
| 596 } | 608 } |
| 597 } | 609 } |
| 598 | 610 |
| 611 resetVisibleSize() { | |
| 612 this._target.emulationAgent().setVisibleSize(this._emulatedPageWidth, this._ emulatedPageHeight); | |
|
dgozman
2017/01/12 21:49:35
If we reset not by passing zeroes, let's not chang
ahmetemirercin
2017/01/13 01:49:23
Done.
| |
| 613 } | |
| 614 | |
| 599 _deviceMetricsOverrideAppliedForTest() { | 615 _deviceMetricsOverrideAppliedForTest() { |
| 600 // Used for sniffing in tests. | 616 // Used for sniffing in tests. |
| 601 } | 617 } |
| 602 | 618 |
| 603 /** | 619 /** |
| 604 * @param {boolean} touchEnabled | 620 * @param {boolean} touchEnabled |
| 605 * @param {boolean} mobile | 621 * @param {boolean} mobile |
| 606 */ | 622 */ |
| 607 _applyTouch(touchEnabled, mobile) { | 623 _applyTouch(touchEnabled, mobile) { |
| 608 Emulation.MultitargetTouchModel.instance().setTouchEnabled(touchEnabled, mob ile); | 624 Emulation.MultitargetTouchModel.instance().setTouchEnabled(touchEnabled, mob ile); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 626 | 642 |
| 627 Emulation.DeviceModeModel.MinDeviceSize = 50; | 643 Emulation.DeviceModeModel.MinDeviceSize = 50; |
| 628 Emulation.DeviceModeModel.MaxDeviceSize = 9999; | 644 Emulation.DeviceModeModel.MaxDeviceSize = 9999; |
| 629 | 645 |
| 630 | 646 |
| 631 Emulation.DeviceModeModel._defaultMobileUserAgent = | 647 Emulation.DeviceModeModel._defaultMobileUserAgent = |
| 632 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'; | 648 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'; |
| 633 Emulation.DeviceModeModel._defaultMobileUserAgent = | 649 Emulation.DeviceModeModel._defaultMobileUserAgent = |
| 634 SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(Emulation.Devi ceModeModel._defaultMobileUserAgent); | 650 SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(Emulation.Devi ceModeModel._defaultMobileUserAgent); |
| 635 Emulation.DeviceModeModel.defaultMobileScaleFactor = 2; | 651 Emulation.DeviceModeModel.defaultMobileScaleFactor = 2; |
| OLD | NEW |