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

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

Issue 2626143004: DevTools: move from Common module - Geometry and CSSShadowModel (Closed)
Patch Set: minimize test diff Created 3 years, 11 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) 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 496
497 /** 497 /**
498 * @return {boolean} 498 * @return {boolean}
499 */ 499 */
500 hasFocus() { 500 hasFocus() {
501 return this.element.hasFocus(); 501 return this.element.hasFocus();
502 } 502 }
503 503
504 /** 504 /**
505 * @return {!Size} 505 * @return {!UI.Size}
506 */ 506 */
507 measurePreferredSize() { 507 measurePreferredSize() {
508 var document = this.element.ownerDocument; 508 var document = this.element.ownerDocument;
509 var oldParent = this.element.parentElement; 509 var oldParent = this.element.parentElement;
510 var oldNextSibling = this.element.nextSibling; 510 var oldNextSibling = this.element.nextSibling;
511 511
512 UI.Widget._originalAppendChild.call(document.body, this.element); 512 UI.Widget._originalAppendChild.call(document.body, this.element);
513 this.element.positionAt(0, 0); 513 this.element.positionAt(0, 0);
514 var result = new Size(this.element.offsetWidth, this.element.offsetHeight); 514 var result = new UI.Size(this.element.offsetWidth, this.element.offsetHeight );
515 515
516 this.element.positionAt(undefined, undefined); 516 this.element.positionAt(undefined, undefined);
517 if (oldParent) 517 if (oldParent)
518 UI.Widget._originalInsertBefore.call(oldParent, this.element, oldNextSibli ng); 518 UI.Widget._originalInsertBefore.call(oldParent, this.element, oldNextSibli ng);
519 else 519 else
520 UI.Widget._originalRemoveChild.call(document.body, this.element); 520 UI.Widget._originalRemoveChild.call(document.body, this.element);
521 return result; 521 return result;
522 } 522 }
523 523
524 /** 524 /**
525 * @return {!Constraints} 525 * @return {!UI.Constraints}
526 */ 526 */
527 calculateConstraints() { 527 calculateConstraints() {
528 return new Constraints(); 528 return new UI.Constraints();
529 } 529 }
530 530
531 /** 531 /**
532 * @return {!Constraints} 532 * @return {!UI.Constraints}
533 */ 533 */
534 constraints() { 534 constraints() {
535 if (typeof this._constraints !== 'undefined') 535 if (typeof this._constraints !== 'undefined')
536 return this._constraints; 536 return this._constraints;
537 if (typeof this._cachedConstraints === 'undefined') 537 if (typeof this._cachedConstraints === 'undefined')
538 this._cachedConstraints = this.calculateConstraints(); 538 this._cachedConstraints = this.calculateConstraints();
539 return this._cachedConstraints; 539 return this._cachedConstraints;
540 } 540 }
541 541
542 /** 542 /**
543 * @param {number} width 543 * @param {number} width
544 * @param {number} height 544 * @param {number} height
545 * @param {number} preferredWidth 545 * @param {number} preferredWidth
546 * @param {number} preferredHeight 546 * @param {number} preferredHeight
547 */ 547 */
548 setMinimumAndPreferredSizes(width, height, preferredWidth, preferredHeight) { 548 setMinimumAndPreferredSizes(width, height, preferredWidth, preferredHeight) {
549 this._constraints = new Constraints(new Size(width, height), new Size(prefer redWidth, preferredHeight)); 549 this._constraints = new UI.Constraints(new UI.Size(width, height), new UI.Si ze(preferredWidth, preferredHeight));
550 this.invalidateConstraints(); 550 this.invalidateConstraints();
551 } 551 }
552 552
553 /** 553 /**
554 * @param {number} width 554 * @param {number} width
555 * @param {number} height 555 * @param {number} height
556 */ 556 */
557 setMinimumSize(width, height) { 557 setMinimumSize(width, height) {
558 this._constraints = new Constraints(new Size(width, height)); 558 this._constraints = new UI.Constraints(new UI.Size(width, height));
559 this.invalidateConstraints(); 559 this.invalidateConstraints();
560 } 560 }
561 561
562 /** 562 /**
563 * @return {boolean} 563 * @return {boolean}
564 */ 564 */
565 _hasNonZeroConstraints() { 565 _hasNonZeroConstraints() {
566 var constraints = this.constraints(); 566 var constraints = this.constraints();
567 return !!( 567 return !!(
568 constraints.minimum.width || constraints.minimum.height || constraints.p referred.width || 568 constraints.minimum.width || constraints.minimum.height || constraints.p referred.width ||
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 /** 608 /**
609 * @param {boolean=} isWebComponent 609 * @param {boolean=} isWebComponent
610 */ 610 */
611 constructor(isWebComponent) { 611 constructor(isWebComponent) {
612 super(isWebComponent); 612 super(isWebComponent);
613 this.contentElement.classList.add('vbox'); 613 this.contentElement.classList.add('vbox');
614 } 614 }
615 615
616 /** 616 /**
617 * @override 617 * @override
618 * @return {!Constraints} 618 * @return {!UI.Constraints}
619 */ 619 */
620 calculateConstraints() { 620 calculateConstraints() {
621 var constraints = new Constraints(); 621 var constraints = new UI.Constraints();
622 622
623 /** 623 /**
624 * @this {!UI.Widget} 624 * @this {!UI.Widget}
625 * @suppressReceiverCheck 625 * @suppressReceiverCheck
626 */ 626 */
627 function updateForChild() { 627 function updateForChild() {
628 var child = this.constraints(); 628 var child = this.constraints();
629 constraints = constraints.widthToMax(child); 629 constraints = constraints.widthToMax(child);
630 constraints = constraints.addHeight(child); 630 constraints = constraints.addHeight(child);
631 } 631 }
(...skipping 10 matching lines...) Expand all
642 /** 642 /**
643 * @param {boolean=} isWebComponent 643 * @param {boolean=} isWebComponent
644 */ 644 */
645 constructor(isWebComponent) { 645 constructor(isWebComponent) {
646 super(isWebComponent); 646 super(isWebComponent);
647 this.contentElement.classList.add('hbox'); 647 this.contentElement.classList.add('hbox');
648 } 648 }
649 649
650 /** 650 /**
651 * @override 651 * @override
652 * @return {!Constraints} 652 * @return {!UI.Constraints}
653 */ 653 */
654 calculateConstraints() { 654 calculateConstraints() {
655 var constraints = new Constraints(); 655 var constraints = new UI.Constraints();
656 656
657 /** 657 /**
658 * @this {!UI.Widget} 658 * @this {!UI.Widget}
659 * @suppressReceiverCheck 659 * @suppressReceiverCheck
660 */ 660 */
661 function updateForChild() { 661 function updateForChild() {
662 var child = this.constraints(); 662 var child = this.constraints();
663 constraints = constraints.addWidth(child); 663 constraints = constraints.addWidth(child);
664 constraints = constraints.heightToMax(child); 664 constraints = constraints.heightToMax(child);
665 } 665 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 UI.Widget.__assert( 747 UI.Widget.__assert(
748 !child.__widgetCounter && !child.__widget, 748 !child.__widgetCounter && !child.__widget,
749 'Attempt to remove element containing widget via regular DOM operation'); 749 'Attempt to remove element containing widget via regular DOM operation');
750 return UI.Widget._originalRemoveChild.call(this, child); 750 return UI.Widget._originalRemoveChild.call(this, child);
751 }; 751 };
752 752
753 Element.prototype.removeChildren = function() { 753 Element.prototype.removeChildren = function() {
754 UI.Widget.__assert(!this.__widgetCounter, 'Attempt to remove element containin g widget via regular DOM operation'); 754 UI.Widget.__assert(!this.__widgetCounter, 'Attempt to remove element containin g widget via regular DOM operation');
755 UI.Widget._originalRemoveChildren.call(this); 755 UI.Widget._originalRemoveChildren.call(this);
756 }; 756 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698