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

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

Issue 1650243004: [DevTools] Option to show device frames in emulation mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Positioning and context menu fixes, addressing review comments Created 4 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 */ 7 */
8 WebInspector.EmulatedDevice = function() 8 WebInspector.EmulatedDevice = function()
9 { 9 {
10 /** @type {string} */ 10 /** @type {string} */
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (result.height < 0 || result.height > WebInspector.DeviceModeMode l.MaxDeviceSize || result.height < WebInspector.DeviceModeModel.MinDeviceSize) 126 if (result.height < 0 || result.height > WebInspector.DeviceModeMode l.MaxDeviceSize || result.height < WebInspector.DeviceModeModel.MinDeviceSize)
127 throw new Error("Emulated device has wrong height: " + result.he ight); 127 throw new Error("Emulated device has wrong height: " + result.he ight);
128 128
129 var outlineInsets = parseValue(json["outline"], "insets", "object", null); 129 var outlineInsets = parseValue(json["outline"], "insets", "object", null);
130 if (outlineInsets) { 130 if (outlineInsets) {
131 result.outlineInsets = parseInsets(outlineInsets); 131 result.outlineInsets = parseInsets(outlineInsets);
132 if (result.outlineInsets.left < 0 || result.outlineInsets.top < 0) 132 if (result.outlineInsets.left < 0 || result.outlineInsets.top < 0)
133 throw new Error("Emulated device has wrong outline insets"); 133 throw new Error("Emulated device has wrong outline insets");
134 result.outlineImage = /** @type {string} */ (parseValue(json["ou tline"], "image", "string")); 134 result.outlineImage = /** @type {string} */ (parseValue(json["ou tline"], "image", "string"));
135 } 135 }
136
137 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu lt); 136 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu lt);
138 } 137 }
139 138
140 var result = new WebInspector.EmulatedDevice(); 139 var result = new WebInspector.EmulatedDevice();
141 result.title = /** @type {string} */ (parseValue(json, "title", "string" )); 140 result.title = /** @type {string} */ (parseValue(json, "title", "string" ));
142 result.type = /** @type {string} */ (parseValue(json, "type", "string")) ; 141 result.type = /** @type {string} */ (parseValue(json, "type", "string")) ;
143 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent", "string")); 142 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent", "string"));
144 143
145 var capabilities = parseValue(json, "capabilities", "object", []); 144 var capabilities = parseValue(json, "capabilities", "object", []);
146 if (!Array.isArray(capabilities)) 145 if (!Array.isArray(capabilities))
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 modeImage: function(mode) 299 modeImage: function(mode)
301 { 300 {
302 if (!mode.image) 301 if (!mode.image)
303 return ""; 302 return "";
304 if (!this._extension) 303 if (!this._extension)
305 return mode.image; 304 return mode.image;
306 return this._extension.module().substituteURL(mode.image); 305 return this._extension.module().substituteURL(mode.image);
307 }, 306 },
308 307
309 /** 308 /**
309 * @param {!WebInspector.EmulatedDevice.Mode} mode
310 * @return {string}
311 */
312 outlineImage: function(mode)
313 {
314 var orientation = this.orientationByName(mode.orientation);
315 if (!orientation.outlineImage)
316 return "";
317 if (!this._extension)
318 return orientation.outlineImage;
319 return this._extension.module().substituteURL(orientation.outlineImage);
320 },
321
322 /**
323 * @param {!WebInspector.EmulatedDevice.Mode} mode
324 * @return {?Insets|null}
dgozman 2016/02/09 21:15:10 just ?Insets
mmccoy 2016/02/10 20:06:34 Done.
325 */
326 outlineInsets: function(mode)
327 {
328 var orientation = this.orientationByName(mode.orientation);
329 if (!orientation.outlineImage)
330 return null;
331 return orientation.outlineInsets;
332 },
333
334 /**
335 * @param {!WebInspector.EmulatedDevice.Mode} mode
336 * @return {?Object|string}
337 */
338 outlineDimensions: function(mode)
339 {
340 var orientation = this.orientationByName(mode.orientation);
341 if (!orientation.outlineImage)
342 return "";
343 var dimensions = {
344 "width": orientation.width + orientation.outlineInsets.left + orient ation.outlineInsets.right,
345 "height": orientation.height + orientation.outlineInsets.top + orien tation.outlineInsets.bottom
346 }
347 return dimensions;
348 },
349
350 /**
310 * @param {string} name 351 * @param {string} name
311 * @return {!WebInspector.EmulatedDevice.Orientation} 352 * @return {!WebInspector.EmulatedDevice.Orientation}
312 */ 353 */
313 orientationByName: function(name) 354 orientationByName: function(name)
314 { 355 {
315 return name === WebInspector.EmulatedDevice.Vertical ? this.vertical : t his.horizontal; 356 return name === WebInspector.EmulatedDevice.Vertical ? this.vertical : t his.horizontal;
316 }, 357 },
317 358
318 /** 359 /**
319 * @return {boolean} 360 * @return {boolean}
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 if (deviceById.has(title)) 536 if (deviceById.has(title))
496 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ ( deviceById.get(title))); 537 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ ( deviceById.get(title)));
497 } 538 }
498 }, 539 },
499 540
500 __proto__: WebInspector.Object.prototype 541 __proto__: WebInspector.Object.prototype
501 } 542 }
502 543
503 /** @type {!WebInspector.EmulatedDevicesList} */ 544 /** @type {!WebInspector.EmulatedDevicesList} */
504 WebInspector.emulatedDevicesList; 545 WebInspector.emulatedDevicesList;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698