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

Side by Side Diff: Source/devtools/front_end/ResponsiveDesignView.js

Issue 340723005: [DevTools] Remove unnecessary emulation checkboxes and simplify UX. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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
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 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @implements {WebInspector.OverridesSupport.PageResizer} 8 * @implements {WebInspector.OverridesSupport.PageResizer}
9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder 9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
10 */ 10 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this._heightSlider = this._heightSliderContainer.createChild("div", "respons ive-design-slider-thumb"); 46 this._heightSlider = this._heightSliderContainer.createChild("div", "respons ive-design-slider-thumb");
47 this._heightSlider.createChild("div", "responsive-design-thumb-handle"); 47 this._heightSlider.createChild("div", "responsive-design-thumb-handle");
48 this._createResizer(this._heightSlider, true); 48 this._createResizer(this._heightSlider, true);
49 49
50 this._inspectedPagePlaceholder = inspectedPagePlaceholder; 50 this._inspectedPagePlaceholder = inspectedPagePlaceholder;
51 inspectedPagePlaceholder.show(this.element); 51 inspectedPagePlaceholder.show(this.element);
52 52
53 this._enabled = false; 53 this._enabled = false;
54 54
55 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo omChanged, this._onZoomChanged, this); 55 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo omChanged, this._onZoomChanged, this);
56 WebInspector.settings.responsiveDesignEnabled.addChangeListener(this._respon siveDesignEnabledChanged, this); 56 WebInspector.overridesSupport.settings.emulationEnabled.addChangeListener(th is._emulationEnabledChanged, this);
57 this._responsiveDesignEnabledChanged(); 57 this._emulationEnabledChanged();
58 this._overridesWarningUpdated(); 58 this._overridesWarningUpdated();
59 }; 59 };
60 60
61 // Measured in DIP. 61 // Measured in DIP.
62 WebInspector.ResponsiveDesignView.SliderWidth = 19; 62 WebInspector.ResponsiveDesignView.SliderWidth = 19;
63 WebInspector.ResponsiveDesignView.RulerWidth = 22; 63 WebInspector.ResponsiveDesignView.RulerWidth = 22;
64 64
65 WebInspector.ResponsiveDesignView.prototype = { 65 WebInspector.ResponsiveDesignView.prototype = {
66 _invalidateCache: function() 66 _invalidateCache: function()
67 { 67 {
68 delete this._cachedScale; 68 delete this._cachedScale;
69 delete this._cachedCssCanvasWidth; 69 delete this._cachedCssCanvasWidth;
70 delete this._cachedCssCanvasHeight; 70 delete this._cachedCssCanvasHeight;
71 delete this._cachedCssHeight; 71 delete this._cachedCssHeight;
72 delete this._cachedCssWidth; 72 delete this._cachedCssWidth;
73 delete this._cachedZoomFactor; 73 delete this._cachedZoomFactor;
74 delete this._availableSize; 74 delete this._availableSize;
75 }, 75 },
76 76
77 _responsiveDesignEnabledChanged: function() 77 _emulationEnabledChanged: function()
78 { 78 {
79 var enabled = WebInspector.settings.responsiveDesignEnabled.get(); 79 var enabled = WebInspector.overridesSupport.settings.emulationEnabled.ge t();
80 if (enabled && !this._enabled) { 80 if (enabled && !this._enabled) {
81 this._invalidateCache(); 81 this._invalidateCache();
82 this._ignoreResize = true; 82 this._ignoreResize = true;
83 this._enabled = true; 83 this._enabled = true;
84 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); 84 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
85 this._inspectedPagePlaceholder.show(this._pageContainer); 85 this._inspectedPagePlaceholder.show(this._pageContainer);
86 this._responsiveDesignContainer.show(this.element); 86 this._responsiveDesignContainer.show(this.element);
87 this.update(this._dipWidth || 0, this._dipHeight || 0, this._scale | | 0); 87 this.update(this._dipWidth || 0, this._dipHeight || 0, this._scale | | 0);
88 delete this._ignoreResize; 88 delete this._ignoreResize;
89 } else if (!enabled && this._enabled) { 89 } else if (!enabled && this._enabled) {
(...skipping 24 matching lines...) Expand all
114 this._updateUI(); 114 this._updateUI();
115 }, 115 },
116 116
117 /** 117 /**
118 * WebInspector.OverridesSupport.PageResizer override. 118 * WebInspector.OverridesSupport.PageResizer override.
119 * @return {!Size} 119 * @return {!Size}
120 */ 120 */
121 availableDipSize: function() 121 availableDipSize: function()
122 { 122 {
123 if (typeof this._availableSize === "undefined") { 123 if (typeof this._availableSize === "undefined") {
124 this._responsiveDesignEnabledChanged(); 124 this._emulationEnabledChanged();
125 var zoomFactor = WebInspector.zoomManager.zoomFactor(); 125 var zoomFactor = WebInspector.zoomManager.zoomFactor();
126 var rect = this._canvasContainer.element.getBoundingClientRect(); 126 var rect = this._canvasContainer.element.getBoundingClientRect();
127 this._availableSize = new Size(rect.width * zoomFactor - WebInspecto r.ResponsiveDesignView.RulerWidth, 127 this._availableSize = new Size(rect.width * zoomFactor - WebInspecto r.ResponsiveDesignView.RulerWidth,
128 rect.height * zoomFactor - WebInspect or.ResponsiveDesignView.RulerWidth); 128 rect.height * zoomFactor - WebInspect or.ResponsiveDesignView.RulerWidth);
129 } 129 }
130 return this._availableSize; 130 return this._availableSize;
131 }, 131 },
132 132
133 /** 133 /**
134 * @param {!Element} element 134 * @param {!Element} element
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 this._toolbarElement.createChild("div", "responsive-design-separator"); 390 this._toolbarElement.createChild("div", "responsive-design-separator");
391 391
392 this._toolbarExpandedChanged(); 392 this._toolbarExpandedChanged();
393 }, 393 },
394 394
395 _createExpandSection: function() 395 _createExpandSection: function()
396 { 396 {
397 this.toolbarExpandedSetting = WebInspector.settings.createSetting("respo nsiveDesignToolbarExpanded", false); 397 this.toolbarExpandedSetting = WebInspector.settings.createSetting("respo nsiveDesignToolbarExpanded", false);
398 var expandSection = this._toolbarElement.createChild("div", "responsive- design-section responsive-design-section-expand"); 398 var expandSection = this._toolbarElement.createChild("div", "responsive- design-section responsive-design-section-expand");
399 this._expandButton = expandSection.createChild("div", "responsive-design -expand-button"); 399 this._expandButton = expandSection.createChild("div", "responsive-design -button");
400 this._expandButton.createChild("div", "responsive-design-icon responsive -design-icon-expand"); 400 this._expandButton.createChild("div", "responsive-design-icon responsive -design-icon-expand");
401 this._expandButton.createChild("span"); 401 this._expandButton.createChild("span");
402 this._expandButton.addEventListener("click", this._toggleToolbarExpanded .bind(this), false); 402 this._expandButton.addEventListener("click", this._toggleToolbarExpanded .bind(this), false);
403 this.toolbarExpandedSetting.addChangeListener(this._toolbarExpandedChang ed, this); 403 this.toolbarExpandedSetting.addChangeListener(this._toolbarExpandedChang ed, this);
404 }, 404 },
405 405
406 _toggleToolbarExpanded: function() 406 _toggleToolbarExpanded: function()
407 { 407 {
408 this.toolbarExpandedSetting.set(!this.toolbarExpandedSetting.get()); 408 this.toolbarExpandedSetting.set(!this.toolbarExpandedSetting.get());
409 }, 409 },
410 410
411 _toolbarExpandedChanged: function() 411 _toolbarExpandedChanged: function()
412 { 412 {
413 var expanded = this.toolbarExpandedSetting.get(); 413 var expanded = this.toolbarExpandedSetting.get();
414 this._expandButton.querySelector("span").textContent = WebInspector.UISt ring(expanded ? "Less" : "More"); 414 this._expandButton.querySelector("span").textContent = WebInspector.UISt ring(expanded ? "Less" : "More");
415 this._toolbarElement.classList.toggle("expanded", expanded); 415 this._toolbarElement.classList.toggle("expanded", expanded);
416 this.onResize(); 416 this.onResize();
417 }, 417 },
418 418
419 _createDeviceSection: function() 419 _createDeviceSection: function()
420 { 420 {
421 var deviceSection = this._toolbarElement.createChild("div", "responsive- design-section responsive-design-section-device"); 421 var deviceSection = this._toolbarElement.createChild("div", "responsive- design-section responsive-design-section-device");
422 422
423 // Device. 423 // Device.
424 var deviceElement = deviceSection.createChild("div", "responsive-design- suite").createChild("div"); 424 var deviceElement = deviceSection.createChild("div", "responsive-design- suite").createChild("div");
425 deviceElement.appendChild(WebInspector.SettingsUI.createSettingCheckbox( WebInspector.UIString("Device"), WebInspector.overridesSupport.settings.emulateD evice, true)); 425 var fieldsetElement = deviceElement.createChild("fieldset");
426 deviceElement.appendChild(WebInspector.overridesSupport.createDeviceSele ct(document)); 426 fieldsetElement.createChild("label").textContent = WebInspector.UIString ("Device");
427 fieldsetElement.appendChild(WebInspector.overridesSupport.createDeviceSe lect(document));
427 428
428 var separator = deviceSection.createChild("div", "responsive-design-sect ion-separator expanded-only"); 429 var separator = deviceSection.createChild("div", "responsive-design-sect ion-separator expanded-only");
429 430
430 var detailsElement = deviceSection.createChild("div", "responsive-design -suite expanded-only"); 431 var detailsElement = deviceSection.createChild("div", "responsive-design -suite expanded-only");
431 432
432 // Dimensions. 433 // Dimensions.
433 var screenElement = detailsElement.createChild("div", ""); 434 var screenElement = detailsElement.createChild("div", "");
434 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI nspector.overridesSupport.settings.emulateDevice); 435 fieldsetElement = screenElement.createChild("fieldset");
435 screenElement.appendChild(fieldsetElement);
436
437 fieldsetElement.createChild("div", "responsive-design-icon responsive-de sign-icon-resolution").title = WebInspector.UIString("Screen resolution"); 436 fieldsetElement.createChild("div", "responsive-design-icon responsive-de sign-icon-resolution").title = WebInspector.UIString("Screen resolution");
438 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", WebI nspector.OverridesSupport.integerInputValidator, true)); 437 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", WebI nspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString ("--")));
439 fieldsetElement.appendChild(document.createTextNode(" \u00D7 ")); 438 fieldsetElement.appendChild(document.createTextNode(" \u00D7 "));
440 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em", Web Inspector.OverridesSupport.integerInputValidator, true)); 439 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em", Web Inspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIStrin g("--")));
441 440
442 this._swapDimensionsElement = fieldsetElement.createChild("button", "res ponsive-design-icon responsive-design-icon-swap"); 441 this._swapDimensionsElement = fieldsetElement.createChild("button", "res ponsive-design-icon responsive-design-icon-swap");
443 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns"); 442 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns");
444 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); 443 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false);
445 444
446 // Device pixel ratio. 445 // Device pixel ratio.
447 detailsElement.createChild("div", "responsive-design-suite-separator"); 446 detailsElement.createChild("div", "responsive-design-suite-separator");
448 var dprElement = detailsElement.createChild("div", ""); 447 var dprElement = detailsElement.createChild("div", "");
449 fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebInspe ctor.overridesSupport.settings.emulateDevice); 448 fieldsetElement = dprElement.createChild("fieldset");
450 dprElement.appendChild(fieldsetElement); 449 fieldsetElement.createChild("div", "responsive-design-icon responsive-de sign-icon-dpr").title = WebInspector.UIString("Device pixel ratio");
450 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "2.5e m", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, WebIns pector.UIString("--")));
451 451
452 fieldsetElement.createChild("div", "responsive-design-icon responsive-de sign-icon-dpr").title = WebInspector.UIString("Device pixel ratio");
453 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "2.5e m", WebInspector.OverridesSupport.doubleInputValidator, true));
454
455 // Touch.
456 if (!WebInspector.overridesSupport.hasTouchInputs()) {
457 detailsElement.createChild("div", "responsive-design-suite-separator ");
458 var touchElement = detailsElement.createChild("div", "");
459 fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI nspector.overridesSupport.settings.emulateDevice);
460 touchElement.appendChild(fieldsetElement);
461 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingChe ckbox(WebInspector.UIString("Touch"), WebInspector.overridesSupport.settings.dev iceTouch, true));
462 }
463
464 // Viewport.
465 detailsElement.createChild("div", "responsive-design-suite-separator"); 452 detailsElement.createChild("div", "responsive-design-suite-separator");
466 var viewportElement = detailsElement.createChild("div", ""); 453 var resetButton = detailsElement.createChild("div", "responsive-design-b utton");
467 fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebInspe ctor.overridesSupport.settings.emulateDevice); 454 resetButton.textContent = WebInspector.UIString("Reset");
468 viewportElement.appendChild(fieldsetElement); 455 resetButton.addEventListener("click", WebInspector.overridesSupport.rese t.bind(WebInspector.overridesSupport), false);
469
470 var viewportCheckbox = WebInspector.SettingsUI.createSettingCheckbox(Web Inspector.UIString("Mobile"), WebInspector.overridesSupport.settings.emulateView port, true);
471 viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, ov erlay scrollbars and default 980px body width");
472 fieldsetElement.appendChild(viewportCheckbox);
473 }, 456 },
474 457
475 _createNetworkSection: function() 458 _createNetworkSection: function()
476 { 459 {
477 var networkSection = this._toolbarElement.createChild("div", "responsive -design-section responsive-design-section-network"); 460 var networkSection = this._toolbarElement.createChild("div", "responsive -design-section responsive-design-section-network");
478 461
479 // Bandwidth. 462 // Bandwidth.
480 var bandwidthElement = networkSection.createChild("div", "responsive-des ign-suite").createChild("div"); 463 var bandwidthElement = networkSection.createChild("div", "responsive-des ign-suite").createChild("div");
481 var networkCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebI nspector.UIString("Bandwidth"), WebInspector.overridesSupport.settings.emulateNe tworkConditions, true); 464 var fieldsetElement = bandwidthElement.createChild("fieldset");
482 bandwidthElement.appendChild(networkCheckbox); 465 var networkCheckbox = fieldsetElement.createChild("label");
483 bandwidthElement.appendChild(WebInspector.overridesSupport.createNetwork ThroughputSelect(document)); 466 networkCheckbox.textContent = WebInspector.UIString("Network");
467 fieldsetElement.appendChild(WebInspector.overridesSupport.createNetworkT hroughputSelect(document));
484 468
485 var separator = networkSection.createChild("div", "responsive-design-sec tion-separator expanded-only"); 469 var separator = networkSection.createChild("div", "responsive-design-sec tion-separator expanded-only");
486 470
487 // User agent. 471 // User agent.
488 var userAgentElement = networkSection.createChild("div", "responsive-des ign-suite expanded-only").createChild("div"); 472 var userAgentElement = networkSection.createChild("div", "responsive-des ign-suite expanded-only").createChild("div");
489 userAgentElement.appendChild(WebInspector.SettingsUI.createSettingLabel( WebInspector.UIString("User Agent:"), WebInspector.overridesSupport.settings.dev iceUserAgent, 32, "240px", WebInspector.UIString("no override"))); 473 fieldsetElement = userAgentElement.createChild("fieldset");
474 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("UA", WebInspector.overridesSupport.settings.userAgent, false, 0, "", undefi ned, false, false, WebInspector.UIString("no override")));
490 475
491 updateNetworkCheckboxTitle(); 476 updateNetworkCheckboxTitle();
492 WebInspector.overridesSupport.settings.networkConditionsDomains.addChang eListener(updateNetworkCheckboxTitle); 477 WebInspector.overridesSupport.settings.networkConditionsDomains.addChang eListener(updateNetworkCheckboxTitle);
493 478
494 function updateNetworkCheckboxTitle() 479 function updateNetworkCheckboxTitle()
495 { 480 {
496 var domains = WebInspector.overridesSupport.settings.networkConditio nsDomains.get(); 481 var domains = WebInspector.overridesSupport.settings.networkConditio nsDomains.get();
497 if (!domains.trim()) { 482 if (!domains.trim()) {
498 networkCheckbox.title = WebInspector.UIString("Limit for all dom ains"); 483 networkCheckbox.title = WebInspector.UIString("Limit for all dom ains");
499 } else { 484 } else {
(...skipping 17 matching lines...) Expand all
517 }, 502 },
518 503
519 _closeOverridesWarning: function() 504 _closeOverridesWarning: function()
520 { 505 {
521 this._warningMessage.querySelector("span").textContent = ""; 506 this._warningMessage.querySelector("span").textContent = "";
522 this._warningMessage.classList.add("hidden"); 507 this._warningMessage.classList.add("hidden");
523 }, 508 },
524 509
525 __proto__: WebInspector.VBox.prototype 510 __proto__: WebInspector.VBox.prototype
526 }; 511 };
OLDNEW
« no previous file with comments | « LayoutTests/inspector/device-emulation/device-emulation-test.js ('k') | Source/devtools/front_end/common/Settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698