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

Unified Diff: third_party/WebKit/Source/devtools/front_end/cm/activeline.js

Issue 2862603003: Revert of DevTools: Roll CodeMirror to 5.25.1
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/cm/activeline.js
diff --git a/third_party/WebKit/Source/devtools/front_end/cm/activeline.js b/third_party/WebKit/Source/devtools/front_end/cm/activeline.js
index aa295d0d86c1550db10fe8bcdf88e0c80c9382c2..b0b3f61af20c6faeb9ae3ab6f6622e3ae225e954 100644
--- a/third_party/WebKit/Source/devtools/front_end/cm/activeline.js
+++ b/third_party/WebKit/Source/devtools/front_end/cm/activeline.js
@@ -1,5 +1,11 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Because sometimes you need to style the cursor's line.
+//
+// Adds an option 'styleActiveLine' which, when enabled, gives the
+// active line's wrapping <div> the CSS class "CodeMirror-activeline",
+// and gives its background <div> the class "CodeMirror-activeline-background".
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -15,17 +21,15 @@
var GUTT_CLASS = "CodeMirror-activeline-gutter";
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
- var prev = old == CodeMirror.Init ? false : old;
- if (val == prev) return
- if (prev) {
+ var prev = old && old != CodeMirror.Init;
+ if (val && !prev) {
+ cm.state.activeLines = [];
+ updateActiveLines(cm, cm.listSelections());
+ cm.on("beforeSelectionChange", selectionChange);
+ } else if (!val && prev) {
cm.off("beforeSelectionChange", selectionChange);
clearActiveLines(cm);
delete cm.state.activeLines;
- }
- if (val) {
- cm.state.activeLines = [];
- updateActiveLines(cm, cm.listSelections());
- cm.on("beforeSelectionChange", selectionChange);
}
});
@@ -48,9 +52,7 @@
var active = [];
for (var i = 0; i < ranges.length; i++) {
var range = ranges[i];
- var option = cm.getOption("styleActiveLine");
- if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
- continue
+ if (!range.empty()) continue;
var line = cm.getLineHandleVisualStart(range.head.line);
if (active[active.length - 1] != line) active.push(line);
}

Powered by Google App Engine
This is Rietveld 408576698