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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 this._agent.enable(); 44 this._agent.enable();
45 45
46 this._fetchResourceTree(); 46 this._fetchResourceTree();
47 47
48 target.registerPageDispatcher(new WebInspector.PageDispatcher(this)); 48 target.registerPageDispatcher(new WebInspector.PageDispatcher(this));
49 49
50 this._securityOriginFrameCount = {}; 50 this._securityOriginFrameCount = {};
51 this._inspectedPageURL = ""; 51 this._inspectedPageURL = "";
52 this._pendingReloadOptions = null; 52 this._pendingReloadOptions = null;
53 this._reloadSuspensionCount = 0; 53 this._reloadSuspensionCount = 0;
54
55 target.runtimeModel.setExecutionContextComparator(this._executionContextComp arator.bind(this));
54 } 56 }
55 57
56 WebInspector.ResourceTreeModel.EventTypes = { 58 WebInspector.ResourceTreeModel.EventTypes = {
57 FrameAdded: "FrameAdded", 59 FrameAdded: "FrameAdded",
58 FrameNavigated: "FrameNavigated", 60 FrameNavigated: "FrameNavigated",
59 FrameDetached: "FrameDetached", 61 FrameDetached: "FrameDetached",
60 FrameResized: "FrameResized", 62 FrameResized: "FrameResized",
61 FrameWillNavigate: "FrameWillNavigate", 63 FrameWillNavigate: "FrameWillNavigate",
62 MainFrameNavigated: "MainFrameNavigated", 64 MainFrameNavigated: "MainFrameNavigated",
63 ResourceAdded: "ResourceAdded", 65 ResourceAdded: "ResourceAdded",
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 */ 477 */
476 function myCallback(protocolError, url, errors, data) 478 function myCallback(protocolError, url, errors, data)
477 { 479 {
478 if (protocolError) { 480 if (protocolError) {
479 callback(url, null, []); 481 callback(url, null, []);
480 return; 482 return;
481 } 483 }
482 callback(url, data || null, errors); 484 callback(url, data || null, errors);
483 } 485 }
484 }, 486 },
487 /**
488 * @param {!WebInspector.ExecutionContext} a
489 * @param {!WebInspector.ExecutionContext} b
490 * @return {number}
491 */
492 _executionContextComparator: function(a,b)
493 {
494 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.
495 {
496 var frame = this.frameForId(frameId)
497 var parents = [];
498 while (frame) {
499 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.
500 frame = frame.parentFrame;
501 }
502 return parents;
503 }.bind(this);
504
505 var framesA = frameParents(a.frameId);
pfeldman 2016/07/09 02:02:08 call it framePath ?
einbinder 2016/07/11 18:40:14 Done.
506 var framesB = frameParents(b.frameId);
507 var frameA;
508 var frameB;
509 for (var i = 0; ; i++) {
510 if (!framesA[i] || !framesB[i] || (framesA[i] !== framesB[i])) {
511 frameA = framesA[i];
512 frameB = framesB[i];
513 break;
514 }
515 }
516 if (!frameA && frameB)
517 return -1;
518
519 if (!frameB && frameA)
520 return 1;
521
522 if (frameA && frameB) {
523 var frameIdDiff = String.hashCode(frameA.id) - String.hashCode(frame B.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.
524 return frameIdDiff;
525 }
526 return WebInspector.ExecutionContext.comparator(a,b);
527 },
485 528
486 __proto__: WebInspector.SDKModel.prototype 529 __proto__: WebInspector.SDKModel.prototype
487 } 530 }
488 531
489 /** 532 /**
490 * @constructor 533 * @constructor
491 * @param {!WebInspector.ResourceTreeModel} model 534 * @param {!WebInspector.ResourceTreeModel} model
492 * @param {?WebInspector.ResourceTreeFrame} parentFrame 535 * @param {?WebInspector.ResourceTreeFrame} parentFrame
493 * @param {!PageAgent.FrameId} frameId 536 * @param {!PageAgent.FrameId} frameId
494 * @param {!PageAgent.Frame=} payload 537 * @param {!PageAgent.Frame=} payload
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 }, 965 },
923 966
924 /** 967 /**
925 * @override 968 * @override
926 */ 969 */
927 interstitialHidden: function() 970 interstitialHidden: function()
928 { 971 {
929 // Frontend is not interested in interstitials. 972 // Frontend is not interested in interstitials.
930 } 973 }
931 } 974 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698