зеркало из https://github.com/mozilla/gecko-dev.git
Bug 757670 - make nsIPresShell::GetLinkLocation faster, r=bz, tbsaunde
This commit is contained in:
Родитель
d31a0461eb
Коммит
2a14b57426
|
@ -23,6 +23,7 @@
|
|||
#include "States.h"
|
||||
#include "StyleInfo.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -1679,13 +1680,8 @@ nsAccessible::Value(nsString& aValue)
|
|||
return;
|
||||
|
||||
// Check if it's a simple xlink.
|
||||
if (nsCoreUtils::IsXLink(mContent)) {
|
||||
nsIPresShell* presShell = mDoc->PresShell();
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
|
||||
presShell->GetLinkLocation(DOMNode, aValue);
|
||||
}
|
||||
}
|
||||
if (nsCoreUtils::IsXLink(mContent))
|
||||
nsContentUtils::GetLinkLocation(mContent->AsElement(), aValue);
|
||||
}
|
||||
|
||||
// nsIAccessibleValue
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
#include "nsHTMLLinkAccessible.h"
|
||||
|
||||
#include "nsCoreUtils.h"
|
||||
#include "nsDocAccessible.h"
|
||||
#include "Role.h"
|
||||
#include "States.h"
|
||||
|
||||
#include "nsDocAccessible.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
|
@ -77,12 +78,8 @@ nsHTMLLinkAccessible::Value(nsString& aValue)
|
|||
aValue.Truncate();
|
||||
|
||||
nsHyperTextAccessible::Value(aValue);
|
||||
if (!aValue.IsEmpty())
|
||||
return;
|
||||
|
||||
nsIPresShell* presShell(mDoc->PresShell());
|
||||
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
|
||||
presShell->GetLinkLocation(DOMNode, aValue);
|
||||
if (aValue.IsEmpty())
|
||||
nsContentUtils::GetLinkLocation(mContent->AsElement(), aValue);
|
||||
}
|
||||
|
||||
PRUint8
|
||||
|
|
|
@ -1388,6 +1388,12 @@ public:
|
|||
bool aClick, bool aIsUserTriggered,
|
||||
bool aIsTrusted);
|
||||
|
||||
/**
|
||||
* Get the link location.
|
||||
*/
|
||||
static void GetLinkLocation(mozilla::dom::Element* aElement,
|
||||
nsString& aLocationString);
|
||||
|
||||
/**
|
||||
* Return top-level widget in the parent chain.
|
||||
*/
|
||||
|
|
|
@ -116,6 +116,7 @@ protected:
|
|||
return !!uri;
|
||||
}
|
||||
|
||||
nsIURI* GetCachedURI() const { return mCachedURI; }
|
||||
bool HasCachedURI() const { return !!mCachedURI; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -4489,6 +4489,19 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsContentUtils::GetLinkLocation(Element* aElement, nsString& aLocationString)
|
||||
{
|
||||
nsCOMPtr<nsIURI> hrefURI = aElement->GetHrefURI();
|
||||
if (hrefURI) {
|
||||
nsCAutoString specUTF8;
|
||||
nsresult rv = hrefURI->GetSpec(specUTF8);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
CopyUTF8toUTF16(specUTF8, aLocationString);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsIWidget*
|
||||
nsContentUtils::GetTopLevelWidget(nsIWidget* aWidget)
|
||||
|
|
|
@ -413,6 +413,12 @@ nsHTMLAnchorElement::GetLinkState() const
|
|||
already_AddRefed<nsIURI>
|
||||
nsHTMLAnchorElement::GetHrefURI() const
|
||||
{
|
||||
nsIURI* uri = Link::GetCachedURI();
|
||||
if (uri) {
|
||||
NS_ADDREF(uri);
|
||||
return uri;
|
||||
}
|
||||
|
||||
return GetHrefURIForAnchors();
|
||||
}
|
||||
|
||||
|
|
|
@ -2536,10 +2536,15 @@ NS_IMETHODIMP DocumentViewerImpl::CopyLinkLocation()
|
|||
// make noise if we're not in a link
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString locationText;
|
||||
nsresult rv = mPresShell->GetLinkLocation(node, locationText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<dom::Element> elm(do_QueryInterface(node));
|
||||
NS_ENSURE_TRUE(elm, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString locationText;
|
||||
nsContentUtils::GetLinkLocation(elm, locationText);
|
||||
if (locationText.IsEmpty())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -112,10 +112,10 @@ typedef struct CapturingContentInfo {
|
|||
nsIContent* mContent;
|
||||
} CapturingContentInfo;
|
||||
|
||||
// d2236911-9b7c-490a-a08b-2580d5f7a6de
|
||||
// fcada634-fdea-45f5-b841-0a361d5f6a68
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xd2236911, 0x9b7c, 0x490a, \
|
||||
{ 0xa0, 0x8b, 0x25, 0x80, 0xd5, 0xf7, 0xa6, 0xde } }
|
||||
{ 0xfcada634, 0xfdea, 0x45f5, \
|
||||
{ 0xb8, 0x41, 0x0a, 0x36, 0x1d, 0x5f, 0x6a, 0x68 } }
|
||||
|
||||
// debug VerifyReflow flags
|
||||
#define VERIFY_REFLOW_ON 0x01
|
||||
|
@ -682,11 +682,6 @@ public:
|
|||
*/
|
||||
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
|
||||
|
||||
/**
|
||||
* Get link location.
|
||||
*/
|
||||
virtual NS_HIDDEN_(nsresult) GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) const = 0;
|
||||
|
||||
/**
|
||||
* Get the caret, if it exists. AddRefs it.
|
||||
*/
|
||||
|
|
|
@ -3335,38 +3335,6 @@ PresShell::GetRectVisibility(nsIFrame* aFrame,
|
|||
return nsRectVisibility_kVisible;
|
||||
}
|
||||
|
||||
// GetLinkLocation: copy link location to clipboard
|
||||
nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString) const
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: PresShell::GetLinkLocation\n");
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
if (content) {
|
||||
nsCOMPtr<nsIURI> hrefURI = content->GetHrefURI();
|
||||
if (hrefURI) {
|
||||
nsCAutoString specUTF8;
|
||||
nsresult rv = hrefURI->GetSpec(specUTF8);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString anchorText;
|
||||
CopyUTF8toUTF16(specUTF8, anchorText);
|
||||
|
||||
// Remove all the '\t', '\r' and '\n' from 'anchorText'
|
||||
static const char strippedChars[] = "\t\r\n";
|
||||
anchorText.StripChars(strippedChars);
|
||||
aLocationString = anchorText;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// if no link, fail.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::ScheduleViewManagerFlush()
|
||||
{
|
||||
|
|
|
@ -134,8 +134,6 @@ public:
|
|||
virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore);
|
||||
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString) const;
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, bool aLeavingPage);
|
||||
|
||||
virtual NS_HIDDEN_(void) UnsuppressPainting();
|
||||
|
|
Загрузка…
Ссылка в новой задаче