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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots 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
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
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 * @unrestricted 28 * @unrestricted
29 */ 29 */
30 WebInspector.Widget = class extends WebInspector.Object { 30 UI.Widget = class extends Common.Object {
31 /** 31 /**
32 * @param {boolean=} isWebComponent 32 * @param {boolean=} isWebComponent
33 */ 33 */
34 constructor(isWebComponent) { 34 constructor(isWebComponent) {
35 super(); 35 super();
36 this.contentElement = createElementWithClass('div', 'widget'); 36 this.contentElement = createElementWithClass('div', 'widget');
37 if (isWebComponent) { 37 if (isWebComponent) {
38 this.element = createElementWithClass('div', 'vbox flex-auto'); 38 this.element = createElementWithClass('div', 'vbox flex-auto');
39 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.elemen t); 39 this._shadowRoot = UI.createShadowRootWithCoreStyles(this.element);
40 this._shadowRoot.appendChild(this.contentElement); 40 this._shadowRoot.appendChild(this.contentElement);
41 } else { 41 } else {
42 this.element = this.contentElement; 42 this.element = this.contentElement;
43 } 43 }
44 this._isWebComponent = isWebComponent; 44 this._isWebComponent = isWebComponent;
45 this.element.__widget = this; 45 this.element.__widget = this;
46 this._visible = false; 46 this._visible = false;
47 this._isRoot = false; 47 this._isRoot = false;
48 this._isShowing = false; 48 this._isShowing = false;
49 this._children = []; 49 this._children = [];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return; 95 return;
96 96
97 var widget = node.__widget; 97 var widget = node.__widget;
98 while (widget._parentWidget) { 98 while (widget._parentWidget) {
99 widget._parentWidget._defaultFocusedChild = widget; 99 widget._parentWidget._defaultFocusedChild = widget;
100 widget = widget._parentWidget; 100 widget = widget._parentWidget;
101 } 101 }
102 } 102 }
103 103
104 markAsRoot() { 104 markAsRoot() {
105 WebInspector.Widget.__assert(!this.element.parentElement, 'Attempt to mark a s root attached node'); 105 UI.Widget.__assert(!this.element.parentElement, 'Attempt to mark as root att ached node');
106 this._isRoot = true; 106 this._isRoot = true;
107 } 107 }
108 108
109 /** 109 /**
110 * @return {?WebInspector.Widget} 110 * @return {?UI.Widget}
111 */ 111 */
112 parentWidget() { 112 parentWidget() {
113 return this._parentWidget; 113 return this._parentWidget;
114 } 114 }
115 115
116 /** 116 /**
117 * @return {!Array.<!WebInspector.Widget>} 117 * @return {!Array.<!UI.Widget>}
118 */ 118 */
119 children() { 119 children() {
120 return this._children; 120 return this._children;
121 } 121 }
122 122
123 /** 123 /**
124 * @param {!WebInspector.Widget} widget 124 * @param {!UI.Widget} widget
125 * @protected 125 * @protected
126 */ 126 */
127 childWasDetached(widget) { 127 childWasDetached(widget) {
128 } 128 }
129 129
130 /** 130 /**
131 * @return {boolean} 131 * @return {boolean}
132 */ 132 */
133 isShowing() { 133 isShowing() {
134 return this._isShowing; 134 return this._isShowing;
(...skipping 25 matching lines...) Expand all
160 return !!this._notificationDepth || (this._parentWidget && this._parentWidge t._inNotification()); 160 return !!this._notificationDepth || (this._parentWidget && this._parentWidge t._inNotification());
161 } 161 }
162 162
163 _parentIsShowing() { 163 _parentIsShowing() {
164 if (this._isRoot) 164 if (this._isRoot)
165 return true; 165 return true;
166 return !!this._parentWidget && this._parentWidget.isShowing(); 166 return !!this._parentWidget && this._parentWidget.isShowing();
167 } 167 }
168 168
169 /** 169 /**
170 * @param {function(this:WebInspector.Widget)} method 170 * @param {function(this:UI.Widget)} method
171 */ 171 */
172 _callOnVisibleChildren(method) { 172 _callOnVisibleChildren(method) {
173 var copy = this._children.slice(); 173 var copy = this._children.slice();
174 for (var i = 0; i < copy.length; ++i) { 174 for (var i = 0; i < copy.length; ++i) {
175 if (copy[i]._parentWidget === this && copy[i]._visible) 175 if (copy[i]._parentWidget === this && copy[i]._visible)
176 method.call(copy[i]); 176 method.call(copy[i]);
177 } 177 }
178 } 178 }
179 179
180 _processWillShow() { 180 _processWillShow() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 _processOnResize() { 214 _processOnResize() {
215 if (this._inNotification()) 215 if (this._inNotification())
216 return; 216 return;
217 if (!this.isShowing()) 217 if (!this.isShowing())
218 return; 218 return;
219 this._notify(this.onResize); 219 this._notify(this.onResize);
220 this._callOnVisibleChildren(this._processOnResize); 220 this._callOnVisibleChildren(this._processOnResize);
221 } 221 }
222 222
223 /** 223 /**
224 * @param {function(this:WebInspector.Widget)} notification 224 * @param {function(this:UI.Widget)} notification
225 */ 225 */
226 _notify(notification) { 226 _notify(notification) {
227 ++this._notificationDepth; 227 ++this._notificationDepth;
228 try { 228 try {
229 notification.call(this); 229 notification.call(this);
230 } finally { 230 } finally {
231 --this._notificationDepth; 231 --this._notificationDepth;
232 } 232 }
233 } 233 }
234 234
(...skipping 10 matching lines...) Expand all
245 } 245 }
246 246
247 onLayout() { 247 onLayout() {
248 } 248 }
249 249
250 /** 250 /**
251 * @param {!Element} parentElement 251 * @param {!Element} parentElement
252 * @param {?Element=} insertBefore 252 * @param {?Element=} insertBefore
253 */ 253 */
254 show(parentElement, insertBefore) { 254 show(parentElement, insertBefore) {
255 WebInspector.Widget.__assert(parentElement, 'Attempt to attach widget with n o parent element'); 255 UI.Widget.__assert(parentElement, 'Attempt to attach widget with no parent e lement');
256 256
257 if (!this._isRoot) { 257 if (!this._isRoot) {
258 // Update widget hierarchy. 258 // Update widget hierarchy.
259 var currentParent = parentElement; 259 var currentParent = parentElement;
260 while (currentParent && !currentParent.__widget) 260 while (currentParent && !currentParent.__widget)
261 currentParent = currentParent.parentElementOrShadowHost(); 261 currentParent = currentParent.parentElementOrShadowHost();
262 WebInspector.Widget.__assert(currentParent, 'Attempt to attach widget to o rphan node'); 262 UI.Widget.__assert(currentParent, 'Attempt to attach widget to orphan node ');
263 this.attach(currentParent.__widget); 263 this.attach(currentParent.__widget);
264 } 264 }
265 265
266 this.showWidget(parentElement, insertBefore); 266 this.showWidget(parentElement, insertBefore);
267 } 267 }
268 268
269 /** 269 /**
270 * @param {!WebInspector.Widget} parentWidget 270 * @param {!UI.Widget} parentWidget
271 */ 271 */
272 attach(parentWidget) { 272 attach(parentWidget) {
273 if (parentWidget === this._parentWidget) 273 if (parentWidget === this._parentWidget)
274 return; 274 return;
275 if (this._parentWidget) 275 if (this._parentWidget)
276 this.detach(); 276 this.detach();
277 this._parentWidget = parentWidget; 277 this._parentWidget = parentWidget;
278 this._parentWidget._children.push(this); 278 this._parentWidget._children.push(this);
279 this._isRoot = false; 279 this._isRoot = false;
280 } 280 }
281 281
282 /** 282 /**
283 * @param {!Element} parentElement 283 * @param {!Element} parentElement
284 * @param {?Element=} insertBefore 284 * @param {?Element=} insertBefore
285 */ 285 */
286 showWidget(parentElement, insertBefore) { 286 showWidget(parentElement, insertBefore) {
287 var currentParent = parentElement; 287 var currentParent = parentElement;
288 while (currentParent && !currentParent.__widget) 288 while (currentParent && !currentParent.__widget)
289 currentParent = currentParent.parentElementOrShadowHost(); 289 currentParent = currentParent.parentElementOrShadowHost();
290 290
291 if (this._isRoot) 291 if (this._isRoot)
292 WebInspector.Widget.__assert(!currentParent, 'Attempt to show root widget under another widget'); 292 UI.Widget.__assert(!currentParent, 'Attempt to show root widget under anot her widget');
293 else 293 else
294 WebInspector.Widget.__assert( 294 UI.Widget.__assert(
295 currentParent && currentParent.__widget === this._parentWidget, 295 currentParent && currentParent.__widget === this._parentWidget,
296 'Attempt to show under node belonging to alien widget'); 296 'Attempt to show under node belonging to alien widget');
297 297
298 var wasVisible = this._visible; 298 var wasVisible = this._visible;
299 if (wasVisible && this.element.parentElement === parentElement) 299 if (wasVisible && this.element.parentElement === parentElement)
300 return; 300 return;
301 301
302 this._visible = true; 302 this._visible = true;
303 303
304 if (!wasVisible && this._parentIsShowing()) 304 if (!wasVisible && this._parentIsShowing())
305 this._processWillShow(); 305 this._processWillShow();
306 306
307 this.element.classList.remove('hidden'); 307 this.element.classList.remove('hidden');
308 308
309 // Reparent 309 // Reparent
310 if (this.element.parentElement !== parentElement) { 310 if (this.element.parentElement !== parentElement) {
311 WebInspector.Widget._incrementWidgetCounter(parentElement, this.element); 311 UI.Widget._incrementWidgetCounter(parentElement, this.element);
312 if (insertBefore) 312 if (insertBefore)
313 WebInspector.Widget._originalInsertBefore.call(parentElement, this.eleme nt, insertBefore); 313 UI.Widget._originalInsertBefore.call(parentElement, this.element, insert Before);
314 else 314 else
315 WebInspector.Widget._originalAppendChild.call(parentElement, this.elemen t); 315 UI.Widget._originalAppendChild.call(parentElement, this.element);
316 } 316 }
317 317
318 if (!wasVisible && this._parentIsShowing()) 318 if (!wasVisible && this._parentIsShowing())
319 this._processWasShown(); 319 this._processWasShown();
320 320
321 if (this._parentWidget && this._hasNonZeroConstraints()) 321 if (this._parentWidget && this._hasNonZeroConstraints())
322 this._parentWidget.invalidateConstraints(); 322 this._parentWidget.invalidateConstraints();
323 else 323 else
324 this._processOnResize(); 324 this._processOnResize();
325 } 325 }
(...skipping 13 matching lines...) Expand all
339 this._visible = false; 339 this._visible = false;
340 var parentElement = this.element.parentElement; 340 var parentElement = this.element.parentElement;
341 341
342 if (this._parentIsShowing()) 342 if (this._parentIsShowing())
343 this._processWillHide(); 343 this._processWillHide();
344 344
345 if (!overrideHideOnDetach && this.shouldHideOnDetach()) { 345 if (!overrideHideOnDetach && this.shouldHideOnDetach()) {
346 this.element.classList.add('hidden'); 346 this.element.classList.add('hidden');
347 } else { 347 } else {
348 // Force legal removal 348 // Force legal removal
349 WebInspector.Widget._decrementWidgetCounter(parentElement, this.element); 349 UI.Widget._decrementWidgetCounter(parentElement, this.element);
350 WebInspector.Widget._originalRemoveChild.call(parentElement, this.element) ; 350 UI.Widget._originalRemoveChild.call(parentElement, this.element);
351 } 351 }
352 352
353 if (this._parentIsShowing()) 353 if (this._parentIsShowing())
354 this._processWasHidden(); 354 this._processWasHidden();
355 if (this._parentWidget && this._hasNonZeroConstraints()) 355 if (this._parentWidget && this._hasNonZeroConstraints())
356 this._parentWidget.invalidateConstraints(); 356 this._parentWidget.invalidateConstraints();
357 } 357 }
358 358
359 detach() { 359 detach() {
360 if (!this._parentWidget && !this._isRoot) 360 if (!this._parentWidget && !this._isRoot)
361 return; 361 return;
362 362
363 if (this._visible) 363 if (this._visible)
364 this._hideWidget(true); 364 this._hideWidget(true);
365 365
366 // Update widget hierarchy. 366 // Update widget hierarchy.
367 if (this._parentWidget) { 367 if (this._parentWidget) {
368 var childIndex = this._parentWidget._children.indexOf(this); 368 var childIndex = this._parentWidget._children.indexOf(this);
369 WebInspector.Widget.__assert(childIndex >= 0, 'Attempt to remove non-child widget'); 369 UI.Widget.__assert(childIndex >= 0, 'Attempt to remove non-child widget');
370 this._parentWidget._children.splice(childIndex, 1); 370 this._parentWidget._children.splice(childIndex, 1);
371 if (this._parentWidget._defaultFocusedChild === this) 371 if (this._parentWidget._defaultFocusedChild === this)
372 this._parentWidget._defaultFocusedChild = null; 372 this._parentWidget._defaultFocusedChild = null;
373 this._parentWidget.childWasDetached(this); 373 this._parentWidget.childWasDetached(this);
374 var parent = this._parentWidget; 374 var parent = this._parentWidget;
375 this._parentWidget = null; 375 this._parentWidget = null;
376 this._processWasDetachedFromHierarchy(); 376 this._processWasDetachedFromHierarchy();
377 } else { 377 } else {
378 WebInspector.Widget.__assert(this._isRoot, 'Removing non-root widget from DOM'); 378 UI.Widget.__assert(this._isRoot, 'Removing non-root widget from DOM');
379 } 379 }
380 } 380 }
381 381
382 detachChildWidgets() { 382 detachChildWidgets() {
383 var children = this._children.slice(); 383 var children = this._children.slice();
384 for (var i = 0; i < children.length; ++i) 384 for (var i = 0; i < children.length; ++i)
385 children[i].detach(); 385 children[i].detach();
386 } 386 }
387 387
388 /** 388 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if (!this.isShowing()) 424 if (!this.isShowing())
425 return; 425 return;
426 this._notify(this.onLayout); 426 this._notify(this.onLayout);
427 this.doResize(); 427 this.doResize();
428 } 428 }
429 429
430 /** 430 /**
431 * @param {string} cssFile 431 * @param {string} cssFile
432 */ 432 */
433 registerRequiredCSS(cssFile) { 433 registerRequiredCSS(cssFile) {
434 WebInspector.appendStyle(this._isWebComponent ? this._shadowRoot : this.elem ent, cssFile); 434 UI.appendStyle(this._isWebComponent ? this._shadowRoot : this.element, cssFi le);
435 } 435 }
436 436
437 printWidgetHierarchy() { 437 printWidgetHierarchy() {
438 var lines = []; 438 var lines = [];
439 this._collectWidgetHierarchy('', lines); 439 this._collectWidgetHierarchy('', lines);
440 console.log(lines.join('\n')); 440 console.log(lines.join('\n'));
441 } 441 }
442 442
443 _collectWidgetHierarchy(prefix, lines) { 443 _collectWidgetHierarchy(prefix, lines) {
444 lines.push(prefix + '[' + this.element.className + ']' + (this._children.len gth ? ' {' : '')); 444 lines.push(prefix + '[' + this.element.className + ']' + (this._children.len gth ? ' {' : ''));
445 445
446 for (var i = 0; i < this._children.length; ++i) 446 for (var i = 0; i < this._children.length; ++i)
447 this._children[i]._collectWidgetHierarchy(prefix + ' ', lines); 447 this._children[i]._collectWidgetHierarchy(prefix + ' ', lines);
448 448
449 if (this._children.length) 449 if (this._children.length)
450 lines.push(prefix + '}'); 450 lines.push(prefix + '}');
451 } 451 }
452 452
453 /** 453 /**
454 * @param {?Element} element 454 * @param {?Element} element
455 */ 455 */
456 setDefaultFocusedElement(element) { 456 setDefaultFocusedElement(element) {
457 this._defaultFocusedElement = element; 457 this._defaultFocusedElement = element;
458 } 458 }
459 459
460 /** 460 /**
461 * @param {!WebInspector.Widget} child 461 * @param {!UI.Widget} child
462 */ 462 */
463 setDefaultFocusedChild(child) { 463 setDefaultFocusedChild(child) {
464 WebInspector.Widget.__assert(child._parentWidget === this, 'Attempt to set n on-child widget as default focused.'); 464 UI.Widget.__assert(child._parentWidget === this, 'Attempt to set non-child w idget as default focused.');
465 this._defaultFocusedChild = child; 465 this._defaultFocusedChild = child;
466 } 466 }
467 467
468 focus() { 468 focus() {
469 if (!this.isShowing()) 469 if (!this.isShowing())
470 return; 470 return;
471 471
472 var element = this._defaultFocusedElement; 472 var element = this._defaultFocusedElement;
473 if (element) { 473 if (element) {
474 if (!element.hasFocus()) 474 if (!element.hasFocus())
(...skipping 21 matching lines...) Expand all
496 } 496 }
497 497
498 /** 498 /**
499 * @return {!Size} 499 * @return {!Size}
500 */ 500 */
501 measurePreferredSize() { 501 measurePreferredSize() {
502 var document = this.element.ownerDocument; 502 var document = this.element.ownerDocument;
503 var oldParent = this.element.parentElement; 503 var oldParent = this.element.parentElement;
504 var oldNextSibling = this.element.nextSibling; 504 var oldNextSibling = this.element.nextSibling;
505 505
506 WebInspector.Widget._originalAppendChild.call(document.body, this.element); 506 UI.Widget._originalAppendChild.call(document.body, this.element);
507 this.element.positionAt(0, 0); 507 this.element.positionAt(0, 0);
508 var result = new Size(this.element.offsetWidth, this.element.offsetHeight); 508 var result = new Size(this.element.offsetWidth, this.element.offsetHeight);
509 509
510 this.element.positionAt(undefined, undefined); 510 this.element.positionAt(undefined, undefined);
511 if (oldParent) 511 if (oldParent)
512 WebInspector.Widget._originalInsertBefore.call(oldParent, this.element, ol dNextSibling); 512 UI.Widget._originalInsertBefore.call(oldParent, this.element, oldNextSibli ng);
513 else 513 else
514 WebInspector.Widget._originalRemoveChild.call(document.body, this.element) ; 514 UI.Widget._originalRemoveChild.call(document.body, this.element);
515 return result; 515 return result;
516 } 516 }
517 517
518 /** 518 /**
519 * @return {!Constraints} 519 * @return {!Constraints}
520 */ 520 */
521 calculateConstraints() { 521 calculateConstraints() {
522 return new Constraints(); 522 return new Constraints();
523 } 523 }
524 524
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 else 587 else
588 this.doLayout(); 588 this.doLayout();
589 } 589 }
590 590
591 invalidateSize() { 591 invalidateSize() {
592 if (this._parentWidget) 592 if (this._parentWidget)
593 this._parentWidget.doLayout(); 593 this._parentWidget.doLayout();
594 } 594 }
595 }; 595 };
596 596
597 WebInspector.Widget._originalAppendChild = Element.prototype.appendChild; 597 UI.Widget._originalAppendChild = Element.prototype.appendChild;
598 WebInspector.Widget._originalInsertBefore = Element.prototype.insertBefore; 598 UI.Widget._originalInsertBefore = Element.prototype.insertBefore;
599 WebInspector.Widget._originalRemoveChild = Element.prototype.removeChild; 599 UI.Widget._originalRemoveChild = Element.prototype.removeChild;
600 WebInspector.Widget._originalRemoveChildren = Element.prototype.removeChildren; 600 UI.Widget._originalRemoveChildren = Element.prototype.removeChildren;
601 601
602 602
603 /** 603 /**
604 * @unrestricted 604 * @unrestricted
605 */ 605 */
606 WebInspector.VBox = class extends WebInspector.Widget { 606 UI.VBox = class extends UI.Widget {
607 /** 607 /**
608 * @param {boolean=} isWebComponent 608 * @param {boolean=} isWebComponent
609 */ 609 */
610 constructor(isWebComponent) { 610 constructor(isWebComponent) {
611 super(isWebComponent); 611 super(isWebComponent);
612 this.contentElement.classList.add('vbox'); 612 this.contentElement.classList.add('vbox');
613 } 613 }
614 614
615 /** 615 /**
616 * @override 616 * @override
617 * @return {!Constraints} 617 * @return {!Constraints}
618 */ 618 */
619 calculateConstraints() { 619 calculateConstraints() {
620 var constraints = new Constraints(); 620 var constraints = new Constraints();
621 621
622 /** 622 /**
623 * @this {!WebInspector.Widget} 623 * @this {!UI.Widget}
624 * @suppressReceiverCheck 624 * @suppressReceiverCheck
625 */ 625 */
626 function updateForChild() { 626 function updateForChild() {
627 var child = this.constraints(); 627 var child = this.constraints();
628 constraints = constraints.widthToMax(child); 628 constraints = constraints.widthToMax(child);
629 constraints = constraints.addHeight(child); 629 constraints = constraints.addHeight(child);
630 } 630 }
631 631
632 this._callOnVisibleChildren(updateForChild); 632 this._callOnVisibleChildren(updateForChild);
633 return constraints; 633 return constraints;
634 } 634 }
635 }; 635 };
636 636
637 /** 637 /**
638 * @unrestricted 638 * @unrestricted
639 */ 639 */
640 WebInspector.HBox = class extends WebInspector.Widget { 640 UI.HBox = class extends UI.Widget {
641 /** 641 /**
642 * @param {boolean=} isWebComponent 642 * @param {boolean=} isWebComponent
643 */ 643 */
644 constructor(isWebComponent) { 644 constructor(isWebComponent) {
645 super(isWebComponent); 645 super(isWebComponent);
646 this.contentElement.classList.add('hbox'); 646 this.contentElement.classList.add('hbox');
647 } 647 }
648 648
649 /** 649 /**
650 * @override 650 * @override
651 * @return {!Constraints} 651 * @return {!Constraints}
652 */ 652 */
653 calculateConstraints() { 653 calculateConstraints() {
654 var constraints = new Constraints(); 654 var constraints = new Constraints();
655 655
656 /** 656 /**
657 * @this {!WebInspector.Widget} 657 * @this {!UI.Widget}
658 * @suppressReceiverCheck 658 * @suppressReceiverCheck
659 */ 659 */
660 function updateForChild() { 660 function updateForChild() {
661 var child = this.constraints(); 661 var child = this.constraints();
662 constraints = constraints.addWidth(child); 662 constraints = constraints.addWidth(child);
663 constraints = constraints.heightToMax(child); 663 constraints = constraints.heightToMax(child);
664 } 664 }
665 665
666 this._callOnVisibleChildren(updateForChild); 666 this._callOnVisibleChildren(updateForChild);
667 return constraints; 667 return constraints;
668 } 668 }
669 }; 669 };
670 670
671 /** 671 /**
672 * @unrestricted 672 * @unrestricted
673 */ 673 */
674 WebInspector.VBoxWithResizeCallback = class extends WebInspector.VBox { 674 UI.VBoxWithResizeCallback = class extends UI.VBox {
675 /** 675 /**
676 * @param {function()} resizeCallback 676 * @param {function()} resizeCallback
677 */ 677 */
678 constructor(resizeCallback) { 678 constructor(resizeCallback) {
679 super(); 679 super();
680 this._resizeCallback = resizeCallback; 680 this._resizeCallback = resizeCallback;
681 } 681 }
682 682
683 /** 683 /**
684 * @override 684 * @override
685 */ 685 */
686 onResize() { 686 onResize() {
687 this._resizeCallback(); 687 this._resizeCallback();
688 } 688 }
689 }; 689 };
690 690
691 /** 691 /**
692 * @unrestricted 692 * @unrestricted
693 */ 693 */
694 WebInspector.WidgetFocusRestorer = class { 694 UI.WidgetFocusRestorer = class {
695 /** 695 /**
696 * @param {!WebInspector.Widget} widget 696 * @param {!UI.Widget} widget
697 */ 697 */
698 constructor(widget) { 698 constructor(widget) {
699 this._widget = widget; 699 this._widget = widget;
700 this._previous = widget.element.ownerDocument.deepActiveElement(); 700 this._previous = widget.element.ownerDocument.deepActiveElement();
701 widget.focus(); 701 widget.focus();
702 } 702 }
703 703
704 restore() { 704 restore() {
705 if (!this._widget) 705 if (!this._widget)
706 return; 706 return;
707 if (this._widget.hasFocus() && this._previous) 707 if (this._widget.hasFocus() && this._previous)
708 this._previous.focus(); 708 this._previous.focus();
709 this._previous = null; 709 this._previous = null;
710 this._widget = null; 710 this._widget = null;
711 } 711 }
712 }; 712 };
713 713
714 /** 714 /**
715 * @override 715 * @override
716 * @param {?Node} child 716 * @param {?Node} child
717 * @return {?Node} 717 * @return {?Node}
718 * @suppress {duplicate} 718 * @suppress {duplicate}
719 */ 719 */
720 Element.prototype.appendChild = function(child) { 720 Element.prototype.appendChild = function(child) {
721 WebInspector.Widget.__assert( 721 UI.Widget.__assert(
722 !child.__widget || child.parentElement === this, 'Attempt to add widget vi a regular DOM operation.'); 722 !child.__widget || child.parentElement === this, 'Attempt to add widget vi a regular DOM operation.');
723 return WebInspector.Widget._originalAppendChild.call(this, child); 723 return UI.Widget._originalAppendChild.call(this, child);
724 }; 724 };
725 725
726 /** 726 /**
727 * @override 727 * @override
728 * @param {?Node} child 728 * @param {?Node} child
729 * @param {?Node} anchor 729 * @param {?Node} anchor
730 * @return {!Node} 730 * @return {!Node}
731 * @suppress {duplicate} 731 * @suppress {duplicate}
732 */ 732 */
733 Element.prototype.insertBefore = function(child, anchor) { 733 Element.prototype.insertBefore = function(child, anchor) {
734 WebInspector.Widget.__assert( 734 UI.Widget.__assert(
735 !child.__widget || child.parentElement === this, 'Attempt to add widget vi a regular DOM operation.'); 735 !child.__widget || child.parentElement === this, 'Attempt to add widget vi a regular DOM operation.');
736 return WebInspector.Widget._originalInsertBefore.call(this, child, anchor); 736 return UI.Widget._originalInsertBefore.call(this, child, anchor);
737 }; 737 };
738 738
739 /** 739 /**
740 * @override 740 * @override
741 * @param {?Node} child 741 * @param {?Node} child
742 * @return {!Node} 742 * @return {!Node}
743 * @suppress {duplicate} 743 * @suppress {duplicate}
744 */ 744 */
745 Element.prototype.removeChild = function(child) { 745 Element.prototype.removeChild = function(child) {
746 WebInspector.Widget.__assert( 746 UI.Widget.__assert(
747 !child.__widgetCounter && !child.__widget, 747 !child.__widgetCounter && !child.__widget,
748 'Attempt to remove element containing widget via regular DOM operation'); 748 'Attempt to remove element containing widget via regular DOM operation');
749 return WebInspector.Widget._originalRemoveChild.call(this, child); 749 return UI.Widget._originalRemoveChild.call(this, child);
750 }; 750 };
751 751
752 Element.prototype.removeChildren = function() { 752 Element.prototype.removeChildren = function() {
753 WebInspector.Widget.__assert( 753 UI.Widget.__assert(
754 !this.__widgetCounter, 'Attempt to remove element containing widget via re gular DOM operation'); 754 !this.__widgetCounter, 'Attempt to remove element containing widget via re gular DOM operation');
755 WebInspector.Widget._originalRemoveChildren.call(this); 755 UI.Widget._originalRemoveChildren.call(this);
756 }; 756 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698