Bug 343156 New ATK: expose new action for images, to open long description

in a new tab
patch by nian.liu at sun.com r=aaronleventhal sr=neil
This commit is contained in:
ginn.chen%sun.com 2006-07-31 05:21:46 +00:00
Родитель fc2834f355
Коммит 6950966214
2 изменённых файлов: 28 добавлений и 1 удалений

Просмотреть файл

@ -47,6 +47,9 @@
#include "nsIImageLoadingContent.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIDOMDocument.h"
#include "nsPIDOMWindow.h"
// --- image -----
@ -210,3 +213,26 @@ void nsHTMLImageAccessible::CacheChildren()
}
}
NS_IMETHODIMP nsHTMLImageAccessible::DoAction(PRUint8 index)
{
if (index == eAction_ShowLongDescription) {
//get the long description uri and open in a new window
nsCOMPtr<nsIDOMHTMLImageElement> element(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
nsAutoString longDesc;
nsresult rv = element->GetLongDesc(longDesc);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> domDocument;
rv = mDOMNode->GetOwnerDocument(getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(piWindow));
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> tmp;
return win->Open(longDesc, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""),
getter_AddRefs(tmp));
}
return nsLinkableAccessible::DoAction(index);
}

Просмотреть файл

@ -57,7 +57,8 @@ public:
nsHTMLImageAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetName(nsAString& _retval);
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetRole(PRUint32 *_retval);
NS_IMETHOD GetRole(PRUint32 *_retval);
NS_IMETHOD DoAction(PRUint8 index);
protected:
virtual void CacheChildren();