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

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

Issue 2263513004: Add support for rich output inside of content editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@editable_nav
Patch Set: Rebase. 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/editing.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
index 4d988b800c8c900b622593c4226cc21756f989f1..fc1e115d4c8725789c960281ca638f5860cf6276 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
@@ -21,7 +21,7 @@ goog.scope(function() {
var AutomationEvent = chrome.automation.AutomationEvent;
var AutomationNode = chrome.automation.AutomationNode;
var Cursor = cursors.Cursor;
-var Dir = AutomationUtil.Dir;
+var Dir = constants.Dir;
var EventType = chrome.automation.EventType;
var Range = cursors.Range;
var RoleType = chrome.automation.RoleType;
@@ -141,6 +141,20 @@ AutomationEditableText.prototype = {
},
/** @override */
+ describeLine: function(lineIndex, triggeredByUser) {
+ if (!this.node_.state.richlyEditable) {
+ cvox.ChromeVoxEditableTextBase.prototype.describeLine.call(
+ this, lineIndex, triggeredByUser);
+ return;
+ }
+ var line = this.getSelectedAutomationLine_();
+ if (line) {
+ new Output().withRichSpeech(line, null, Output.EventType.NAVIGATE)
+ .go();
+ }
+ },
+
+ /** @override */
getLineStart: function(lineIndex) {
if (!this.multiline || lineIndex == 0)
return 0;
@@ -178,9 +192,16 @@ AutomationEditableText.prototype = {
var range;
if (this.multiline) {
var lineIndex = this.getLineIndex(this.start);
- if (lineIndex == 0) {
- isFirstLine = true;
- output.formatForBraille('$name', this.node_);
+ if (this.node_.state.richlyEditable) {
+ range = this.getSelectedAutomationLine_();
+ } else {
+ if (lineIndex == 0) {
+ isFirstLine = true;
+ output.formatForBraille('$name', this.node_);
+ }
+ range = new Range(
+ new Cursor(this.node_, this.getLineStart(lineIndex)),
+ new Cursor(this.node_, this.getLineEnd(lineIndex)));
}
range = new Range(
new Cursor(this.node_, this.getLineStart(lineIndex)),
@@ -188,10 +209,26 @@ AutomationEditableText.prototype = {
} else {
range = Range.fromNode(this.node_);
}
- output.withBraille(range, null, Output.EventType.NAVIGATE);
+ if (range)
+ output.withBraille(range, null, Output.EventType.NAVIGATE);
if (isFirstLine)
output.formatForBraille('@tag_textarea');
output.go();
+ },
+
+ /**
+ * @return {Range}
+ * @private
+ */
+ getSelectedAutomationLine_: function() {
+ if (!this.node_.root.anchorObject || !this.node_.root.focusObject)
+ return null;
+
+ var start = Cursor.fromNode(this.node_.root.anchorObject);
+ start = start.move(Unit.LINE, Movement.BOUND, Dir.BACKWARD);
+ var end = Cursor.fromNode(this.node_.root.focusObject);
+ end = end.move(Unit.LINE, Movement.BOUND, Dir.FORWARD);
+ return new Range(start, end);
}
};

Powered by Google App Engine
This is Rietveld 408576698