summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-01-25 11:39:07 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-01-25 15:20:42 +0000
commit6c91641271e536ffaa88a1dff5127e42ee99a91e (patch)
tree703d9dd49602377ddc90cbf886aad37913f2496b /chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js
parentb145b7fafd36f0c260d6a768c81fc14e32578099 (diff)
downloadqtwebengine-chromium-6c91641271e536ffaa88a1dff5127e42ee99a91e.tar.gz
BASELINE: Update Chromium to 49.0.2623.23
Also adds missing printing sources. Change-Id: I3726b8f0c7d6751c9fc846096c571fadca7108cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js')
-rw-r--r--chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js90
1 files changed, 0 insertions, 90 deletions
diff --git a/chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js b/chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js
deleted file mode 100644
index 606000b3e48..00000000000
--- a/chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_util.js
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 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.
-
-/**
- * @fileoverview Shared util methods between api.js and api_implementation.js
- * for doing common tasks such as passing node references between page script
- * and ChromeVox.
- */
-
-if (typeof(goog) != 'undefined' && goog.provide){
- goog.provide('cvox.ApiUtil');
-}
-
-
-if (!window['cvox']) {
- window['cvox'] = {};
-}
-
-/**
- * @constructor
- */
-cvox.ApiUtils = function() {
-};
-
-/**
- * The next id to use for the cvoxid attribute that we add to elements
- * in order to be able to find them from the content script.
- * @type {number}
- */
-cvox.ApiUtils.nextCvoxId_ = 1;
-
-/**
- * Makes a serializable reference to a node.
- * If the node or its parent has an ID, reference it directly. Otherwise,
- * add a temporary cvoxid attribute. This has a corresponding method in
- * api_implementation.js to decode this and return a node.
- * @param {Node} targetNode The node to reference.
- * @return {Object} A serializable node reference.
- */
-cvox.ApiUtils.makeNodeReference = function(targetNode) {
- if (targetNode.id && document.getElementById(targetNode.id) == targetNode) {
- return {'id': targetNode.id};
- } else if (targetNode instanceof HTMLElement) {
- var cvoxid = cvox.ApiUtils.nextCvoxId_;
- targetNode.setAttribute('cvoxid', cvoxid);
- cvox.ApiUtils.nextCvoxId_ = (cvox.ApiUtils.nextCvoxId_ + 1) % 100;
- return {'cvoxid': cvoxid};
- } else if (targetNode.parentElement) {
- var parent = targetNode.parentElement;
- var childIndex = -1;
- for (var i = 0; i < parent.childNodes.length; i++) {
- if (parent.childNodes[i] == targetNode) {
- childIndex = i;
- break;
- }
- }
- if (childIndex >= 0) {
- var cvoxid = cvox.ApiUtils.nextCvoxId_;
- parent.setAttribute('cvoxid', cvoxid);
- cvox.ApiUtils.nextCvoxId_ = (cvox.ApiUtils.nextCvoxId_ + 1) % 100;
- return {'cvoxid': cvoxid, 'childIndex': childIndex};
- }
- }
- throw 'Cannot reference node: ' + targetNode;
-};
-
-/**
- * Retrieves a node from its serializable node reference.
- *
- * @param {Object} nodeRef A serializable reference to a node.
- * @return {Node} The node on the page that this object refers to.
- */
-cvox.ApiUtils.getNodeFromRef = function(nodeRef) {
- if (nodeRef['id']) {
- return document.getElementById(nodeRef['id']);
- } else if (nodeRef['cvoxid']) {
- var selector = '*[cvoxid="' + nodeRef['cvoxid'] + '"]';
- var element = document.querySelector(selector);
- if (element && element.removeAttribute) {
- element.removeAttribute('cvoxid');
- }
- if (nodeRef['childIndex'] != null) {
- return element.childNodes[nodeRef['childIndex']];
- } else {
- return element;
- }
- }
- throw 'Bad node reference: ' + cvox.ChromeVoxJSON.stringify(nodeRef);
-};