OLD | NEW |
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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 if (typeof this._minimumSize !== "undefined") | 520 if (typeof this._minimumSize !== "undefined") |
521 return this._minimumSize; | 521 return this._minimumSize; |
522 if (typeof this._cachedMinimumSize === "undefined") | 522 if (typeof this._cachedMinimumSize === "undefined") |
523 this._cachedMinimumSize = this.calculateMinimumSize(); | 523 this._cachedMinimumSize = this.calculateMinimumSize(); |
524 return this._cachedMinimumSize; | 524 return this._cachedMinimumSize; |
525 }, | 525 }, |
526 | 526 |
527 /** | 527 /** |
528 * @param {number} width | 528 * @param {number} width |
529 * @param {number} height | 529 * @param {number} height |
| 530 * @param {number=} preferredWidth |
| 531 * @param {number=} preferredHeight |
530 */ | 532 */ |
531 setMinimumSize: function(width, height) | 533 setMinimumSize: function(width, height, preferredWidth, preferredHeight) |
532 { | 534 { |
533 this._minimumSize = new Size(width, height); | 535 this._minimumSize = new Size(width, height, preferredWidth, preferredHei
ght); |
534 this.invalidateMinimumSize(); | 536 this.invalidateMinimumSize(); |
535 }, | 537 }, |
536 | 538 |
537 /** | 539 /** |
538 * @return {boolean} | 540 * @return {boolean} |
539 */ | 541 */ |
540 _hasNonZeroMinimumSize: function() | 542 _hasNonZeroMinimumSize: function() |
541 { | 543 { |
542 var size = this.minimumSize(); | 544 var size = this.minimumSize(); |
543 return size.width || size.height; | 545 return !!(size.width || size.height || size.preferredWidth || size.prefe
rredHeight); |
544 }, | 546 }, |
545 | 547 |
546 invalidateMinimumSize: function() | 548 invalidateMinimumSize: function() |
547 { | 549 { |
548 var cached = this._cachedMinimumSize; | 550 var cached = this._cachedMinimumSize; |
549 delete this._cachedMinimumSize; | 551 delete this._cachedMinimumSize; |
550 var actual = this.minimumSize(); | 552 var actual = this.minimumSize(); |
551 if (!actual.isEqual(cached) && this._parentView) | 553 if (!actual.isEqual(cached) && this._parentView) |
552 this._parentView.invalidateMinimumSize(); | 554 this._parentView.invalidateMinimumSize(); |
553 else | 555 else |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 WebInspector.View.call(this); | 605 WebInspector.View.call(this); |
604 this.element.classList.add("vbox"); | 606 this.element.classList.add("vbox"); |
605 }; | 607 }; |
606 | 608 |
607 WebInspector.VBox.prototype = { | 609 WebInspector.VBox.prototype = { |
608 /** | 610 /** |
609 * @return {!Size} | 611 * @return {!Size} |
610 */ | 612 */ |
611 calculateMinimumSize: function() | 613 calculateMinimumSize: function() |
612 { | 614 { |
613 var width = 0; | 615 var size = new Size(0, 0); |
614 var height = 0; | |
615 | 616 |
616 /** | 617 /** |
617 * @this {!WebInspector.View} | 618 * @this {!WebInspector.View} |
618 * @suppressReceiverCheck | 619 * @suppressReceiverCheck |
619 */ | 620 */ |
620 function updateForChild() | 621 function updateForChild() |
621 { | 622 { |
622 var size = this.minimumSize(); | 623 var childSize = this.minimumSize(); |
623 width = Math.max(width, size.width); | 624 size = size.widthToMax(childSize); |
624 height += size.height; | 625 size = size.addHeight(childSize); |
625 } | 626 } |
626 | 627 |
627 this._callOnVisibleChildren(updateForChild); | 628 this._callOnVisibleChildren(updateForChild); |
628 return new Size(width, height); | 629 return size; |
629 }, | 630 }, |
630 | 631 |
631 __proto__: WebInspector.View.prototype | 632 __proto__: WebInspector.View.prototype |
632 }; | 633 }; |
633 | 634 |
634 /** | 635 /** |
635 * @constructor | 636 * @constructor |
636 * @extends {WebInspector.View} | 637 * @extends {WebInspector.View} |
637 */ | 638 */ |
638 WebInspector.HBox = function() | 639 WebInspector.HBox = function() |
639 { | 640 { |
640 WebInspector.View.call(this); | 641 WebInspector.View.call(this); |
641 this.element.classList.add("hbox"); | 642 this.element.classList.add("hbox"); |
642 }; | 643 }; |
643 | 644 |
644 WebInspector.HBox.prototype = { | 645 WebInspector.HBox.prototype = { |
645 /** | 646 /** |
646 * @return {!Size} | 647 * @return {!Size} |
647 */ | 648 */ |
648 calculateMinimumSize: function() | 649 calculateMinimumSize: function() |
649 { | 650 { |
650 var width = 0; | 651 var size = new Size(0, 0); |
651 var height = 0; | |
652 | 652 |
653 /** | 653 /** |
654 * @this {!WebInspector.View} | 654 * @this {!WebInspector.View} |
655 * @suppressReceiverCheck | 655 * @suppressReceiverCheck |
656 */ | 656 */ |
657 function updateForChild() | 657 function updateForChild() |
658 { | 658 { |
659 var size = this.minimumSize(); | 659 var childSize = this.minimumSize(); |
660 width += size.width; | 660 size = size.addWidth(childSize); |
661 height = Math.max(height, size.height); | 661 size = size.heightToMax(childSize); |
662 } | 662 } |
663 | 663 |
664 this._callOnVisibleChildren(updateForChild); | 664 this._callOnVisibleChildren(updateForChild); |
665 return new Size(width, height); | 665 return size; |
666 }, | 666 }, |
667 | 667 |
668 __proto__: WebInspector.View.prototype | 668 __proto__: WebInspector.View.prototype |
669 }; | 669 }; |
670 | 670 |
671 /** | 671 /** |
672 * @constructor | 672 * @constructor |
673 * @extends {WebInspector.VBox} | 673 * @extends {WebInspector.VBox} |
674 * @param {function()} resizeCallback | 674 * @param {function()} resizeCallback |
675 */ | 675 */ |
(...skipping 29 matching lines...) Expand all Loading... |
705 { | 705 { |
706 WebInspector.View._assert(!child.__viewCounter && !child.__view, "Attempt to
remove element containing view via regular DOM operation"); | 706 WebInspector.View._assert(!child.__viewCounter && !child.__view, "Attempt to
remove element containing view via regular DOM operation"); |
707 return WebInspector.View._originalRemoveChild.call(this, child); | 707 return WebInspector.View._originalRemoveChild.call(this, child); |
708 } | 708 } |
709 | 709 |
710 Element.prototype.removeChildren = function() | 710 Element.prototype.removeChildren = function() |
711 { | 711 { |
712 WebInspector.View._assert(!this.__viewCounter, "Attempt to remove element co
ntaining view via regular DOM operation"); | 712 WebInspector.View._assert(!this.__viewCounter, "Attempt to remove element co
ntaining view via regular DOM operation"); |
713 WebInspector.View._originalRemoveChildren.call(this); | 713 WebInspector.View._originalRemoveChildren.call(this); |
714 } | 714 } |
OLD | NEW |