Open Bug 1312250 Opened 8 years ago Updated 2 months ago

Display non default properties before others, with specific styling

Categories

(DevTools :: DOM, defect, P2)

defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: salar2k, Unassigned)

References

(Blocks 1 open bug)

Details

Feature Request:
In DOM tab, in the list, user defined objects should be on top of the list and preferably in bold.
This new behavior is like the way Firebug does it.
Yes, agreed, this would be great to have.

Honza
Priority: -- → P2
Hi,

I think I tracked down properties enumeration to ``devtools/client/dom/content/reducers/grips.js``.
If I understand correctly, these properties are sorted there and then appear in a TreeView (``devtools/client/dom/content/components/dom-tree.js``), where there are displayed as Reps, each Rep type having its own render in ``devtools/client/shared/components/reps`` (I am sure I am taking shortcuts here...)

What I can't really see is where we have the information that the property is a "User defined" object, so that we can sort and also display accordingly?
(In reply to y.gravrand from comment #2)
> What I can't really see is where we have the information that the property
> is a "User defined" object, so that we can sort and also display accordingly?
AFAIK there is no such information.

Firebug had a list of all built-in window props and every object that wasn't in the list was treated as user-defined. Obviously, keeping the list up to date required some maintenance.

Better approach could be to build the list dynamically from an empty window. This should be done by devtools server (backend) and info about user-defined objects send to the client as part of the grip packet.

@Alex, what do you think about this? Would it be a problem to extend the protocol and send also an information about whether a window props is user defined or built-in?

Honza
Flags: needinfo?(poirot.alex)
(In reply to Jan Honza Odvarko [:Honza] from comment #3)
> @Alex, what do you think about this? Would it be a problem to extend the
> protocol and send also an information about whether a window props is user
> defined or built-in?

Do you only need this feature against the global scope of documents? (i.e. the window object)

Can't the grip flag each property to indicate if that's user defined or not?
May be through an option? I don't know what's the best way to check for user defined, but xray wrapper may help as it hides content objects and only exposes DOM interfaces. But chrome expandos may confuse your code as any chrome code may add expandos (new custom property) on them.

Otherwise do you already have an actor specific to the DOM panel where you would put your "get window built-ins names" request? Also note that this would not highlight properties being overloaded by the page.

I think I'm fine with whatever solution you come up with as soon as it is efficient! I'm especially concerned here about the performances of this. (Object.getOwnPropertyNames(window).length on an empty document is 800!)
Flags: needinfo?(poirot.alex)
Product: Firefox → DevTools
Severity: normal → S3

Note that we do that in the ObjectInspector. How we do it is definitely not ideal but is good enough https://searchfox.org/mozilla-central/rev/da49863c3d6f34038d00f5ba701b9a2ad9cbadba/devtools/client/shared/components/object-inspector/utils/node.js#39-43,179-181

let WINDOW_PROPERTIES = {};

if (typeof window === "object") {
  WINDOW_PROPERTIES = Object.getOwnPropertyNames(window);
}
...
function isDefaultWindowProperty(name) {
  return WINDOW_PROPERTIES.includes(name);
}
Summary: Developer Tools DOM: Display Order → Display non default properties before others, with specific styling
You need to log in before you can comment on or make changes to this bug.