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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js

Issue 2163093003: [DevTools] Remove Object.values and Object.isEmpty from utilities.js (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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 */ 476 */
477 WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, projectI d, path, sourceFileId, lineNumber, columnNumber, condition, enabled) 477 WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, projectI d, path, sourceFileId, lineNumber, columnNumber, condition, enabled)
478 { 478 {
479 this._breakpointManager = breakpointManager; 479 this._breakpointManager = breakpointManager;
480 this._projectId = projectId; 480 this._projectId = projectId;
481 this._path = path; 481 this._path = path;
482 this._lineNumber = lineNumber; 482 this._lineNumber = lineNumber;
483 this._columnNumber = columnNumber; 483 this._columnNumber = columnNumber;
484 this._sourceFileId = sourceFileId; 484 this._sourceFileId = sourceFileId;
485 485
486 /** @type {!Object.<string, number>} */ 486 /** @type {!Map<string, number>} */
487 this._numberOfDebuggerLocationForUILocation = {}; 487 this._numberOfDebuggerLocationForUILocation = new Map();
488 488
489 // Force breakpoint update. 489 // Force breakpoint update.
490 /** @type {string} */ this._condition; 490 /** @type {string} */ this._condition;
491 /** @type {boolean} */ this._enabled; 491 /** @type {boolean} */ this._enabled;
492 /** @type {boolean} */ this._isRemoved; 492 /** @type {boolean} */ this._isRemoved;
493 /** @type {!WebInspector.UILocation|undefined} */ this._fakePrimaryLocation; 493 /** @type {!WebInspector.UILocation|undefined} */ this._fakePrimaryLocation;
494 494
495 this._currentState = null; 495 this._currentState = null;
496 /** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.Targe tBreakpoint>}*/ 496 /** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.Targe tBreakpoint>}*/
497 this._targetBreakpoints = new Map(); 497 this._targetBreakpoints = new Map();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 * @param {!WebInspector.UILocation} newUILocation 573 * @param {!WebInspector.UILocation} newUILocation
574 */ 574 */
575 _replaceUILocation: function(oldUILocation, newUILocation) 575 _replaceUILocation: function(oldUILocation, newUILocation)
576 { 576 {
577 if (this._isRemoved) 577 if (this._isRemoved)
578 return; 578 return;
579 579
580 this._removeUILocation(oldUILocation, true); 580 this._removeUILocation(oldUILocation, true);
581 this._removeFakeBreakpointAtPrimaryLocation(); 581 this._removeFakeBreakpointAtPrimaryLocation();
582 582
583 if (!this._numberOfDebuggerLocationForUILocation[newUILocation.id()]) 583 var current = (this._numberOfDebuggerLocationForUILocation.get(newUILoca tion.id()) || 0) + 1;
584 this._numberOfDebuggerLocationForUILocation[newUILocation.id()] = 0; 584 this._numberOfDebuggerLocationForUILocation.set(newUILocation.id(), curr ent);
585 585 if (current === 1)
586 if (++this._numberOfDebuggerLocationForUILocation[newUILocation.id()] == = 1)
587 this._breakpointManager._uiLocationAdded(this, newUILocation); 586 this._breakpointManager._uiLocationAdded(this, newUILocation);
588 }, 587 },
589 588
590 /** 589 /**
591 * @param {?WebInspector.UILocation} uiLocation 590 * @param {?WebInspector.UILocation} uiLocation
592 * @param {boolean=} muteCreationFakeBreakpoint 591 * @param {boolean=} muteCreationFakeBreakpoint
593 */ 592 */
594 _removeUILocation: function(uiLocation, muteCreationFakeBreakpoint) 593 _removeUILocation: function(uiLocation, muteCreationFakeBreakpoint)
595 { 594 {
596 if (!uiLocation || --this._numberOfDebuggerLocationForUILocation[uiLocat ion.id()] !== 0) 595 if (!uiLocation || !this._numberOfDebuggerLocationForUILocation.has(uiLo cation.id()))
596 return;
597 var current = (this._numberOfDebuggerLocationForUILocation.get(uiLocatio n.id()) || 0) - 1;
598 this._numberOfDebuggerLocationForUILocation.set(uiLocation.id(), current );
599 if (current !== 0)
597 return; 600 return;
598 601
599 delete this._numberOfDebuggerLocationForUILocation[uiLocation.id()]; 602 this._numberOfDebuggerLocationForUILocation.delete(uiLocation.id());
600 this._breakpointManager._uiLocationRemoved(this, uiLocation); 603 this._breakpointManager._uiLocationRemoved(this, uiLocation);
601 if (!muteCreationFakeBreakpoint) 604 if (!muteCreationFakeBreakpoint)
602 this._fakeBreakpointAtPrimaryLocation(); 605 this._fakeBreakpointAtPrimaryLocation();
603 }, 606 },
604 607
605 /** 608 /**
606 * @return {boolean} 609 * @return {boolean}
607 */ 610 */
608 enabled: function() 611 enabled: function()
609 { 612 {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 /** 690 /**
688 * @return {string} 691 * @return {string}
689 */ 692 */
690 _breakpointStorageId: function() 693 _breakpointStorageId: function()
691 { 694 {
692 return WebInspector.BreakpointManager._breakpointStorageId(this._sourceF ileId, this._lineNumber, this._columnNumber); 695 return WebInspector.BreakpointManager._breakpointStorageId(this._sourceF ileId, this._lineNumber, this._columnNumber);
693 }, 696 },
694 697
695 _fakeBreakpointAtPrimaryLocation: function() 698 _fakeBreakpointAtPrimaryLocation: function()
696 { 699 {
697 if (this._isRemoved || !Object.isEmpty(this._numberOfDebuggerLocationFor UILocation) || this._fakePrimaryLocation) 700 if (this._isRemoved || this._numberOfDebuggerLocationForUILocation.size || this._fakePrimaryLocation)
698 return; 701 return;
699 702
700 var uiSourceCode = this._breakpointManager._workspace.uiSourceCode(this. _projectId, this._path); 703 var uiSourceCode = this._breakpointManager._workspace.uiSourceCode(this. _projectId, this._path);
701 if (!uiSourceCode) 704 if (!uiSourceCode)
702 return; 705 return;
703 706
704 this._fakePrimaryLocation = uiSourceCode.uiLocation(this._lineNumber, th is._columnNumber); 707 this._fakePrimaryLocation = uiSourceCode.uiLocation(this._lineNumber, th is._columnNumber);
705 if (this._fakePrimaryLocation) 708 if (this._fakePrimaryLocation)
706 this._breakpointManager._uiLocationAdded(this, this._fakePrimaryLoca tion); 709 this._breakpointManager._uiLocationAdded(this, this._fakePrimaryLoca tion);
707 }, 710 },
(...skipping 26 matching lines...) Expand all
734 WebInspector.BreakpointManager.TargetBreakpoint = function(debuggerModel, breakp oint, networkMapping, debuggerWorkspaceBinding) 737 WebInspector.BreakpointManager.TargetBreakpoint = function(debuggerModel, breakp oint, networkMapping, debuggerWorkspaceBinding)
735 { 738 {
736 WebInspector.SDKObject.call(this, debuggerModel.target()); 739 WebInspector.SDKObject.call(this, debuggerModel.target());
737 this._debuggerModel = debuggerModel; 740 this._debuggerModel = debuggerModel;
738 this._breakpoint = breakpoint; 741 this._breakpoint = breakpoint;
739 this._networkMapping = networkMapping; 742 this._networkMapping = networkMapping;
740 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; 743 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
741 744
742 this._liveLocations = new WebInspector.LiveLocationPool(); 745 this._liveLocations = new WebInspector.LiveLocationPool();
743 746
744 /** @type {!Object.<string, !WebInspector.UILocation>} */ 747 /** @type {!Map<string, !WebInspector.UILocation>} */
745 this._uiLocations = {}; 748 this._uiLocations = new Map();
746 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug gerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); 749 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug gerWasDisabled, this._cleanUpAfterDebuggerIsGone, this);
747 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug gerWasEnabled, this._scheduleUpdateInDebugger, this); 750 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug gerWasEnabled, this._scheduleUpdateInDebugger, this);
748 this._hasPendingUpdate = false; 751 this._hasPendingUpdate = false;
749 this._isUpdating = false; 752 this._isUpdating = false;
750 this._cancelCallback = false; 753 this._cancelCallback = false;
751 this._currentState = null; 754 this._currentState = null;
752 if (this._debuggerModel.debuggerEnabled()) 755 if (this._debuggerModel.debuggerEnabled())
753 this._scheduleUpdateInDebugger(); 756 this._scheduleUpdateInDebugger();
754 } 757 }
755 758
756 WebInspector.BreakpointManager.TargetBreakpoint.prototype = { 759 WebInspector.BreakpointManager.TargetBreakpoint.prototype = {
757 760
758 _resetLocations: function() 761 _resetLocations: function()
759 { 762 {
760 var uiLocations = Object.values(this._uiLocations); 763 for (var uiLocation of this._uiLocations.values())
761 for (var i = 0; i < uiLocations.length; ++i) 764 this._breakpoint._removeUILocation(uiLocation);
762 this._breakpoint._removeUILocation(uiLocations[i]);
763 765
764 this._uiLocations = {}; 766 this._uiLocations.clear();
765 this._liveLocations.disposeAll(); 767 this._liveLocations.disposeAll();
766 }, 768 },
767 769
768 _scheduleUpdateInDebugger: function() 770 _scheduleUpdateInDebugger: function()
769 { 771 {
770 if (this._isUpdating) { 772 if (this._isUpdating) {
771 this._hasPendingUpdate = true; 773 this._hasPendingUpdate = true;
772 return; 774 return;
773 } 775 }
774 776
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 917
916 /** 918 /**
917 * @param {!WebInspector.DebuggerModel.Location} location 919 * @param {!WebInspector.DebuggerModel.Location} location
918 * @param {!WebInspector.LiveLocation} liveLocation 920 * @param {!WebInspector.LiveLocation} liveLocation
919 */ 921 */
920 _locationUpdated: function(location, liveLocation) 922 _locationUpdated: function(location, liveLocation)
921 { 923 {
922 var uiLocation = liveLocation.uiLocation(); 924 var uiLocation = liveLocation.uiLocation();
923 if (!uiLocation) 925 if (!uiLocation)
924 return; 926 return;
925 var oldUILocation = this._uiLocations[location.id()] || null; 927 var oldUILocation = this._uiLocations.get(location.id()) || null;
926 this._uiLocations[location.id()] = uiLocation; 928 this._uiLocations.set(location.id(), uiLocation);
927 this._breakpoint._replaceUILocation(oldUILocation, uiLocation); 929 this._breakpoint._replaceUILocation(oldUILocation, uiLocation);
928 }, 930 },
929 931
930 /** 932 /**
931 * @param {!WebInspector.DebuggerModel.Location} location 933 * @param {!WebInspector.DebuggerModel.Location} location
932 * @return {boolean} 934 * @return {boolean}
933 */ 935 */
934 _addResolvedLocation: function(location) 936 _addResolvedLocation: function(location)
935 { 937 {
936 var uiLocation = this._debuggerWorkspaceBinding.rawLocationToUILocation( location); 938 var uiLocation = this._debuggerWorkspaceBinding.rawLocationToUILocation( location);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 { 1083 {
1082 this.sourceFileId = breakpoint._sourceFileId; 1084 this.sourceFileId = breakpoint._sourceFileId;
1083 this.lineNumber = breakpoint.lineNumber(); 1085 this.lineNumber = breakpoint.lineNumber();
1084 this.columnNumber = breakpoint.columnNumber(); 1086 this.columnNumber = breakpoint.columnNumber();
1085 this.condition = breakpoint.condition(); 1087 this.condition = breakpoint.condition();
1086 this.enabled = breakpoint.enabled(); 1088 this.enabled = breakpoint.enabled();
1087 } 1089 }
1088 1090
1089 /** @type {!WebInspector.BreakpointManager} */ 1091 /** @type {!WebInspector.BreakpointManager} */
1090 WebInspector.breakpointManager; 1092 WebInspector.breakpointManager;
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698