Skip to content

Commit 355c97d

Browse files
committed
Gadgets/Stdrev: Handle all cases of fully closed ranges
Fix for revision selector to correctly filter rows of the form "(since C++14) (until C++17)"
1 parent 600d384 commit 355c97d

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

gadgets/standard_revisions.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*
23
Copyright (C) 2013-2017 Povilas Kanapickas <povilas@radix.lt>
34
@@ -217,6 +218,11 @@ $(function() {
217218
this.map[rev] = true;
218219
}
219220

221+
// Sets the visibility on the given revision to true.
222+
VisibilityMap.prototype.remove = function(rev) {
223+
this.map[rev] = false;
224+
}
225+
220226

221227
/* Fills the visibility map with the given value. After the operation
222228
map.is_visible_on(rev) == value for all valid revisions.
@@ -285,28 +291,28 @@ $(function() {
285291
// FIXME: this function handles only certain cases of fully closed ranges
286292
function get_visibility_map_cxx(el) {
287293
// DIFF: 0, CXX98: 1, CXX11: 2, CXX14: 3, CXX17: 4
288-
if (el.hasClass('t-since-cxx17')) {
289-
return new VisibilityMap([Rev.CXX17]);
290-
}
291-
if (el.hasClass('t-since-cxx14')) {
292-
return new VisibilityMap([Rev.CXX14, Rev.CXX17]);
293-
}
294-
if (el.hasClass('t-since-cxx11')) {
295-
if (el.hasClass('t-until-cxx14')) {
296-
return new VisibilityMap([Rev.CXX11]);
294+
var classes_cxx = [
295+
{ rev: Rev.CXX11, since: 't-since-cxx11', until: 't-until-cxx11' },
296+
{ rev: Rev.CXX14, since: 't-since-cxx14', until: 't-until-cxx14' },
297+
{ rev: Rev.CXX17, since: 't-since-cxx17', until: 't-until-cxx17' },
298+
];
299+
var map = new VisibilityMap();
300+
for (var i = 0; i < classes_cxx.length; i++) {
301+
if (el.hasClass(classes_cxx[i].since)) {
302+
break;
297303
}
298-
return new VisibilityMap([Rev.CXX11, Rev.CXX14, Rev.CXX17]);
299-
}
300-
if (el.hasClass('t-until-cxx11')) {
301-
return new VisibilityMap([Rev.CXX98]);
302304
}
303-
if (el.hasClass('t-until-cxx14')) {
304-
return new VisibilityMap([Rev.CXX98, Rev.CXX11]);
305+
if (i === classes_cxx.length) {
306+
map.add(Rev.CXX98);
307+
i = 0;
305308
}
306-
if (el.hasClass('t-until-cxx17')) {
307-
return new VisibilityMap([Rev.CXX98, Rev.CXX11, Rev.CXX14]);
309+
for (; i < classes_cxx.length; i++) {
310+
if (el.hasClass(classes_cxx[i].until)) {
311+
break;
312+
}
313+
map.add(classes_cxx[i].rev);
308314
}
309-
return new VisibilityMap([Rev.CXX98, Rev.CXX11, Rev.CXX14, Rev.CXX17]);
315+
return map;
310316
}
311317

312318
function get_visibility_map_c(el) {
@@ -1150,7 +1156,7 @@ $(function() {
11501156
// process the member dcls
11511157
el.children('.t-dcl').each(function() {
11521158
var new_id = process_tr($(this), has_num, has_revs,
1153-
new_def.revs.slice());
1159+
new_def.revs.clone());
11541160
new_def.children.push(new_id);
11551161
});
11561162

0 commit comments

Comments
 (0)