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

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

Issue 214663005: [DevTools] Add preferred size to WebInspector.View. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Constraints Created 6 years, 9 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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 /** 208 /**
209 * @param {?Size} size 209 * @param {?Size} size
210 * @return {boolean} 210 * @return {boolean}
211 */ 211 */
212 Size.prototype.isEqual = function(size) 212 Size.prototype.isEqual = function(size)
213 { 213 {
214 return !!size && this.width === size.width && this.height === size.height; 214 return !!size && this.width === size.width && this.height === size.height;
215 }; 215 };
216 216
217 /** 217 /**
218 * @param {!Size} size
219 * @return {!Size}
220 */
221 Size.prototype.widthToMax = function(size)
222 {
223 if (typeof size === "undefined") {
224 console.error(new Error().stack);
225 }
226 return new Size(Math.max(this.width, size.width), this.height);
227 };
228
229 /**
230 * @param {!Size} size
231 * @return {!Size}
232 */
233 Size.prototype.addWidth = function(size)
234 {
235 return new Size(this.width + size.width, this.height);
236 };
237
238 /**
239 * @param {!Size} size
240 * @return {!Size}
241 */
242 Size.prototype.heightToMax = function(size)
243 {
244 return new Size(this.width, Math.max(this.height, size.height));
245 };
246
247 /**
248 * @param {!Size} size
249 * @return {!Size}
250 */
251 Size.prototype.addHeight = function(size)
252 {
253 return new Size(this.width, this.height + size.height);
254 };
255
256 /**
257 * @constructor
258 * @param {!Size} minimum
259 * @param {?Size=} preferred
260 */
261 function Constraints(minimum, preferred)
262 {
263 /**
264 * @type {!Size}
265 */
266 this.minimum = minimum;
267
268 /**
269 * @type {!Size}
270 */
271 this.preferred = preferred || minimum;
272 }
273
274 /**
275 * @param {?Constraints} constraints
276 * @return {boolean}
277 */
278 Constraints.prototype.isEqual = function(constraints)
279 {
280 return !!constraints && this.minimum.isEqual(constraints.minimum) && this.pr eferred.isEqual(constraints.preferred);
281 };
282
283 /**
284 * @param {!Constraints} constraints
285 * @return {!Constraints}
286 */
287 Constraints.prototype.widthToMax = function(constraints)
288 {
289 return new Constraints(this.minimum.widthToMax(constraints.minimum), this.pr eferred.widthToMax(constraints.preferred));
290 };
291
292 /**
293 * @param {!Constraints} constraints
294 * @return {!Constraints}
295 */
296 Constraints.prototype.addWidth = function(constraints)
297 {
298 return new Constraints(this.minimum.addWidth(constraints.minimum), this.pref erred.addWidth(constraints.preferred));
299 };
300
301 /**
302 * @param {!Constraints} constraints
303 * @return {!Constraints}
304 */
305 Constraints.prototype.heightToMax = function(constraints)
306 {
307 return new Constraints(this.minimum.heightToMax(constraints.minimum), this.p referred.heightToMax(constraints.preferred));
308 };
309
310 /**
311 * @param {!Constraints} constraints
312 * @return {!Constraints}
313 */
314 Constraints.prototype.addHeight = function(constraints)
315 {
316 return new Constraints(this.minimum.addHeight(constraints.minimum), this.pre ferred.addHeight(constraints.preferred));
317 };
318
319 /**
218 * @param {?Element=} containerElement 320 * @param {?Element=} containerElement
219 * @return {!Size} 321 * @return {!Size}
220 */ 322 */
221 Element.prototype.measurePreferredSize = function(containerElement) 323 Element.prototype.measurePreferredSize = function(containerElement)
222 { 324 {
223 containerElement = containerElement || document.body; 325 containerElement = containerElement || document.body;
224 containerElement.appendChild(this); 326 containerElement.appendChild(this);
225 this.positionAt(0, 0); 327 this.positionAt(0, 0);
226 var result = new Size(this.offsetWidth, this.offsetHeight); 328 var result = new Size(this.offsetWidth, this.offsetHeight);
227 this.positionAt(undefined, undefined); 329 this.positionAt(undefined, undefined);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 */ 696 */
595 function isEnterKey(event) { 697 function isEnterKey(event) {
596 // Check if in IME. 698 // Check if in IME.
597 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; 699 return event.keyCode !== 229 && event.keyIdentifier === "Enter";
598 } 700 }
599 701
600 function consumeEvent(e) 702 function consumeEvent(e)
601 { 703 {
602 e.consume(); 704 e.consume();
603 } 705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698