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

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

Issue 2966973002: Reland: Expand EditableLine to include non-inline text box leafs (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/editing_test.extjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 71bfbbcd13fcef3181cd5b41107b4c0a7a9833f2..199e4065051218e14740693862f0c68e14530339 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
@@ -547,9 +547,9 @@ editing.EditableLine = function(
// Computed members.
/** @private {Spannable} */
this.value_;
- /** @private {AutomationNode} */
+ /** @private {AutomationNode|undefined} */
this.lineStart_;
- /** @private {AutomationNode} */
+ /** @private {AutomationNode|undefined} */
this.lineEnd_;
/** @private {AutomationNode|undefined} */
this.startContainer_;
@@ -593,24 +593,27 @@ editing.EditableLine.prototype = {
// Annotate each chunk with its associated inline text box node.
this.value_.setSpan(this.lineStart_, 0, nameLen);
- // If the current selection is not on an inline text box (e.g. an image),
- // return early here so that the line contents are just the node. This is
- // pending the ability to show non-text leaf inline objects.
- if (this.lineStart_.role != RoleType.INLINE_TEXT_BOX)
- return;
-
- // Also, track their static text parents.
+ // Also, track the nodes necessary for selection (either their parents, in
+ // the case of inline text boxes, or the node itself).
var parents = [this.startContainer_];
// Compute the start of line.
var lineStart = this.lineStart_;
- while (lineStart.previousOnLine && lineStart.previousOnLine.role) {
- lineStart = lineStart.previousOnLine;
- if (lineStart.role != RoleType.INLINE_TEXT_BOX)
- continue;
+
+ // Hack: note underlying bugs require these hacks.
+ while ((lineStart.previousOnLine && lineStart.previousOnLine.role) ||
+ (lineStart.previousSibling && lineStart.previousSibling.lastChild &&
+ lineStart.previousSibling.lastChild.nextOnLine == lineStart)) {
+ if (lineStart.previousOnLine)
+ lineStart = lineStart.previousOnLine;
+ else
+ lineStart = lineStart.previousSibling.lastChild;
this.lineStart_ = lineStart;
- if (parents[0] != lineStart.parent)
+
+ if (lineStart.role != RoleType.INLINE_TEXT_BOX)
+ parents.unshift(lineStart);
+ else if (parents[0] != lineStart.parent)
parents.unshift(lineStart.parent);
var prepend = new Spannable(lineStart.name, lineStart);
@@ -620,13 +623,21 @@ editing.EditableLine.prototype = {
this.lineStartContainer_ = this.lineStart_.parent;
var lineEnd = this.lineEnd_;
- while (lineEnd.nextOnLine && lineEnd.nextOnLine.role) {
- lineEnd = lineEnd.nextOnLine;
- if (lineEnd.role != RoleType.INLINE_TEXT_BOX)
- continue;
+
+ // Hack: note underlying bugs require these hacks.
+ while ((lineEnd.nextOnLine && lineEnd.nextOnLine.role) ||
+ (lineEnd.nextSibling &&
+ lineEnd.nextSibling.previousOnLine == lineEnd)) {
+ if (lineEnd.nextOnLine)
+ lineEnd = lineEnd.nextOnLine;
+ else
+ lineEnd = lineEnd.nextSibling.firstChild;
this.lineEnd_ = lineEnd;
- if (parents[parents.length - 1] != lineEnd.parent)
+
+ if (lineEnd.role != RoleType.INLINE_TEXT_BOX)
+ parents.push(this.lineEnd_);
+ else if (parents[parents.length - 1] != lineEnd.parent)
parents.push(this.lineEnd_.parent);
var annotation = lineEnd;
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/editing_test.extjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698