mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 160153. Accessibility: Report fully expanded URL's. r=jgaunt, sr=jst
This commit is contained in:
parent
b78133bb8e
commit
0f8d4f1827
@ -559,9 +559,9 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccess
|
||||
//There is a "use map"
|
||||
*_retval = new nsHTMLImageMapAccessible(node, weakShell);
|
||||
}
|
||||
else
|
||||
*_retval = new nsHTMLImageAccessible(node, weakShell);
|
||||
}
|
||||
else
|
||||
*_retval = new nsHTMLImageAccessible(node, weakShell);
|
||||
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1217,7 +1217,8 @@ NS_IMETHODIMP nsAccessible::AppendStringWithSpaces(nsAString *aFlatString, const
|
||||
{
|
||||
// Insert spaces to insure that words from controls aren't jammed together
|
||||
if (!textEquivalent.IsEmpty()) {
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
if (!aFlatString->IsEmpty())
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
aFlatString->Append(textEquivalent);
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
@ -1243,6 +1244,7 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
|
||||
elt->GetAttribute(NS_LITERAL_STRING("value"), textEquivalent); // Prefer value over tooltiptext
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("tooltiptext"), textEquivalent);
|
||||
textEquivalent.CompressWhitespace();
|
||||
return AppendStringWithSpaces(aFlatString, textEquivalent);
|
||||
}
|
||||
|
||||
@ -1272,16 +1274,18 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (display->IsBlockLevel() || display->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
isHTMLBlock = PR_TRUE;
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
if (!aFlatString->IsEmpty())
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsAutoString text;
|
||||
textContent->CopyText(text);
|
||||
text.CompressWhitespace();
|
||||
if (text.Length()>0)
|
||||
aFlatString->Append(text);
|
||||
if (isHTMLBlock)
|
||||
if (isHTMLBlock && !aFlatString->IsEmpty())
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
return NS_OK;
|
||||
@ -1289,7 +1293,7 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBRElement> brElement(do_QueryInterface(aContent));
|
||||
if (brElement) { // If it's a line break, insert a space so that words aren't jammed together
|
||||
aFlatString->Append(NS_LITERAL_STRING(" "));
|
||||
aFlatString->Append(NS_LITERAL_STRING("\r\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1307,10 +1311,18 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
|
||||
elt->GetAttribute(NS_LITERAL_STRING("alt"), textEquivalent);
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), textEquivalent);
|
||||
if (imageContent) {
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
nsCOMPtr<nsIDOMNode> imageNode(do_QueryInterface(aContent));
|
||||
if (imageNode && presShell)
|
||||
presShell->GetImageLocation(imageNode, textEquivalent);
|
||||
}
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("src"), textEquivalent);
|
||||
|
||||
if (textEquivalent.IsEmpty())
|
||||
elt->GetAttribute(NS_LITERAL_STRING("data"), textEquivalent); // for <object>s with images
|
||||
textEquivalent.CompressWhitespace();
|
||||
return AppendStringWithSpaces(aFlatString, textEquivalent);
|
||||
}
|
||||
|
||||
@ -1319,6 +1331,25 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAccessible::AppendFlatStringFromSubtree(nsIContent *aContent, nsAString *aFlatString)
|
||||
{
|
||||
nsresult rv = AppendFlatStringFromSubtreeRecurse(aContent, aFlatString);
|
||||
if (NS_SUCCEEDED(rv) && !aFlatString->IsEmpty()) {
|
||||
nsAString::const_iterator start, end;
|
||||
aFlatString->BeginReading(start);
|
||||
aFlatString->EndReading(end);
|
||||
|
||||
PRInt32 spacesToTruncate = 0;
|
||||
while (-- end != start && *end == ' ')
|
||||
++ spacesToTruncate;
|
||||
|
||||
if (spacesToTruncate > 0)
|
||||
aFlatString->Truncate(aFlatString->Length() - spacesToTruncate);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAccessible::AppendFlatStringFromSubtreeRecurse(nsIContent *aContent, nsAString *aFlatString)
|
||||
{
|
||||
// Depth first search for all text nodes that are decendants of content node.
|
||||
// Append all the text into one flat string
|
||||
|
@ -111,11 +111,11 @@ protected:
|
||||
NS_IMETHOD CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList);
|
||||
// helper method to verify frames
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
static nsresult InitStringBundleService();
|
||||
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
|
||||
static nsresult GetTranslatedString(const nsAString& aKey, nsAString& aStringOut);
|
||||
void GetScrollOffset(nsRect *aRect);
|
||||
void GetScreenOrigin(nsIPresContext *aPresContext, nsIFrame *aFrame, nsRect *aRect);
|
||||
nsresult AppendFlatStringFromSubtreeRecurse(nsIContent *aContent, nsAString *aFlatString);
|
||||
|
||||
// Data Members
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
|
@ -274,9 +274,10 @@ NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsLinkableAccessible::GetAccValue(nsAString& _retval)
|
||||
{
|
||||
if (IsALink()) {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mLinkContent));
|
||||
if (elt)
|
||||
return elt->GetAttribute(NS_LITERAL_STRING("href"), _retval);
|
||||
nsCOMPtr<nsIDOMNode> linkNode(do_QueryInterface(mLinkContent));
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
if (linkNode && presShell)
|
||||
return presShell->GetLinkLocation(linkNode, _retval);
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -63,14 +63,7 @@ NS_IMETHODIMP nsHTMLLinkAccessible::GetAccName(nsAString& _retval)
|
||||
if (!IsALink()) // Also initializes private data members
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString name;
|
||||
nsresult rv = AppendFlatStringFromSubtree(mLinkContent, &name);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var needed until CompressWhitespace built for nsAString
|
||||
name.CompressWhitespace();
|
||||
_retval.Assign(name);
|
||||
}
|
||||
return rv;
|
||||
return AppendFlatStringFromSubtree(mLinkContent,&_retval);
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
@ -81,6 +74,14 @@ NS_IMETHODIMP nsHTMLLinkAccessible::GetAccRole(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
nsLinkableAccessible::GetAccState(_retval);
|
||||
*_retval &= ~(STATE_READONLY|STATE_SELECTABLE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long anchors; */
|
||||
NS_IMETHODIMP nsHTMLLinkAccessible::GetAnchors(PRInt32 *aAnchors)
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
nsHTMLLinkAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAString& _retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -47,5 +47,10 @@ nsTextAccessible(aDomNode, aShell)
|
||||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAString& _retval)
|
||||
{
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
nsAutoString accName;
|
||||
if (NS_FAILED(mDOMNode->GetNodeValue(accName)))
|
||||
return NS_ERROR_FAILURE;
|
||||
accName.CompressWhitespace();
|
||||
_retval = accName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -109,6 +109,7 @@
|
||||
#include "nsIXULDocument.h" // Temporary code for Bug 136185
|
||||
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIClipboardHelper.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
@ -5465,7 +5466,16 @@ NS_IMETHODIMP DocumentViewerImpl::CopyLinkLocation()
|
||||
// make noise if we're not in a link
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
return mPresShell->DoCopyLinkLocation(node);
|
||||
|
||||
nsAutoString locationText;
|
||||
rv = mPresShell->GetLinkLocation(node, locationText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(locationText);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentViewerImpl::CopyImageLocation()
|
||||
@ -5476,7 +5486,16 @@ NS_IMETHODIMP DocumentViewerImpl::CopyImageLocation()
|
||||
// make noise if we're not in an image
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
return mPresShell->DoCopyImageLocation(node);
|
||||
|
||||
nsAutoString locationText;
|
||||
rv = mPresShell->GetImageLocation(node, locationText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(locationText);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentViewerImpl::CopyImageContents()
|
||||
|
@ -109,6 +109,7 @@
|
||||
#include "nsIXULDocument.h" // Temporary code for Bug 136185
|
||||
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIClipboardHelper.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
@ -5465,7 +5466,16 @@ NS_IMETHODIMP DocumentViewerImpl::CopyLinkLocation()
|
||||
// make noise if we're not in a link
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
return mPresShell->DoCopyLinkLocation(node);
|
||||
|
||||
nsAutoString locationText;
|
||||
rv = mPresShell->GetLinkLocation(node, locationText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(locationText);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentViewerImpl::CopyImageLocation()
|
||||
@ -5476,7 +5486,16 @@ NS_IMETHODIMP DocumentViewerImpl::CopyImageLocation()
|
||||
// make noise if we're not in an image
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
return mPresShell->DoCopyImageLocation(node);
|
||||
|
||||
nsAutoString locationText;
|
||||
rv = mPresShell->GetImageLocation(node, locationText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(locationText);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentViewerImpl::CopyImageContents()
|
||||
|
@ -402,14 +402,18 @@ public:
|
||||
NS_IMETHOD DoCopy() = 0;
|
||||
|
||||
/**
|
||||
* Copy link location.
|
||||
* Get link location.
|
||||
*/
|
||||
NS_IMETHOD DoCopyLinkLocation(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
|
||||
|
||||
/**
|
||||
* Copy image methods.
|
||||
* Get image location.
|
||||
*/
|
||||
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
|
||||
|
||||
/**
|
||||
* Copy image.
|
||||
*/
|
||||
NS_IMETHOD DoCopyImageLocation(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode) = 0;
|
||||
|
||||
/**
|
||||
|
@ -1095,8 +1095,8 @@ public:
|
||||
NS_IMETHOD GetFrameManager(nsIFrameManager** aFrameManager) const;
|
||||
|
||||
NS_IMETHOD DoCopy();
|
||||
NS_IMETHOD DoCopyLinkLocation(nsIDOMNode* aNode);
|
||||
NS_IMETHOD DoCopyImageLocation(nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
|
||||
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString);
|
||||
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
|
||||
@ -4328,11 +4328,11 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// DoCopyLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
// GetLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: PresShell::DoCopyLinkLocation\n");
|
||||
printf("dr :: PresShell::GetLinkLocation\n");
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
@ -4397,27 +4397,23 @@ NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
}
|
||||
|
||||
if (anchor || area || link || xlinkType.Equals(NS_LITERAL_STRING("simple"))) {
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
//Remove all the '\t', '\r' and '\n' from 'anchorText'
|
||||
anchorText.StripChars(strippedChars);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(anchorText);
|
||||
aLocationString = anchorText;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if no link, fail.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// DoCopyImageLocation: copy image location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
||||
// GetImageLocation: copy image location to clipboard
|
||||
NS_IMETHODIMP PresShell::GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: PresShell::DoCopyImageLocation\n");
|
||||
printf("dr :: PresShell::GetImageLocation\n");
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
@ -4426,24 +4422,7 @@ NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
||||
// are we an image?
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (img) {
|
||||
// if so, get the src
|
||||
nsAutoString srcText;
|
||||
rv = img->GetSrc(srcText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the src onto the clipboard
|
||||
return clipboard->CopyString(srcText);
|
||||
}
|
||||
|
||||
// if no image, fail.
|
||||
return NS_ERROR_FAILURE;
|
||||
return img->GetSrc(aLocationString);
|
||||
}
|
||||
|
||||
// DoCopyImageContents: copy image contents to clipboard
|
||||
|
@ -402,14 +402,18 @@ public:
|
||||
NS_IMETHOD DoCopy() = 0;
|
||||
|
||||
/**
|
||||
* Copy link location.
|
||||
* Get link location.
|
||||
*/
|
||||
NS_IMETHOD DoCopyLinkLocation(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
|
||||
|
||||
/**
|
||||
* Copy image methods.
|
||||
* Get image location.
|
||||
*/
|
||||
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
|
||||
|
||||
/**
|
||||
* Copy image.
|
||||
*/
|
||||
NS_IMETHOD DoCopyImageLocation(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode) = 0;
|
||||
|
||||
/**
|
||||
|
@ -1095,8 +1095,8 @@ public:
|
||||
NS_IMETHOD GetFrameManager(nsIFrameManager** aFrameManager) const;
|
||||
|
||||
NS_IMETHOD DoCopy();
|
||||
NS_IMETHOD DoCopyLinkLocation(nsIDOMNode* aNode);
|
||||
NS_IMETHOD DoCopyImageLocation(nsIDOMNode* aNode);
|
||||
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
|
||||
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString);
|
||||
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
|
||||
@ -4328,11 +4328,11 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// DoCopyLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
// GetLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: PresShell::DoCopyLinkLocation\n");
|
||||
printf("dr :: PresShell::GetLinkLocation\n");
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
@ -4397,27 +4397,23 @@ NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
}
|
||||
|
||||
if (anchor || area || link || xlinkType.Equals(NS_LITERAL_STRING("simple"))) {
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
//Remove all the '\t', '\r' and '\n' from 'anchorText'
|
||||
anchorText.StripChars(strippedChars);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(anchorText);
|
||||
aLocationString = anchorText;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if no link, fail.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// DoCopyImageLocation: copy image location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
||||
// GetImageLocation: copy image location to clipboard
|
||||
NS_IMETHODIMP PresShell::GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: PresShell::DoCopyImageLocation\n");
|
||||
printf("dr :: PresShell::GetImageLocation\n");
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
@ -4426,24 +4422,7 @@ NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
||||
// are we an image?
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (img) {
|
||||
// if so, get the src
|
||||
nsAutoString srcText;
|
||||
rv = img->GetSrc(srcText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the src onto the clipboard
|
||||
return clipboard->CopyString(srcText);
|
||||
}
|
||||
|
||||
// if no image, fail.
|
||||
return NS_ERROR_FAILURE;
|
||||
return img->GetSrc(aLocationString);
|
||||
}
|
||||
|
||||
// DoCopyImageContents: copy image contents to clipboard
|
||||
|
Loading…
Reference in New Issue
Block a user