diff --git a/accessible/public/nsIAccessibleText.idl b/accessible/public/nsIAccessibleText.idl index 9928481b456..879421d945c 100644 --- a/accessible/public/nsIAccessibleText.idl +++ b/accessible/public/nsIAccessibleText.idl @@ -42,11 +42,10 @@ #include "nsISupports.idl" typedef long nsAccessibleTextBoundary; -typedef long nsAccessibleCoordType; interface nsIAccessible; -[scriptable, uuid(80e64909-e96b-45e9-81c9-3521a2dea7bb)] +[scriptable, uuid(17389a66-5cc5-4550-80e0-49e7b63990a4)] interface nsIAccessibleText : nsISupports { const nsAccessibleTextBoundary BOUNDARY_CHAR = 0; @@ -58,9 +57,6 @@ interface nsIAccessibleText : nsISupports const nsAccessibleTextBoundary BOUNDARY_LINE_END = 6; const nsAccessibleTextBoundary BOUNDARY_ATTRIBUTE_RANGE = 7; - const nsAccessibleCoordType COORD_TYPE_SCREEN = 0; - const nsAccessibleCoordType COORD_TYPE_WINDOW = 1; - attribute long caretOffset; readonly attribute long characterCount; @@ -104,12 +100,36 @@ interface nsIAccessibleText : nsISupports out long rangeStartOffset, out long rangeEndOffset); + /** + * Returns the bounding box of the specified position. + * + * The virtual character after the last character of the represented text, + * i.e. 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. + * + * @param offset - Index of the character for which to return its bounding + * box. The valid range is 0..length. + * @param x - X coordinate of the bounding box of the referenced character. + * @param y - Y coordinate of the bounding box of the referenced character. + * @param width - Width of the bounding box of the referenced character. + * @param height - Height of the bounding box of the referenced character. + * @param coordType - Specifies if the coordinates are relative to the screen + * or to the parent window (see constants declared in + * nsIAccessibleCoordinateType). + */ void getCharacterExtents (in long offset, out long x, out long y, out long width, out long height, - in nsAccessibleCoordType coordType); + in unsigned long coordType); void getRangeExtents (in long startOffset, in long endOffset, @@ -117,14 +137,24 @@ interface nsIAccessibleText : nsISupports out long y, out long width, out long height, - in nsAccessibleCoordType coordType); + in unsigned long coordType); /** * Get the text offset at the given point, or return -1 * if no character exists at that point + * + * @param 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. + * @param 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. + * @param coordType - Screen coordinates or window coordinates (see constants + * declared in nsIAccessibleCoordinateType). + * @return offset - Index of the character under the given point or -1 if + * the point is invalid or there is no character under + * the point. */ long getOffsetAtPoint (in long x, in long y, - in nsAccessibleCoordType coordType); + in unsigned long coordType); void getSelectionBounds (in long selectionNum, out long startOffset, diff --git a/accessible/public/nsIAccessibleTypes.idl b/accessible/public/nsIAccessibleTypes.idl index 0a1d3149436..be4ac5a9e51 100755 --- a/accessible/public/nsIAccessibleTypes.idl +++ b/accessible/public/nsIAccessibleTypes.idl @@ -87,7 +87,7 @@ interface nsIAccessibleScrollType : nsISupports * These constants define which coordinate system a point is located in. Note, * keep them synchronized with IA2CoordinateType. */ -[scriptable, uuid(15a523bb-fb3b-4cb2-af87-ad26ea792c4c)] +[scriptable, uuid(c9fbdf10-619e-436f-bf4b-8566686f1577)] interface nsIAccessibleCoordinateType : nsISupports { /** @@ -95,9 +95,14 @@ interface nsIAccessibleCoordinateType : nsISupports */ const unsigned long COORDTYPE_SCREEN_RELATIVE = 0x00; + /** + * The coordinates are relative to the window. + */ + const unsigned long COORDTYPE_WINDOW_RELATIVE = 0x01; + /** * The coordinates are relative to the upper left corner of the bounding box * of the immediate parent. */ - const unsigned long COORDTYPE_PARENT_RELATIVE = 0x01; + const unsigned long COORDTYPE_PARENT_RELATIVE = 0x02; }; diff --git a/accessible/src/atk/nsMaiInterfaceText.cpp b/accessible/src/atk/nsMaiInterfaceText.cpp index 9bbc3c72fcb..c314012b2b3 100644 --- a/accessible/src/atk/nsMaiInterfaceText.cpp +++ b/accessible/src/atk/nsMaiInterfaceText.cpp @@ -284,9 +284,14 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset, PRInt32 extY = 0, extX = 0; PRInt32 extWidth = 0, extHeight = 0; + + PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ? + nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE : + nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE; + nsresult rv = accText->GetCharacterExtents(aOffset, &extX, &extY, &extWidth, &extHeight, - aCoords); + geckoCoordType); *aX = extX; *aY = extY; *aWidth = extWidth; @@ -311,10 +316,15 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset, PRInt32 extY = 0, extX = 0; PRInt32 extWidth = 0, extHeight = 0; + + PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ? + nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE : + nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE; + nsresult rv = accText->GetRangeExtents(aStartOffset, aEndOffset, &extX, &extY, &extWidth, &extHeight, - aCoords); + geckoCoordType); aRect->x = extX; aRect->y = extY; aRect->width = extWidth; @@ -353,7 +363,11 @@ getOffsetAtPointCB(AtkText *aText, NS_ENSURE_TRUE(accText, -1); PRInt32 offset = 0; - accText->GetOffsetAtPoint(aX, aY, aCoords, &offset); + PRUint32 geckoCoordType = (aCoords == ATK_XY_SCREEN) ? + nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE : + nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE; + + accText->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset); return NS_STATIC_CAST(gint, offset); } diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index f9921a82f7d..c115f474f1f 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -855,7 +855,7 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute */ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterExtents(PRInt32 aOffset, PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight, - nsAccessibleCoordType aCoordType) + PRUint32 aCoordType) { return GetRangeExtents(aOffset, aOffset + 1, aX, aY, aWidth, aHeight, aCoordType); } @@ -866,7 +866,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterExtents(PRInt32 aOffset, PRInt3 NS_IMETHODIMP nsHyperTextAccessible::GetRangeExtents(PRInt32 aStartOffset, PRInt32 aEndOffset, PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight, - nsAccessibleCoordType aCoordType) + PRUint32 aCoordType) { nsIntRect boundsRect; nsIFrame *endFrameUnused; @@ -879,7 +879,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetRangeExtents(PRInt32 aStartOffset, PRInt *aWidth = boundsRect.width; *aHeight = boundsRect.height; - if (aCoordType == COORD_TYPE_WINDOW) { + if (aCoordType == nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE) { //co-ord type = window nsCOMPtr shell = GetPresShell(); NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); @@ -911,7 +911,9 @@ NS_IMETHODIMP nsHyperTextAccessible::GetRangeExtents(PRInt32 aStartOffset, PRInt * Gets the offset of the character located at coordinates x and y. x and y are interpreted as being relative to * the screen or this widget's window depending on coords. */ -NS_IMETHODIMP nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, nsAccessibleCoordType aCoordType, PRInt32 *aOffset) +NS_IMETHODIMP +nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, + PRUint32 aCoordType, PRInt32 *aOffset) { *aOffset = -1; nsCOMPtr shell = GetPresShell(); @@ -924,7 +926,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, ns } nsIntRect frameScreenRect = hyperFrame->GetScreenRectExternal(); - if (aCoordType == COORD_TYPE_WINDOW) { + if (aCoordType == nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE) { nsCOMPtr doc = shell->GetDocument(); nsCOMPtr docView(do_QueryInterface(doc)); NS_ENSURE_TRUE(docView, NS_ERROR_FAILURE);