ASDenysPetrov created this revision. ASDenysPetrov added reviewers: vsavchenko, NoQ. ASDenysPetrov added a project: clang. Herald added subscribers: manas, steakhal, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun. ASDenysPetrov requested review of this revision. Herald added a subscriber: cfe-commits.
Change and replace some functions which IE does not support. This patch is made as a continuation of D92639 <https://reviews.llvm.org/D92639> revision. Also improve hot keys behavior. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D107366 Files: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -1289,15 +1289,32 @@ return out; }; +var classListAdd = function(el, theClass) { + if(!el.className.baseVal) + el.className += " " + theClass; + else + el.className.baseVal += " " + theClass; +}; + +var classListRemove = function(el, theClass) { + var className = (!el.className.baseVal) ? + el.className : el.className.baseVal; + className = className.replace(" " + theClass, ""); + if(!el.className.baseVal) + el.className = className; + else + el.className.baseVal = className; +}; + var scrollTo = function(el) { querySelectorAllArray(".selected").forEach(function(s) { - s.classList.remove("selected"); + classListRemove(s, "selected"); }); - el.classList.add("selected"); + classListAdd(el, "selected"); window.scrollBy(0, el.getBoundingClientRect().top - (window.innerHeight / 2)); highlightArrowsForSelectedEvent(); -} +}; var move = function(num, up, numItems) { if (num == 1 && up || num == numItems - 1 && !up) { @@ -1332,9 +1349,11 @@ if (event.defaultPrevented) { return; } - if (event.key == "j") { + // key 'j' + if (event.keyCode == 74) { navigateTo(/*up=*/false); - } else if (event.key == "k") { + // key 'k' + } else if (event.keyCode == 75) { navigateTo(/*up=*/true); } else { return; @@ -1350,8 +1369,11 @@ <script type='text/javascript'> // Return range of numbers from a range [lower, upper). function range(lower, upper) { - const size = upper - lower; - return Array.from(new Array(size), (x, i) => i + lower); + var array = []; + for (var i = lower; i <= upper; ++i) { + array.push(i); + } + return array; } var getRelatedArrowIndices = function(pathId) { @@ -1371,7 +1393,9 @@ const arrowIndicesToHighlight = getRelatedArrowIndices(selectedNum); arrowIndicesToHighlight.forEach((index) => { var arrow = document.querySelector("#arrow" + index); - arrow.classList.add("selected"); + if(arrow) { + classListAdd(arrow, "selected") + } }); }
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -1289,15 +1289,32 @@ return out; }; +var classListAdd = function(el, theClass) { + if(!el.className.baseVal) + el.className += " " + theClass; + else + el.className.baseVal += " " + theClass; +}; + +var classListRemove = function(el, theClass) { + var className = (!el.className.baseVal) ? + el.className : el.className.baseVal; + className = className.replace(" " + theClass, ""); + if(!el.className.baseVal) + el.className = className; + else + el.className.baseVal = className; +}; + var scrollTo = function(el) { querySelectorAllArray(".selected").forEach(function(s) { - s.classList.remove("selected"); + classListRemove(s, "selected"); }); - el.classList.add("selected"); + classListAdd(el, "selected"); window.scrollBy(0, el.getBoundingClientRect().top - (window.innerHeight / 2)); highlightArrowsForSelectedEvent(); -} +}; var move = function(num, up, numItems) { if (num == 1 && up || num == numItems - 1 && !up) { @@ -1332,9 +1349,11 @@ if (event.defaultPrevented) { return; } - if (event.key == "j") { + // key 'j' + if (event.keyCode == 74) { navigateTo(/*up=*/false); - } else if (event.key == "k") { + // key 'k' + } else if (event.keyCode == 75) { navigateTo(/*up=*/true); } else { return; @@ -1350,8 +1369,11 @@ <script type='text/javascript'> // Return range of numbers from a range [lower, upper). function range(lower, upper) { - const size = upper - lower; - return Array.from(new Array(size), (x, i) => i + lower); + var array = []; + for (var i = lower; i <= upper; ++i) { + array.push(i); + } + return array; } var getRelatedArrowIndices = function(pathId) { @@ -1371,7 +1393,9 @@ const arrowIndicesToHighlight = getRelatedArrowIndices(selectedNum); arrowIndicesToHighlight.forEach((index) => { var arrow = document.querySelector("#arrow" + index); - arrow.classList.add("selected"); + if(arrow) { + classListAdd(arrow, "selected") + } }); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits