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

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: saved main size 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 var nodeToRemove = node; 191 var nodeToRemove = node;
192 node = node.nextSibling; 192 node = node.nextSibling;
193 nodeToRemove.remove(); 193 nodeToRemove.remove();
194 } 194 }
195 } 195 }
196 196
197 /** 197 /**
198 * @constructor 198 * @constructor
199 * @param {number} width 199 * @param {number} width
200 * @param {number} height 200 * @param {number} height
201 * @param {number=} preferredWidth
202 * @param {number=} preferredHeight
201 */ 203 */
202 function Size(width, height) 204 function Size(width, height, preferredWidth, preferredHeight)
vsevik 2014/03/28 16:13:26 I don't think we should merge them, it's confusing
dgozman 2014/03/28 18:05:02 Created a Constraints object.
203 { 205 {
204 this.width = width; 206 this.width = width;
205 this.height = height; 207 this.height = height;
208 this.preferredWidth = preferredWidth;
209 if (typeof preferredWidth === "undefined")
210 this.preferredWidth = width;
211 this.preferredHeight = preferredHeight;
212 if (typeof preferredHeight === "undefined")
213 this.preferredHeight = height;
206 } 214 }
207 215
208 /** 216 /**
209 * @param {?Size} size 217 * @param {?Size} size
210 * @return {boolean} 218 * @return {boolean}
211 */ 219 */
212 Size.prototype.isEqual = function(size) 220 Size.prototype.isEqual = function(size)
213 { 221 {
214 return !!size && this.width === size.width && this.height === size.height; 222 return !!size && this.width === size.width && this.height === size.height && this.preferredWidth == size.preferredWidth && this.preferredHeight == size.pref erredHeight;
215 }; 223 };
216 224
217 /** 225 /**
226 * @return {!Size}
227 */
228 Size.prototype.widthToMax = function(size)
vsevik 2014/03/28 16:13:26 Size.prototype.constrainWidth = function(minWidth,
dgozman 2014/03/28 18:05:02 But I need a Size with width to be a maximum of tw
vsevik 2014/03/28 18:24:50 size.widthToMax(new Size(w, 0)) would be equivalen
229 {
230 return new Size(Math.max(this.width, size.width), this.height, Math.max(this .preferredWidth, size.preferredWidth), this.preferredHeight);
231 };
232
233 /**
234 * @return {!Size}
235 */
236 Size.prototype.addWidth = function(size)
vsevik 2014/03/28 16:13:26 Size.prototype.addWidth = function(width)
237 {
238 return new Size(this.width + size.width, this.height, this.preferredWidth + size.preferredWidth, this.preferredHeight);
239 };
240
241 /**
242 * @return {!Size}
243 */
244 Size.prototype.heightToMax = function(size)
245 {
246 return new Size(this.width, Math.max(this.height, size.height), this.preferr edWidth, Math.max(this.preferredHeight, size.preferredHeight));
247 };
248
249 /**
250 * @return {!Size}
251 */
252 Size.prototype.addHeight = function(size)
253 {
254 return new Size(this.width, this.height + size.height, this.preferredWidth, this.preferredHeight + size.preferredHeight);
255 };
256
257 /**
218 * @param {?Element=} containerElement 258 * @param {?Element=} containerElement
219 * @return {!Size} 259 * @return {!Size}
220 */ 260 */
221 Element.prototype.measurePreferredSize = function(containerElement) 261 Element.prototype.measurePreferredSize = function(containerElement)
222 { 262 {
223 containerElement = containerElement || document.body; 263 containerElement = containerElement || document.body;
224 containerElement.appendChild(this); 264 containerElement.appendChild(this);
225 this.positionAt(0, 0); 265 this.positionAt(0, 0);
226 var result = new Size(this.offsetWidth, this.offsetHeight); 266 var result = new Size(this.offsetWidth, this.offsetHeight);
227 this.positionAt(undefined, undefined); 267 this.positionAt(undefined, undefined);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 */ 634 */
595 function isEnterKey(event) { 635 function isEnterKey(event) {
596 // Check if in IME. 636 // Check if in IME.
597 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; 637 return event.keyCode !== 229 && event.keyIdentifier === "Enter";
598 } 638 }
599 639
600 function consumeEvent(e) 640 function consumeEvent(e)
601 { 641 {
602 e.consume(); 642 e.consume();
603 } 643 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/SourcesPanel.js » ('j') | Source/devtools/front_end/SourcesView.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698