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

Side by Side Diff: Source/devtools/front_end/ui/Widget.js

Issue 1113813002: [DevTools] Rename View to Widget. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 7 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 | « Source/devtools/front_end/ui/View.js ('k') | Source/devtools/front_end/ui/emptyView.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 /** 27 /**
28 * @constructor 28 * @constructor
29 * @extends {WebInspector.Object} 29 * @extends {WebInspector.Object}
30 * @param {boolean=} isWebComponent 30 * @param {boolean=} isWebComponent
31 */ 31 */
32 WebInspector.View = function(isWebComponent) 32 WebInspector.Widget = function(isWebComponent)
33 { 33 {
34 this.contentElement = createElementWithClass("div", "view"); 34 this.contentElement = createElementWithClass("div", "widget");
35 if (isWebComponent) { 35 if (isWebComponent) {
36 WebInspector.installComponentRootStyles(this.contentElement); 36 WebInspector.installComponentRootStyles(this.contentElement);
37 this.element = createElementWithClass("div", "vbox flex-auto"); 37 this.element = createElementWithClass("div", "vbox flex-auto");
38 this._shadowRoot = this.element.createShadowRoot(); 38 this._shadowRoot = this.element.createShadowRoot();
39 this._shadowRoot.appendChild(this.contentElement); 39 this._shadowRoot.appendChild(this.contentElement);
40 } else { 40 } else {
41 this.element = this.contentElement; 41 this.element = this.contentElement;
42 } 42 }
43 this._isWebComponent = isWebComponent; 43 this._isWebComponent = isWebComponent;
44 this.element.__view = this; 44 this.element.__widget = this;
45 this._visible = true; 45 this._visible = true;
46 this._isRoot = false; 46 this._isRoot = false;
47 this._isShowing = false; 47 this._isShowing = false;
48 this._children = []; 48 this._children = [];
49 this._hideOnDetach = false; 49 this._hideOnDetach = false;
50 this._notificationDepth = 0; 50 this._notificationDepth = 0;
51 } 51 }
52 52
53 /** 53 /**
54 * @param {string} cssFile 54 * @param {string} cssFile
55 * @return {!Element} 55 * @return {!Element}
56 */ 56 */
57 WebInspector.View.createStyleElement = function(cssFile) 57 WebInspector.Widget.createStyleElement = function(cssFile)
58 { 58 {
59 var content = Runtime.cachedResources[cssFile] || ""; 59 var content = Runtime.cachedResources[cssFile] || "";
60 if (!content) 60 if (!content)
61 console.error(cssFile + " not preloaded. Check module.json"); 61 console.error(cssFile + " not preloaded. Check module.json");
62 var styleElement = createElement("style"); 62 var styleElement = createElement("style");
63 styleElement.type = "text/css"; 63 styleElement.type = "text/css";
64 styleElement.textContent = content; 64 styleElement.textContent = content;
65 return styleElement; 65 return styleElement;
66 } 66 }
67 67
68 WebInspector.View.prototype = { 68 WebInspector.Widget.prototype = {
69 markAsRoot: function() 69 markAsRoot: function()
70 { 70 {
71 WebInspector.installComponentRootStyles(this.element); 71 WebInspector.installComponentRootStyles(this.element);
72 WebInspector.View.__assert(!this.element.parentElement, "Attempt to mark as root attached node"); 72 WebInspector.Widget.__assert(!this.element.parentElement, "Attempt to ma rk as root attached node");
73 this._isRoot = true; 73 this._isRoot = true;
74 }, 74 },
75 75
76 /** 76 /**
77 * @return {?WebInspector.View} 77 * @return {?WebInspector.Widget}
78 */ 78 */
79 parentView: function() 79 parentWidget: function()
80 { 80 {
81 return this._parentView; 81 return this._parentWidget;
82 }, 82 },
83 83
84 /** 84 /**
85 * @return {!Array.<!WebInspector.View>} 85 * @return {!Array.<!WebInspector.Widget>}
86 */ 86 */
87 children: function() 87 children: function()
88 { 88 {
89 return this._children; 89 return this._children;
90 }, 90 },
91 91
92 /** 92 /**
93 * @param {!WebInspector.View} view 93 * @param {!WebInspector.Widget} widget
94 * @protected 94 * @protected
95 */ 95 */
96 childWasDetached: function(view) 96 childWasDetached: function(widget)
97 { 97 {
98 }, 98 },
99 99
100 /** 100 /**
101 * @return {boolean} 101 * @return {boolean}
102 */ 102 */
103 isShowing: function() 103 isShowing: function()
104 { 104 {
105 return this._isShowing; 105 return this._isShowing;
106 }, 106 },
(...skipping 15 matching lines...) Expand all
122 setHideOnDetach: function() 122 setHideOnDetach: function()
123 { 123 {
124 this._hideOnDetach = true; 124 this._hideOnDetach = true;
125 }, 125 },
126 126
127 /** 127 /**
128 * @return {boolean} 128 * @return {boolean}
129 */ 129 */
130 _inNotification: function() 130 _inNotification: function()
131 { 131 {
132 return !!this._notificationDepth || (this._parentView && this._parentVie w._inNotification()); 132 return !!this._notificationDepth || (this._parentWidget && this._parentW idget._inNotification());
133 }, 133 },
134 134
135 _parentIsShowing: function() 135 _parentIsShowing: function()
136 { 136 {
137 if (this._isRoot) 137 if (this._isRoot)
138 return true; 138 return true;
139 return this._parentView && this._parentView.isShowing(); 139 return this._parentWidget && this._parentWidget.isShowing();
140 }, 140 },
141 141
142 /** 142 /**
143 * @param {function(this:WebInspector.View)} method 143 * @param {function(this:WebInspector.Widget)} method
144 */ 144 */
145 _callOnVisibleChildren: function(method) 145 _callOnVisibleChildren: function(method)
146 { 146 {
147 var copy = this._children.slice(); 147 var copy = this._children.slice();
148 for (var i = 0; i < copy.length; ++i) { 148 for (var i = 0; i < copy.length; ++i) {
149 if (copy[i]._parentView === this && copy[i]._visible) 149 if (copy[i]._parentWidget === this && copy[i]._visible)
150 method.call(copy[i]); 150 method.call(copy[i]);
151 } 151 }
152 }, 152 },
153 153
154 _processWillShow: function() 154 _processWillShow: function()
155 { 155 {
156 this._callOnVisibleChildren(this._processWillShow); 156 this._callOnVisibleChildren(this._processWillShow);
157 this._isShowing = true; 157 this._isShowing = true;
158 }, 158 },
159 159
(...skipping 26 matching lines...) Expand all
186 { 186 {
187 if (this._inNotification()) 187 if (this._inNotification())
188 return; 188 return;
189 if (!this.isShowing()) 189 if (!this.isShowing())
190 return; 190 return;
191 this._notify(this.onResize); 191 this._notify(this.onResize);
192 this._callOnVisibleChildren(this._processOnResize); 192 this._callOnVisibleChildren(this._processOnResize);
193 }, 193 },
194 194
195 /** 195 /**
196 * @param {function(this:WebInspector.View)} notification 196 * @param {function(this:WebInspector.Widget)} notification
197 */ 197 */
198 _notify: function(notification) 198 _notify: function(notification)
199 { 199 {
200 ++this._notificationDepth; 200 ++this._notificationDepth;
201 try { 201 try {
202 notification.call(this); 202 notification.call(this);
203 } finally { 203 } finally {
204 --this._notificationDepth; 204 --this._notificationDepth;
205 } 205 }
206 }, 206 },
(...skipping 13 matching lines...) Expand all
220 onLayout: function() 220 onLayout: function()
221 { 221 {
222 }, 222 },
223 223
224 /** 224 /**
225 * @param {?Element} parentElement 225 * @param {?Element} parentElement
226 * @param {?Element=} insertBefore 226 * @param {?Element=} insertBefore
227 */ 227 */
228 show: function(parentElement, insertBefore) 228 show: function(parentElement, insertBefore)
229 { 229 {
230 WebInspector.View.__assert(parentElement, "Attempt to attach view with n o parent element"); 230 WebInspector.Widget.__assert(parentElement, "Attempt to attach widget wi th no parent element");
231 231
232 // Update view hierarchy 232 // Update widget hierarchy.
233 if (this.element.parentElement !== parentElement) { 233 if (this.element.parentElement !== parentElement) {
234 if (this.element.parentElement) 234 if (this.element.parentElement)
235 this.detach(); 235 this.detach();
236 236
237 var currentParent = parentElement; 237 var currentParent = parentElement;
238 while (currentParent && !currentParent.__view) 238 while (currentParent && !currentParent.__widget)
239 currentParent = currentParent.parentElementOrShadowHost(); 239 currentParent = currentParent.parentElementOrShadowHost();
240 240
241 if (currentParent) { 241 if (currentParent) {
242 this._parentView = currentParent.__view; 242 this._parentWidget = currentParent.__widget;
243 this._parentView._children.push(this); 243 this._parentWidget._children.push(this);
244 this._isRoot = false; 244 this._isRoot = false;
245 } else 245 } else
246 WebInspector.View.__assert(this._isRoot, "Attempt to attach view to orphan node"); 246 WebInspector.Widget.__assert(this._isRoot, "Attempt to attach wi dget to orphan node");
247 } else if (this._visible) { 247 } else if (this._visible) {
248 return; 248 return;
249 } 249 }
250 250
251 this._visible = true; 251 this._visible = true;
252 252
253 if (this._parentIsShowing()) 253 if (this._parentIsShowing())
254 this._processWillShow(); 254 this._processWillShow();
255 255
256 this.element.classList.add("visible"); 256 this.element.classList.add("visible");
257 257
258 // Reparent 258 // Reparent
259 if (this.element.parentElement !== parentElement) { 259 if (this.element.parentElement !== parentElement) {
260 WebInspector.View._incrementViewCounter(parentElement, this.element) ; 260 WebInspector.Widget._incrementWidgetCounter(parentElement, this.elem ent);
261 if (insertBefore) 261 if (insertBefore)
262 WebInspector.View._originalInsertBefore.call(parentElement, this .element, insertBefore); 262 WebInspector.Widget._originalInsertBefore.call(parentElement, th is.element, insertBefore);
263 else 263 else
264 WebInspector.View._originalAppendChild.call(parentElement, this. element); 264 WebInspector.Widget._originalAppendChild.call(parentElement, thi s.element);
265 } 265 }
266 266
267 if (this._parentIsShowing()) 267 if (this._parentIsShowing())
268 this._processWasShown(); 268 this._processWasShown();
269 269
270 if (this._parentView && this._hasNonZeroConstraints()) 270 if (this._parentWidget && this._hasNonZeroConstraints())
271 this._parentView.invalidateConstraints(); 271 this._parentWidget.invalidateConstraints();
272 else 272 else
273 this._processOnResize(); 273 this._processOnResize();
274 }, 274 },
275 275
276 /** 276 /**
277 * @param {boolean=} overrideHideOnDetach 277 * @param {boolean=} overrideHideOnDetach
278 */ 278 */
279 detach: function(overrideHideOnDetach) 279 detach: function(overrideHideOnDetach)
280 { 280 {
281 var parentElement = this.element.parentElement; 281 var parentElement = this.element.parentElement;
282 if (!parentElement) 282 if (!parentElement)
283 return; 283 return;
284 284
285 if (this._parentIsShowing()) 285 if (this._parentIsShowing())
286 this._processWillHide(); 286 this._processWillHide();
287 287
288 if (!overrideHideOnDetach && this._shouldHideOnDetach()) { 288 if (!overrideHideOnDetach && this._shouldHideOnDetach()) {
289 this.element.classList.remove("visible"); 289 this.element.classList.remove("visible");
290 this._visible = false; 290 this._visible = false;
291 if (this._parentIsShowing()) 291 if (this._parentIsShowing())
292 this._processWasHidden(); 292 this._processWasHidden();
293 if (this._parentView && this._hasNonZeroConstraints()) 293 if (this._parentWidget && this._hasNonZeroConstraints())
294 this._parentView.invalidateConstraints(); 294 this._parentWidget.invalidateConstraints();
295 return; 295 return;
296 } 296 }
297 297
298 // Force legal removal 298 // Force legal removal
299 WebInspector.View._decrementViewCounter(parentElement, this.element); 299 WebInspector.Widget._decrementWidgetCounter(parentElement, this.element) ;
300 WebInspector.View._originalRemoveChild.call(parentElement, this.element) ; 300 WebInspector.Widget._originalRemoveChild.call(parentElement, this.elemen t);
301 301
302 this._visible = false; 302 this._visible = false;
303 if (this._parentIsShowing()) 303 if (this._parentIsShowing())
304 this._processWasHidden(); 304 this._processWasHidden();
305 305
306 // Update view hierarchy 306 // Update widget hierarchy.
307 if (this._parentView) { 307 if (this._parentWidget) {
308 var childIndex = this._parentView._children.indexOf(this); 308 var childIndex = this._parentWidget._children.indexOf(this);
309 WebInspector.View.__assert(childIndex >= 0, "Attempt to remove non-c hild view"); 309 WebInspector.Widget.__assert(childIndex >= 0, "Attempt to remove non -child widget");
310 this._parentView._children.splice(childIndex, 1); 310 this._parentWidget._children.splice(childIndex, 1);
311 this._parentView.childWasDetached(this); 311 this._parentWidget.childWasDetached(this);
312 var parent = this._parentView; 312 var parent = this._parentWidget;
313 this._parentView = null; 313 this._parentWidget = null;
314 if (this._hasNonZeroConstraints()) 314 if (this._hasNonZeroConstraints())
315 parent.invalidateConstraints(); 315 parent.invalidateConstraints();
316 } else 316 } else
317 WebInspector.View.__assert(this._isRoot, "Removing non-root view fro m DOM"); 317 WebInspector.Widget.__assert(this._isRoot, "Removing non-root widget from DOM");
318 }, 318 },
319 319
320 detachChildViews: function() 320 detachChildWidgets: function()
321 { 321 {
322 var children = this._children.slice(); 322 var children = this._children.slice();
323 for (var i = 0; i < children.length; ++i) 323 for (var i = 0; i < children.length; ++i)
324 children[i].detach(); 324 children[i].detach();
325 }, 325 },
326 326
327 /** 327 /**
328 * @return {!Array.<!Element>} 328 * @return {!Array.<!Element>}
329 */ 329 */
330 elementsToRestoreScrollPositionsFor: function() 330 elementsToRestoreScrollPositionsFor: function()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 return; 369 return;
370 this._notify(this.onLayout); 370 this._notify(this.onLayout);
371 this.doResize(); 371 this.doResize();
372 }, 372 },
373 373
374 /** 374 /**
375 * @param {string} cssFile 375 * @param {string} cssFile
376 */ 376 */
377 registerRequiredCSS: function(cssFile) 377 registerRequiredCSS: function(cssFile)
378 { 378 {
379 (this._isWebComponent ? this._shadowRoot : this.element).appendChild(Web Inspector.View.createStyleElement(cssFile)); 379 (this._isWebComponent ? this._shadowRoot : this.element).appendChild(Web Inspector.Widget.createStyleElement(cssFile));
380 }, 380 },
381 381
382 printViewHierarchy: function() 382 printWidgetHierarchy: function()
383 { 383 {
384 var lines = []; 384 var lines = [];
385 this._collectViewHierarchy("", lines); 385 this._collectWidgetHierarchy("", lines);
386 console.log(lines.join("\n")); 386 console.log(lines.join("\n"));
387 }, 387 },
388 388
389 _collectViewHierarchy: function(prefix, lines) 389 _collectWidgetHierarchy: function(prefix, lines)
390 { 390 {
391 lines.push(prefix + "[" + this.element.className + "]" + (this._children .length ? " {" : "")); 391 lines.push(prefix + "[" + this.element.className + "]" + (this._children .length ? " {" : ""));
392 392
393 for (var i = 0; i < this._children.length; ++i) 393 for (var i = 0; i < this._children.length; ++i)
394 this._children[i]._collectViewHierarchy(prefix + " ", lines); 394 this._children[i]._collectWidgetHierarchy(prefix + " ", lines);
395 395
396 if (this._children.length) 396 if (this._children.length)
397 lines.push(prefix + "}"); 397 lines.push(prefix + "}");
398 }, 398 },
399 399
400 /** 400 /**
401 * @return {!Element} 401 * @return {!Element}
402 */ 402 */
403 defaultFocusedElement: function() 403 defaultFocusedElement: function()
404 { 404 {
(...skipping 25 matching lines...) Expand all
430 var activeElement = this.element.ownerDocument.activeElement; 430 var activeElement = this.element.ownerDocument.activeElement;
431 return activeElement && activeElement.isSelfOrDescendant(this.element); 431 return activeElement && activeElement.isSelfOrDescendant(this.element);
432 }, 432 },
433 433
434 /** 434 /**
435 * @return {!Size} 435 * @return {!Size}
436 */ 436 */
437 measurePreferredSize: function() 437 measurePreferredSize: function()
438 { 438 {
439 var document = this.element.ownerDocument; 439 var document = this.element.ownerDocument;
440 WebInspector.View._originalAppendChild.call(document.body, this.element) ; 440 WebInspector.Widget._originalAppendChild.call(document.body, this.elemen t);
441 this.element.positionAt(0, 0); 441 this.element.positionAt(0, 0);
442 var result = new Size(this.element.offsetWidth, this.element.offsetHeigh t); 442 var result = new Size(this.element.offsetWidth, this.element.offsetHeigh t);
443 this.element.positionAt(undefined, undefined); 443 this.element.positionAt(undefined, undefined);
444 WebInspector.View._originalRemoveChild.call(document.body, this.element) ; 444 WebInspector.Widget._originalRemoveChild.call(document.body, this.elemen t);
445 return result; 445 return result;
446 }, 446 },
447 447
448 /** 448 /**
449 * @return {!Constraints} 449 * @return {!Constraints}
450 */ 450 */
451 calculateConstraints: function() 451 calculateConstraints: function()
452 { 452 {
453 return new Constraints(); 453 return new Constraints();
454 }, 454 },
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 { 494 {
495 var constraints = this.constraints(); 495 var constraints = this.constraints();
496 return !!(constraints.minimum.width || constraints.minimum.height || con straints.preferred.width || constraints.preferred.height); 496 return !!(constraints.minimum.width || constraints.minimum.height || con straints.preferred.width || constraints.preferred.height);
497 }, 497 },
498 498
499 invalidateConstraints: function() 499 invalidateConstraints: function()
500 { 500 {
501 var cached = this._cachedConstraints; 501 var cached = this._cachedConstraints;
502 delete this._cachedConstraints; 502 delete this._cachedConstraints;
503 var actual = this.constraints(); 503 var actual = this.constraints();
504 if (!actual.isEqual(cached) && this._parentView) 504 if (!actual.isEqual(cached) && this._parentWidget)
505 this._parentView.invalidateConstraints(); 505 this._parentWidget.invalidateConstraints();
506 else 506 else
507 this.doLayout(); 507 this.doLayout();
508 }, 508 },
509 509
510 __proto__: WebInspector.Object.prototype 510 __proto__: WebInspector.Object.prototype
511 } 511 }
512 512
513 WebInspector.View._originalAppendChild = Element.prototype.appendChild; 513 WebInspector.Widget._originalAppendChild = Element.prototype.appendChild;
514 WebInspector.View._originalInsertBefore = Element.prototype.insertBefore; 514 WebInspector.Widget._originalInsertBefore = Element.prototype.insertBefore;
515 WebInspector.View._originalRemoveChild = Element.prototype.removeChild; 515 WebInspector.Widget._originalRemoveChild = Element.prototype.removeChild;
516 WebInspector.View._originalRemoveChildren = Element.prototype.removeChildren; 516 WebInspector.Widget._originalRemoveChildren = Element.prototype.removeChildren;
517 517
518 WebInspector.View._incrementViewCounter = function(parentElement, childElement) 518 WebInspector.Widget._incrementWidgetCounter = function(parentElement, childEleme nt)
519 { 519 {
520 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0 ); 520 var count = (childElement.__widgetCounter || 0) + (childElement.__widget ? 1 : 0);
521 if (!count) 521 if (!count)
522 return; 522 return;
523 523
524 while (parentElement) { 524 while (parentElement) {
525 parentElement.__viewCounter = (parentElement.__viewCounter || 0) + count ; 525 parentElement.__widgetCounter = (parentElement.__widgetCounter || 0) + c ount;
526 parentElement = parentElement.parentElementOrShadowHost(); 526 parentElement = parentElement.parentElementOrShadowHost();
527 } 527 }
528 } 528 }
529 529
530 WebInspector.View._decrementViewCounter = function(parentElement, childElement) 530 WebInspector.Widget._decrementWidgetCounter = function(parentElement, childEleme nt)
531 { 531 {
532 var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0 ); 532 var count = (childElement.__widgetCounter || 0) + (childElement.__widget ? 1 : 0);
533 if (!count) 533 if (!count)
534 return; 534 return;
535 535
536 while (parentElement) { 536 while (parentElement) {
537 parentElement.__viewCounter -= count; 537 parentElement.__widgetCounter -= count;
538 parentElement = parentElement.parentElementOrShadowHost(); 538 parentElement = parentElement.parentElementOrShadowHost();
539 } 539 }
540 } 540 }
541 541
542 WebInspector.View.__assert = function(condition, message) 542 WebInspector.Widget.__assert = function(condition, message)
543 { 543 {
544 if (!condition) { 544 if (!condition) {
545 console.trace(); 545 console.trace();
546 throw new Error(message); 546 throw new Error(message);
547 } 547 }
548 } 548 }
549 549
550 /** 550 /**
551 * @constructor 551 * @constructor
552 * @extends {WebInspector.View} 552 * @extends {WebInspector.Widget}
553 * @param {boolean=} isWebComponent 553 * @param {boolean=} isWebComponent
554 */ 554 */
555 WebInspector.VBox = function(isWebComponent) 555 WebInspector.VBox = function(isWebComponent)
556 { 556 {
557 WebInspector.View.call(this, isWebComponent); 557 WebInspector.Widget.call(this, isWebComponent);
558 this.contentElement.classList.add("vbox"); 558 this.contentElement.classList.add("vbox");
559 }; 559 };
560 560
561 WebInspector.VBox.prototype = { 561 WebInspector.VBox.prototype = {
562 /** 562 /**
563 * @override 563 * @override
564 * @return {!Constraints} 564 * @return {!Constraints}
565 */ 565 */
566 calculateConstraints: function() 566 calculateConstraints: function()
567 { 567 {
568 var constraints = new Constraints(); 568 var constraints = new Constraints();
569 569
570 /** 570 /**
571 * @this {!WebInspector.View} 571 * @this {!WebInspector.Widget}
572 * @suppressReceiverCheck 572 * @suppressReceiverCheck
573 */ 573 */
574 function updateForChild() 574 function updateForChild()
575 { 575 {
576 var child = this.constraints(); 576 var child = this.constraints();
577 constraints = constraints.widthToMax(child); 577 constraints = constraints.widthToMax(child);
578 constraints = constraints.addHeight(child); 578 constraints = constraints.addHeight(child);
579 } 579 }
580 580
581 this._callOnVisibleChildren(updateForChild); 581 this._callOnVisibleChildren(updateForChild);
582 return constraints; 582 return constraints;
583 }, 583 },
584 584
585 __proto__: WebInspector.View.prototype 585 __proto__: WebInspector.Widget.prototype
586 }; 586 };
587 587
588 /** 588 /**
589 * @constructor 589 * @constructor
590 * @extends {WebInspector.View} 590 * @extends {WebInspector.Widget}
591 * @param {boolean=} isWebComponent 591 * @param {boolean=} isWebComponent
592 */ 592 */
593 WebInspector.HBox = function(isWebComponent) 593 WebInspector.HBox = function(isWebComponent)
594 { 594 {
595 WebInspector.View.call(this, isWebComponent); 595 WebInspector.Widget.call(this, isWebComponent);
596 this.contentElement.classList.add("hbox"); 596 this.contentElement.classList.add("hbox");
597 }; 597 };
598 598
599 WebInspector.HBox.prototype = { 599 WebInspector.HBox.prototype = {
600 /** 600 /**
601 * @override 601 * @override
602 * @return {!Constraints} 602 * @return {!Constraints}
603 */ 603 */
604 calculateConstraints: function() 604 calculateConstraints: function()
605 { 605 {
606 var constraints = new Constraints(); 606 var constraints = new Constraints();
607 607
608 /** 608 /**
609 * @this {!WebInspector.View} 609 * @this {!WebInspector.Widget}
610 * @suppressReceiverCheck 610 * @suppressReceiverCheck
611 */ 611 */
612 function updateForChild() 612 function updateForChild()
613 { 613 {
614 var child = this.constraints(); 614 var child = this.constraints();
615 constraints = constraints.addWidth(child); 615 constraints = constraints.addWidth(child);
616 constraints = constraints.heightToMax(child); 616 constraints = constraints.heightToMax(child);
617 } 617 }
618 618
619 this._callOnVisibleChildren(updateForChild); 619 this._callOnVisibleChildren(updateForChild);
620 return constraints; 620 return constraints;
621 }, 621 },
622 622
623 __proto__: WebInspector.View.prototype 623 __proto__: WebInspector.Widget.prototype
624 }; 624 };
625 625
626 /** 626 /**
627 * @constructor 627 * @constructor
628 * @extends {WebInspector.VBox} 628 * @extends {WebInspector.VBox}
629 * @param {function()} resizeCallback 629 * @param {function()} resizeCallback
630 */ 630 */
631 WebInspector.VBoxWithResizeCallback = function(resizeCallback) 631 WebInspector.VBoxWithResizeCallback = function(resizeCallback)
632 { 632 {
633 WebInspector.VBox.call(this); 633 WebInspector.VBox.call(this);
(...skipping 10 matching lines...) Expand all
644 } 644 }
645 645
646 /** 646 /**
647 * @override 647 * @override
648 * @param {?Node} child 648 * @param {?Node} child
649 * @return {?Node} 649 * @return {?Node}
650 * @suppress {duplicate} 650 * @suppress {duplicate}
651 */ 651 */
652 Element.prototype.appendChild = function(child) 652 Element.prototype.appendChild = function(child)
653 { 653 {
654 WebInspector.View.__assert(!child.__view || child.parentElement === this, "A ttempt to add view via regular DOM operation."); 654 WebInspector.Widget.__assert(!child.__widget || child.parentElement === this , "Attempt to add widget via regular DOM operation.");
655 return WebInspector.View._originalAppendChild.call(this, child); 655 return WebInspector.Widget._originalAppendChild.call(this, child);
656 } 656 }
657 657
658 /** 658 /**
659 * @override 659 * @override
660 * @param {?Node} child 660 * @param {?Node} child
661 * @param {?Node} anchor 661 * @param {?Node} anchor
662 * @return {!Node} 662 * @return {!Node}
663 * @suppress {duplicate} 663 * @suppress {duplicate}
664 */ 664 */
665 Element.prototype.insertBefore = function(child, anchor) 665 Element.prototype.insertBefore = function(child, anchor)
666 { 666 {
667 WebInspector.View.__assert(!child.__view || child.parentElement === this, "A ttempt to add view via regular DOM operation."); 667 WebInspector.Widget.__assert(!child.__widget || child.parentElement === this , "Attempt to add widget via regular DOM operation.");
668 return WebInspector.View._originalInsertBefore.call(this, child, anchor); 668 return WebInspector.Widget._originalInsertBefore.call(this, child, anchor);
669 } 669 }
670 670
671 /** 671 /**
672 * @override 672 * @override
673 * @param {?Node} child 673 * @param {?Node} child
674 * @return {!Node} 674 * @return {!Node}
675 * @suppress {duplicate} 675 * @suppress {duplicate}
676 */ 676 */
677 Element.prototype.removeChild = function(child) 677 Element.prototype.removeChild = function(child)
678 { 678 {
679 WebInspector.View.__assert(!child.__viewCounter && !child.__view, "Attempt t o remove element containing view via regular DOM operation"); 679 WebInspector.Widget.__assert(!child.__widgetCounter && !child.__widget, "Att empt to remove element containing widget via regular DOM operation");
680 return WebInspector.View._originalRemoveChild.call(this, child); 680 return WebInspector.Widget._originalRemoveChild.call(this, child);
681 } 681 }
682 682
683 Element.prototype.removeChildren = function() 683 Element.prototype.removeChildren = function()
684 { 684 {
685 WebInspector.View.__assert(!this.__viewCounter, "Attempt to remove element c ontaining view via regular DOM operation"); 685 WebInspector.Widget.__assert(!this.__widgetCounter, "Attempt to remove eleme nt containing widget via regular DOM operation");
686 WebInspector.View._originalRemoveChildren.call(this); 686 WebInspector.Widget._originalRemoveChildren.call(this);
687 } 687 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/View.js ('k') | Source/devtools/front_end/ui/emptyView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698