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

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

Issue 2446113004: DevTools: add tests for device mode's responsive mode (Closed)
Patch Set: ac Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/device-mode/device-mode-responsive-expected.txt ('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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * @param {!WebInspector.DeviceModeModel} model 6 * @param {!WebInspector.DeviceModeModel} model
7 * @param {!WebInspector.Setting} showMediaInspectorSetting 7 * @param {!WebInspector.Setting} showMediaInspectorSetting
8 * @param {!WebInspector.Setting} showRulersSetting 8 * @param {!WebInspector.Setting} showRulersSetting
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 /** 77 /**
78 * @param {!WebInspector.Toolbar} toolbar 78 * @param {!WebInspector.Toolbar} toolbar
79 */ 79 */
80 _fillMainToolbar: function(toolbar) 80 _fillMainToolbar: function(toolbar)
81 { 81 {
82 var widthInput = createElementWithClass("input", "device-mode-size-input "); 82 var widthInput = createElementWithClass("input", "device-mode-size-input ");
83 widthInput.maxLength = 4; 83 widthInput.maxLength = 4;
84 widthInput.type = "text"; 84 widthInput.type = "text";
85 widthInput.title = WebInspector.UIString("Width"); 85 widthInput.title = WebInspector.UIString("Width");
86 this._updateWidthInput = WebInspector.bindInput(widthInput, applyWidth.b ind(this), WebInspector.DeviceModeModel.deviceSizeValidator, true); 86 this._updateWidthInput = WebInspector.bindInput(widthInput, this._applyW idth.bind(this), WebInspector.DeviceModeModel.deviceSizeValidator, true);
87 this._widthInput = widthInput; 87 this._widthInput = widthInput;
88 this._widthItem = this._wrapToolbarItem(widthInput); 88 this._widthItem = this._wrapToolbarItem(widthInput);
89 toolbar.appendToolbarItem(this._widthItem); 89 toolbar.appendToolbarItem(this._widthItem);
90 90
91 var xElement = createElementWithClass("div", "device-mode-x"); 91 var xElement = createElementWithClass("div", "device-mode-x");
92 xElement.textContent = "\u00D7"; 92 xElement.textContent = "\u00D7";
93 this._xItem = this._wrapToolbarItem(xElement); 93 this._xItem = this._wrapToolbarItem(xElement);
94 toolbar.appendToolbarItem(this._xItem); 94 toolbar.appendToolbarItem(this._xItem);
95 95
96 var heightInput = createElementWithClass("input", "device-mode-size-inpu t"); 96 var heightInput = createElementWithClass("input", "device-mode-size-inpu t");
97 heightInput.maxLength = 4; 97 heightInput.maxLength = 4;
98 heightInput.type = "text"; 98 heightInput.type = "text";
99 heightInput.title = WebInspector.UIString("Height (leave empty for full) "); 99 heightInput.title = WebInspector.UIString("Height (leave empty for full) ");
100 this._updateHeightInput = WebInspector.bindInput(heightInput, applyHeigh t.bind(this), validateHeight, true); 100 this._updateHeightInput = WebInspector.bindInput(heightInput, this._appl yHeight.bind(this), validateHeight, true);
101 this._heightInput = heightInput; 101 this._heightInput = heightInput;
102 this._heightItem = this._wrapToolbarItem(heightInput); 102 this._heightItem = this._wrapToolbarItem(heightInput);
103 toolbar.appendToolbarItem(this._heightItem); 103 toolbar.appendToolbarItem(this._heightItem);
104 104
105 /** 105 /**
106 * @param {string} value 106 * @param {string} value
107 * @return {boolean} 107 * @return {boolean}
108 */ 108 */
109 function validateHeight(value) 109 function validateHeight(value)
110 { 110 {
111 return !value || WebInspector.DeviceModeModel.deviceSizeValidator(va lue); 111 return !value || WebInspector.DeviceModeModel.deviceSizeValidator(va lue);
112 } 112 }
113
114 /**
115 * @param {string} value
116 * @this {WebInspector.DeviceModeToolbar}
117 */
118 function applyWidth(value)
119 {
120 var width = value ? Number(value) : 0;
121 this._model.setWidthAndScaleToFit(width);
122 }
123
124 /**
125 * @param {string} value
126 * @this {WebInspector.DeviceModeToolbar}
127 */
128 function applyHeight(value)
129 {
130 var height = value ? Number(value) : 0;
131 this._model.setHeightAndScaleToFit(height);
132 }
133 }, 113 },
134 114
135 /** 115 /**
116 * @param {string} value
117 */
118 _applyWidth: function(value)
119 {
120 var width = value ? Number(value) : 0;
121 this._model.setWidthAndScaleToFit(width);
122 },
123
124 /**
125 * @param {string} value
126 */
127 _applyHeight: function(value)
128 {
129 var height = value ? Number(value) : 0;
130 this._model.setHeightAndScaleToFit(height);
131 },
132
133 /**
136 * @param {!WebInspector.Toolbar} toolbar 134 * @param {!WebInspector.Toolbar} toolbar
137 */ 135 */
138 _fillRightToolbar: function(toolbar) 136 _fillRightToolbar: function(toolbar)
139 { 137 {
140 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass(" div", "device-mode-empty-toolbar-element"))); 138 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass(" div", "device-mode-empty-toolbar-element")));
141 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe nuItems.bind(this)); 139 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe nuItems.bind(this));
142 this._scaleItem.setTitle(WebInspector.UIString("Zoom")); 140 this._scaleItem.setTitle(WebInspector.UIString("Zoom"));
143 this._scaleItem.setGlyph(""); 141 this._scaleItem.setGlyph("");
144 this._scaleItem.turnIntoSelect(); 142 this._scaleItem.turnIntoSelect();
145 toolbar.appendToolbarItem(this._scaleItem); 143 toolbar.appendToolbarItem(this._scaleItem);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 this._emulateDevice(device); 578 this._emulateDevice(device);
581 return; 579 return;
582 } 580 }
583 } 581 }
584 } 582 }
585 } 583 }
586 584
587 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null, null); 585 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null, null);
588 } 586 }
589 }; 587 };
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/device-mode/device-mode-responsive-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698