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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js

Issue 2238613002: Support output for Chrome's native find in ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@text_markers
Patch Set: Created 4 years, 4 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
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js
new file mode 100644
index 0000000000000000000000000000000000000000..18d5a6c0597f60be694d1da34dd21fa02c129435
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js
@@ -0,0 +1,57 @@
+// Copyright 2016 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 Handles output for Chrome's built-in find.
+ */
+goog.provide('FindHandler');
+
+goog.require('Output');
+
+/**
+ * Responds to mode changes.
+ * @param {ChromeVoxMode} newMode
+ * @param {?ChromeVoxMode} oldMode Can be null at startup when no range was
+ * previously set.
+ */
+FindHandler.onModeChanged = function(newMode, oldMode) {
+ if (newMode == ChromeVoxMode.FORCE_NEXT)
+ FindHandler.init_();
+ else
+ FindHandler.uninit_();
+};
+
+/**
+ * Initializes this module.
+ * @private
+ */
+FindHandler.init_ = function() {
+ FindHandler.uninit_();
+ chrome.automation.addTreeChangeObserver(
+ 'textMarkerChanges', FindHandler.onTextMatch_);
+};
+
+/**
+ * Uninitializes this module.
+ * @private
+ */
+FindHandler.uninit_ = function() {
+ chrome.automation.removeTreeChangeObserver(FindHandler.onTextMatch_);
+};
+
+/**
+ * @param {Object} evt
+ * @private
+ */
+FindHandler.onTextMatch_ = function(evt) {
+ if (!evt.target.markerTypes.some(function(markerType) {
+ return markerType == 3 /* Text match */;
+ }))
+ return;
+
+ var range = cursors.Range.fromNode(evt.target);
dmazzoni 2016/08/10 22:12:10 Does this work if there are multiple matches?
+ ChromeVoxState.instance.setCurrentRange(range);
+ new Output()
+ .withRichSpeechAndBraille(range, null, Output.EventType.NAVIGATE)
+ .go();
+};

Powered by Google App Engine
This is Rietveld 408576698