get deepEquivalent() {
    var newNode = this.node;
    var newIndex = this.index_;
    while (newNode.firstChild) {
      if (newNode.role == RoleType.STATIC_TEXT) {
        // Text offset.
        // Re-interpret the index as an offset into an inlineTextBox.
        var target = newNode.firstChild;
        var length = 0;
        while (target && length < newIndex) {
          var newLength = length + target.name.length;

          // Either |newIndex| falls between target's text or |newIndex| is the
          // total length of all sibling text content.
          if ((length <= newIndex && newIndex < newLength) ||
              (newIndex == newLength && !target.nextSibling))
            break;
          length = newLength;
          target = target.nextSibling;
        }
        if (target) {
          newNode = target;
          newIndex = newIndex - length;
        }
        break;
      } else if (
          newNode.role != RoleType.TEXT_FIELD &&
          newNode.role != RoleType.INLINE_TEXT_BOX &&
          newNode.children[newIndex]) {
        // Valid node offset.
        newNode = newNode.children[newIndex];
        newIndex = 0;
      } else {
        // This offset is a text offset into the descendant visible
        // text. Approximate this by indexing into the inline text boxes.
        var lines = newNode.findAll({role: RoleType.INLINE_TEXT_BOX});
        if (!lines.length)
          break;

        var targetLine, targetIndex = 0;
        for (var i = 0, line, cur = 0; line = lines[i]; i++) {
          cur += line.name.length;
          if (cur > newIndex) {
            targetLine = line;
            targetIndex = newIndex - (cur - line.name.length);
            break;
          }
        }
        if (!targetLine) {
          // If we got here, that means the index is actually beyond the total
          // length of text. Just get the last line.
          targetLine = lines[lines.length - 1];
          targetIndex = targetLine.name.length;
        }
        newNode = targetLine;
        newIndex = targetIndex;
        break;
      }
    }

    return new cursors.Cursor(newNode, newIndex);
  }
/**
   * Returns the deepest equivalent cursor.
   * @return {cursors.Cursor}
   */
Returns the deepest equivalent cursor.
Returns the deepest equivalent cursor .
get deepEquivalent() {
    var newNode = this.node;
    var newIndex = this.index_;
    while (newNode.firstChild) {
      if (newNode.role == RoleType.STATIC_TEXT) {
        var target = newNode.firstChild;
        var length = 0;
        while (target && length < newIndex) {
          var newLength = length + target.name.length;
          if ((length <= newIndex && newIndex < newLength) ||
              (newIndex == newLength && !target.nextSibling))
            break;
          length = newLength;
          target = target.nextSibling;
        }
        if (target) {
          newNode = target;
          newIndex = newIndex - length;
        }
        break;
      } else if (
          newNode.role != RoleType.TEXT_FIELD &&
          newNode.role != RoleType.INLINE_TEXT_BOX &&
          newNode.children[newIndex]) {
        newNode = newNode.children[newIndex];
        newIndex = 0;
      } else {
        var lines = newNode.findAll({role: RoleType.INLINE_TEXT_BOX});
        if (!lines.length)
          break;
        var targetLine, targetIndex = 0;
        for (var i = 0, line, cur = 0; line = lines[i]; i++) {
          cur += line.name.length;
          if (cur > newIndex) {
            targetLine = line;
            targetIndex = newIndex - (cur - line.name.length);
            break;
          }
        }
        if (!targetLine) {
          targetLine = lines[lines.length - 1];
          targetIndex = targetLine.name.length;
        }
        newNode = targetLine;
        newIndex = targetIndex;
        break;
      }
    }
    return new cursors.Cursor(newNode, newIndex);
  }
get deepEquivalent ( ) { var newNode = this . node ; var newIndex = this . index_ ; while ( newNode . firstChild ) { if ( newNode . role == RoleType . STATIC_TEXT ) { var target = newNode . firstChild ; var length = 0 ; while ( target && length < newIndex ) { var newLength = length + target . name . length ; if ( ( length <= newIndex && newIndex < newLength ) || ( newIndex == newLength && ! target . nextSibling ) ) break ; length = newLength ; target = target . nextSibling ; } if ( target ) { newNode = target ; newIndex = newIndex - length ; } break ; } else if ( newNode . role != RoleType . TEXT_FIELD && newNode . role != RoleType . INLINE_TEXT_BOX && newNode . children [ newIndex ] ) { newNode = newNode . children [ newIndex ] ; newIndex = 0 ; } else { var lines = newNode . findAll ( { role : RoleType . INLINE_TEXT_BOX } ) ; if ( ! lines . length ) break ; var targetLine , targetIndex = 0 ; for ( var i = 0 , line , cur = 0 ; line = lines [ i ] ; i ++ ) { cur += line . name . length ; if ( cur > newIndex ) { targetLine = line ; targetIndex = newIndex - ( cur - line . name . length ) ; break ; } } if ( ! targetLine ) { targetLine = lines [ lines . length - 1 ] ; targetIndex = targetLine . name . length ; } newNode = targetLine ; newIndex = targetIndex ; break ; } } return new cursors . Cursor ( newNode , newIndex ) ; }
Returns the deepest equivalent cursor.
Returns the deepest equivalent cursor .
// Text offset. // Re-interpret the index as an offset into an inlineTextBox. // Either |newIndex| falls between target's text or |newIndex| is the // total length of all sibling text content. // Valid node offset. // This offset is a text offset into the descendant visible // text. Approximate this by indexing into the inline text boxes. // If we got here, that means the index is actually beyond the total // length of text. Just get the last line.