Chromium Code Reviews| 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 0539a60ab96e10b5eed5f5346626c7eb5c668dc4..f5691b43c723cd0f0800ac1e136b756a75e75fdc 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js |
| @@ -51,6 +51,8 @@ WebInspector.ResourceTreeModel = function(target) |
| this._inspectedPageURL = ""; |
| this._pendingReloadOptions = null; |
| this._reloadSuspensionCount = 0; |
| + |
| + target.runtimeModel.setExecutionContextComparator(this._executionContextComparator.bind(this)); |
| } |
| WebInspector.ResourceTreeModel.EventTypes = { |
| @@ -482,6 +484,47 @@ WebInspector.ResourceTreeModel.prototype = { |
| callback(url, data || null, errors); |
| } |
| }, |
| + /** |
| + * @param {!WebInspector.ExecutionContext} a |
| + * @param {!WebInspector.ExecutionContext} b |
| + * @return {number} |
| + */ |
| + _executionContextComparator: function(a,b) |
| + { |
| + var frameParents = function(frameId) |
|
pfeldman
2016/07/09 02:02:08
We used annotated named functions:
/**
* @param
einbinder
2016/07/11 18:40:14
Done.
|
| + { |
| + var frame = this.frameForId(frameId) |
| + var parents = []; |
| + while (frame) { |
| + parents.unshift(frame); |
|
pfeldman
2016/07/09 02:02:09
You should reverse the order and push instead - it
einbinder
2016/07/11 18:40:14
Done.
|
| + frame = frame.parentFrame; |
| + } |
| + return parents; |
| + }.bind(this); |
| + |
| + var framesA = frameParents(a.frameId); |
|
pfeldman
2016/07/09 02:02:08
call it framePath ?
einbinder
2016/07/11 18:40:14
Done.
|
| + var framesB = frameParents(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) { |
| + var frameIdDiff = String.hashCode(frameA.id) - String.hashCode(frameB.id); |
|
pfeldman
2016/07/09 02:02:08
You can use localeCompare here - it should not be
einbinder
2016/07/11 18:40:14
Done.
|
| + return frameIdDiff; |
| + } |
| + return WebInspector.ExecutionContext.comparator(a,b); |
| + }, |
| __proto__: WebInspector.SDKModel.prototype |
| } |