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

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

Issue 335383004: DevTools: responsive design rulers UI tweaks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « no previous file | 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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 WebInspector.settings.responsiveDesign.enabled.addChangeListener(this._respo nsiveDesignEnabledChanged, this); 50 WebInspector.settings.responsiveDesign.enabled.addChangeListener(this._respo nsiveDesignEnabledChanged, this);
51 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener(thi s._maybeEnableResponsiveDesign, this); 51 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener(thi s._maybeEnableResponsiveDesign, this);
52 WebInspector.overridesSupport.settings.emulateTouchEvents.addChangeListener( this._maybeEnableResponsiveDesign, this); 52 WebInspector.overridesSupport.settings.emulateTouchEvents.addChangeListener( this._maybeEnableResponsiveDesign, this);
53 WebInspector.overridesSupport.settings.overrideDeviceResolution.addChangeLis tener(this._maybeEnableResponsiveDesign, this); 53 WebInspector.overridesSupport.settings.overrideDeviceResolution.addChangeLis tener(this._maybeEnableResponsiveDesign, this);
54 this._responsiveDesignEnabledChanged(); 54 this._responsiveDesignEnabledChanged();
55 this._overridesWarningUpdated(); 55 this._overridesWarningUpdated();
56 }; 56 };
57 57
58 // Measured in DIP. 58 // Measured in DIP.
59 WebInspector.ResponsiveDesignView.SliderWidth = 19; 59 WebInspector.ResponsiveDesignView.SliderWidth = 19;
60 WebInspector.ResponsiveDesignView.RulerWidth = 20; 60 WebInspector.ResponsiveDesignView.RulerWidth = 22;
61 61
62 WebInspector.ResponsiveDesignView.prototype = { 62 WebInspector.ResponsiveDesignView.prototype = {
63 _maybeEnableResponsiveDesign: function() 63 _maybeEnableResponsiveDesign: function()
64 { 64 {
65 if (this._enabled) 65 if (this._enabled)
66 return; 66 return;
67 if (WebInspector.overridesSupport.settings.emulateViewport.get() || 67 if (WebInspector.overridesSupport.settings.emulateViewport.get() ||
68 WebInspector.overridesSupport.settings.emulateTouchEvents.get() || 68 WebInspector.overridesSupport.settings.emulateTouchEvents.get() ||
69 WebInspector.overridesSupport.settings.overrideDeviceResolution. get()) { 69 WebInspector.overridesSupport.settings.overrideDeviceResolution. get()) {
70 WebInspector.settings.responsiveDesign.enabled.set(true); 70 WebInspector.settings.responsiveDesign.enabled.set(true);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 canvas.style.height = cssCanvasHeight + "px"; 207 canvas.style.height = cssCanvasHeight + "px";
208 208
209 var zoomFactor = WebInspector.zoomManager.zoomFactor(); 209 var zoomFactor = WebInspector.zoomManager.zoomFactor();
210 var dipCanvasWidth = cssCanvasWidth * zoomFactor; 210 var dipCanvasWidth = cssCanvasWidth * zoomFactor;
211 var dipCanvasHeight = cssCanvasHeight * zoomFactor; 211 var dipCanvasHeight = cssCanvasHeight * zoomFactor;
212 212
213 var deviceScaleFactor = window.devicePixelRatio; 213 var deviceScaleFactor = window.devicePixelRatio;
214 canvas.width = deviceScaleFactor * cssCanvasWidth; 214 canvas.width = deviceScaleFactor * cssCanvasWidth;
215 canvas.height = deviceScaleFactor * cssCanvasHeight; 215 canvas.height = deviceScaleFactor * cssCanvasHeight;
216 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe ight); 216 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe ight);
217 217 context.font = "10px " + WebInspector.fontFamily();
218 context.font = "11px " + WebInspector.fontFamily();
219 218
220 const rulerStep = 100; 219 const rulerStep = 100;
221 const rulerSubStep = 5; 220 const rulerSubStep = 5;
222 const gridStep = 50; 221 const gridStep = 50;
223 const gridSubStep = 10; 222 const gridSubStep = 10;
224 const rulerBackgroundColor = "rgb(64, 64, 64)"; 223 const rulerBackgroundColor = "rgb(0, 0, 0)";
225 const backgroundColor = "rgb(102, 102, 102)"; 224 const backgroundColor = "rgb(102, 102, 102)";
226 const lightLineColor = "rgb(132, 132, 132)"; 225 const lightLineColor = "rgb(132, 132, 132)";
227 const darkLineColor = "rgb(114, 114, 114)"; 226 const darkLineColor = "rgb(114, 114, 114)";
228 const textColor = "rgb(180, 180, 180)"; 227 const rulerColor = "rgb(125, 125, 125)";
228 const textColor = "rgb(168, 168, 168)";
229 229
230 var scale = this._scale || 1; 230 var scale = this._scale || 1;
231 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; 231 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth;
232 var dipGridWidth = dipCanvasWidth / scale - rulerWidth; 232 var dipGridWidth = dipCanvasWidth / scale - rulerWidth;
233 var dipGridHeight = dipCanvasHeight / scale - rulerWidth; 233 var dipGridHeight = dipCanvasHeight / scale - rulerWidth;
234 rulerWidth /= scale; 234 rulerWidth /= scale;
235 context.scale(scale, scale); 235 context.scale(scale, scale);
236 context.translate(rulerWidth, rulerWidth); 236 context.translate(rulerWidth, rulerWidth);
237 237
238 context.fillStyle = rulerBackgroundColor; 238 context.fillStyle = rulerBackgroundColor;
239 context.fillRect(-rulerWidth, -rulerWidth, dipGridWidth + rulerWidth, ru lerWidth); 239 context.fillRect(-rulerWidth, -rulerWidth, dipGridWidth + rulerWidth, ru lerWidth);
240 context.fillRect(-rulerWidth, 0, rulerWidth, dipGridHeight); 240 context.fillRect(-rulerWidth, 0, rulerWidth, dipGridHeight);
241 241
242 context.fillStyle = backgroundColor; 242 context.fillStyle = backgroundColor;
243 context.fillRect(0, 0, dipGridWidth, dipGridHeight); 243 context.fillRect(0, 0, dipGridWidth, dipGridHeight);
244 244
245 context.translate(0.5, 0.5); 245 context.translate(0.5, 0.5);
246 context.strokeStyle = textColor; 246 context.strokeStyle = rulerColor;
247 context.fillStyle = textColor; 247 context.fillStyle = textColor;
248 context.lineWidth = 1; 248 context.lineWidth = 1;
249 249
250 // Draw vertical ruler. 250 // Draw vertical ruler.
251 for (var x = 0; x < dipGridWidth; x += rulerSubStep) { 251 for (var x = 0; x < dipGridWidth; x += rulerSubStep) {
252 var color = darkLineColor; 252 var color = darkLineColor;
253 var y = -rulerWidth / 4; 253 var y = -rulerWidth / 4;
254 if (!(x % (rulerStep / 4)))
255 y = -rulerWidth / 2;
254 if (!(x % (rulerStep / 2))) 256 if (!(x % (rulerStep / 2)))
255 y = -rulerWidth / 2; 257 y = -rulerWidth + 2;
256 258
257 if (!(x % rulerStep)) { 259 if (!(x % rulerStep)) {
258 if (x) { 260 context.save();
259 context.save(); 261 context.translate(x, 0);
260 context.translate(x, 0); 262 context.fillText(x, 2, -rulerWidth / 2);
261 context.fillText(x, 2, -rulerWidth / 2); 263 context.restore();
262 context.restore(); 264 y = -rulerWidth;
263 }
264 y = -rulerWidth * 2 / 3;
265 } 265 }
266 266
267 context.beginPath(); 267 context.beginPath();
268 context.moveTo(x, y); 268 context.moveTo(x, y);
269 context.lineTo(x, 0); 269 context.lineTo(x, 0);
270 context.stroke(); 270 context.stroke();
271 } 271 }
272 272
273 // Draw horizontal ruler. 273 // Draw horizontal ruler.
274 for (var y = 0; y < dipGridHeight; y += rulerSubStep) { 274 for (var y = 0; y < dipGridHeight; y += rulerSubStep) {
275 var color = darkLineColor; 275 var color = darkLineColor;
276 x = -rulerWidth / 4; 276 x = -rulerWidth / 4;
277 if (!(y % (rulerStep / 4)))
278 x = -rulerWidth / 2;
277 if (!(y % (rulerStep / 2))) 279 if (!(y % (rulerStep / 2)))
278 x = -rulerWidth / 2; 280 x = -rulerWidth + 2;
279 281
280 if (!(y % rulerStep)) { 282 if (!(y % rulerStep)) {
281 if (y) { 283 context.save();
282 context.save(); 284 context.translate(0, y);
283 context.translate(0, y); 285 context.rotate(-Math.PI / 2);
284 context.rotate(-Math.PI / 2); 286 context.fillText(y, 2, -rulerWidth / 2);
285 context.fillText(y, 2, -rulerWidth / 2); 287 context.restore();
286 context.restore(); 288 x = -rulerWidth;
287 }
288 x = -rulerWidth * 2 / 3;
289 } 289 }
290 290
291 context.beginPath(); 291 context.beginPath();
292 context.moveTo(x, y); 292 context.moveTo(x, y);
293 context.lineTo(0, y); 293 context.lineTo(0, y);
294 context.stroke(); 294 context.stroke();
295 } 295 }
296 296
297 // Draw grid. 297 // Draw grid.
298 drawGrid(darkLineColor, gridSubStep); 298 drawGrid(darkLineColor, gridSubStep);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 if (this._warningMessage.textContent === message) 536 if (this._warningMessage.textContent === message)
537 return; 537 return;
538 this._warningMessage.classList.toggle("hidden", !message); 538 this._warningMessage.classList.toggle("hidden", !message);
539 this._warningMessage.textContent = message; 539 this._warningMessage.textContent = message;
540 this._invalidateCache(); 540 this._invalidateCache();
541 this.onResize(); 541 this.onResize();
542 }, 542 },
543 543
544 __proto__: WebInspector.VBox.prototype 544 __proto__: WebInspector.VBox.prototype
545 }; 545 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698