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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js

Issue 2492343002: Devtools: Pretty print fix for CSS coverage decorations. (Closed)
Patch Set: Pretty print fix for CSS coverage decorations. Created 4 years, 1 month 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 this._origin = ''; 53 this._origin = '';
54 this._parentURL = ''; 54 this._parentURL = '';
55 this._name = url; 55 this._name = url;
56 } 56 }
57 57
58 this._contentType = contentType; 58 this._contentType = contentType;
59 /** @type {?function(?string)} */ 59 /** @type {?function(?string)} */
60 this._requestContentCallback = null; 60 this._requestContentCallback = null;
61 /** @type {?Promise<?string>} */ 61 /** @type {?Promise<?string>} */
62 this._requestContentPromise = null; 62 this._requestContentPromise = null;
63 /** @type {!Map<string, !Map<number, !Workspace.UISourceCode.LineMarker>>} * / 63 /** @type {!Multimap<string, !Workspace.UISourceCode.LineMarker>} */
64 this._lineDecorations = new Map(); 64 this._decorations = new Multimap();
65 65
66 /** @type {!Array.<!Workspace.Revision>} */ 66 /** @type {!Array.<!Workspace.Revision>} */
67 this.history = []; 67 this.history = [];
68 68
69 /** @type {!Array<!Workspace.UISourceCode.Message>} */ 69 /** @type {!Array<!Workspace.UISourceCode.Message>} */
70 this._messages = []; 70 this._messages = [];
71 } 71 }
72 72
73 /** 73 /**
74 * @return {!Promise<?Workspace.UISourceCodeMetadata>} 74 * @return {!Promise<?Workspace.UISourceCodeMetadata>}
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 for (var message of messages) 601 for (var message of messages)
602 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message); 602 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message);
603 } 603 }
604 604
605 /** 605 /**
606 * @param {number} lineNumber 606 * @param {number} lineNumber
607 * @param {string} type 607 * @param {string} type
608 * @param {?} data 608 * @param {?} data
609 */ 609 */
610 addLineDecoration(lineNumber, type, data) { 610 addLineDecoration(lineNumber, type, data) {
611 var markers = this._lineDecorations.get(type); 611 this.addDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type, data);
612 if (!markers) {
613 markers = new Map();
614 this._lineDecorations.set(type, markers);
615 }
616 var marker = new Workspace.UISourceCode.LineMarker(lineNumber, type, data);
617 markers.set(lineNumber, marker);
618 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAd ded, marker);
619 } 612 }
620 613
621 /** 614 /**
622 * @param {number} lineNumber 615 * @param {!Common.TextRange} range
623 * @param {string} type 616 * @param {string} type
617 * @param {?} data
624 */ 618 */
625 removeLineDecoration(lineNumber, type) { 619 addDecoration(range, type, data) {
626 var markers = this._lineDecorations.get(type); 620 var marker = new Workspace.UISourceCode.LineMarker(range, type, data);
627 if (!markers) 621 this._decorations.set(type, marker);
628 return; 622 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAd ded, marker);
629 var marker = markers.get(lineNumber);
630 if (!marker)
631 return;
632 markers.delete(lineNumber);
633 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRe moved, marker);
634 if (!markers.size)
635 this._lineDecorations.delete(type);
636 } 623 }
637 624
638 /** 625 /**
639 * @param {string} type 626 * @param {string} type
640 */ 627 */
641 removeAllLineDecorations(type) { 628 removeDecorationsForType(type) {
642 var markers = this._lineDecorations.get(type); 629 var markers = this._decorations.get(type);
643 if (!markers) 630 this._decorations.removeAll(type);
644 return;
645 this._lineDecorations.delete(type);
646 markers.forEach(marker => { 631 markers.forEach(marker => {
647 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker); 632 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker);
648 }); 633 });
649 } 634 }
650 635
651 /** 636 /**
637 * @return {!Array<!Workspace.UISourceCode.LineMarker>}
638 */
639 allDecorations() {
640 return this._decorations.valuesArray();
641 }
642
643 removeAllDecorations() {
644 this._decorations.valuesArray().forEach(marker =>
645 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorati onRemoved, marker));
lushnikov 2016/11/17 17:55:52 event sending should be the last thing you do. Oth
646 this._decorations.clear();
647 }
648
649 /**
652 * @param {string} type 650 * @param {string} type
653 * @return {?Map<number, !Workspace.UISourceCode.LineMarker>} 651 * @return {!Set<!Workspace.UISourceCode.LineMarker>}
654 */ 652 */
655 lineDecorations(type) { 653 decorationsForType(type) {
656 return this._lineDecorations.get(type) || null; 654 return this._decorations.get(type);
657 } 655 }
658 }; 656 };
659 657
660 /** @enum {symbol} */ 658 /** @enum {symbol} */
661 Workspace.UISourceCode.Events = { 659 Workspace.UISourceCode.Events = {
662 WorkingCopyChanged: Symbol('WorkingCopyChanged'), 660 WorkingCopyChanged: Symbol('WorkingCopyChanged'),
663 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), 661 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'),
664 TitleChanged: Symbol('TitleChanged'), 662 TitleChanged: Symbol('TitleChanged'),
665 SourceMappingChanged: Symbol('SourceMappingChanged'), 663 SourceMappingChanged: Symbol('SourceMappingChanged'),
666 MessageAdded: Symbol('MessageAdded'), 664 MessageAdded: Symbol('MessageAdded'),
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 Workspace.UISourceCode.Message.Level = { 897 Workspace.UISourceCode.Message.Level = {
900 Error: 'Error', 898 Error: 'Error',
901 Warning: 'Warning' 899 Warning: 'Warning'
902 }; 900 };
903 901
904 /** 902 /**
905 * @unrestricted 903 * @unrestricted
906 */ 904 */
907 Workspace.UISourceCode.LineMarker = class { 905 Workspace.UISourceCode.LineMarker = class {
908 /** 906 /**
909 * @param {number} line 907 * @param {!Common.TextRange} range
910 * @param {string} type 908 * @param {string} type
911 * @param {?} data 909 * @param {?} data
912 */ 910 */
913 constructor(line, type, data) { 911 constructor(range, type, data) {
914 this._line = line; 912 this._range = range;
915 this._type = type; 913 this._type = type;
916 this._data = data; 914 this._data = data;
917 } 915 }
918 916
919 /** 917 /**
920 * @return {number} 918 * @return {!Common.TextRange}
921 */ 919 */
922 line() { 920 range() {
923 return this._line; 921 return this._range;
924 } 922 }
925 923
926 /** 924 /**
927 * @return {string} 925 * @return {string}
928 */ 926 */
929 type() { 927 type() {
930 return this._type; 928 return this._type;
931 } 929 }
932 930
933 /** 931 /**
(...skipping 10 matching lines...) Expand all
944 Workspace.UISourceCodeMetadata = class { 942 Workspace.UISourceCodeMetadata = class {
945 /** 943 /**
946 * @param {?Date} modificationTime 944 * @param {?Date} modificationTime
947 * @param {?number} contentSize 945 * @param {?number} contentSize
948 */ 946 */
949 constructor(modificationTime, contentSize) { 947 constructor(modificationTime, contentSize) {
950 this.modificationTime = modificationTime; 948 this.modificationTime = modificationTime;
951 this.contentSize = contentSize; 949 this.contentSize = contentSize;
952 } 950 }
953 }; 951 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698