nsIAccessibleText 编辑

accessible/public/nsIAccessibleText.idlScriptable Please add a summary to this article. Inherits from: nsISupports Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

Method overview

void addSelection(in long startOffset, in long endOffset);
nsIAccessible getAttributeRange(in long offset, out long rangeStartOffset, out long rangeEndOffset); Obsolete since Gecko 1.9.1
wchar getCharacterAtOffset(in long offset);
void getCharacterExtents(in long offset, out long x, out long y, out long width, out long height, in unsigned long coordType);
long getOffsetAtPoint(in long x, in long y, in unsigned long coordType);
void getRangeExtents(in long startOffset, in long endOffset, out long x, out long y, out long width, out long height, in unsigned long coordType);
void getSelectionBounds(in long selectionNum, out long startOffset, out long endOffset);
AString getText(in long startOffset, in long endOffset);
AString getTextAfterOffset(in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset);
AString getTextAtOffset(in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset);
nsIPersistentProperties getTextAttributes(in boolean includeDefAttrs, in long offset, out long rangeStartOffset, out long rangeEndOffset);
AString getTextBeforeOffset(in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset);
void removeSelection(in long selectionNum);
void scrollSubstringTo(in long startIndex, in long endIndex, in unsigned long scrollType);
void scrollSubstringToPoint(in long startIndex, in long endIndex, in unsigned long coordinateType, in long x, in long y);
void setSelectionBounds(in long selectionNum, in long startOffset, in long endOffset);

Attributes

AttributeTypeDescription
caretOffsetlongThe current current caret offset. If set < 0 then caret will be placed at the end of the text.
characterCountlongRead only.
defaultTextAttributesnsIPersistentPropertiesReturn the text attributes that apply to the entire accessible. Read only.
selectionCountlongRead only.

Constants

Text Offset Constants

ConstantValueDescription
TEXT_OFFSET_END_OF_TEXT-1Will be treated as the equal to the end of the text.
TEXT_OFFSET_CARET-2Will be treated as the caret position.

Text Boundary Constants

ConstantValueDescription
BOUNDARY_CHAR0 
BOUNDARY_WORD_START1 
BOUNDARY_WORD_END2 
BOUNDARY_SENTENCE_START3Do not use in new code.
BOUNDARY_SENTENCE_END4Do not use in new code.
BOUNDARY_LINE_START5 
BOUNDARY_LINE_END6 
BOUNDARY_ATTRIBUTE_RANGE7 

Coordinate Type Constants

Obsolete since Gecko 1.9 (Firefox 3)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

ConstantValueDescription
COORD_TYPE_SCREEN0 
COORD_TYPE_WINDOW1 

Methods

addSelection()

void addSelection(
  in long startOffset,
  in long endOffset
);
Parameters
startOffset
endOffset

getAttributeRange()

Obsolete since Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

Get the accessible and start/end offsets around the given offset. This accessible get return the DOM node and layout frame with the uniform attributes for this range of text.

nsIAccessible getAttributeRange(
  in long offset,
  out long rangeStartOffset,
  out long rangeEndOffset
);
Parameters
offset
rangeStartOffset
rangeEndOffset
Return value

 

getCharacterAtOffset()

It would be better to return an unsigned long here, to allow unicode chars > 16 bits.

wchar getCharacterAtOffset(
  in long offset
);
Parameters
offset
Return value

 

getCharacterExtents()

Returns the bounding box of the specified position.

The virtual character after the last character of the represented text, that is the one at position length is a special case. It represents the current input position and will therefore typically be queried by AT more often than other positions. Because it does not represent an existing character its bounding box is defined in relation to preceding characters. It should be roughly equivalent to the bounding box of some character when inserted at the end of the text. Its height typically being the maximal height of all the characters in the text or the height of the preceding character, its width being at least one pixel so that the bounding box is not degenerate.

void getCharacterExtents(
  in long offset,
  out long x,
  out long y,
  out long width,
  out long height,
  in unsigned long coordType
);
Parameters
offset
Index of the character for which to return its bounding box. The valid range is 0..length.
x
X coordinate of the bounding box of the referenced character.
y
Y coordinate of the bounding box of the referenced character.
width
Width of the bounding box of the referenced character.
height
Height of the bounding box of the referenced character.
coordType
Specifies if the coordinates are relative to the screen or to the parent window (see constants declared in nsIAccessibleCoordinateType.Constants).

getOffsetAtPoint()

Get the text offset at the given point, or return -1 if no character exists at that point.

long getOffsetAtPoint(
  in long x,
  in long y,
  in unsigned long coordType
);
Parameters
x
The position's x value for which to look up the index of the character that is rendered on to the display at that point.
y
The position's y value for which to look up the index of the character that is rendered on to the display at that point.
coordType
Screen coordinates or window coordinates (see constants declared in nsIAccessibleCoordinateType).
Return value

Offset - Index of the character under the given point or -1 if the point is invalid or there is no character under the point.

getRangeExtents()

The virtual character after the last character of the represented text, that is the one at position length is a special case. It represents the current input position and will therefore typically be queried by AT more often than other positions. Because it does not represent an existing character its bounding box is defined in relation to preceding characters. It should be roughly equivalent to the bounding box of some character when inserted at the end of the text. Its height typically being the maximal height of all the characters in the text or the height of the preceding character, its width being at least one pixel so that the bounding box is not degenerate.

void getRangeExtents(
  in long startOffset,
  in long endOffset,
  out long x,
  out long y,
  out long width,
  out long height,
  in unsigned long coordType
);
Parameters
startOffset
Index of the character for which to return its bounding box. The valid range is 0..length.
endOffset
Index of the character for which to return its bounding box. The valid range is 0..length.
x
X coordinate of the bounding box of the referenced character.
y
Y coordinate of the bounding box of the referenced character.
width
Width of the bounding box of the referenced character.
height
Height of the bounding box of the referenced character.
coordType
Specifies if the coordinates are relative to the screen or to the parent window (see constants declared in nsIAccessibleCoordinateType.Constants.

getSelectionBounds()

void getSelectionBounds(
  in long selectionNum,
  out long startOffset,
  out long endOffset
);
Parameters
selectionNum
startOffset
endOffset

getText()

String methods may need to return multibyte-encoded strings, since some locales can not be encoded using 16-bit chars. So this method might return UTF-16 strings, or it could return "string" values which are UTF-8.

AString getText(
  in long startOffset,
  in long endOffset
);
Parameters
startOffset
endOffset
Return value

 

getTextAfterOffset()

String methods may need to return multibyte-encoded strings, since some locales can't be encoded using 16-bit chars. So this method might return UTF-16 strings, or it could return "string" values which are UTF-8.

AString getTextAfterOffset(
  in long offset,
  in nsAccessibleTextBoundary boundaryType,
  out long startOffset,
  out long endOffset
);
Parameters
offset
boundaryType
startOffset
endOffset
Return value

 

getTextAtOffset()

String methods may need to return multibyte-encoded strings, since some locales can't be encoded using 16-bit chars. So this method might return UTF-16 strings, or it could return "string" values which are UTF-8.

AString getTextAtOffset(
  in long offset,
  in nsAccessibleTextBoundary boundaryType,
  out long startOffset,
  out long endOffset
);
Parameters
offset
boundaryType
startOffset
endOffset
Return value

 

getTextAttributes()

Get the accessible start/end offsets around the given offset, return the text attributes for this range of text.

nsIPersistentProperties getTextAttributes(
  in boolean includeDefAttrs,
  in long offset,
  out long rangeStartOffset,
  out long rangeEndOffset
);
Parameters
includeDefAttrs
Points whether text attributes applied to the entire accessible should be included or not.
offset
Text offset.
rangeStartOffset
Start offset of the range of text.
rangeEndOffset
End offset of the range of text.
Return value

 

Exceptions thrown
Missing Exception

getTextBeforeOffset()

String methods may need to return multibyte-encoded strings, since some locales can't be encoded using 16-bit chars. So this method might return UTF-16 strings, or it could return "string" values which are UTF-8.

AString getTextBeforeOffset(
  in long offset,
  in nsAccessibleTextBoundary boundaryType,
  out long startOffset,
  out long endOffset
);
Parameters
offset
boundaryType
startOffset
endOffset
Return value

 

removeSelection()

void removeSelection(
  in long selectionNum
);
Parameters
selectionNum

scrollSubstringTo()

Makes a specific part of string visible on screen.

void scrollSubstringTo(
  in long startIndex,
  in long endIndex,
  in unsigned long scrollType
);
Parameters
startIndex
0-based character offset.
endIndex
0-based character offset - the offset of the character just past the last character of the string.
scrollType
Defines how to scroll (see nsIAccessibleScrollType.Constants for available constants)

scrollSubstringToPoint()

Moves the top left of a substring to a specified location.

void scrollSubstringToPoint(
  in long startIndex,
  in long endIndex,
  in unsigned long coordinateType,
  in long x,
  in long y
);
Parameters
startIndex
0-based character offset.
endIndex
0-based character offset - the offset of the character just past the last character of the string.
coordinateType
Specifies the coordinates origin (for available constants refer to nsIAccessibleCoordinateType.Constants)
x
Defines the x coordinate.
y
Defines the y coordinate.

setSelectionBounds()

Set the bounds for the given selection range.

void setSelectionBounds(
  in long selectionNum,
  in long startOffset,
  in long endOffset
);
Parameters
selectionNum
startOffset
endOffset

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:105 次

字数:21058

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文