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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 27 matching lines...) Expand all
38 WebInspector.SDKModel.call(this, WebInspector.RuntimeModel, target); 38 WebInspector.SDKModel.call(this, WebInspector.RuntimeModel, target);
39 39
40 this._agent = target.runtimeAgent(); 40 this._agent = target.runtimeAgent();
41 this.target().registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(t his)); 41 this.target().registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(t his));
42 if (target.hasJSContext()) 42 if (target.hasJSContext())
43 this._agent.enable(); 43 this._agent.enable();
44 /** 44 /**
45 * @type {!Object.<number, !WebInspector.ExecutionContext>} 45 * @type {!Object.<number, !WebInspector.ExecutionContext>}
46 */ 46 */
47 this._executionContextById = {}; 47 this._executionContextById = {};
48 this._executionContextComparator = WebInspector.ExecutionContext.comparator;
48 49
49 if (WebInspector.moduleSetting("customFormatters").get()) 50 if (WebInspector.moduleSetting("customFormatters").get())
50 this._agent.setCustomObjectFormatterEnabled(true); 51 this._agent.setCustomObjectFormatterEnabled(true);
51 52
52 WebInspector.moduleSetting("customFormatters").addChangeListener(this._custo mFormattersStateChanged.bind(this)); 53 WebInspector.moduleSetting("customFormatters").addChangeListener(this._custo mFormattersStateChanged.bind(this));
53 } 54 }
54 55
55 WebInspector.RuntimeModel.Events = { 56 WebInspector.RuntimeModel.Events = {
56 ExecutionContextCreated: "ExecutionContextCreated", 57 ExecutionContextCreated: "ExecutionContextCreated",
57 ExecutionContextDestroyed: "ExecutionContextDestroyed", 58 ExecutionContextDestroyed: "ExecutionContextDestroyed",
58 ExecutionContextChanged: "ExecutionContextChanged" 59 ExecutionContextChanged: "ExecutionContextChanged"
59 } 60 }
60 61
61 WebInspector.RuntimeModel._privateScript = "private script"; 62 WebInspector.RuntimeModel._privateScript = "private script";
62 63
63 WebInspector.RuntimeModel.prototype = { 64 WebInspector.RuntimeModel.prototype = {
64 65
65 /** 66 /**
66 * @return {!Array.<!WebInspector.ExecutionContext>} 67 * @return {!Array.<!WebInspector.ExecutionContext>}
67 */ 68 */
68 executionContexts: function() 69 executionContexts: function()
69 { 70 {
70 return Object.values(this._executionContextById); 71 return Object.values(this._executionContextById).sort(this.executionCont extComparator());
71 }, 72 },
72 73
73 /** 74 /**
75 * @param {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionCo ntext)} comparator
76 */
77 setExecutionContextComparator: function(comparator)
78 {
79 this._executionContextComparator = comparator;
80 },
81
82 /**
83 * @return {function(!WebInspector.ExecutionContext,!WebInspector.ExecutionC ontext)} comparator
84 */
85 executionContextComparator: function()
86 {
87 return this._executionContextComparator;
88 },
89
90 /**
74 * @return {?WebInspector.ExecutionContext} 91 * @return {?WebInspector.ExecutionContext}
75 */ 92 */
76 defaultExecutionContext: function() 93 defaultExecutionContext: function()
77 { 94 {
78 for (var context of Object.values(this._executionContextById)) { 95 for (var context of Object.values(this._executionContextById)) {
79 if (context.isDefault) 96 if (context.isDefault)
80 return context; 97 return context;
81 } 98 }
82 return null; 99 return null;
83 }, 100 },
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 return 3; 463 return 3;
447 if (target.isDedicatedWorker()) 464 if (target.isDedicatedWorker())
448 return 2; 465 return 2;
449 return 1; 466 return 1;
450 } 467 }
451 468
452 var weightDiff = targetWeight(a.target()) - targetWeight(b.target()); 469 var weightDiff = targetWeight(a.target()) - targetWeight(b.target());
453 if (weightDiff) 470 if (weightDiff)
454 return -weightDiff; 471 return -weightDiff;
455 472
456 var frameIdDiff = String.hashCode(a.frameId) - String.hashCode(b.frameId);
457 if (frameIdDiff)
458 return frameIdDiff;
459
460 // Main world context should always go first. 473 // Main world context should always go first.
461 if (a.isDefault) 474 if (a.isDefault)
462 return -1; 475 return -1;
463 if (b.isDefault) 476 if (b.isDefault)
464 return +1; 477 return +1;
465 return a.name.localeCompare(b.name); 478 return a.name.localeCompare(b.name);
466 } 479 }
467 480
468 WebInspector.ExecutionContext.prototype = { 481 WebInspector.ExecutionContext.prototype = {
469 /** 482 /**
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 }, 875 },
863 876
864 /** 877 /**
865 * @return {!Promise<undefined>} 878 * @return {!Promise<undefined>}
866 */ 879 */
867 remove: function() 880 remove: function()
868 { 881 {
869 if (!this._removeFunction) 882 if (!this._removeFunction)
870 return Promise.resolve(); 883 return Promise.resolve();
871 return this._removeFunction.callFunctionPromise(callCustomRemove, [ 884 return this._removeFunction.callFunctionPromise(callCustomRemove, [
872 WebInspector.RemoteObject.toCallArgument(this._type), 885 WebInspector.RemoteObject.toCallArgument(this._type),
873 WebInspector.RemoteObject.toCallArgument(this._originalHandler), 886 WebInspector.RemoteObject.toCallArgument(this._originalHandler),
874 WebInspector.RemoteObject.toCallArgument(this._useCapture), 887 WebInspector.RemoteObject.toCallArgument(this._useCapture),
875 WebInspector.RemoteObject.toCallArgument(this._passive), 888 WebInspector.RemoteObject.toCallArgument(this._passive),
876 ]).then(() => undefined); 889 ]).then(() => undefined);
877 890
878 /** 891 /**
879 * @param {string} type 892 * @param {string} type
880 * @param {function()} listener 893 * @param {function()} listener
881 * @param {boolean} useCapture 894 * @param {boolean} useCapture
882 * @param {boolean} passive 895 * @param {boolean} passive
883 * @this {Function} 896 * @this {Function}
884 * @suppressReceiverCheck 897 * @suppressReceiverCheck
885 */ 898 */
886 function callCustomRemove(type, listener, useCapture, passive) 899 function callCustomRemove(type, listener, useCapture, passive)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 /** 965 /**
953 * @return {boolean} 966 * @return {boolean}
954 */ 967 */
955 isNormalListenerType: function() 968 isNormalListenerType: function()
956 { 969 {
957 return this._listenerType === "normal"; 970 return this._listenerType === "normal";
958 }, 971 },
959 972
960 __proto__: WebInspector.SDKObject.prototype 973 __proto__: WebInspector.SDKObject.prototype
961 } 974 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698