REOPENED Bug 239129
Web Inspector: Clean up `WI.DOMNode` to no longer require the shared `WI.DOMManager` be passed during construction
https://bugs.webkit.org/show_bug.cgi?id=239129
Summary Web Inspector: Clean up `WI.DOMNode` to no longer require the shared `WI.DOMM...
Patrick Angle
Reported 2022-04-12 09:25:33 PDT
Followup from review on bug 189687.
Attachments
Patch v1.0 (8.08 KB, patch)
2022-04-12 09:58 PDT, Patrick Angle
no flags
Patch v1.1 (9.43 KB, patch)
2022-04-12 13:46 PDT, Patrick Angle
no flags
Patch v1.2 - Review nit (9.48 KB, patch)
2022-04-12 14:00 PDT, Patrick Angle
no flags
Patch v1.2 - Correct typos in for loops (9.48 KB, patch)
2022-04-12 15:38 PDT, Patrick Angle
no flags
[fast-cq] Patch v1.3 - Add reviewer to changelog (9.44 KB, patch)
2022-04-13 11:31 PDT, Patrick Angle
no flags
Radar WebKit Bug Importer
Comment 1 2022-04-12 09:25:46 PDT
Patrick Angle
Comment 2 2022-04-12 09:58:18 PDT
Created attachment 457339 [details] Patch v1.0
Devin Rousso
Comment 3 2022-04-12 12:35:59 PDT
Comment on attachment 457339 [details] Patch v1.0 View in context: https://bugs.webkit.org/attachment.cgi?id=457339&action=review I actually had something similar I was working on last night :P > Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js:191 > + setNodeForId(nodeId, node) NIT: It's probably not necessary to path both the `nodeId` and `node` given that the `node.id` should match the `nodeId`, so we could just use `node.id` instead. > Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js:195 > + this._idToDOMNode[nodeId] = node; IMO the fact that this is only used in one spot makes me think that having a method for it is maybe overkill. Yes it's not our usual style to allow for private members to be accessed outside of that class, but perhaps for a one-off like this that's somewhat OK (especially since we don't want this to be used by anyone else). > Source/WebInspectorUI/UserInterface/Models/DOMNode.js:35 > + constructor(doc, isInShadowTree, payload) While we're at it, I think we could/should adjust this to be more in line with modern Web Inspector style: - rename `doc` to `ownerDocument` - have `payload` as the first parameter as that's really the only one that's required (yes technically `ownerDocument` is normally expected, but the fact that there's a codepath where it's not used (when `this._nodeType === Node.DOCUMENT_NODE`) in my mind means it's not required) - move `ownerDocument` and `isInShadowTree` to an `options = {}` parameter resulting in something like `constructor(payload, {ownerDocument, isInShadowTree} = {})`, which should let us get rid of all the `null` provided when creating any `WI.DOMNode`. And I'd also make these changes to `WI.DOMNode.newOrExistingFromPayload` so that they match :)
Patrick Angle
Comment 4 2022-04-12 13:46:05 PDT
Created attachment 457411 [details] Patch v1.1
Devin Rousso
Comment 5 2022-04-12 13:53:03 PDT
Comment on attachment 457411 [details] Patch v1.1 View in context: https://bugs.webkit.org/attachment.cgi?id=457411&action=review r=me, nice! Thanks for iterating :) > Source/WebInspectorUI/UserInterface/Models/DOMNode.js:60 > + this.ownerDocument = this._nodeType === Node.DOCUMENT_NODE ? this : ownerDocument; NIT: probably could/should have a `console.assert(this.ownerDocument, this);` right after :)
Patrick Angle
Comment 6 2022-04-12 14:00:04 PDT
Created attachment 457443 [details] Patch v1.2 - Review nit
Patrick Angle
Comment 7 2022-04-12 15:38:55 PDT
Created attachment 457484 [details] Patch v1.2 - Correct typos in for loops
Patrick Angle
Comment 8 2022-04-13 11:31:26 PDT
Created attachment 457551 [details] [fast-cq] Patch v1.3 - Add reviewer to changelog
EWS
Comment 9 2022-04-13 11:54:26 PDT
Committed r292818 (249598@main): <https://commits.webkit.org/249598@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 457551 [details].
Patrick Angle
Comment 10 2022-05-22 11:13:05 PDT
Reverted in https://commits.webkit.org/250847@main due to issues between frontend and backend representation of DOM tree.
Note You need to log in before you can comment on or make changes to this bug.