private int getStartOffset() {
      if (fromStart) return 0;
      TextRange range = getElementRange(startPointer);
      return range != null ? range.getStartOffset() : -1;
    }
private int getStartOffset()