Web Inspector: [SI] DOMManager rescans every DOM node for each pending frame document when splicing#69441
Draft
Ahmad-S792 wants to merge 1 commit into
Conversation
…g frame document when splicing https://bugs.webkit.org/show_bug.cgi?id=319454 rdar://182266167 Reviewed by NOBODY (OOPS!). When a cross-origin frame document arrives before its owning iframe element is known, it is queued and re-tried later. _trySpliceUnsplicedFrameDocuments() ran that retry by calling _trySpliceFrameDocumentIntoNode() once per pending document, and each call allocated a fresh Object.values(this._idToDOMNode) and linearly scanned every known DOM node to find a matching iframe/frame element. It also constructed a new URL for the frame document's URL on every candidate node. The result was O(pendingDocuments * totalNodes) work with a per-document array allocation and redundant per-node URL parsing. Collect the candidate iframe/frame elements once per pass in _unmatchedFrameNodes() and reuse that list across all pending documents, and resolve the frame document's URL lazily at most once per document. This lowers the cost to O(totalNodes + pendingDocuments * frameElements) with no behavior change: an element matched by an earlier document in the same pass is still skipped via its now-set contentDocument, so duplicate-URL documents and already-populated iframes behave exactly as before. Test: inspector/unit-tests/dom-frame-document-splice.html * LayoutTests/inspector/unit-tests/dom-frame-document-splice-expected.txt: Added. * LayoutTests/inspector/unit-tests/dom-frame-document-splice.html: Added. * Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js: (WI.DOMManager.prototype._unmatchedFrameNodes): (WI.DOMManager.prototype._trySpliceFrameDocumentIntoNode): (WI.DOMManager.prototype._trySpliceUnsplicedFrameDocuments):
Collaborator
|
EWS run on current version of this PR (hash c009a18) Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧪 ios-wk2-wpt
c009a18
c009a18