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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Processes events related to editing text and emits the 6 * @fileoverview Processes events related to editing text and emits the
7 * appropriate spoken and braille feedback. 7 * appropriate spoken and braille feedback.
8 */ 8 */
9 9
10 goog.provide('editing.TextEditHandler'); 10 goog.provide('editing.TextEditHandler');
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 /** @private {!Cursor} */ 541 /** @private {!Cursor} */
542 this.end_ = new Cursor(endNode, endIndex); 542 this.end_ = new Cursor(endNode, endIndex);
543 this.end_ = this.end_.deepEquivalent || this.end_; 543 this.end_ = this.end_.deepEquivalent || this.end_;
544 /** @private {number} */ 544 /** @private {number} */
545 this.localContainerStartOffset_ = startIndex; 545 this.localContainerStartOffset_ = startIndex;
546 546
547 // Computed members. 547 // Computed members.
548 /** @private {Spannable} */ 548 /** @private {Spannable} */
549 this.value_; 549 this.value_;
550 /** @private {AutomationNode} */ 550 /** @private {AutomationNode|undefined} */
551 this.lineStart_; 551 this.lineStart_;
552 /** @private {AutomationNode} */ 552 /** @private {AutomationNode|undefined} */
553 this.lineEnd_; 553 this.lineEnd_;
554 /** @private {AutomationNode|undefined} */ 554 /** @private {AutomationNode|undefined} */
555 this.startContainer_; 555 this.startContainer_;
556 /** @private {AutomationNode|undefined} */ 556 /** @private {AutomationNode|undefined} */
557 this.lineStartContainer_; 557 this.lineStartContainer_;
558 /** @private {number} */ 558 /** @private {number} */
559 this.localLineStartContainerOffset_ = 0; 559 this.localLineStartContainerOffset_ = 0;
560 /** @private {AutomationNode|undefined} */ 560 /** @private {AutomationNode|undefined} */
561 this.lineEndContainer_; 561 this.lineEndContainer_;
562 /** @private {number} */ 562 /** @private {number} */
(...skipping 23 matching lines...) Expand all
586 // Initialize defaults. 586 // Initialize defaults.
587 this.lineStart_ = lineBase.node; 587 this.lineStart_ = lineBase.node;
588 this.lineEnd_ = this.lineStart_; 588 this.lineEnd_ = this.lineStart_;
589 this.startContainer_ = this.lineStart_.parent; 589 this.startContainer_ = this.lineStart_.parent;
590 this.lineStartContainer_ = this.lineStart_.parent; 590 this.lineStartContainer_ = this.lineStart_.parent;
591 this.lineEndContainer_ = this.lineStart_.parent; 591 this.lineEndContainer_ = this.lineStart_.parent;
592 592
593 // Annotate each chunk with its associated inline text box node. 593 // Annotate each chunk with its associated inline text box node.
594 this.value_.setSpan(this.lineStart_, 0, nameLen); 594 this.value_.setSpan(this.lineStart_, 0, nameLen);
595 595
596 // If the current selection is not on an inline text box (e.g. an image), 596 // Also, track the nodes necessary for selection (either their parents, in
597 // return early here so that the line contents are just the node. This is 597 // the case of inline text boxes, or the node itself).
598 // pending the ability to show non-text leaf inline objects.
599 if (this.lineStart_.role != RoleType.INLINE_TEXT_BOX)
600 return;
601
602 // Also, track their static text parents.
603 var parents = [this.startContainer_]; 598 var parents = [this.startContainer_];
604 599
605 // Compute the start of line. 600 // Compute the start of line.
606 var lineStart = this.lineStart_; 601 var lineStart = this.lineStart_;
607 while (lineStart.previousOnLine && lineStart.previousOnLine.role) { 602
608 lineStart = lineStart.previousOnLine; 603 // Hack: note underlying bugs require these hacks.
609 if (lineStart.role != RoleType.INLINE_TEXT_BOX) 604 while ((lineStart.previousOnLine && lineStart.previousOnLine.role) ||
610 continue; 605 (lineStart.previousSibling && lineStart.previousSibling.lastChild &&
606 lineStart.previousSibling.lastChild.nextOnLine == lineStart)) {
607 if (lineStart.previousOnLine)
608 lineStart = lineStart.previousOnLine;
609 else
610 lineStart = lineStart.previousSibling.lastChild;
611 611
612 this.lineStart_ = lineStart; 612 this.lineStart_ = lineStart;
613 if (parents[0] != lineStart.parent) 613
614 if (lineStart.role != RoleType.INLINE_TEXT_BOX)
615 parents.unshift(lineStart);
616 else if (parents[0] != lineStart.parent)
614 parents.unshift(lineStart.parent); 617 parents.unshift(lineStart.parent);
615 618
616 var prepend = new Spannable(lineStart.name, lineStart); 619 var prepend = new Spannable(lineStart.name, lineStart);
617 prepend.append(this.value_); 620 prepend.append(this.value_);
618 this.value_ = prepend; 621 this.value_ = prepend;
619 } 622 }
620 this.lineStartContainer_ = this.lineStart_.parent; 623 this.lineStartContainer_ = this.lineStart_.parent;
621 624
622 var lineEnd = this.lineEnd_; 625 var lineEnd = this.lineEnd_;
623 while (lineEnd.nextOnLine && lineEnd.nextOnLine.role) { 626
624 lineEnd = lineEnd.nextOnLine; 627 // Hack: note underlying bugs require these hacks.
625 if (lineEnd.role != RoleType.INLINE_TEXT_BOX) 628 while ((lineEnd.nextOnLine && lineEnd.nextOnLine.role) ||
626 continue; 629 (lineEnd.nextSibling &&
630 lineEnd.nextSibling.previousOnLine == lineEnd)) {
631 if (lineEnd.nextOnLine)
632 lineEnd = lineEnd.nextOnLine;
633 else
634 lineEnd = lineEnd.nextSibling.firstChild;
627 635
628 this.lineEnd_ = lineEnd; 636 this.lineEnd_ = lineEnd;
629 if (parents[parents.length - 1] != lineEnd.parent) 637
638 if (lineEnd.role != RoleType.INLINE_TEXT_BOX)
639 parents.push(this.lineEnd_);
640 else if (parents[parents.length - 1] != lineEnd.parent)
630 parents.push(this.lineEnd_.parent); 641 parents.push(this.lineEnd_.parent);
631 642
632 var annotation = lineEnd; 643 var annotation = lineEnd;
633 if (lineEnd == this.end_.node) 644 if (lineEnd == this.end_.node)
634 annotation = this.end_; 645 annotation = this.end_;
635 646
636 this.value_.append(new Spannable(lineEnd.name, annotation)); 647 this.value_.append(new Spannable(lineEnd.name, annotation));
637 } 648 }
638 this.lineEndContainer_ = this.lineEnd_.parent; 649 this.lineEndContainer_ = this.lineEnd_.parent;
639 650
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 * @return {boolean} 812 * @return {boolean}
802 */ 813 */
803 isSameLineAndSelection: function(otherLine) { 814 isSameLineAndSelection: function(otherLine) {
804 return this.isSameLine(otherLine) && 815 return this.isSameLine(otherLine) &&
805 this.startOffset == otherLine.startOffset && 816 this.startOffset == otherLine.startOffset &&
806 this.endOffset == otherLine.endOffset; 817 this.endOffset == otherLine.endOffset;
807 } 818 }
808 }; 819 };
809 820
810 }); 821 });
OLDNEW
« 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