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

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 {!Map<string, !Array<!Workspace.UISourceCode.LineMarker>>} */
lushnikov 2016/11/16 22:53:54 Map<string, Array<LineMarker>> is a... Multimap<st
64 this._lineDecorations = new Map(); 64 this._decorations = new Map();
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 markers = this._decorations.get(type);
627 if (!markers) 621 if (!markers) {
628 return; 622 markers = [];
629 var marker = markers.get(lineNumber); 623 this._decorations.set(type, markers);
630 if (!marker) 624 }
631 return; 625 var marker = new Workspace.UISourceCode.LineMarker(range, type, data);
632 markers.delete(lineNumber); 626 markers.push(marker);
633 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRe moved, marker); 627 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAd ded, marker);
634 if (!markers.size)
635 this._lineDecorations.delete(type);
636 } 628 }
637 629
638 /** 630 /**
639 * @param {string} type 631 * @param {string} type
640 */ 632 */
641 removeAllLineDecorations(type) { 633 removeAllTypeDecorations(type) {
lushnikov 2016/11/16 22:53:54 removeDecorationsForType
642 var markers = this._lineDecorations.get(type); 634 var markers = this._decorations.get(type);
643 if (!markers) 635 if (!markers)
644 return; 636 return;
645 this._lineDecorations.delete(type); 637 this._decorations.delete(type);
646 markers.forEach(marker => { 638 markers.forEach(marker => {
647 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker); 639 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker);
648 }); 640 });
649 } 641 }
650 642
651 /** 643 /**
644 * @return {!Map<string, !Array<!Workspace.UISourceCode.LineMarker>>}
lushnikov 2016/11/16 22:53:54 why does it return a map? Let's just return an arr
645 */
646 get allDecorations() {
lushnikov 2016/11/16 22:53:54 let's not use getters
647 return this._decorations;
648 }
649
650 removeAllDecorations() {
651 this._decorations.clear();
lushnikov 2016/11/16 22:53:54 this should dispatch LineDecorationRemoved events
652 }
653
654 /**
652 * @param {string} type 655 * @param {string} type
653 * @return {?Map<number, !Workspace.UISourceCode.LineMarker>} 656 * @return {!Array<!Workspace.UISourceCode.LineMarker>}
654 */ 657 */
655 lineDecorations(type) { 658 decorations(type) {
lushnikov 2016/11/16 22:53:54 decorationsForType
656 return this._lineDecorations.get(type) || null; 659 return this._decorations.get(type) || null;
657 } 660 }
658 }; 661 };
659 662
660 /** @enum {symbol} */ 663 /** @enum {symbol} */
661 Workspace.UISourceCode.Events = { 664 Workspace.UISourceCode.Events = {
662 WorkingCopyChanged: Symbol('WorkingCopyChanged'), 665 WorkingCopyChanged: Symbol('WorkingCopyChanged'),
663 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), 666 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'),
664 TitleChanged: Symbol('TitleChanged'), 667 TitleChanged: Symbol('TitleChanged'),
665 SourceMappingChanged: Symbol('SourceMappingChanged'), 668 SourceMappingChanged: Symbol('SourceMappingChanged'),
666 MessageAdded: Symbol('MessageAdded'), 669 MessageAdded: Symbol('MessageAdded'),
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 Workspace.UISourceCode.Message.Level = { 902 Workspace.UISourceCode.Message.Level = {
900 Error: 'Error', 903 Error: 'Error',
901 Warning: 'Warning' 904 Warning: 'Warning'
902 }; 905 };
903 906
904 /** 907 /**
905 * @unrestricted 908 * @unrestricted
906 */ 909 */
907 Workspace.UISourceCode.LineMarker = class { 910 Workspace.UISourceCode.LineMarker = class {
908 /** 911 /**
909 * @param {number} line 912 * @param {!Common.TextRange} range
910 * @param {string} type 913 * @param {string} type
911 * @param {?} data 914 * @param {?} data
912 */ 915 */
913 constructor(line, type, data) { 916 constructor(range, type, data) {
914 this._line = line; 917 this._range = range;
915 this._type = type; 918 this._type = type;
916 this._data = data; 919 this._data = data;
917 } 920 }
918 921
919 /** 922 /**
920 * @return {number} 923 * @return {number}
921 */ 924 */
922 line() { 925 line() {
lushnikov 2016/11/16 22:53:54 can we drop this method now?
923 return this._line; 926 return this._range.startLine;
924 } 927 }
925 928
926 /** 929 /**
930 * @return {!Common.TextRange}
931 */
932 range() {
933 return this._range;
934 }
935
936 /**
927 * @return {string} 937 * @return {string}
928 */ 938 */
929 type() { 939 type() {
930 return this._type; 940 return this._type;
931 } 941 }
932 942
933 /** 943 /**
934 * @return {*} 944 * @return {*}
935 */ 945 */
936 data() { 946 data() {
937 return this._data; 947 return this._data;
938 } 948 }
939 }; 949 };
940 950
941 /** 951 /**
942 * @unrestricted 952 * @unrestricted
943 */ 953 */
944 Workspace.UISourceCodeMetadata = class { 954 Workspace.UISourceCodeMetadata = class {
945 /** 955 /**
946 * @param {?Date} modificationTime 956 * @param {?Date} modificationTime
947 * @param {?number} contentSize 957 * @param {?number} contentSize
948 */ 958 */
949 constructor(modificationTime, contentSize) { 959 constructor(modificationTime, contentSize) {
950 this.modificationTime = modificationTime; 960 this.modificationTime = modificationTime;
951 this.contentSize = contentSize; 961 this.contentSize = contentSize;
952 } 962 }
953 }; 963 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698