зеркало из 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 "States.h"
|
||||||
#include "StyleInfo.h"
|
#include "StyleInfo.h"
|
||||||
|
|
||||||
|
#include "nsContentUtils.h"
|
||||||
#include "nsIDOMCSSValue.h"
|
#include "nsIDOMCSSValue.h"
|
||||||
#include "nsIDOMCSSPrimitiveValue.h"
|
#include "nsIDOMCSSPrimitiveValue.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
|
@ -1679,13 +1680,8 @@ nsAccessible::Value(nsString& aValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if it's a simple xlink.
|
// Check if it's a simple xlink.
|
||||||
if (nsCoreUtils::IsXLink(mContent)) {
|
if (nsCoreUtils::IsXLink(mContent))
|
||||||
nsIPresShell* presShell = mDoc->PresShell();
|
nsContentUtils::GetLinkLocation(mContent->AsElement(), aValue);
|
||||||
if (presShell) {
|
|
||||||
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
|
|
||||||
presShell->GetLinkLocation(DOMNode, aValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIAccessibleValue
|
// nsIAccessibleValue
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
#include "nsHTMLLinkAccessible.h"
|
#include "nsHTMLLinkAccessible.h"
|
||||||
|
|
||||||
#include "nsCoreUtils.h"
|
#include "nsCoreUtils.h"
|
||||||
|
#include "nsDocAccessible.h"
|
||||||
#include "Role.h"
|
#include "Role.h"
|
||||||
#include "States.h"
|
#include "States.h"
|
||||||
|
|
||||||
#include "nsDocAccessible.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsEventStates.h"
|
#include "nsEventStates.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
|
|
||||||
|
@ -77,12 +78,8 @@ nsHTMLLinkAccessible::Value(nsString& aValue)
|
||||||
aValue.Truncate();
|
aValue.Truncate();
|
||||||
|
|
||||||
nsHyperTextAccessible::Value(aValue);
|
nsHyperTextAccessible::Value(aValue);
|
||||||
if (!aValue.IsEmpty())
|
if (aValue.IsEmpty())
|
||||||
return;
|
nsContentUtils::GetLinkLocation(mContent->AsElement(), aValue);
|
||||||
|
|
||||||
nsIPresShell* presShell(mDoc->PresShell());
|
|
||||||
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
|
|
||||||
presShell->GetLinkLocation(DOMNode, aValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint8
|
PRUint8
|
||||||
|
|
|
@ -1388,6 +1388,12 @@ public:
|
||||||
bool aClick, bool aIsUserTriggered,
|
bool aClick, bool aIsUserTriggered,
|
||||||
bool aIsTrusted);
|
bool aIsTrusted);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the link location.
|
||||||
|
*/
|
||||||
|
static void GetLinkLocation(mozilla::dom::Element* aElement,
|
||||||
|
nsString& aLocationString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return top-level widget in the parent chain.
|
* Return top-level widget in the parent chain.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -116,6 +116,7 @@ protected:
|
||||||
return !!uri;
|
return !!uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIURI* GetCachedURI() const { return mCachedURI; }
|
||||||
bool HasCachedURI() const { return !!mCachedURI; }
|
bool HasCachedURI() const { return !!mCachedURI; }
|
||||||
|
|
||||||
private:
|
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 */
|
/* static */
|
||||||
nsIWidget*
|
nsIWidget*
|
||||||
nsContentUtils::GetTopLevelWidget(nsIWidget* aWidget)
|
nsContentUtils::GetTopLevelWidget(nsIWidget* aWidget)
|
||||||
|
|
|
@ -413,6 +413,12 @@ nsHTMLAnchorElement::GetLinkState() const
|
||||||
already_AddRefed<nsIURI>
|
already_AddRefed<nsIURI>
|
||||||
nsHTMLAnchorElement::GetHrefURI() const
|
nsHTMLAnchorElement::GetHrefURI() const
|
||||||
{
|
{
|
||||||
|
nsIURI* uri = Link::GetCachedURI();
|
||||||
|
if (uri) {
|
||||||
|
NS_ADDREF(uri);
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
return GetHrefURIForAnchors();
|
return GetHrefURIForAnchors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2536,10 +2536,15 @@ NS_IMETHODIMP DocumentViewerImpl::CopyLinkLocation()
|
||||||
// make noise if we're not in a link
|
// make noise if we're not in a link
|
||||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
nsAutoString locationText;
|
nsCOMPtr<dom::Element> elm(do_QueryInterface(node));
|
||||||
nsresult rv = mPresShell->GetLinkLocation(node, locationText);
|
NS_ENSURE_TRUE(elm, NS_ERROR_FAILURE);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
|
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));
|
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
|
|
@ -112,10 +112,10 @@ typedef struct CapturingContentInfo {
|
||||||
nsIContent* mContent;
|
nsIContent* mContent;
|
||||||
} CapturingContentInfo;
|
} CapturingContentInfo;
|
||||||
|
|
||||||
// d2236911-9b7c-490a-a08b-2580d5f7a6de
|
// fcada634-fdea-45f5-b841-0a361d5f6a68
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0xd2236911, 0x9b7c, 0x490a, \
|
{ 0xfcada634, 0xfdea, 0x45f5, \
|
||||||
{ 0xa0, 0x8b, 0x25, 0x80, 0xd5, 0xf7, 0xa6, 0xde } }
|
{ 0xb8, 0x41, 0x0a, 0x36, 0x1d, 0x5f, 0x6a, 0x68 } }
|
||||||
|
|
||||||
// debug VerifyReflow flags
|
// debug VerifyReflow flags
|
||||||
#define VERIFY_REFLOW_ON 0x01
|
#define VERIFY_REFLOW_ON 0x01
|
||||||
|
@ -682,11 +682,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
|
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.
|
* Get the caret, if it exists. AddRefs it.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3335,38 +3335,6 @@ PresShell::GetRectVisibility(nsIFrame* aFrame,
|
||||||
return nsRectVisibility_kVisible;
|
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
|
void
|
||||||
PresShell::ScheduleViewManagerFlush()
|
PresShell::ScheduleViewManagerFlush()
|
||||||
{
|
{
|
||||||
|
|
|
@ -134,8 +134,6 @@ public:
|
||||||
virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore);
|
virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore);
|
||||||
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
|
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_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, bool aLeavingPage);
|
||||||
|
|
||||||
virtual NS_HIDDEN_(void) UnsuppressPainting();
|
virtual NS_HIDDEN_(void) UnsuppressPainting();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче