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

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: Don't forget to bit shift in SendTreeChanges (checking against cached overall tree filter). 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..5aa0a7c1dfad5ce532f786677f369b9cd3935a10
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/find_handler.js
@@ -0,0 +1,56 @@
+// 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() {
+ 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 & 4 /* Text match */;
+ }))
+ return;
+
+ var range = cursors.Range.fromNode(evt.target);
+ ChromeVoxState.instance.setCurrentRange(range);
+ new Output()
+ .withRichSpeechAndBraille(range, null, Output.EventType.NAVIGATE)
+ .go();
+};

Powered by Google App Engine
This is Rietveld 408576698