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

Unified Diff: ui/accessibility/extensions/colorenhancer/src/cvd.js

Issue 2771613002: Accessibility: Fix color enhancer disable option (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/accessibility/extensions/colorenhancer/res/cvd.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/extensions/colorenhancer/src/cvd.js
diff --git a/ui/accessibility/extensions/colorenhancer/src/cvd.js b/ui/accessibility/extensions/colorenhancer/src/cvd.js
index 1bf7daa6ca3dbfd3bc5a873f40a8cb0c220ed76c..59a92db368f4c80793d0fd34ad72818198c1e643 100644
--- a/ui/accessibility/extensions/colorenhancer/src/cvd.js
+++ b/ui/accessibility/extensions/colorenhancer/src/cvd.js
@@ -282,7 +282,6 @@
*/
function getEffectiveCvdMatrix(cvdType, severity, delta, simulate, enable) {
if (!enable) {
- //TODO(mustaq): we should remove matrices at the svg level
return IDENTITY_MATRIX_3x3;
}
@@ -352,9 +351,7 @@
var matrixElem = document.getElementById('cvd_matrix_' + next);
matrixElem.setAttribute('values', svgMatrixStringFrom3x3(matrix));
- var html = document.documentElement;
- html.classList.remove('filter' + curFilter);
- html.classList.add('filter' + next);
+ document.documentElement.setAttribute('cvd', next);
curFilter = next;
}
@@ -363,20 +360,24 @@
* Updates the SVG matrix using the current settings.
*/
function update() {
- if (!document.body) {
- document.addEventListener('DOMContentLoaded', update);
- return;
- }
+ if (curEnable) {
+ if (!document.body) {
+ document.addEventListener('DOMContentLoaded', update);
+ return;
+ }
- var effectiveMatrix = getEffectiveCvdMatrix(
- curType, curSeverity, curDelta * 2 - 1, curSimulate, curEnable);
+ var effectiveMatrix = getEffectiveCvdMatrix(
+ curType, curSeverity, curDelta * 2 - 1, curSimulate, curEnable);
- setFilter(effectiveMatrix);
+ setFilter(effectiveMatrix);
- // TODO(kevers): Check if a call to getComputedStyle is sufficient to force
- // an update.
- window.scrollBy(0, 1);
- window.scrollBy(0, -1);
+ if (window == window.top) {
+ window.scrollBy(0, 1);
+ window.scrollBy(0, -1);
+ }
+ } else {
+ clearFilter();
+ }
}
@@ -428,8 +429,17 @@
}
}
- if (changed)
+ if (changed) {
update();
+ }
+ }
+
+
+ /**
+ * Remove the filter from the page.
+ */
+ function clearFilter() {
+ document.documentElement.removeAttribute('cvd');
}
@@ -465,9 +475,7 @@
* Clears color correction filter.
*/
exports.clearColorEnhancementFilter = function() {
- var html = document.documentElement;
- html.classList.remove('filter0');
- html.classList.remove('filter1');
+ clearFilter();
};
})(this);
« no previous file with comments | « ui/accessibility/extensions/colorenhancer/res/cvd.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698