mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 542632 - Protect nsGenericHTMLElement::GetHrefURIForAnchors
Also makes DNS prefetching take mozilla::dom::Link instead of nsIContent. r=bz
This commit is contained in:
parent
0404720b47
commit
f18a5a1370
@ -49,9 +49,15 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
#define MOZILLA_DOM_LINK_IMPLEMENTATION_IID \
|
||||||
|
{ 0x0c032581, 0x1c8a, 0x4fff, \
|
||||||
|
{ 0xbe, 0x9a, 0xfb, 0x6e, 0x2e, 0xe4, 0x22, 0x2e } }
|
||||||
|
|
||||||
class Link : public nsISupports
|
class Link : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
|
||||||
|
|
||||||
static const nsLinkState defaultState = eLinkState_Unknown;
|
static const nsLinkState defaultState = eLinkState_Unknown;
|
||||||
Link();
|
Link();
|
||||||
virtual nsLinkState GetLinkState() const;
|
virtual nsLinkState GetLinkState() const;
|
||||||
@ -123,6 +129,8 @@ private:
|
|||||||
nsIContent *mContent;
|
nsIContent *mContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
@ -198,9 +198,6 @@ public:
|
|||||||
nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
|
nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
|
||||||
PRBool IsHTMLLink(nsIURI** aURI) const;
|
PRBool IsHTMLLink(nsIURI** aURI) const;
|
||||||
|
|
||||||
// Used by A, AREA, LINK, and STYLE.
|
|
||||||
already_AddRefed<nsIURI> GetHrefURIForAnchors() const;
|
|
||||||
|
|
||||||
// As above, but makes sure to return a URI object that we can mutate with
|
// As above, but makes sure to return a URI object that we can mutate with
|
||||||
// impunity without changing our current URI. That is, if the URI is cached
|
// impunity without changing our current URI. That is, if the URI is cached
|
||||||
// it clones it and returns the clone.
|
// it clones it and returns the clone.
|
||||||
@ -723,6 +720,9 @@ protected:
|
|||||||
return value > 0 ? eTrue : (value == 0 ? eFalse : eInherit);
|
return value > 0 ? eTrue : (value == 0 ? eFalse : eInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by A, AREA, LINK, and STYLE.
|
||||||
|
already_AddRefed<nsIURI> GetHrefURIForAnchors() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Returns whether this element is an editable root. There are two types of
|
* Returns whether this element is an editable root. There are two types of
|
||||||
|
@ -152,11 +152,12 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLAnchorElement, nsGenericElement)
|
|||||||
|
|
||||||
// QueryInterface implementation for nsHTMLAnchorElement
|
// QueryInterface implementation for nsHTMLAnchorElement
|
||||||
NS_INTERFACE_TABLE_HEAD(nsHTMLAnchorElement)
|
NS_INTERFACE_TABLE_HEAD(nsHTMLAnchorElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLAnchorElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLAnchorElement,
|
||||||
nsIDOMHTMLAnchorElement,
|
nsIDOMHTMLAnchorElement,
|
||||||
nsIDOMNSHTMLAnchorElement,
|
nsIDOMNSHTMLAnchorElement,
|
||||||
nsIDOMNSHTMLAnchorElement2,
|
nsIDOMNSHTMLAnchorElement2,
|
||||||
nsILink)
|
nsILink,
|
||||||
|
Link)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAnchorElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAnchorElement,
|
||||||
nsGenericHTMLElement)
|
nsGenericHTMLElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAnchorElement)
|
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAnchorElement)
|
||||||
|
@ -137,11 +137,12 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLAreaElement, nsGenericElement)
|
|||||||
|
|
||||||
// QueryInterface implementation for nsHTMLAreaElement
|
// QueryInterface implementation for nsHTMLAreaElement
|
||||||
NS_INTERFACE_TABLE_HEAD(nsHTMLAreaElement)
|
NS_INTERFACE_TABLE_HEAD(nsHTMLAreaElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLAreaElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLAreaElement,
|
||||||
nsIDOMHTMLAreaElement,
|
nsIDOMHTMLAreaElement,
|
||||||
nsIDOMNSHTMLAreaElement,
|
nsIDOMNSHTMLAreaElement,
|
||||||
nsIDOMNSHTMLAreaElement2,
|
nsIDOMNSHTMLAreaElement2,
|
||||||
nsILink)
|
nsILink,
|
||||||
|
Link)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAreaElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAreaElement,
|
||||||
nsGenericHTMLElement)
|
nsGenericHTMLElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAreaElement)
|
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAreaElement)
|
||||||
|
@ -53,9 +53,11 @@
|
|||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsGenericHTMLElement.h"
|
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
|
#include "mozilla/dom/Link.h"
|
||||||
|
|
||||||
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
||||||
PRBool sDisablePrefetchHTTPSPref;
|
PRBool sDisablePrefetchHTTPSPref;
|
||||||
@ -125,7 +127,7 @@ nsHTMLDNSPrefetch::IsAllowed (nsIDocument *aDocument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDNSPrefetch::Prefetch(nsGenericHTMLElement *aElement, PRUint16 flags)
|
nsHTMLDNSPrefetch::Prefetch(Link *aElement, PRUint16 flags)
|
||||||
{
|
{
|
||||||
if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
|
if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
@ -134,19 +136,19 @@ nsHTMLDNSPrefetch::Prefetch(nsGenericHTMLElement *aElement, PRUint16 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDNSPrefetch::PrefetchLow(nsGenericHTMLElement *aElement)
|
nsHTMLDNSPrefetch::PrefetchLow(Link *aElement)
|
||||||
{
|
{
|
||||||
return Prefetch(aElement, nsIDNSService::RESOLVE_PRIORITY_LOW);
|
return Prefetch(aElement, nsIDNSService::RESOLVE_PRIORITY_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDNSPrefetch::PrefetchMedium(nsGenericHTMLElement *aElement)
|
nsHTMLDNSPrefetch::PrefetchMedium(Link *aElement)
|
||||||
{
|
{
|
||||||
return Prefetch(aElement, nsIDNSService::RESOLVE_PRIORITY_MEDIUM);
|
return Prefetch(aElement, nsIDNSService::RESOLVE_PRIORITY_MEDIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDNSPrefetch::PrefetchHigh(nsGenericHTMLElement *aElement)
|
nsHTMLDNSPrefetch::PrefetchHigh(Link *aElement)
|
||||||
{
|
{
|
||||||
return Prefetch(aElement, 0);
|
return Prefetch(aElement, 0);
|
||||||
}
|
}
|
||||||
@ -229,7 +231,7 @@ nsHTMLDNSPrefetch::nsDeferrals::Flush()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDNSPrefetch::nsDeferrals::Add(PRUint16 flags, nsGenericHTMLElement *aElement)
|
nsHTMLDNSPrefetch::nsDeferrals::Add(PRUint16 flags, Link *aElement)
|
||||||
{
|
{
|
||||||
// The FIFO has no lock, so it can only be accessed on main thread
|
// The FIFO has no lock, so it can only be accessed on main thread
|
||||||
NS_ASSERTION(NS_IsMainThread(), "nsDeferrals::Add must be on main thread");
|
NS_ASSERTION(NS_IsMainThread(), "nsDeferrals::Add must be on main thread");
|
||||||
@ -259,9 +261,8 @@ nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue()
|
|||||||
while (mHead != mTail) {
|
while (mHead != mTail) {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryReferent(mEntries[mTail].mElement);
|
nsCOMPtr<nsIContent> content = do_QueryReferent(mEntries[mTail].mElement);
|
||||||
if (content && content->GetOwnerDoc()) {
|
if (content && content->GetOwnerDoc()) {
|
||||||
nsCOMPtr<nsIURI> hrefURI;
|
nsCOMPtr<Link> link = do_QueryInterface(content);
|
||||||
hrefURI =
|
nsCOMPtr<nsIURI> hrefURI(link ? link->GetURI() : nsnull);
|
||||||
nsGenericHTMLElement::FromContent(content)->GetHrefURIForAnchors();
|
|
||||||
if (hrefURI)
|
if (hrefURI)
|
||||||
hrefURI->GetAsciiHost(hostName);
|
hrefURI->GetAsciiHost(hostName);
|
||||||
|
|
||||||
|
@ -49,8 +49,12 @@
|
|||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
|
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsGenericHTMLElement;
|
|
||||||
class nsITimer;
|
class nsITimer;
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
class Link;
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
class nsHTMLDNSPrefetch
|
class nsHTMLDNSPrefetch
|
||||||
{
|
{
|
||||||
@ -71,16 +75,16 @@ public:
|
|||||||
// weight, but its request is also more likely to be dropped due to a
|
// weight, but its request is also more likely to be dropped due to a
|
||||||
// full queue and it may only be used from the main thread.
|
// full queue and it may only be used from the main thread.
|
||||||
|
|
||||||
static nsresult PrefetchHigh(nsGenericHTMLElement *aElement);
|
static nsresult PrefetchHigh(mozilla::dom::Link *aElement);
|
||||||
static nsresult PrefetchMedium(nsGenericHTMLElement *aElement);
|
static nsresult PrefetchMedium(mozilla::dom::Link *aElement);
|
||||||
static nsresult PrefetchLow(nsGenericHTMLElement *aElement);
|
static nsresult PrefetchLow(mozilla::dom::Link *aElement);
|
||||||
static nsresult PrefetchHigh(nsAString &host);
|
static nsresult PrefetchHigh(nsAString &host);
|
||||||
static nsresult PrefetchMedium(nsAString &host);
|
static nsresult PrefetchMedium(nsAString &host);
|
||||||
static nsresult PrefetchLow(nsAString &host);
|
static nsresult PrefetchLow(nsAString &host);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static nsresult Prefetch(nsAString &host, PRUint16 flags);
|
static nsresult Prefetch(nsAString &host, PRUint16 flags);
|
||||||
static nsresult Prefetch(nsGenericHTMLElement *aElement, PRUint16 flags);
|
static nsresult Prefetch(mozilla::dom::Link *aElement, PRUint16 flags);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class nsListener : public nsIDNSListener
|
class nsListener : public nsIDNSListener
|
||||||
@ -107,7 +111,7 @@ public:
|
|||||||
nsDeferrals();
|
nsDeferrals();
|
||||||
|
|
||||||
void Activate();
|
void Activate();
|
||||||
nsresult Add(PRUint16 flags, nsGenericHTMLElement *aElement);
|
nsresult Add(PRUint16 flags, mozilla::dom::Link *aElement);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsDeferrals();
|
~nsDeferrals();
|
||||||
|
@ -148,11 +148,12 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLLinkElement, nsGenericElement)
|
|||||||
|
|
||||||
// QueryInterface implementation for nsHTMLLinkElement
|
// QueryInterface implementation for nsHTMLLinkElement
|
||||||
NS_INTERFACE_TABLE_HEAD(nsHTMLLinkElement)
|
NS_INTERFACE_TABLE_HEAD(nsHTMLLinkElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLLinkElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLLinkElement,
|
||||||
nsIDOMHTMLLinkElement,
|
nsIDOMHTMLLinkElement,
|
||||||
nsIDOMLinkStyle,
|
nsIDOMLinkStyle,
|
||||||
nsILink,
|
nsILink,
|
||||||
nsIStyleSheetLinkingElement)
|
nsIStyleSheetLinkingElement,
|
||||||
|
Link)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLinkElement,
|
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLinkElement,
|
||||||
nsGenericHTMLElement)
|
nsGenericHTMLElement)
|
||||||
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLinkElement)
|
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLinkElement)
|
||||||
@ -375,7 +376,7 @@ already_AddRefed<nsIURI>
|
|||||||
nsHTMLLinkElement::GetStyleSheetURL(PRBool* aIsInline)
|
nsHTMLLinkElement::GetStyleSheetURL(PRBool* aIsInline)
|
||||||
{
|
{
|
||||||
*aIsInline = PR_FALSE;
|
*aIsInline = PR_FALSE;
|
||||||
return GetHrefURIForAnchors();
|
return Link::GetURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -61,8 +61,13 @@ NS_IMPL_ADDREF_INHERITED(nsSVGAElement, nsSVGAElementBase)
|
|||||||
NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
|
NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
|
||||||
|
|
||||||
NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
|
NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
|
||||||
NS_NODE_INTERFACE_TABLE5(nsSVGAElement, nsIDOMNode, nsIDOMElement,
|
NS_NODE_INTERFACE_TABLE6(nsSVGAElement,
|
||||||
nsIDOMSVGElement, nsIDOMSVGAElement, nsILink)
|
nsIDOMNode,
|
||||||
|
nsIDOMElement,
|
||||||
|
nsIDOMSVGElement,
|
||||||
|
nsIDOMSVGAElement,
|
||||||
|
nsILink,
|
||||||
|
Link)
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAElement)
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAElement)
|
||||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAElementBase)
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGAElementBase)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user