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

Unified Diff: ui/accessibility/extensions/longdesc/lastRightClick.js

Issue 593293002: Initial checkin of accessibility extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix license issues Created 6 years, 3 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/longdesc/icon.png ('k') | ui/accessibility/extensions/longdesc/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/extensions/longdesc/lastRightClick.js
diff --git a/ui/accessibility/extensions/longdesc/lastRightClick.js b/ui/accessibility/extensions/longdesc/lastRightClick.js
new file mode 100644
index 0000000000000000000000000000000000000000..42566b9ad30d4231c96cd4a905f105a3429fbbb6
--- /dev/null
+++ b/ui/accessibility/extensions/longdesc/lastRightClick.js
@@ -0,0 +1,96 @@
+/* Copyright (c) 2014 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+var borderColor;
+var borderStyle;
+var borderWidth;
+
+chrome.storage.onChanged.addListener(function(changes, namespace) {
+ if (changes.addBorder.newValue) {
+ addBorders();
+ } else {
+ removeBorders();
+ }
+});
+
+chrome.storage.sync.get("addBorder", function(item) {
+ if (item.addBorder) {
+ addBorders();
+ }
+});
+
+document.addEventListener('contextmenu', function(element) {
+ updateContextMenuItem(element);
+}, false);
+
+document.addEventListener('mouseover', function(element) {
+ updateContextMenuItem(element);
+}, false);
+
+document.addEventListener('focus', function(element) {
+ updateContextMenuItem(element);
+});
+
+/**
+ * Sends a message to the backgrond script notifying it to
+ * enable or disable the context menu item.
+ *
+ * @param element
+ */
+function updateContextMenuItem(element) {
+ var longDesc = '';
+ var ariaDescribedAt = '';
+
+ if (element.target.hasAttribute("longdesc")) {
+ longDesc = element.target.getAttribute("longdesc");
+ }
+
+ if (element.target.hasAttribute("aria-describedat")) {
+ ariaDescribedAt = element.target.getAttribute("aria-describedat");
+ }
+
+ if (longDesc !== '' || ariaDescribedAt !== '') {
+ chrome.runtime.sendMessage({
+ ariaDescribedAt: ariaDescribedAt,
+ longDesc: longDesc,
+ enabled: true
+ });
+ } else {
+ chrome.runtime.sendMessage({
+ enabled: false
+ });
+ }
+}
+
+/**
+ * Modify border to make the HTML element more visible.
+ */
+function addBorders() {
+ var elementArray = new Array(document.querySelectorAll('[longdesc]'));
+ elementArray.concat(new Array(document.querySelectorAll('[aria-describedat]')));
+
+ for (var i = 0; i < elementArray.length; i++) {
+ borderColor = elementArray[0][i].style.borderColor;
+ borderStyle = elementArray[0][i].style.borderStyle;
+ borderWidth = elementArray[0][i].style.borderWidth;
+
+ elementArray[0][i].style.borderColor = 'blue';
+ elementArray[0][i].style.borderStyle = 'groove';
+ elementArray[0][i].style.borderWidth = '15px';
+ }
+}
+
+/**
+ * Revert back to the original border styling.
+ */
+function removeBorders() {
+ var elementArray = new Array(document.querySelectorAll('[longdesc]'));
+ elementArray.concat(new Array(document.querySelectorAll('[aria-describedat]')));
+
+ for (var i = 0; i < elementArray.length; i++) {
+ elementArray[0][i].style.borderColor = borderColor;
+ elementArray[0][i].style.borderStyle = borderStyle;
+ elementArray[0][i].style.borderWidth = borderWidth;
+ }
+}
« no previous file with comments | « ui/accessibility/extensions/longdesc/icon.png ('k') | ui/accessibility/extensions/longdesc/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698