зеркало из https://github.com/mozilla/pjs.git
Bug 418368 - Create tests for NSIAccessibleHyperlink interface p=marco.zehe@googlemail.com (Marco Zehe) r=surkov.alexander@gmail.com (Alexander Surkov) a=beltzner@mozilla.com (Mike Beltzner)
This commit is contained in:
Родитель
cabc56f12c
Коммит
b7b83370fd
|
@ -43,19 +43,73 @@
|
|||
interface nsIURI;
|
||||
interface nsIAccessible;
|
||||
|
||||
[scriptable, uuid(a492c7d6-1dd1-11b2-9bc0-80614884799a)]
|
||||
/**
|
||||
* A cross-platform interface that supports hyperlink-specific properties and
|
||||
* methods. Anchors, image maps, xul:labels with class="text-link" implement this interface.
|
||||
*/
|
||||
[scriptable, uuid(fe1dd8c0-d50a-4634-b51d-2b20bfb1e231)]
|
||||
interface nsIAccessibleHyperLink : nsISupports
|
||||
{
|
||||
readonly attribute long anchors;
|
||||
/**
|
||||
* Returns the offset of the link within the parent accessible.
|
||||
*/
|
||||
readonly attribute long startIndex;
|
||||
|
||||
/**
|
||||
* Returns the end index of the link within the parent accessible.
|
||||
*
|
||||
* @note The link itself is represented by one embedded character within the
|
||||
* parent text, so the endIndex should be startIndex + 1.
|
||||
*/
|
||||
readonly attribute long endIndex;
|
||||
|
||||
nsIURI getURI (in long i);
|
||||
/**
|
||||
* Determines whether the link is valid (e. g. points to a valid URL).
|
||||
*
|
||||
* @note XXX Currently only used with ARIA links, and the author has to
|
||||
* specify that the link is invalid via the aria-invalid="true" attribute.
|
||||
* In all other cases, TRUE is returned.
|
||||
*/
|
||||
readonly attribute boolean valid;
|
||||
|
||||
nsIAccessible getObject (in long i);
|
||||
/**
|
||||
* Determines whether the element currently has the focus, e. g. after
|
||||
* returning from the destination page.
|
||||
*
|
||||
* @note ARIA links can only be focused if they have the tabindex
|
||||
* attribute set. Also, state_focused should then be set on the accessible
|
||||
* for this link.
|
||||
*/
|
||||
readonly attribute boolean selected;
|
||||
|
||||
boolean isValid ();
|
||||
boolean isSelected ();
|
||||
/**
|
||||
* The numbber of anchors within this Hyperlink. Is normally 1 for anchors.
|
||||
* This anchor is, for example, the visible output of the html:a tag.
|
||||
* With an Image Map, reflects the actual areas within the map.
|
||||
*/
|
||||
readonly attribute long anchorsCount;
|
||||
|
||||
/**
|
||||
* Returns the URI at the given index.
|
||||
*
|
||||
* @note ARIA hyperlinks do not have an URI to point to, since clicks are
|
||||
* processed via JavaScript. Therefore this property does not work on ARIA
|
||||
* links.
|
||||
*
|
||||
* @param index The 0-based index of the URI to be returned.
|
||||
*
|
||||
* @return the nsIURI object containing the specifications for the URI.
|
||||
*/
|
||||
nsIURI getURI (in long index);
|
||||
|
||||
/**
|
||||
* Returns a reference to the object at the given index.
|
||||
*
|
||||
* @param index The 0-based index whose object is to be returned.
|
||||
*
|
||||
* @return the nsIAccessible object at the desired index.
|
||||
*/
|
||||
nsIAccessible getAnchor (in long index);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -236,7 +236,7 @@ getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
|
|||
NS_ENSURE_TRUE(accHyperlink, nsnull);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accObj;
|
||||
accHyperlink->GetObject(aLinkIndex, getter_AddRefs(accObj));
|
||||
accHyperlink->GetAnchor(aLinkIndex, getter_AddRefs(accObj));
|
||||
NS_ENSURE_TRUE(accObj, nsnull);
|
||||
|
||||
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accObj);
|
||||
|
@ -275,7 +275,7 @@ isValidCB(AtkHyperlink *aLink)
|
|||
NS_ENSURE_TRUE(accHyperlink, FALSE);
|
||||
|
||||
PRBool isValid = PR_FALSE;
|
||||
nsresult rv = accHyperlink->IsValid(&isValid);
|
||||
nsresult rv = accHyperlink->GetValid(&isValid);
|
||||
return (NS_FAILED(rv)) ? FALSE : static_cast<gboolean>(isValid);
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ getAnchorCountCB(AtkHyperlink *aLink)
|
|||
NS_ENSURE_TRUE(accHyperlink, -1);
|
||||
|
||||
PRInt32 count = -1;
|
||||
nsresult rv = accHyperlink->GetAnchors(&count);
|
||||
nsresult rv = accHyperlink->GetAnchorsCount(&count);
|
||||
return (NS_FAILED(rv)) ? -1 : static_cast<gint>(count);
|
||||
}
|
||||
|
||||
|
|
|
@ -3210,33 +3210,45 @@ NS_IMETHODIMP nsAccessible::SelectAllSelection(PRBool *_retval)
|
|||
// nsIAccessibleHyperLink, which helps determine where it is located
|
||||
// within containing text
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetAnchors(PRInt32 *aAnchors)
|
||||
// readonly attribute long nsIAccessibleHyperLink::anchorsCount
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetAnchorsCount(PRInt32 *aAnchorsCount)
|
||||
{
|
||||
*aAnchors = 1;
|
||||
NS_ENSURE_ARG_POINTER(aAnchorsCount);
|
||||
*aAnchorsCount = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetStartIndex(PRInt32 *aStartIndex)
|
||||
// readonly attribute long nsIAccessibleHyperLink::startIndex
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetStartIndex(PRInt32 *aStartIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStartIndex);
|
||||
*aStartIndex = 0;
|
||||
PRInt32 endIndex;
|
||||
return GetLinkOffset(aStartIndex, &endIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetEndIndex(PRInt32 *aEndIndex)
|
||||
// readonly attribute long nsIAccessibleHyperLink::endIndex
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetEndIndex(PRInt32 *aEndIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEndIndex);
|
||||
*aEndIndex = 0;
|
||||
PRInt32 startIndex;
|
||||
return GetLinkOffset(&startIndex, aEndIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetURI(PRInt32 i, nsIURI **aURI)
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetURI(PRInt32 i, nsIURI **aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
*aURI = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetObject(PRInt32 aIndex,
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetAnchor(PRInt32 aIndex,
|
||||
nsIAccessible **aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
|
@ -3250,21 +3262,26 @@ NS_IMETHODIMP nsAccessible::GetObject(PRInt32 aIndex,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIAccessibleHyperLink::IsValid()
|
||||
NS_IMETHODIMP nsAccessible::IsValid(PRBool *aIsValid)
|
||||
// readonly attribute boolean nsIAccessibleHyperLink::valid
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetValid(PRBool *aValid)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValid);
|
||||
PRUint32 state = State(this);
|
||||
*aIsValid = (0 == (state & nsIAccessibleStates::STATE_INVALID));
|
||||
*aValid = (0 == (state & nsIAccessibleStates::STATE_INVALID));
|
||||
// XXX In order to implement this we would need to follow every link
|
||||
// Perhaps we can get information about invalid links from the cache
|
||||
// In the mean time authors can use role="link" aria_invalid="true"
|
||||
// In the mean time authors can use role="link" aria-invalid="true"
|
||||
// to force it for links they internally know to be invalid
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::IsSelected(PRBool *aIsSelected)
|
||||
// readonly attribute boolean nsIAccessibleHyperLink::selected
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetSelected(PRBool *aSelected)
|
||||
{
|
||||
*aIsSelected = (gLastFocusedNode == mDOMNode);
|
||||
NS_ENSURE_ARG_POINTER(aSelected);
|
||||
*aSelected = (gLastFocusedNode == mDOMNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,12 +226,12 @@ NS_IMETHODIMP nsHTMLImageAccessible::DoAction(PRUint8 index)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAccessibleHyperLink
|
||||
NS_IMETHODIMP
|
||||
nsHTMLImageAccessible::GetAnchors(PRInt32 *aAnchors)
|
||||
nsHTMLImageAccessible::GetAnchorsCount(PRInt32 *aAnchors)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAnchors);
|
||||
|
||||
if (!mMapElement)
|
||||
return nsLinkableAccessible::GetAnchors(aAnchors);
|
||||
return nsLinkableAccessible::GetAnchorsCount(aAnchors);
|
||||
|
||||
return GetChildCount(aAnchors);
|
||||
}
|
||||
|
@ -262,13 +262,13 @@ nsHTMLImageAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLImageAccessible::GetObject(PRInt32 aIndex, nsIAccessible **aAccessible)
|
||||
nsHTMLImageAccessible::GetAnchor(PRInt32 aIndex, nsIAccessible **aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
*aAccessible = nsnull;
|
||||
|
||||
if (!mMapElement)
|
||||
return nsLinkableAccessible::GetObject(aIndex, aAccessible);
|
||||
return nsLinkableAccessible::GetAnchor(aIndex, aAccessible);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
|
||||
if (mapAreas) {
|
||||
|
|
|
@ -67,9 +67,9 @@ public:
|
|||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
|
||||
// nsIAccessibleHyperLink
|
||||
NS_IMETHOD GetAnchors(PRInt32 *aAnchors);
|
||||
NS_IMETHOD GetAnchorsCount(PRInt32 *aAnchors);
|
||||
NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI);
|
||||
NS_IMETHOD GetObject(PRInt32 aIndex, nsIAccessible **aAccessible);
|
||||
NS_IMETHOD GetAnchor(PRInt32 aIndex, nsIAccessible **aAccessible);
|
||||
|
||||
// nsPIAccessNode
|
||||
NS_IMETHOD Shutdown();
|
||||
|
|
|
@ -87,7 +87,7 @@ __try {
|
|||
return E_FAIL;
|
||||
|
||||
nsCOMPtr<nsIAccessible> anchor;
|
||||
nsresult rv = acc->GetObject(aIndex, getter_AddRefs(anchor));
|
||||
nsresult rv = acc->GetAnchor(aIndex, getter_AddRefs(anchor));
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
|
@ -202,7 +202,7 @@ __try {
|
|||
return E_FAIL;
|
||||
|
||||
PRBool isValid = PR_FALSE;
|
||||
nsresult rv = acc->IsValid(&isValid);
|
||||
nsresult rv = acc->GetValid(&isValid);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ _TEST_FILES =\
|
|||
test_nsIAccessibleTable_3.html \
|
||||
test_nsIAccessibleTable_4.html \
|
||||
test_nsIAccessibleTable_listboxes.xul \
|
||||
test_nsIAccessibleHyperlink.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
Загрузка…
Ссылка в новой задаче