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

Side by Side Diff: Source/devtools/front_end/sdk/OverridesSupport.js

Issue 341483004: [DevTools] Add desktop device presets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, test fix Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/ResponsiveDesignView.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 update: function(dipWidth, dipHeight, scale) { }, 75 update: function(dipWidth, dipHeight, scale) { },
76 76
77 /** 77 /**
78 * Available size for the page. 78 * Available size for the page.
79 * @return {!Size} 79 * @return {!Size}
80 */ 80 */
81 availableDipSize: function() { } 81 availableDipSize: function() { }
82 }; 82 };
83 83
84 /** 84 /**
85 * @param {string} description
86 * @param {string} userAgent
85 * @constructor 87 * @constructor
86 * @param {number} width
87 * @param {number} height
88 * @param {number} deviceScaleFactor
89 * @param {boolean} textAutosizing
90 */ 88 */
91 WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScal eFactor, textAutosizing) 89 WebInspector.OverridesSupport.Device = function(description, userAgent)
92 { 90 {
93 this.width = width; 91 this.width = 800;
94 this.height = height; 92 this.height = 600;
95 this.deviceScaleFactor = deviceScaleFactor; 93 this.deviceScaleFactor = 1;
96 this.textAutosizing = textAutosizing; 94 this.textAutosizing = true;
95 this.userAgent = userAgent;
96 this.touch = true;
97 this.viewport = true;
98
99 var splitMetrics = description.split("x");
100 if (splitMetrics.length >= 3) {
101 this.width = parseInt(splitMetrics[0], 10);
102 this.height = parseInt(splitMetrics[1], 10);
103 this.deviceScaleFactor = parseFloat(splitMetrics[2]);
104 }
105 if (splitMetrics.length >= 4)
106 this.touch = splitMetrics[3] == 1;
107 if (splitMetrics.length >= 5)
108 this.viewport = splitMetrics[4] == 1;
97 } 109 }
98 110
99 /** 111 /**
100 * @return {!WebInspector.OverridesSupport.DeviceMetrics}
101 */
102 WebInspector.OverridesSupport.DeviceMetrics.parseSetting = function(value)
103 {
104 var width = screen.width;
105 var height = screen.height;
106 var deviceScaleFactor = 1;
107 var textAutosizing = true;
108 if (value) {
109 var splitMetrics = value.split("x");
110 if (splitMetrics.length >= 3) {
111 width = parseInt(splitMetrics[0], 10);
112 height = parseInt(splitMetrics[1], 10);
113 deviceScaleFactor = parseFloat(splitMetrics[2]);
114 if (splitMetrics.length == 4)
115 textAutosizing = splitMetrics[3] == 1;
116 }
117 }
118 return new WebInspector.OverridesSupport.DeviceMetrics(width, height, device ScaleFactor, textAutosizing);
119 }
120
121 /**
122 * @constructor 112 * @constructor
123 * @param {number} latitude 113 * @param {number} latitude
124 * @param {number} longitude 114 * @param {number} longitude
125 * @param {string} error 115 * @param {string} error
126 */ 116 */
127 WebInspector.OverridesSupport.GeolocationPosition = function(latitude, longitude , error) 117 WebInspector.OverridesSupport.GeolocationPosition = function(latitude, longitude , error)
128 { 118 {
129 this.latitude = latitude; 119 this.latitude = latitude;
130 this.longitude = longitude; 120 this.longitude = longitude;
131 this.error = error; 121 this.error = error;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 function test(s) 279 function test(s)
290 { 280 {
291 return /^[\w\-]+(\.[\w\-]+)*$/.test(s.trim()); 281 return /^[\w\-]+(\.[\w\-]+)*$/.test(s.trim());
292 } 282 }
293 283
294 if (!value.trim()) 284 if (!value.trim())
295 return ""; 285 return "";
296 return value.split(",").every(test) ? "" : WebInspector.UIString("Value must be a comma-separated list of domains"); 286 return value.split(",").every(test) ? "" : WebInspector.UIString("Value must be a comma-separated list of domains");
297 } 287 }
298 288
289 // Second element is user agent value.
299 // Third element lists device metrics separated by 'x': 290 // Third element lists device metrics separated by 'x':
300 // - screen width, 291 // - screen width,
301 // - screen height, 292 // - screen height,
302 // - device scale factor, 293 // - device scale factor,
294 // - touch (true by default if not present),
295 // - viewport (true by default if not present).
303 WebInspector.OverridesSupport._phones = [ 296 WebInspector.OverridesSupport._phones = [
304 ["Apple iPhone 3GS", 297 ["Apple iPhone 3GS",
305 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", 298 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
306 "320x480x1"], 299 "320x480x1"],
307 ["Apple iPhone 4", 300 ["Apple iPhone 4",
308 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", 301 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
309 "320x480x2"], 302 "320x480x2"],
310 ["Apple iPhone 5", 303 ["Apple iPhone 5",
311 "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/5 37.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53", 304 "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/5 37.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
312 "320x568x2"], 305 "320x568x2"],
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/5 25.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2", 415 "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/5 25.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2",
423 "1280x800x1"], 416 "1280x800x1"],
424 ["Samsung Galaxy Tab 7.7, 8.9, 10.1", 417 ["Samsung Galaxy Tab 7.7, 8.9, 10.1",
425 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", 418 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
426 "1280x800x1"], 419 "1280x800x1"],
427 ["Samsung Galaxy Tab", 420 ["Samsung Galaxy Tab",
428 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", 421 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
429 "1024x600x1"], 422 "1024x600x1"],
430 ]; 423 ];
431 424
425 WebInspector.OverridesSupport._desktops = [
426 ["Chromebook Pixel",
427 "Mozilla/5.0 (X11; CrOS x86_64 3912.23.0) AppleWebKit/537.36 (KHTML, like G ecko) Chrome/27.0.1453.46 Safari/537.36",
428 "1280x950x2x1x0"],
429 ["Apple MacBook Pro",
430 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36",
431 "1280x800x1x0x0"],
432 ["Apple MacBook Pro Retina",
433 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36",
434 "1440x900x2x0x0"],
435 ["Apple MacBook Air",
436 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36",
437 "1366x768x1x0x0"],
438 ];
439
432 WebInspector.OverridesSupport._userAgents = [ 440 WebInspector.OverridesSupport._userAgents = [
433 ["Android 4.0.2 \u2014 Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Versio n/4.0 Mobile Safari/534.30"], 441 ["Android 4.0.2 \u2014 Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Versio n/4.0 Mobile Safari/534.30"],
434 ["Android 2.3 \u2014 Nexus S", "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"], 442 ["Android 2.3 \u2014 Nexus S", "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"],
435 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KH TML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"], 443 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KH TML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"],
436 ["BlackBerry \u2014 PlayBook 2.1", "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536. 2+"], 444 ["BlackBerry \u2014 PlayBook 2.1", "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536. 2+"],
437 ["BlackBerry \u2014 9900", "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en- US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534. 11+"], 445 ["BlackBerry \u2014 9900", "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en- US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534. 11+"],
438 ["Chrome 31 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) App leWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"], 446 ["Chrome 31 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) App leWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"],
439 ["Chrome 31 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.3 6 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"], 447 ["Chrome 31 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.3 6 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"],
440 ["Chrome \u2014 Android Tablet", "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safar i/535.19"], 448 ["Chrome \u2014 Android Tablet", "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safar i/535.19"],
441 ["Chrome \u2014 Android Mobile", "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"], 449 ["Chrome \u2014 Android Mobile", "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"],
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 this._pageResizer = pageResizer; 508 this._pageResizer = pageResizer;
501 if (this._pageResizer) { 509 if (this._pageResizer) {
502 this._pageResizer.addEventListener(WebInspector.OverridesSupport.Pag eResizer.Events.AvailableSizeChanged, this._onPageResizerAvailableSizeChanged, t his); 510 this._pageResizer.addEventListener(WebInspector.OverridesSupport.Pag eResizer.Events.AvailableSizeChanged, this._onPageResizerAvailableSizeChanged, t his);
503 this._pageResizer.addEventListener(WebInspector.OverridesSupport.Pag eResizer.Events.ResizeRequested, this._onPageResizerResizeRequested, this); 511 this._pageResizer.addEventListener(WebInspector.OverridesSupport.Pag eResizer.Events.ResizeRequested, this._onPageResizerResizeRequested, this);
504 } 512 }
505 if (this._initialized) 513 if (this._initialized)
506 this._deviceMetricsChanged(); 514 this._deviceMetricsChanged();
507 }, 515 },
508 516
509 /** 517 /**
510 * @param {string} deviceMetrics 518 * @param {!WebInspector.OverridesSupport.Device} device
511 * @param {string} userAgent
512 */ 519 */
513 emulateDevice: function(deviceMetrics, userAgent) 520 emulateDevice: function(device)
514 { 521 {
515 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(d eviceMetrics);
516 this._deviceMetricsChangedListenerMuted = true; 522 this._deviceMetricsChangedListenerMuted = true;
517 this._userAgentChangedListenerMuted = true; 523 this._userAgentChangedListenerMuted = true;
518 this.settings.deviceUserAgent.set(userAgent); 524 this.settings.deviceUserAgent.set(device.userAgent);
519 this.settings.deviceWidth.set(metrics.width); 525 this.settings.deviceWidth.set(device.width);
520 this.settings.deviceHeight.set(metrics.height); 526 this.settings.deviceHeight.set(device.height);
521 this.settings.deviceScaleFactor.set(metrics.deviceScaleFactor); 527 this.settings.deviceScaleFactor.set(device.deviceScaleFactor);
522 this.settings.deviceTextAutosizing.set(metrics.textAutosizing); 528 this.settings.deviceTextAutosizing.set(device.textAutosizing);
523 this.settings.deviceTouch.set(true); 529 this.settings.deviceTouch.set(device.touch);
524 this.settings.emulateViewport.set(true); 530 this.settings.emulateViewport.set(device.viewport);
525 this.settings.emulateDevice.set(true); 531 this.settings.emulateDevice.set(true);
526 delete this._deviceMetricsChangedListenerMuted; 532 delete this._deviceMetricsChangedListenerMuted;
527 delete this._userAgentChangedListenerMuted; 533 delete this._userAgentChangedListenerMuted;
528 534
529 if (this._initialized) { 535 if (this._initialized) {
530 this._deviceMetricsChanged(); 536 this._deviceMetricsChanged();
531 this._userAgentChanged(); 537 this._userAgentChanged();
532 } 538 }
533 }, 539 },
534 540
(...skipping 10 matching lines...) Expand all
545 delete this._deviceMetricsChangedListenerMuted; 551 delete this._deviceMetricsChangedListenerMuted;
546 delete this._userAgentChangedListenerMuted; 552 delete this._userAgentChangedListenerMuted;
547 553
548 if (this._initialized) { 554 if (this._initialized) {
549 this._deviceMetricsChanged(); 555 this._deviceMetricsChanged();
550 this._userAgentChanged(); 556 this._userAgentChanged();
551 } 557 }
552 }, 558 },
553 559
554 /** 560 /**
555 * @param {string} deviceMetrics 561 * @param {!WebInspector.OverridesSupport.Device} device
556 * @param {string} userAgent
557 * @return {boolean} 562 * @return {boolean}
558 */ 563 */
559 isEmulatingDevice: function(deviceMetrics, userAgent) 564 isEmulatingDevice: function(device)
560 { 565 {
561 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(d eviceMetrics); 566 return this.settings.deviceUserAgent.get() === device.userAgent
562 return this.settings.deviceUserAgent.get() === userAgent 567 && this.settings.deviceWidth.get() === device.width
563 && this.settings.deviceWidth.get() === metrics.width 568 && this.settings.deviceHeight.get() === device.height
564 && this.settings.deviceHeight.get() === metrics.height 569 && this.settings.deviceScaleFactor.get() === device.deviceScaleFacto r
565 && this.settings.deviceScaleFactor.get() === metrics.deviceScaleFact or 570 && this.settings.deviceTextAutosizing.get() === device.textAutosizin g
566 && this.settings.deviceTextAutosizing.get() === metrics.textAutosizi ng 571 && this.settings.deviceTouch.get() === device.touch
567 && this.settings.deviceTouch.get() 572 && this.settings.emulateViewport.get() === device.viewport;
568 && this.settings.emulateViewport.get();
569 }, 573 },
570 574
571 applyInitialOverrides: function() 575 applyInitialOverrides: function()
572 { 576 {
573 if (!this._target) { 577 if (!this._target) {
574 this._applyInitialOverridesOnTargetAdded = true; 578 this._applyInitialOverridesOnTargetAdded = true;
575 return; 579 return;
576 } 580 }
577 581
578 this._initialized = true; 582 this._initialized = true;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 1066
1063 /** 1067 /**
1064 * @param {!Document} document 1068 * @param {!Document} document
1065 * @return {!Element} 1069 * @return {!Element}
1066 */ 1070 */
1067 createDeviceSelect: function(document) 1071 createDeviceSelect: function(document)
1068 { 1072 {
1069 var deviceSelectElement = document.createElement("select"); 1073 var deviceSelectElement = document.createElement("select");
1070 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin gDevice(); 1074 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin gDevice();
1071 1075
1072 var devices = WebInspector.OverridesSupport._phones.concat(WebInspector. OverridesSupport._tablets); 1076 var devices = WebInspector.OverridesSupport._phones.concat(WebInspector. OverridesSupport._tablets).concat(WebInspector.OverridesSupport._desktops);
1073 devices.sort(); 1077 devices.sort();
1074 1078
1075 var selectDevice = [WebInspector.UIString("<Select device>"), "", ""]; 1079 var selectDevice = [WebInspector.UIString("<Select device>"), "", ""];
1076 devices = devices.concat([selectDevice]); 1080 devices = devices.concat([selectDevice]);
1077 for (var i = 0; i < devices.length; ++i) { 1081 for (var i = 0; i < devices.length; ++i) {
1078 var device = devices[i]; 1082 var device = devices[i];
1079 var option = new Option(device[0], device[0]); 1083 var option = new Option(device[0], device[0]);
1080 option.userAgent = device[1]; 1084 option.device = new WebInspector.OverridesSupport.Device(device[2], device[1]);
1081 option.metrics = device[2];
1082 deviceSelectElement.add(option); 1085 deviceSelectElement.add(option);
1083 } 1086 }
1084 1087
1085 deviceSelectElement.addEventListener("change", deviceSelected, false); 1088 deviceSelectElement.addEventListener("change", deviceSelected, false);
1086 1089
1087 var emulatedSettingChangedMuted = false; 1090 var emulatedSettingChangedMuted = false;
1088 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu latedSettingChanged); 1091 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu latedSettingChanged);
1089 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em ulatedSettingChanged); 1092 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em ulatedSettingChanged);
1090 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen er(emulatedSettingChanged); 1093 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen er(emulatedSettingChanged);
1091 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis tener(emulatedSettingChanged); 1094 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis tener(emulatedSettingChanged);
1092 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener (emulatedSettingChanged); 1095 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener (emulatedSettingChanged);
1093 WebInspector.overridesSupport.settings.deviceFitWindow.addChangeListener (emulatedSettingChanged); 1096 WebInspector.overridesSupport.settings.deviceFitWindow.addChangeListener (emulatedSettingChanged);
1094 WebInspector.overridesSupport.settings.deviceTouch.addChangeListener(emu latedSettingChanged); 1097 WebInspector.overridesSupport.settings.deviceTouch.addChangeListener(emu latedSettingChanged);
1095 WebInspector.overridesSupport.settings.deviceUserAgent.addChangeListener (emulatedSettingChanged); 1098 WebInspector.overridesSupport.settings.deviceUserAgent.addChangeListener (emulatedSettingChanged);
1096 emulatedSettingChanged(); 1099 emulatedSettingChanged();
1097 1100
1098 function deviceSelected() 1101 function deviceSelected()
1099 { 1102 {
1100 if (deviceSelectElement.selectedIndex === devices.length - 1) 1103 if (deviceSelectElement.selectedIndex === devices.length - 1)
1101 return; 1104 return;
1102 1105
1103 var option = deviceSelectElement.options[deviceSelectElement.selecte dIndex]; 1106 var option = deviceSelectElement.options[deviceSelectElement.selecte dIndex];
1104 emulatedSettingChangedMuted = true; 1107 emulatedSettingChangedMuted = true;
1105 WebInspector.overridesSupport.emulateDevice(option.metrics, option.u serAgent); 1108 WebInspector.overridesSupport.emulateDevice(option.device);
1106 emulatedSettingChangedMuted = false; 1109 emulatedSettingChangedMuted = false;
1107 } 1110 }
1108 1111
1109 function emulatedSettingChanged() 1112 function emulatedSettingChanged()
1110 { 1113 {
1111 if (emulatedSettingChangedMuted) 1114 if (emulatedSettingChangedMuted)
1112 return; 1115 return;
1113 1116
1114 var index = devices.length - 1; 1117 var index = devices.length - 1;
1115 for (var i = 0; i < devices.length; ++i) { 1118 for (var i = 0; i < devices.length; ++i) {
1116 var option = deviceSelectElement.options[i]; 1119 var option = deviceSelectElement.options[i];
1117 if (WebInspector.overridesSupport.isEmulatingDevice(option.metri cs, option.userAgent)) { 1120 if (WebInspector.overridesSupport.isEmulatingDevice(option.devic e)) {
1118 index = i; 1121 index = i;
1119 break; 1122 break;
1120 } 1123 }
1121 } 1124 }
1122 deviceSelectElement.selectedIndex = index; 1125 deviceSelectElement.selectedIndex = index;
1123 } 1126 }
1124 1127
1125 return deviceSelectElement; 1128 return deviceSelectElement;
1126 }, 1129 },
1127 1130
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 }, 1175 },
1173 1176
1174 __proto__: WebInspector.Object.prototype 1177 __proto__: WebInspector.Object.prototype
1175 } 1178 }
1176 1179
1177 1180
1178 /** 1181 /**
1179 * @type {!WebInspector.OverridesSupport} 1182 * @type {!WebInspector.OverridesSupport}
1180 */ 1183 */
1181 WebInspector.overridesSupport; 1184 WebInspector.overridesSupport;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ResponsiveDesignView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698