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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/cm/overlay.js

Issue 2166603002: DevTools: roll CodeMirror (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert unnecessary typeIn change 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 // CodeMirror, copyright (c) by Marijn Haverbeke and others 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE 2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3 3
4 // Utility function that allows modes to be combined. The mode given 4 // Utility function that allows modes to be combined. The mode given
5 // as the base argument takes care of most of the normal mode 5 // as the base argument takes care of most of the normal mode
6 // functionality, but a second (typically simple) mode is used, which 6 // functionality, but a second (typically simple) mode is used, which
7 // can override the style of text. Both modes get to parse all of the 7 // can override the style of text. Both modes get to parse all of the
8 // text, but when both assign a non-null style to a piece of code, the 8 // text, but when both assign a non-null style to a piece of code, the
9 // overlay wins, unless the combine argument was true and not overridden, 9 // overlay wins, unless the combine argument was true and not overridden,
10 // or state.overlay.combineTokens was true, in which case the styles are 10 // or state.overlay.combineTokens was true, in which case the styles are
(...skipping 10 matching lines...) Expand all
21 "use strict"; 21 "use strict";
22 22
23 CodeMirror.overlayMode = function(base, overlay, combine) { 23 CodeMirror.overlayMode = function(base, overlay, combine) {
24 return { 24 return {
25 startState: function() { 25 startState: function() {
26 return { 26 return {
27 base: CodeMirror.startState(base), 27 base: CodeMirror.startState(base),
28 overlay: CodeMirror.startState(overlay), 28 overlay: CodeMirror.startState(overlay),
29 basePos: 0, baseCur: null, 29 basePos: 0, baseCur: null,
30 overlayPos: 0, overlayCur: null, 30 overlayPos: 0, overlayCur: null,
31 lineSeen: null 31 streamSeen: null
32 }; 32 };
33 }, 33 },
34 copyState: function(state) { 34 copyState: function(state) {
35 return { 35 return {
36 base: CodeMirror.copyState(base, state.base), 36 base: CodeMirror.copyState(base, state.base),
37 overlay: CodeMirror.copyState(overlay, state.overlay), 37 overlay: CodeMirror.copyState(overlay, state.overlay),
38 basePos: state.basePos, baseCur: null, 38 basePos: state.basePos, baseCur: null,
39 overlayPos: state.overlayPos, overlayCur: null 39 overlayPos: state.overlayPos, overlayCur: null
40 }; 40 };
41 }, 41 },
42 42
43 token: function(stream, state) { 43 token: function(stream, state) {
44 if (stream.sol() || stream.string != state.lineSeen || 44 if (stream != state.streamSeen ||
45 Math.min(state.basePos, state.overlayPos) < stream.start) { 45 Math.min(state.basePos, state.overlayPos) < stream.start) {
46 state.lineSeen = stream.string; 46 state.streamSeen = stream;
47 state.basePos = state.overlayPos = stream.start; 47 state.basePos = state.overlayPos = stream.start;
48 } 48 }
49 49
50 if (stream.start == state.basePos) { 50 if (stream.start == state.basePos) {
51 state.baseCur = base.token(stream, state.base); 51 state.baseCur = base.token(stream, state.base);
52 state.basePos = stream.pos; 52 state.basePos = stream.pos;
53 } 53 }
54 if (stream.start == state.overlayPos) { 54 if (stream.start == state.overlayPos) {
55 stream.pos = stream.start; 55 stream.pos = stream.start;
56 state.overlayCur = overlay.token(stream, state.overlay); 56 state.overlayCur = overlay.token(stream, state.overlay);
(...skipping 19 matching lines...) Expand all
76 innerMode: function(state) { return {state: state.base, mode: base}; }, 76 innerMode: function(state) { return {state: state.base, mode: base}; },
77 77
78 blankLine: function(state) { 78 blankLine: function(state) {
79 if (base.blankLine) base.blankLine(state.base); 79 if (base.blankLine) base.blankLine(state.base);
80 if (overlay.blankLine) overlay.blankLine(state.overlay); 80 if (overlay.blankLine) overlay.blankLine(state.overlay);
81 } 81 }
82 }; 82 };
83 }; 83 };
84 84
85 }); 85 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698