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

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

Issue 2174863003: DevTools: traverse widget hierarchy to reveal views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 else 544 else
545 this.doLayout(); 545 this.doLayout();
546 }, 546 },
547 547
548 invalidateSize: function() 548 invalidateSize: function()
549 { 549 {
550 if (this._parentWidget) 550 if (this._parentWidget)
551 this._parentWidget.doLayout(); 551 this._parentWidget.doLayout();
552 }, 552 },
553 553
554 /**
555 * @return {boolean}
556 */
557 revealWidget: function()
558 {
559 if (!this._parentWidget)
560 return this._isRoot;
561 if (!this._parentWidget.revealChild(this))
562 return false;
563 return this._parentWidget.revealWidget();
564 },
565
566 /**
567 * @param {!WebInspector.Widget} widget
568 * @return {boolean}
569 * @protected
570 */
571 revealChild: function(widget) { return true; },
572
554 __proto__: WebInspector.Object.prototype 573 __proto__: WebInspector.Object.prototype
555 } 574 }
556 575
557 WebInspector.Widget._originalAppendChild = Element.prototype.appendChild; 576 WebInspector.Widget._originalAppendChild = Element.prototype.appendChild;
558 WebInspector.Widget._originalInsertBefore = Element.prototype.insertBefore; 577 WebInspector.Widget._originalInsertBefore = Element.prototype.insertBefore;
559 WebInspector.Widget._originalRemoveChild = Element.prototype.removeChild; 578 WebInspector.Widget._originalRemoveChild = Element.prototype.removeChild;
560 WebInspector.Widget._originalRemoveChildren = Element.prototype.removeChildren; 579 WebInspector.Widget._originalRemoveChildren = Element.prototype.removeChildren;
561 580
562 WebInspector.Widget._incrementWidgetCounter = function(parentElement, childEleme nt) 581 WebInspector.Widget._incrementWidgetCounter = function(parentElement, childEleme nt)
563 { 582 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 708
690 /** 709 /**
691 * @constructor 710 * @constructor
692 * @extends {WebInspector.VBox} 711 * @extends {WebInspector.VBox}
693 * @param {string} title 712 * @param {string} title
694 * @param {boolean=} isWebComponent 713 * @param {boolean=} isWebComponent
695 */ 714 */
696 WebInspector.View = function(title, isWebComponent) 715 WebInspector.View = function(title, isWebComponent)
697 { 716 {
698 WebInspector.VBox.call(this, isWebComponent); 717 WebInspector.VBox.call(this, isWebComponent);
699 this.element.classList.add("view");
700 this._title = title; 718 this._title = title;
701 /** @type {!Array<!WebInspector.ToolbarItem>} */ 719 /** @type {!Array<!WebInspector.ToolbarItem>} */
702 this._toolbarItems = []; 720 this._toolbarItems = [];
703 } 721 }
704 722
705 WebInspector.View.prototype = { 723 WebInspector.View.prototype = {
706 /** 724 /**
707 * @return {string} 725 * @return {string}
708 */ 726 */
709 title: function() 727 title: function()
710 { 728 {
711 return this._title; 729 return this._title;
712 }, 730 },
713 731
714 /** 732 /**
715 * @param {function()} callback
716 */
717 setRevealCallback: function(callback)
718 {
719 this._revealCallback = callback;
720 if (this._setRevealRequested) {
721 callback();
722 delete this._setRevealRequested;
723 }
724 },
725
726 /**
727 * @param {function(boolean)} callback
728 */
729 setRequestVisibleCallback: function(callback)
730 {
731 this._requestVisibleCallback = callback;
732 if (this._setVisibleRequested !== undefined) {
733 callback(this._setVisibleRequested);
734 delete this._setVisibleRequested;
735 }
736 },
737
738 requestReveal: function()
739 {
740 if (this._revealCallback)
741 this._revealCallback();
742 else
743 this._setRevealRequested = true;
744 },
745
746 /**
747 * @param {boolean} visible
748 */
749 requestSetVisible: function(visible)
750 {
751 if (this._requestVisibleCallback)
752 this._requestVisibleCallback(visible);
753 else
754 this._setVisibleRequested = visible;
755 },
756
757 /**
758 * @param {!WebInspector.ToolbarItem} item 733 * @param {!WebInspector.ToolbarItem} item
759 */ 734 */
760 addToolbarItem: function(item) 735 addToolbarItem: function(item)
761 { 736 {
762 this._toolbarItems.push(item); 737 this._toolbarItems.push(item);
763 }, 738 },
764 739
765 /** 740 /**
766 * @return {!Array<!WebInspector.ToolbarItem>} 741 * @return {!Array<!WebInspector.ToolbarItem>}
767 */ 742 */
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 { 783 {
809 WebInspector.Widget.__assert(!child.__widgetCounter && !child.__widget, "Att empt to remove element containing widget via regular DOM operation"); 784 WebInspector.Widget.__assert(!child.__widgetCounter && !child.__widget, "Att empt to remove element containing widget via regular DOM operation");
810 return WebInspector.Widget._originalRemoveChild.call(this, child); 785 return WebInspector.Widget._originalRemoveChild.call(this, child);
811 } 786 }
812 787
813 Element.prototype.removeChildren = function() 788 Element.prototype.removeChildren = function()
814 { 789 {
815 WebInspector.Widget.__assert(!this.__widgetCounter, "Attempt to remove eleme nt containing widget via regular DOM operation"); 790 WebInspector.Widget.__assert(!this.__widgetCounter, "Attempt to remove eleme nt containing widget via regular DOM operation");
816 WebInspector.Widget._originalRemoveChildren.call(this); 791 WebInspector.Widget._originalRemoveChildren.call(this);
817 } 792 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698