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

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

Issue 354833004: DevTools: [CodeMirror] roll CodeMirror to version @e20d175 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/cm/matchbrackets.js ('k') | Source/devtools/front_end/cm/php.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 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
1 // Utility function that allows modes to be combined. The mode given 4 // Utility function that allows modes to be combined. The mode given
2 // 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
3 // functionality, but a second (typically simple) mode is used, which 6 // functionality, but a second (typically simple) mode is used, which
4 // 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
5 // 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
6 // overlay wins, unless the combine argument was true, in which case 9 // overlay wins, unless the combine argument was true and not overridden,
7 // the styles are combined. 10 // or state.overlay.combineTokens was true, in which case the styles are
11 // combined.
8 12
9 // overlayParser is the old, deprecated name 13 (function(mod) {
10 CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, comb ine) { 14 if (typeof exports == "object" && typeof module == "object") // CommonJS
15 mod(require("../../lib/codemirror"));
16 else if (typeof define == "function" && define.amd) // AMD
17 define(["../../lib/codemirror"], mod);
18 else // Plain browser env
19 mod(CodeMirror);
20 })(function(CodeMirror) {
21 "use strict";
22
23 CodeMirror.overlayMode = function(base, overlay, combine) {
11 return { 24 return {
12 startState: function() { 25 startState: function() {
13 return { 26 return {
14 base: CodeMirror.startState(base), 27 base: CodeMirror.startState(base),
15 overlay: CodeMirror.startState(overlay), 28 overlay: CodeMirror.startState(overlay),
16 basePos: 0, baseCur: null, 29 basePos: 0, baseCur: null,
17 overlayPos: 0, overlayCur: null 30 overlayPos: 0, overlayCur: null,
31 lineSeen: null
18 }; 32 };
19 }, 33 },
20 copyState: function(state) { 34 copyState: function(state) {
21 return { 35 return {
22 base: CodeMirror.copyState(base, state.base), 36 base: CodeMirror.copyState(base, state.base),
23 overlay: CodeMirror.copyState(overlay, state.overlay), 37 overlay: CodeMirror.copyState(overlay, state.overlay),
24 basePos: state.basePos, baseCur: null, 38 basePos: state.basePos, baseCur: null,
25 overlayPos: state.overlayPos, overlayCur: null 39 overlayPos: state.overlayPos, overlayCur: null
26 }; 40 };
27 }, 41 },
28 42
29 token: function(stream, state) { 43 token: function(stream, state) {
44 if (stream.sol() || stream.string != state.lineSeen ||
45 Math.min(state.basePos, state.overlayPos) < stream.start) {
46 state.lineSeen = stream.string;
47 state.basePos = state.overlayPos = stream.start;
48 }
49
30 if (stream.start == state.basePos) { 50 if (stream.start == state.basePos) {
31 state.baseCur = base.token(stream, state.base); 51 state.baseCur = base.token(stream, state.base);
32 state.basePos = stream.pos; 52 state.basePos = stream.pos;
33 } 53 }
34 if (stream.start == state.overlayPos) { 54 if (stream.start == state.overlayPos) {
35 stream.pos = stream.start; 55 stream.pos = stream.start;
36 state.overlayCur = overlay.token(stream, state.overlay); 56 state.overlayCur = overlay.token(stream, state.overlay);
37 state.overlayPos = stream.pos; 57 state.overlayPos = stream.pos;
38 } 58 }
39 stream.pos = Math.min(state.basePos, state.overlayPos); 59 stream.pos = Math.min(state.basePos, state.overlayPos);
40 if (stream.eol()) state.basePos = state.overlayPos = 0;
41 60
61 // state.overlay.combineTokens always takes precedence over combine,
62 // unless set to null
42 if (state.overlayCur == null) return state.baseCur; 63 if (state.overlayCur == null) return state.baseCur;
43 if (state.baseCur != null && combine) return state.baseCur + " " + state.o verlayCur; 64 else if (state.baseCur != null &&
65 state.overlay.combineTokens ||
66 combine && state.overlay.combineTokens == null)
67 return state.baseCur + " " + state.overlayCur;
44 else return state.overlayCur; 68 else return state.overlayCur;
45 }, 69 },
46 70
47 indent: base.indent && function(state, textAfter) { 71 indent: base.indent && function(state, textAfter) {
48 return base.indent(state.base, textAfter); 72 return base.indent(state.base, textAfter);
49 }, 73 },
50 electricChars: base.electricChars, 74 electricChars: base.electricChars,
51 75
52 innerMode: function(state) { return {state: state.base, mode: base}; }, 76 innerMode: function(state) { return {state: state.base, mode: base}; },
53 77
54 blankLine: function(state) { 78 blankLine: function(state) {
55 if (base.blankLine) base.blankLine(state.base); 79 if (base.blankLine) base.blankLine(state.base);
56 if (overlay.blankLine) overlay.blankLine(state.overlay); 80 if (overlay.blankLine) overlay.blankLine(state.overlay);
57 } 81 }
58 }; 82 };
59 }; 83 };
84
85 });
OLDNEW
« no previous file with comments | « Source/devtools/front_end/cm/matchbrackets.js ('k') | Source/devtools/front_end/cm/php.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698