Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsMaiInterfaceHypertext.cpp File Reference
#include "nsMaiInterfaceHypertext.h"
#include "nsIAccessibleDocument.h"
#include "nsPIAccessNode.h"

Go to the source code of this file.

Functions

static G_BEGIN_DECLS void interfaceInitCB (AtkHypertextIface *aIface)
static AtkHyperlink * getLinkCB (AtkHypertext *aText, gint aLinkIndex)
static gint getLinkCountCB (AtkHypertext *aText)
static gint getLinkIndexCB (AtkHypertext *aText, gint aCharIndex)

Function Documentation

AtkHyperlink * getLinkCB ( AtkHypertext *  aText,
gint  aLinkIndex 
) [static]

Definition at line 113 of file nsMaiInterfaceHypertext.cpp.

{
    nsresult rv;
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, nsnull);

    MaiInterfaceHypertext *maiHypertext =
        NS_STATIC_CAST(MaiInterfaceHypertext *,
                       accWrap->GetMaiInterface(MAI_INTERFACE_HYPERTEXT));
    NS_ENSURE_TRUE(accWrap, nsnull);

    nsCOMPtr<nsIWeakReference> weakShell;
    rv = maiHypertext->GetWeakShell(getter_AddRefs(weakShell));
    NS_ENSURE_SUCCESS(rv, nsnull);

    nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
                            getter_AddRefs(accHyperlink));
    NS_ENSURE_TRUE(accHyperlink, nsnull);

    nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
    rv = accHyperlink->GetLink(aLinkIndex, getter_AddRefs(hyperLink));
    if (NS_FAILED(rv) || !hyperLink)
        return nsnull;

    // The MaiHyperlink and its nsIAccessibleHyperlink are in the same cache.
    // we take hyperlink->get() as Id for the MaiHyperlink.
    // release our ref to the previous one

    nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
        nsAccessNode::GetDocAccessibleFor(weakShell);
    if (!accessibleDoc) {
        NS_WARNING("No accessible document for this presshell");
        return nsnull;
    }
    nsCOMPtr<nsIAccessNode> maiNode;
    accessibleDoc->GetCachedAccessNode(NS_STATIC_CAST(void*, hyperLink.get()),
                                       getter_AddRefs(maiNode));
    // if the maiHyperlink is not in cache, create it.
    if (!maiNode) {
        maiNode = new MaiHyperlink(hyperLink, nsnull, weakShell);
        if (!maiNode) {
            NS_WARNING("OUT OF MEMORY");
            return nsnull;
        }
        nsCOMPtr<nsPIAccessNode> pMaiNode = do_QueryInterface(maiNode);
        pMaiNode->Init();  // add to cache.
    }

    // we can get AtkHyperlink from the MaiHyperlink
    nsIAccessNode *tmpNode = maiNode;
    MaiHyperlink *maiHyperlink = NS_STATIC_CAST(MaiHyperlink *, tmpNode);

    /* we should not addref the atkhyperlink because we are "get" not "ref" */
    return maiHyperlink->GetAtkHyperlink();
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint getLinkCountCB ( AtkHypertext *  aText) [static]

Definition at line 171 of file nsMaiInterfaceHypertext.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, -1);

    nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
                            getter_AddRefs(accHyperlink));
    NS_ENSURE_TRUE(accHyperlink, -1);

    PRInt32 count = -1;
    nsresult rv = accHyperlink->GetLinks(&count);
    NS_ENSURE_SUCCESS(rv, -1);

    return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint getLinkIndexCB ( AtkHypertext *  aText,
gint  aCharIndex 
) [static]

Definition at line 189 of file nsMaiInterfaceHypertext.cpp.

{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
    NS_ENSURE_TRUE(accWrap, -1);

    nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
                            getter_AddRefs(accHyperlink));
    NS_ENSURE_TRUE(accHyperlink, -1);

    PRInt32 index = -1;
    nsresult rv = accHyperlink->GetLinkIndex(aCharIndex, &index);
    NS_ENSURE_SUCCESS(rv, -1);

    return index;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void interfaceInitCB ( AtkHypertextIface *  aIface) [static]

Definition at line 103 of file nsMaiInterfaceHypertext.cpp.

{
    g_return_if_fail(aIface != NULL);

    aIface->get_link = getLinkCB;
    aIface->get_n_links = getLinkCountCB;
    aIface->get_link_index = getLinkIndexCB;
}

Here is the call graph for this function:

Here is the caller graph for this function: