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

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

Issue 2965683002: Expand EditableLine to include non-inline text box leafs (Closed)
Patch Set: We want last child of previous sibling. 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 /** @private {!Cursor} */ 550 /** @private {!Cursor} */
551 this.end_ = new Cursor(endNode, endIndex); 551 this.end_ = new Cursor(endNode, endIndex);
552 this.end_ = this.end_.deepEquivalent || this.end_; 552 this.end_ = this.end_.deepEquivalent || this.end_;
553 /** @private {number} */ 553 /** @private {number} */
554 this.localContainerStartOffset_ = startIndex; 554 this.localContainerStartOffset_ = startIndex;
555 555
556 // Computed members. 556 // Computed members.
557 /** @private {Spannable} */ 557 /** @private {Spannable} */
558 this.value_; 558 this.value_;
559 /** @private {AutomationNode} */ 559 /** @private {AutomationNode|undefined} */
560 this.lineStart_; 560 this.lineStart_;
561 /** @private {AutomationNode} */ 561 /** @private {AutomationNode|undefined} */
562 this.lineEnd_; 562 this.lineEnd_;
563 /** @private {AutomationNode|undefined} */ 563 /** @private {AutomationNode|undefined} */
564 this.startContainer_; 564 this.startContainer_;
565 /** @private {AutomationNode|undefined} */ 565 /** @private {AutomationNode|undefined} */
566 this.lineStartContainer_; 566 this.lineStartContainer_;
567 /** @private {number} */ 567 /** @private {number} */
568 this.localLineStartContainerOffset_ = 0; 568 this.localLineStartContainerOffset_ = 0;
569 /** @private {AutomationNode|undefined} */ 569 /** @private {AutomationNode|undefined} */
570 this.lineEndContainer_; 570 this.lineEndContainer_;
571 /** @private {number} */ 571 /** @private {number} */
(...skipping 23 matching lines...) Expand all
595 // Initialize defaults. 595 // Initialize defaults.
596 this.lineStart_ = lineBase.node; 596 this.lineStart_ = lineBase.node;
597 this.lineEnd_ = this.lineStart_; 597 this.lineEnd_ = this.lineStart_;
598 this.startContainer_ = this.lineStart_.parent; 598 this.startContainer_ = this.lineStart_.parent;
599 this.lineStartContainer_ = this.lineStart_.parent; 599 this.lineStartContainer_ = this.lineStart_.parent;
600 this.lineEndContainer_ = this.lineStart_.parent; 600 this.lineEndContainer_ = this.lineStart_.parent;
601 601
602 // Annotate each chunk with its associated inline text box node. 602 // Annotate each chunk with its associated inline text box node.
603 this.value_.setSpan(this.lineStart_, 0, nameLen); 603 this.value_.setSpan(this.lineStart_, 0, nameLen);
604 604
605 // If the current selection is not on an inline text box (e.g. an image), 605 // Also, track the nodes necessary for selection (either their parents, in
606 // return early here so that the line contents are just the node. This is 606 // the case of inline text boxes, or the node itself).
607 // pending the ability to show non-text leaf inline objects.
608 if (this.lineStart_.role != RoleType.INLINE_TEXT_BOX)
609 return;
610
611 // Also, track their static text parents.
612 var parents = [this.startContainer_]; 607 var parents = [this.startContainer_];
613 608
614 // Compute the start of line. 609 // Compute the start of line.
615 var lineStart = this.lineStart_; 610 var lineStart = this.lineStart_;
616 while (lineStart.previousOnLine && lineStart.previousOnLine.role) { 611
617 lineStart = lineStart.previousOnLine; 612 // Hack: note underlying bugs require these hacks.
618 if (lineStart.role != RoleType.INLINE_TEXT_BOX) 613 while ((lineStart.previousOnLine && lineStart.previousOnLine.role) ||
619 continue; 614 (lineStart.previousSibling && lineStart.previousSibling.lastChild &&
615 lineStart.previousSibling.lastChild.nextOnLine == lineStart)) {
616 if (lineStart.previousOnLine)
617 lineStart = lineStart.previousOnLine;
618 else
619 lineStart = lineStart.previousSibling.lastChild;
620 620
621 this.lineStart_ = lineStart; 621 this.lineStart_ = lineStart;
622 if (parents[0] != lineStart.parent) 622
623 if (lineStart.role != RoleType.INLINE_TEXT_BOX)
624 parents.unshift(lineStart);
625 else if (parents[0] != lineStart.parent)
623 parents.unshift(lineStart.parent); 626 parents.unshift(lineStart.parent);
624 627
625 var prepend = new Spannable(lineStart.name, lineStart); 628 var prepend = new Spannable(lineStart.name, lineStart);
626 prepend.append(this.value_); 629 prepend.append(this.value_);
627 this.value_ = prepend; 630 this.value_ = prepend;
628 } 631 }
629 this.lineStartContainer_ = this.lineStart_.parent; 632 this.lineStartContainer_ = this.lineStart_.parent;
630 633
631 var lineEnd = this.lineEnd_; 634 var lineEnd = this.lineEnd_;
632 while (lineEnd.nextOnLine && lineEnd.nextOnLine.role) { 635
633 lineEnd = lineEnd.nextOnLine; 636 // Hack: note underlying bugs require these hacks.
634 if (lineEnd.role != RoleType.INLINE_TEXT_BOX) 637 while ((lineEnd.nextOnLine && lineEnd.nextOnLine.role) ||
635 continue; 638 (lineEnd.nextSibling &&
639 lineEnd.nextSibling.previousOnLine == lineEnd)) {
640 if (lineEnd.nextOnLine)
641 lineEnd = lineEnd.nextOnLine;
642 else
643 lineEnd = lineEnd.nextSibling.firstChild;
636 644
637 this.lineEnd_ = lineEnd; 645 this.lineEnd_ = lineEnd;
638 if (parents[parents.length - 1] != lineEnd.parent) 646
647 if (lineEnd.role != RoleType.INLINE_TEXT_BOX)
648 parents.push(this.lineEnd_);
649 else if (parents[parents.length - 1] != lineEnd.parent)
639 parents.push(this.lineEnd_.parent); 650 parents.push(this.lineEnd_.parent);
640 651
641 var annotation = lineEnd; 652 var annotation = lineEnd;
642 if (lineEnd == this.end_.node) 653 if (lineEnd == this.end_.node)
643 annotation = this.end_; 654 annotation = this.end_;
644 655
645 this.value_.append(new Spannable(lineEnd.name, annotation)); 656 this.value_.append(new Spannable(lineEnd.name, annotation));
646 } 657 }
647 this.lineEndContainer_ = this.lineEnd_.parent; 658 this.lineEndContainer_ = this.lineEnd_.parent;
648 659
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 * @return {boolean} 821 * @return {boolean}
811 */ 822 */
812 isSameLineAndSelection: function(otherLine) { 823 isSameLineAndSelection: function(otherLine) {
813 return this.isSameLine(otherLine) && 824 return this.isSameLine(otherLine) &&
814 this.startOffset == otherLine.startOffset && 825 this.startOffset == otherLine.startOffset &&
815 this.endOffset == otherLine.endOffset; 826 this.endOffset == otherLine.endOffset;
816 } 827 }
817 }; 828 };
818 829
819 }); 830 });
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