Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js

Issue 1907263002: DevTools: Fix all outstanding JavaScript style issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove yoda disable. fix throw parens Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {function()} updateCallback 7 * @param {function()} updateCallback
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.DeviceModeModel = function(updateCallback) 10 WebInspector.DeviceModeModel = function(updateCallback)
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 /** 427 /**
428 * @param {boolean} resetPageScaleFactor 428 * @param {boolean} resetPageScaleFactor
429 */ 429 */
430 _calculateAndEmulate: function(resetPageScaleFactor) 430 _calculateAndEmulate: function(resetPageScaleFactor)
431 { 431 {
432 if (!this._target) 432 if (!this._target)
433 this._onTargetAvailable = this._calculateAndEmulate.bind(this, reset PageScaleFactor); 433 this._onTargetAvailable = this._calculateAndEmulate.bind(this, reset PageScaleFactor);
434 434
435 if (this._type === WebInspector.DeviceModeModel.Type.Device) { 435 if (this._type === WebInspector.DeviceModeModel.Type.Device) {
436 var orientation = this._device.orientationByName(this._mode.orientat ion); 436 var orientation = this._device.orientationByName(this._mode.orientat ion);
437 var outline = (this._deviceOutlineSetting.get() && Runtime.experimen ts.isEnabled("deviceFrames"))? orientation.outlineInsets : new Insets(0,0,0,0); 437 var outline = (this._deviceOutlineSetting.get() && Runtime.experimen ts.isEnabled("deviceFrames")) ? orientation.outlineInsets : new Insets(0,0,0,0);
438 this._fitScale = this._calculateFitScale(orientation.width, orientat ion.height); 438 this._fitScale = this._calculateFitScale(orientation.width, orientat ion.height);
439 if (this._device.mobile()) 439 if (this._device.mobile())
440 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; 440 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch;
441 else 441 else
442 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop; 442 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop;
443 this._applyDeviceMetrics(new Size(orientation.width, orientation.hei ght), this._mode.insets, outline, this._scaleSetting.get(), this._device.deviceS caleFactor, this._device.mobile(), this._mode.orientation == WebInspector.Emulat edDevice.Horizontal ? "landscapePrimary" : "portraitPrimary", resetPageScaleFact or); 443 this._applyDeviceMetrics(new Size(orientation.width, orientation.hei ght), this._mode.insets, outline, this._scaleSetting.get(), this._device.deviceS caleFactor, this._device.mobile(), this._mode.orientation == WebInspector.Emulat edDevice.Horizontal ? "landscapePrimary" : "portraitPrimary", resetPageScaleFact or);
444 this._applyUserAgent(this._device.userAgent); 444 this._applyUserAgent(this._device.userAgent);
445 this._applyTouch(this._device.touch(), this._device.mobile()); 445 this._applyTouch(this._device.touch(), this._device.mobile());
446 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { 446 } else if (this._type === WebInspector.DeviceModeModel.Type.None) {
447 this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height); 447 this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height);
(...skipping 21 matching lines...) Expand all
469 this._updateCallback.call(null); 469 this._updateCallback.call(null);
470 }, 470 },
471 471
472 /** 472 /**
473 * @param {number} screenWidth 473 * @param {number} screenWidth
474 * @param {number} screenHeight 474 * @param {number} screenHeight
475 * @return {number} 475 * @return {number}
476 */ 476 */
477 _calculateFitScale: function(screenWidth, screenHeight) 477 _calculateFitScale: function(screenWidth, screenHeight)
478 { 478 {
479 var scale = Math.min(screenWidth ? this._preferredSize.width / screenWid th: 1, screenHeight ? this._preferredSize.height / screenHeight : 1); 479 var scale = Math.min(screenWidth ? this._preferredSize.width / screenWid th : 1, screenHeight ? this._preferredSize.height / screenHeight : 1);
480 return Math.min(scale, 1); 480 return Math.min(scale, 1);
481 }, 481 },
482 482
483 /** 483 /**
484 * @param {number} width 484 * @param {number} width
485 * @param {number} height 485 * @param {number} height
486 */ 486 */
487 setSizeAndScaleToFit: function(width, height) 487 setSizeAndScaleToFit: function(width, height)
488 { 488 {
489 this._scaleSetting.set(this._calculateFitScale(width, height)); 489 this._scaleSetting.set(this._calculateFitScale(width, height));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 586
587 /** 587 /**
588 * @param {boolean} touchEnabled 588 * @param {boolean} touchEnabled
589 * @param {boolean} mobile 589 * @param {boolean} mobile
590 */ 590 */
591 _applyTouch: function(touchEnabled, mobile) 591 _applyTouch: function(touchEnabled, mobile)
592 { 592 {
593 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); 593 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile);
594 } 594 }
595 } 595 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698