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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js

Issue 2136763002: DevTools: Sort execution contexts in nested frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflict 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
index 8f5b5c556d952f8684ed0ecc65228cfba2d22711..035b4ac10cc57e420402d17232bd6be3f1a443e2 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
@@ -55,6 +55,8 @@ WebInspector.ResourceTreeModel = function(target, networkManager)
this._inspectedPageURL = "";
this._pendingReloadOptions = null;
this._reloadSuspensionCount = 0;
+
+ target.runtimeModel.setExecutionContextComparator(this._executionContextComparator.bind(this));
}
WebInspector.ResourceTreeModel.EventTypes = {
@@ -486,6 +488,49 @@ WebInspector.ResourceTreeModel.prototype = {
callback(url, data || null, errors);
}
},
+ /**
+ * @param {!WebInspector.ExecutionContext} a
+ * @param {!WebInspector.ExecutionContext} b
+ * @return {number}
+ */
+ _executionContextComparator: function(a,b)
+ {
+ /**
+ * @param {!WebInspector.ResourceTreeFrame} frame
+ */
+ function framePath(frame)
+ {
+ var currentFrame = frame;
+ var parents = [];
+ while (currentFrame) {
+ parents.push(currentFrame);
+ currentFrame = currentFrame.parentFrame;
+ }
+ return parents.reverse();
+ }
+
+ var framesA = a.frameId ? framePath(this.frameForId(a.frameId)) : [];
+ var framesB = b.frameId ? framePath(this.frameForId(b.frameId)) : [];
+ var frameA;
+ var frameB;
+ for (var i = 0; ; i++) {
+ if (!framesA[i] || !framesB[i] || (framesA[i] !== framesB[i])) {
+ frameA = framesA[i];
+ frameB = framesB[i];
+ break;
+ }
+ }
+ if (!frameA && frameB)
+ return -1;
+
+ if (!frameB && frameA)
+ return 1;
+
+ if (frameA && frameB) {
+ return frameA.id.localeCompare(frameB.id);
+ }
+ return WebInspector.ExecutionContext.comparator(a,b);
+ },
__proto__: WebInspector.SDKModel.prototype
}

Powered by Google App Engine
This is Rietveld 408576698