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

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

Issue 1720973002: [DevTools] Add device type to custom device presets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @implements {WebInspector.ListWidget.Delegate} 8 * @implements {WebInspector.ListWidget.Delegate}
9 */ 9 */
10 WebInspector.DevicesSettingsTab = function() 10 WebInspector.DevicesSettingsTab = function()
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 device.title = editor.control("title").value.trim(); 147 device.title = editor.control("title").value.trim();
148 device.vertical.width = editor.control("width").value ? parseInt(editor. control("width").value, 10) : 0; 148 device.vertical.width = editor.control("width").value ? parseInt(editor. control("width").value, 10) : 0;
149 device.vertical.height = editor.control("height").value ? parseInt(edito r.control("height").value, 10) : 0; 149 device.vertical.height = editor.control("height").value ? parseInt(edito r.control("height").value, 10) : 0;
150 device.horizontal.width = device.vertical.height; 150 device.horizontal.width = device.vertical.height;
151 device.horizontal.height = device.vertical.width; 151 device.horizontal.height = device.vertical.width;
152 device.deviceScaleFactor = editor.control("scale").value ? parseFloat(ed itor.control("scale").value) : 0; 152 device.deviceScaleFactor = editor.control("scale").value ? parseFloat(ed itor.control("scale").value) : 0;
153 device.userAgent = editor.control("user-agent").value; 153 device.userAgent = editor.control("user-agent").value;
154 device.modes = []; 154 device.modes = [];
155 device.modes.push({title: "", orientation: WebInspector.EmulatedDevice.V ertical, insets: new Insets(0, 0, 0, 0), images: null}); 155 device.modes.push({title: "", orientation: WebInspector.EmulatedDevice.V ertical, insets: new Insets(0, 0, 0, 0), images: null});
156 device.modes.push({title: "", orientation: WebInspector.EmulatedDevice.H orizontal, insets: new Insets(0, 0, 0, 0), images: null}); 156 device.modes.push({title: "", orientation: WebInspector.EmulatedDevice.H orizontal, insets: new Insets(0, 0, 0, 0), images: null});
157 157 device.capabilities = [];
158 var uaType = editor.control("ua-type").value;
159 if (uaType === WebInspector.DeviceModeModel.UA.Mobile || uaType === WebI nspector.DeviceModeModel.UA.MobileNoTouch)
160 device.capabilities.push(WebInspector.EmulatedDevice.Capability.Mobi le);
161 if (uaType === WebInspector.DeviceModeModel.UA.Mobile || uaType === WebI nspector.DeviceModeModel.UA.DesktopTouch)
162 device.capabilities.push(WebInspector.EmulatedDevice.Capability.Touc h);
158 if (isNew) 163 if (isNew)
159 this._emulatedDevicesList.addCustomDevice(device); 164 this._emulatedDevicesList.addCustomDevice(device);
160 else 165 else
161 this._emulatedDevicesList.saveCustomDevices(); 166 this._emulatedDevicesList.saveCustomDevices();
162 this._addCustomButton.scrollIntoViewIfNeeded(); 167 this._addCustomButton.scrollIntoViewIfNeeded();
163 this._addCustomButton.focus(); 168 this._addCustomButton.focus();
164 }, 169 },
165 170
166 /** 171 /**
167 * @override 172 * @override
168 * @param {*} item 173 * @param {*} item
169 * @return {!WebInspector.ListWidget.Editor} 174 * @return {!WebInspector.ListWidget.Editor}
170 */ 175 */
171 beginEdit: function(item) 176 beginEdit: function(item)
172 { 177 {
173 var device = /** @type {!WebInspector.EmulatedDevice} */ (item); 178 var device = /** @type {!WebInspector.EmulatedDevice} */ (item);
174 var editor = this._createEditor(); 179 var editor = this._createEditor();
175 editor.control("title").value = device.title; 180 editor.control("title").value = device.title;
176 editor.control("width").value = this._toNumericInputValue(device.vertica l.width); 181 editor.control("width").value = this._toNumericInputValue(device.vertica l.width);
177 editor.control("height").value = this._toNumericInputValue(device.vertic al.height); 182 editor.control("height").value = this._toNumericInputValue(device.vertic al.height);
178 editor.control("scale").value = this._toNumericInputValue(device.deviceS caleFactor); 183 editor.control("scale").value = this._toNumericInputValue(device.deviceS caleFactor);
179 editor.control("user-agent").value = device.userAgent; 184 editor.control("user-agent").value = device.userAgent;
185 var uaType;
186 if (device.mobile())
187 uaType = device.touch() ? WebInspector.DeviceModeModel.UA.Mobile : W ebInspector.DeviceModeModel.UA.MobileNoTouch;
188 else
189 uaType = device.touch() ? WebInspector.DeviceModeModel.UA.DesktopTou ch : WebInspector.DeviceModeModel.UA.Desktop;
190 editor.control("ua-type").value = uaType;
180 return editor; 191 return editor;
181 }, 192 },
182 193
183 /** 194 /**
184 * @return {!WebInspector.ListWidget.Editor} 195 * @return {!WebInspector.ListWidget.Editor}
185 */ 196 */
186 _createEditor: function() 197 _createEditor: function()
187 { 198 {
188 if (this._editor) 199 if (this._editor)
189 return this._editor; 200 return this._editor;
190 201
191 var editor = new WebInspector.ListWidget.Editor(); 202 var editor = new WebInspector.ListWidget.Editor();
192 this._editor = editor; 203 this._editor = editor;
193 var content = editor.contentElement(); 204 var content = editor.contentElement();
194 205
195 var fields = content.createChild("div", "devices-edit-fields"); 206 var fields = content.createChild("div", "devices-edit-fields");
196 fields.appendChild(editor.createInput("title", "text", WebInspector.UISt ring("Device name"), titleValidator)); 207 fields.createChild("div", "hbox").appendChild(editor.createInput("title" , "text", WebInspector.UIString("Device name"), titleValidator));
197 var screen = fields.createChild("div", "hbox"); 208 var screen = fields.createChild("div", "hbox");
198 var width = editor.createInput("width", "text", WebInspector.UIString("W idth"), sizeValidator); 209 screen.appendChild(editor.createInput("width", "text", WebInspector.UISt ring("Width"), sizeValidator));
199 width.classList.add("device-edit-small"); 210 screen.appendChild(editor.createInput("height", "text", WebInspector.UIS tring("height"), sizeValidator));
200 screen.appendChild(width); 211 var dpr = editor.createInput("scale", "text", WebInspector.UIString("Dev ice pixel ratio"), scaleValidator);
201 var height = editor.createInput("height", "text", WebInspector.UIString( "height"), sizeValidator); 212 dpr.classList.add("device-edit-fixed");
202 height.classList.add("device-edit-small"); 213 screen.appendChild(dpr);
203 screen.appendChild(height); 214 var ua = fields.createChild("div", "hbox");
204 screen.appendChild(editor.createInput("scale", "text", WebInspector.UISt ring("Device pixel ratio"), scaleValidator)); 215 ua.appendChild(editor.createInput("user-agent", "text", WebInspector.UIS tring("User agent string"), () => true));
205 fields.appendChild(editor.createInput("user-agent", "text", WebInspector .UIString("User agent string"), userAgentValidator)); 216 var uaType = editor.createSelect("ua-type", [WebInspector.DeviceModeMode l.UA.Mobile, WebInspector.DeviceModeModel.UA.MobileNoTouch, WebInspector.DeviceM odeModel.UA.Desktop, WebInspector.DeviceModeModel.UA.DesktopTouch], () => true);
217 uaType.classList.add("device-edit-fixed");
218 ua.appendChild(uaType);
206 219
207 return editor; 220 return editor;
208 221
209 /** 222 /**
210 * @param {*} item 223 * @param {*} item
211 * @param {number} index 224 * @param {number} index
212 * @param {!HTMLInputElement|!HTMLSelectElement} input 225 * @param {!HTMLInputElement|!HTMLSelectElement} input
213 * @return {boolean} 226 * @return {boolean}
214 */ 227 */
215 function titleValidator(item, index, input) 228 function titleValidator(item, index, input)
(...skipping 16 matching lines...) Expand all
232 /** 245 /**
233 * @param {*} item 246 * @param {*} item
234 * @param {number} index 247 * @param {number} index
235 * @param {!HTMLInputElement|!HTMLSelectElement} input 248 * @param {!HTMLInputElement|!HTMLSelectElement} input
236 * @return {boolean} 249 * @return {boolean}
237 */ 250 */
238 function scaleValidator(item, index, input) 251 function scaleValidator(item, index, input)
239 { 252 {
240 return WebInspector.DeviceModeModel.deviceScaleFactorValidator(input .value); 253 return WebInspector.DeviceModeModel.deviceScaleFactorValidator(input .value);
241 } 254 }
242
243 /**
244 * @param {*} item
245 * @param {number} index
246 * @param {!HTMLInputElement|!HTMLSelectElement} input
247 * @return {boolean}
248 */
249 function userAgentValidator(item, index, input)
250 {
251 return true;
252 }
253 }, 255 },
254 256
255 __proto__: WebInspector.VBox.prototype 257 __proto__: WebInspector.VBox.prototype
256 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698