Bug 1515951 - [release 112] Option to not auto expand a node if it has a lot of children (#7510). r=bhackett
authorJason Laster <jlaster@mozilla.com>
Sun, 23 Dec 2018 14:44:35 -0500
changeset 509102 48aa3ee2c926a0ca3900d810ceedcfe88c4b57b4
parent 509101 006f69326ccc4ad8bc70d348550ab4920f249e7b
child 509103 05ce3a72db7854e0bfd42d6d5abb8d460501d2ce
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1515951
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1515951 - [release 112] Option to not auto expand a node if it has a lot of children (#7510). r=bhackett
devtools/client/debugger/new/dist/vendors.js
devtools/client/shared/components/reps/reps.js
--- a/devtools/client/debugger/new/dist/vendors.js
+++ b/devtools/client/debugger/new/dist/vendors.js
@@ -5038,16 +5038,20 @@ class Tree extends Component {
       onFocus: _propTypes2.default.func,
 
       // The depth to which we should automatically expand new items.
       autoExpandDepth: _propTypes2.default.number,
       // Should auto expand all new items or just the new items under the first
       // root item.
       autoExpandAll: _propTypes2.default.bool,
 
+      // Auto expand a node only if number of its children
+      // are less than autoExpandNodeChildrenLimit
+      autoExpandNodeChildrenLimit: _propTypes2.default.number,
+
       // Note: the two properties below are mutually exclusive. Only one of the
       // label properties is necessary.
       // ID of an element whose textual content serves as an accessible label
       // for a tree.
       labelledby: _propTypes2.default.string,
       // Accessibility label for a tree widget.
       label: _propTypes2.default.string,
 
@@ -5129,32 +5133,37 @@ class Tree extends Component {
     if (this.props.focused && prevProps.focused !== this.props.focused) {
       this._scrollNodeIntoView(this.props.focused);
       // Always keep the focus on the tree itself.
       this.treeRef.focus();
     }
   }
 
   _autoExpand() {
-    if (!this.props.autoExpandDepth) {
+    const { autoExpandDepth, autoExpandNodeChildrenLimit } = this.props;
+    if (!autoExpandDepth) {
       return;
     }
 
     // Automatically expand the first autoExpandDepth levels for new items. Do
     // not use the usual DFS infrastructure because we don't want to ignore
     // collapsed nodes.
     const autoExpand = (item, currentDepth) => {
-      if (currentDepth >= this.props.autoExpandDepth || this.state.seen.has(item)) {
+      if (currentDepth >= autoExpandDepth || this.state.seen.has(item)) {
+        return;
+      }
+
+      const children = this.props.getChildren(item);
+      if (autoExpandNodeChildrenLimit && children.length > autoExpandNodeChildrenLimit) {
         return;
       }
 
       this.props.onExpand(item);
       this.state.seen.add(item);
 
-      const children = this.props.getChildren(item);
       const length = children.length;
       for (let i = 0; i < length; i++) {
         autoExpand(children[i], currentDepth + 1);
       }
     };
 
     const roots = this.props.getRoots();
     const length = roots.length;
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -4098,16 +4098,20 @@ class Tree extends Component {
       onFocus: _propTypes2.default.func,
 
       // The depth to which we should automatically expand new items.
       autoExpandDepth: _propTypes2.default.number,
       // Should auto expand all new items or just the new items under the first
       // root item.
       autoExpandAll: _propTypes2.default.bool,
 
+      // Auto expand a node only if number of its children
+      // are less than autoExpandNodeChildrenLimit
+      autoExpandNodeChildrenLimit: _propTypes2.default.number,
+
       // Note: the two properties below are mutually exclusive. Only one of the
       // label properties is necessary.
       // ID of an element whose textual content serves as an accessible label
       // for a tree.
       labelledby: _propTypes2.default.string,
       // Accessibility label for a tree widget.
       label: _propTypes2.default.string,
 
@@ -4189,32 +4193,37 @@ class Tree extends Component {
     if (this.props.focused && prevProps.focused !== this.props.focused) {
       this._scrollNodeIntoView(this.props.focused);
       // Always keep the focus on the tree itself.
       this.treeRef.focus();
     }
   }
 
   _autoExpand() {
-    if (!this.props.autoExpandDepth) {
+    const { autoExpandDepth, autoExpandNodeChildrenLimit } = this.props;
+    if (!autoExpandDepth) {
       return;
     }
 
     // Automatically expand the first autoExpandDepth levels for new items. Do
     // not use the usual DFS infrastructure because we don't want to ignore
     // collapsed nodes.
     const autoExpand = (item, currentDepth) => {
-      if (currentDepth >= this.props.autoExpandDepth || this.state.seen.has(item)) {
+      if (currentDepth >= autoExpandDepth || this.state.seen.has(item)) {
+        return;
+      }
+
+      const children = this.props.getChildren(item);
+      if (autoExpandNodeChildrenLimit && children.length > autoExpandNodeChildrenLimit) {
         return;
       }
 
       this.props.onExpand(item);
       this.state.seen.add(item);
 
-      const children = this.props.getChildren(item);
       const length = children.length;
       for (let i = 0; i < length; i++) {
         autoExpand(children[i], currentDepth + 1);
       }
     };
 
     const roots = this.props.getRoots();
     const length = roots.length;