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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js

Issue 2605693003: DevTools: introduce object previews experiment (Closed)
Patch Set: tests Created 3 years, 11 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return 0; 72 return 0;
73 // Array lengths in V8-generated descriptions switched from square brackets to parentheses. 73 // Array lengths in V8-generated descriptions switched from square brackets to parentheses.
74 // Both formats are checked in case the front end is dealing with an old ver sion of V8. 74 // Both formats are checked in case the front end is dealing with an old ver sion of V8.
75 var matches = object.description.match(/\[([0-9]+)\]/) || object.description .match(/\(([0-9]+)\)/); 75 var matches = object.description.match(/\[([0-9]+)\]/) || object.description .match(/\(([0-9]+)\)/);
76 if (!matches) 76 if (!matches)
77 return 0; 77 return 0;
78 return parseInt(matches[1], 10); 78 return parseInt(matches[1], 10);
79 } 79 }
80 80
81 /** 81 /**
82 * @param {!Protocol.Runtime.ObjectPreview} preview
83 * @return {number}
84 */
85 static numEntries(preview) {
dgozman 2017/01/10 22:26:10 setOrMapEntriesCount
luoe 2017/01/13 01:11:45 mapOrSetEntriesCount
86 if (preview.subtype !== 'map' && preview.subtype !== 'set')
87 return 0;
88 var matches = preview.description.match(/\(([0-9]+)\)/);
89 if (!matches)
90 return 0;
91 return parseInt(matches[1], 10);
92 }
93
94 /**
82 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool ean|undefined|null} object 95 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool ean|undefined|null} object
83 * @return {!Protocol.Runtime.CallArgument} 96 * @return {!Protocol.Runtime.CallArgument}
84 */ 97 */
85 static toCallArgument(object) { 98 static toCallArgument(object) {
86 var type = typeof object; 99 var type = typeof object;
87 if (type === 'undefined') 100 if (type === 'undefined')
88 return {}; 101 return {};
89 if (type === 'number') { 102 if (type === 'number') {
90 var description = String(object); 103 var description = String(object);
91 if (object === 0 && 1 / object < 0) 104 if (object === 0 && 1 / object < 0)
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 */ 503 */
491 get preview() { 504 get preview() {
492 return this._preview; 505 return this._preview;
493 } 506 }
494 507
495 /** 508 /**
496 * @override 509 * @override
497 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 510 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
498 */ 511 */
499 getOwnProperties(callback) { 512 getOwnProperties(callback) {
500 this.doGetProperties(true, false, false, callback); 513 if (Runtime.experiments.isEnabled('objectPreviews'))
dgozman 2017/01/10 22:26:10 Instead of checking experiment here, we should pas
luoe 2017/01/13 01:11:45 Moved to a few callers in ObjectPropertiesSection.
514 this.doGetProperties(true, false, true, callback);
515 else
516 this.doGetProperties(true, false, false, callback);
501 } 517 }
502 518
503 /** 519 /**
504 * @override 520 * @override
505 * @param {boolean} accessorPropertiesOnly 521 * @param {boolean} accessorPropertiesOnly
506 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 522 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
507 */ 523 */
508 getAllProperties(accessorPropertiesOnly, callback) { 524 getAllProperties(accessorPropertiesOnly, callback) {
509 this.doGetProperties(false, accessorPropertiesOnly, false, callback); 525 if (Runtime.experiments.isEnabled('objectPreviews'))
dgozman 2017/01/10 22:26:10 ditto
luoe 2017/01/13 01:11:46 Done.
526 this.doGetProperties(false, accessorPropertiesOnly, true, callback);
527 else
528 this.doGetProperties(false, accessorPropertiesOnly, false, callback);
510 } 529 }
511 530
512 /** 531 /**
513 * @override 532 * @override
514 * @return {!Promise<?Array<!SDK.EventListener>>} 533 * @return {!Promise<?Array<!SDK.EventListener>>}
515 */ 534 */
516 eventListeners() { 535 eventListeners() {
517 return new Promise(eventListeners.bind(this)); 536 return new Promise(eventListeners.bind(this));
518 /** 537 /**
519 * @param {function(?)} fulfill 538 * @param {function(?)} fulfill
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 } 1435 }
1417 } 1436 }
1418 1437
1419 /** 1438 /**
1420 * @return {!SDK.RemoteObject} 1439 * @return {!SDK.RemoteObject}
1421 */ 1440 */
1422 object() { 1441 object() {
1423 return this._object; 1442 return this._object;
1424 } 1443 }
1425 }; 1444 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698