Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Classes related to cursors that point to and select parts of | 6 * @fileoverview Classes related to cursors that point to and select parts of |
| 7 * the automation tree. | 7 * the automation tree. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('cursors.Cursor'); | 10 goog.provide('cursors.Cursor'); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Represents a position within the automation tree. | 70 * Represents a position within the automation tree. |
| 71 * @constructor | 71 * @constructor |
| 72 * @param {!AutomationNode} node | 72 * @param {!AutomationNode} node |
| 73 * @param {number} index A 0-based index into this cursor node's primary | 73 * @param {number} index A 0-based index into this cursor node's primary |
| 74 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole | 74 * accessible name. An index of |cursors.NODE_INDEX| means the node as a whole |
| 75 * is pointed to and covers the case where the accessible text is empty. | 75 * is pointed to and covers the case where the accessible text is empty. |
| 76 */ | 76 */ |
| 77 cursors.Cursor = function(node, index) { | 77 cursors.Cursor = function(node, index) { |
| 78 // Compensate for specific issues in Blink. | |
| 79 if (node.role == RoleType.STATIC_TEXT && node.name.length == index) { | |
| 80 // Re-interpret this case as the beginning of the next node. | |
| 81 var nextNode = AutomationUtil.findNextNode( | |
| 82 node, Dir.FORWARD, AutomationPredicate.leafOrStaticText); | |
| 83 | |
| 84 // The exception is when a user types at the end of a line. In that case, | |
| 85 // staying on the current node is appropriate. | |
| 86 if (nextNode && nextNode.nextOnLine) { | |
| 87 node = nextNode; | |
| 88 index = 0; | |
| 89 } | |
| 90 } else if (node.role == RoleType. | |
| 91 DIV && node.state.richlyEditable && | |
|
dmazzoni
2017/05/25 21:00:37
nit: very weird wrapping of DIV
Also, there's pro
David Tseng
2017/05/25 21:39:20
Done.
| |
| 92 (node.firstChild && | |
| 93 (node.firstChild.role == RoleType.LINE_BREAK || | |
| 94 node.firstChild.role == RoleType.STATIC_TEXT))) { | |
| 95 // Re-interpret this case as pointing to the text under the div. | |
| 96 node = node.find({ role: RoleType.INLINE_TEXT_BOX }) || node; | |
| 97 } | |
| 98 | |
| 78 /** @type {number} @private */ | 99 /** @type {number} @private */ |
| 79 this.index_ = index; | 100 this.index_ = index; |
| 80 /** @type {Array<AutomationNode>} @private */ | 101 /** @type {Array<AutomationNode>} @private */ |
| 81 this.ancestry_ = []; | 102 this.ancestry_ = []; |
| 82 var nodeWalker = node; | 103 var nodeWalker = node; |
| 83 while (nodeWalker) { | 104 while (nodeWalker) { |
| 84 this.ancestry_.push(nodeWalker); | 105 this.ancestry_.push(nodeWalker); |
| 85 nodeWalker = nodeWalker.parent; | 106 nodeWalker = nodeWalker.parent; |
| 86 if (nodeWalker && nodeWalker.role == RoleType.WINDOW) | 107 if (nodeWalker && nodeWalker.role == RoleType.WINDOW) |
| 87 break; | 108 break; |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 /** | 764 /** |
| 744 * Returns whether this range has valid start and end cursors. | 765 * Returns whether this range has valid start and end cursors. |
| 745 * @return {boolean} | 766 * @return {boolean} |
| 746 */ | 767 */ |
| 747 isValid: function() { | 768 isValid: function() { |
| 748 return this.start.isValid() && this.end.isValid(); | 769 return this.start.isValid() && this.end.isValid(); |
| 749 } | 770 } |
| 750 }; | 771 }; |
| 751 | 772 |
| 752 }); // goog.scope | 773 }); // goog.scope |
| OLD | NEW |