Bug 908530 part 1. Make Link::GetURI return a raw pointer so we don't have to include nsIURI.h in Link.h. r=khuey

This commit is contained in:
Boris Zbarsky 2013-08-23 22:42:39 -04:00
parent 253a8c8d80
commit 12e653e224
4 changed files with 17 additions and 23 deletions

View File

@ -111,27 +111,20 @@ Link::LinkState() const
return nsEventStates();
}
already_AddRefed<nsIURI>
nsIURI*
Link::GetURI() const
{
nsCOMPtr<nsIURI> uri(mCachedURI);
// If we have this URI cached, use it.
if (uri) {
return uri.forget();
if (mCachedURI) {
return mCachedURI;
}
// Otherwise obtain it.
Link *self = const_cast<Link *>(this);
Element *element = self->mElement;
uri = element->GetHrefURI();
mCachedURI = element->GetHrefURI();
// We want to cache the URI if we have it
if (uri) {
mCachedURI = uri;
}
return uri.forget();
return mCachedURI;
}
void

View File

@ -21,8 +21,8 @@ namespace dom {
class Element;
#define MOZILLA_DOM_LINK_IMPLEMENTATION_IID \
{ 0x7EA57721, 0xE373, 0x458E, \
{0x8F, 0x44, 0xF8, 0x96, 0x56, 0xB4, 0x14, 0xF5 } }
{ 0xb25edee6, 0xdd35, 0x4f8b, \
{ 0xab, 0x90, 0x66, 0xd0, 0xbd, 0x3c, 0x22, 0xd5 } }
class Link : public nsISupports
{
@ -45,8 +45,8 @@ public:
/**
* @return the URI this link is for, if available.
*/
already_AddRefed<nsIURI> GetURI() const;
virtual already_AddRefed<nsIURI> GetURIExternal() const {
nsIURI* GetURI() const;
virtual nsIURI* GetURIExternal() const {
return GetURI();
}
@ -111,11 +111,11 @@ protected:
*/
bool HasURI() const
{
if (mCachedURI)
if (HasCachedURI()) {
return true;
}
nsCOMPtr<nsIURI> uri(GetURI());
return !!uri;
return !!GetURI();
}
nsIURI* GetCachedURI() const { return mCachedURI; }

View File

@ -329,7 +329,8 @@ HTMLLinkElement::GetStyleSheetURL(bool* aIsInline)
if (href.IsEmpty()) {
return nullptr;
}
return Link::GetURI();
nsCOMPtr<nsIURI> uri = Link::GetURI();
return uri.forget();
}
void

View File

@ -101,7 +101,7 @@ Link::ResetLinkState(bool aNotify, bool aHasHref)
NS_NOTREACHED("Unexpected call to Link::ResetLinkState");
}
already_AddRefed<nsIURI>
nsIURI*
Link::GetURI() const
{
NS_NOTREACHED("Unexpected call to Link::GetURI");