Bug 1129795 - Convert docshell/base/ to Gecko style. r=mccr8,smaug

This commit is contained in:
Birunthan Mohanathas
2015-02-13 21:36:37 +02:00
parent 25b867caa0
commit 9a04e80e2c
31 changed files with 12267 additions and 12168 deletions

View File

@@ -65,7 +65,8 @@ public:
*/ */
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0; NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
enum VisitFlags { enum VisitFlags
{
/** /**
* Indicates whether the URI was loaded in a top-level window. * Indicates whether the URI was loaded in a top-level window.
*/ */
@@ -101,11 +102,9 @@ public:
* @param aFlags * @param aFlags
* The VisitFlags describing this visit. * The VisitFlags describing this visit.
*/ */
NS_IMETHOD VisitURI( NS_IMETHOD VisitURI(nsIURI* aURI,
nsIURI *aURI,
nsIURI* aLastVisitedURI, nsIURI* aLastVisitedURI,
uint32_t aFlags uint32_t aFlags) = 0;
) = 0;
/** /**
* Set the title of the URI. * Set the title of the URI.

View File

@@ -31,8 +31,9 @@ namespace mozilla {
* to separate the safebrowsing cookie. * to separate the safebrowsing cookie.
*/ */
class LoadContext MOZ_FINAL : public nsILoadContext, class LoadContext MOZ_FINAL
public nsIInterfaceRequestor : public nsILoadContext
, public nsIInterfaceRequestor
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

View File

@@ -93,12 +93,12 @@ LoadInfo::TriggeringPrincipal()
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadInfo::GetLoadingDocument(nsIDOMDocument** outLoadingDocument) LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
{ {
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext); nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
if (node) { if (node) {
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc()); nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
context.forget(outLoadingDocument); context.forget(aResult);
} }
return NS_OK; return NS_OK;
} }
@@ -111,16 +111,17 @@ LoadInfo::LoadingNode()
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadInfo::GetSecurityFlags(nsSecurityFlags* outSecurityFlags) LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
{ {
*outSecurityFlags = mSecurityFlags; *aResult = mSecurityFlags;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal) LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
{ {
*aInheritPrincipal = (mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL); *aInheritPrincipal =
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
return NS_OK; return NS_OK;
} }
@@ -132,9 +133,9 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType) LoadInfo::GetContentPolicyType(nsContentPolicyType* aResult)
{ {
*outContentPolicyType = mContentPolicyType; *aResult = mContentPolicyType;
return NS_OK; return NS_OK;
} }
@@ -153,9 +154,9 @@ LoadInfo::BaseURI()
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadInfo::GetInnerWindowID(uint32_t* outInnerWindowID) LoadInfo::GetInnerWindowID(uint32_t* aResult)
{ {
*outInnerWindowID = mInnerWindowID; *aResult = mInnerWindowID;
return NS_OK; return NS_OK;
} }

View File

@@ -34,7 +34,8 @@ SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
bool isOverriden = false; bool isOverriden = false;
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel); nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
if (pbChannel && if (pbChannel &&
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) && NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
&isOverriden)) &&
isOverriden) { isOverriden) {
mUsePrivateBrowsing = isPrivate; mUsePrivateBrowsing = isPrivate;
mIsPrivateBitValid = true; mIsPrivateBitValid = true;

View File

@@ -37,15 +37,8 @@ public:
void Init(nsILoadContext* aLoadContext); void Init(nsILoadContext* aLoadContext);
bool IsNotNull() const bool IsNotNull() const { return mIsNotNull; }
{ bool IsPrivateBitValid() const { return mIsPrivateBitValid; }
return mIsNotNull;
}
bool IsPrivateBitValid() const
{
return mIsPrivateBitValid;
}
// used to indicate if child-side LoadContext * was null. // used to indicate if child-side LoadContext * was null.
bool mIsNotNull; bool mIsNotNull;

View File

@@ -34,9 +34,9 @@ public:
// Check whether two markers should be considered the same, // Check whether two markers should be considered the same,
// for the purpose of pairing start and end markers. Normally // for the purpose of pairing start and end markers. Normally
// this definition suffices. // this definition suffices.
virtual bool Equals(const TimelineMarker* other) virtual bool Equals(const TimelineMarker* aOther)
{ {
return strcmp(mName, other->mName) == 0; return strcmp(mName, aOther->mName) == 0;
} }
// Add details specific to this marker type to aMarker. The // Add details specific to this marker type to aMarker. The
@@ -44,34 +44,18 @@ public:
// called on both the starting and ending markers of a pair. // called on both the starting and ending markers of a pair.
// Ordinarily the ending marker doesn't need to do anything // Ordinarily the ending marker doesn't need to do anything
// here. // here.
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) {}
{
}
virtual void AddLayerRectangles(mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&) virtual void AddLayerRectangles(
mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
{ {
MOZ_ASSERT_UNREACHABLE("can only be called on layer markers"); MOZ_ASSERT_UNREACHABLE("can only be called on layer markers");
} }
const char* GetName() const const char* GetName() const { return mName; }
{ TracingMetadata GetMetaData() const { return mMetaData; }
return mName; DOMHighResTimeStamp GetTime() const { return mTime; }
} const nsString& GetCause() const { return mCause; }
TracingMetadata GetMetaData() const
{
return mMetaData;
}
DOMHighResTimeStamp GetTime() const
{
return mTime;
}
const nsString& GetCause() const
{
return mCause;
}
JSObject* GetStack() JSObject* GetStack()
{ {
@@ -82,7 +66,6 @@ public:
} }
protected: protected:
void CaptureStack() void CaptureStack()
{ {
JSContext* ctx = nsContentUtils::GetCurrentJSContext(); JSContext* ctx = nsContentUtils::GetCurrentJSContext();
@@ -97,7 +80,6 @@ protected:
} }
private: private:
const char* mName; const char* mName;
TracingMetadata mMetaData; TracingMetadata mMetaData;
DOMHighResTimeStamp mTime; DOMHighResTimeStamp mTime;

View File

@@ -12,7 +12,8 @@
NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule) NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
struct RedirEntry { struct RedirEntry
{
const char* id; const char* id;
const char* url; const char* url;
uint32_t flags; uint32_t flags;
@@ -29,61 +30,93 @@ struct RedirEntry {
URI. Perhaps we should separate the two concepts out... URI. Perhaps we should separate the two concepts out...
*/ */
static RedirEntry kRedirMap[] = { static RedirEntry kRedirMap[] = {
{ "", "chrome://global/content/about.xhtml", {
nsIAboutModule::ALLOW_SCRIPT }, "", "chrome://global/content/about.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 }, { "about", "chrome://global/content/aboutAbout.xhtml", 0 },
{ "credits", "http://www.mozilla.org/credits/", {
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT }, "credits", "http://www.mozilla.org/credits/",
{ "mozilla", "chrome://global/content/mozilla.xhtml", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT }, },
{
"mozilla", "chrome://global/content/mozilla.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{ "plugins", "chrome://global/content/plugins.html", 0 }, { "plugins", "chrome://global/content/plugins.html", 0 },
{ "config", "chrome://global/content/config.xul", 0 }, { "config", "chrome://global/content/config.xul", 0 },
#ifdef MOZ_CRASHREPORTER #ifdef MOZ_CRASHREPORTER
{ "crashes", "chrome://global/content/crashes.xhtml", 0 }, { "crashes", "chrome://global/content/crashes.xhtml", 0 },
#endif #endif
{ "logo", "chrome://branding/content/about.png", {
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT}, "logo", "chrome://branding/content/about.png",
{ "buildconfig", "chrome://global/content/buildconfig.html", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT }, },
{ "license", "chrome://global/content/license.html", {
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT }, "buildconfig", "chrome://global/content/buildconfig.html",
{ "neterror", "chrome://global/content/netError.xhtml", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"license", "chrome://global/content/license.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"neterror", "chrome://global/content/netError.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT }, nsIAboutModule::HIDE_FROM_ABOUTABOUT
{ "memory", "chrome://global/content/aboutMemory.xhtml", },
nsIAboutModule::ALLOW_SCRIPT }, {
{ "compartments", "chrome://global/content/aboutCompartments.xhtml", "memory", "chrome://global/content/aboutMemory.xhtml",
nsIAboutModule::ALLOW_SCRIPT }, nsIAboutModule::ALLOW_SCRIPT
{ "addons", "chrome://mozapps/content/extensions/extensions.xul", },
nsIAboutModule::ALLOW_SCRIPT }, {
{ "newaddon", "chrome://mozapps/content/extensions/newaddon.xul", "compartments", "chrome://global/content/aboutCompartments.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"addons", "chrome://mozapps/content/extensions/extensions.xul",
nsIAboutModule::ALLOW_SCRIPT
},
{
"newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT }, nsIAboutModule::HIDE_FROM_ABOUTABOUT
{ "support", "chrome://global/content/aboutSupport.xhtml", },
nsIAboutModule::ALLOW_SCRIPT }, {
{ "telemetry", "chrome://global/content/aboutTelemetry.xhtml", "support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT }, nsIAboutModule::ALLOW_SCRIPT
{ "networking", "chrome://global/content/aboutNetworking.xhtml", },
nsIAboutModule::ALLOW_SCRIPT }, {
{ "webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml", "telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT }, nsIAboutModule::ALLOW_SCRIPT
},
{
"networking", "chrome://global/content/aboutNetworking.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
// about:srcdoc is unresolvable by specification. It is included here // about:srcdoc is unresolvable by specification. It is included here
// because the security manager would disallow srcdoc iframes otherwise. // because the security manager would disallow srcdoc iframes otherwise.
{ "srcdoc", "about:blank", {
"srcdoc", "about:blank",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT } nsIAboutModule::HIDE_FROM_ABOUTABOUT
}
}; };
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap); static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
NS_IMETHODIMP NS_IMETHODIMP
nsAboutRedirector::NewChannel(nsIURI* aURI, nsAboutRedirector::NewChannel(nsIURI* aURI,
nsILoadInfo* aLoadInfo, nsILoadInfo* aLoadInfo,
nsIChannel** result) nsIChannel** aResult)
{ {
NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_ARG_POINTER(aURI);
NS_ASSERTION(result, "must not be null"); NS_ASSERTION(aResult, "must not be null");
nsAutoCString path; nsAutoCString path;
nsresult rv = NS_GetAboutModuleName(aURI, path); nsresult rv = NS_GetAboutModuleName(aURI, path);
@@ -92,11 +125,8 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv); nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
for (int i = 0; i < kRedirTotal; i++) {
for (int i=0; i<kRedirTotal; i++) if (!strcmp(path.get(), kRedirMap[i].id)) {
{
if (!strcmp(path.get(), kRedirMap[i].id))
{
nsCOMPtr<nsIChannel> tempChannel; nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI; nsCOMPtr<nsIURI> tempURI;
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url); rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
@@ -109,17 +139,16 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel), rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI, tempURI,
aLoadInfo); aLoadInfo);
} else {
rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
} }
else { if (NS_FAILED(rv)) {
rv = ioService->NewChannelFromURI(tempURI,
getter_AddRefs(tempChannel));
}
if (NS_FAILED(rv))
return rv; return rv;
}
tempChannel->SetOriginalURI(aURI); tempChannel->SetOriginalURI(aURI);
NS_ADDREF(*result = tempChannel); NS_ADDREF(*aResult = tempChannel);
return rv; return rv;
} }
} }
@@ -129,7 +158,7 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result) nsAboutRedirector::GetURIFlags(nsIURI* aURI, uint32_t* aResult)
{ {
NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_ARG_POINTER(aURI);
@@ -137,11 +166,9 @@ nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
nsresult rv = NS_GetAboutModuleName(aURI, name); nsresult rv = NS_GetAboutModuleName(aURI, name);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
for (int i=0; i < kRedirTotal; i++) for (int i = 0; i < kRedirTotal; i++) {
{ if (name.EqualsASCII(kRedirMap[i].id)) {
if (name.EqualsASCII(kRedirMap[i].id)) *aResult = kRedirMap[i].flags;
{
*result = kRedirMap[i].flags;
return NS_OK; return NS_OK;
} }
} }
@@ -151,9 +178,9 @@ nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI *aURI, nsAString &result) nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult)
{ {
SetDOMStringToNull(result); SetDOMStringToNull(aResult);
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@@ -161,8 +188,9 @@ nsresult
nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{ {
nsAboutRedirector* about = new nsAboutRedirector(); nsAboutRedirector* about = new nsAboutRedirector();
if (about == nullptr) if (!about) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(about); NS_ADDREF(about);
nsresult rv = about->QueryInterface(aIID, aResult); nsresult rv = about->QueryInterface(aIID, aResult);
NS_RELEASE(about); NS_RELEASE(about);

View File

@@ -17,8 +17,7 @@ public:
nsAboutRedirector() {} nsAboutRedirector() {}
static nsresult static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected: protected:
virtual ~nsAboutRedirector() {} virtual ~nsAboutRedirector() {}

View File

@@ -48,7 +48,6 @@ nsDSURIContentListener::Init()
return rv; return rv;
} }
//***************************************************************************** //*****************************************************************************
// nsDSURIContentListener::nsISupports // nsDSURIContentListener::nsISupports
//***************************************************************************** //*****************************************************************************
@@ -79,8 +78,9 @@ nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
nsCOMPtr<nsIURIContentListener> parentListener; nsCOMPtr<nsIURIContentListener> parentListener;
GetParentContentListener(getter_AddRefs(parentListener)); GetParentContentListener(getter_AddRefs(parentListener));
if (parentListener) if (parentListener) {
return parentListener->OnStartURIOpen(aURI, aAbortOpen); return parentListener->OnStartURIOpen(aURI, aAbortOpen);
}
return NS_OK; return NS_OK;
} }
@@ -88,7 +88,7 @@ nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
NS_IMETHODIMP NS_IMETHODIMP
nsDSURIContentListener::DoContent(const char* aContentType, nsDSURIContentListener::DoContent(const char* aContentType,
bool aIsContentPreferred, bool aIsContentPreferred,
nsIRequest* request, nsIRequest* aRequest,
nsIStreamListener** aContentHandler, nsIStreamListener** aContentHandler,
bool* aAbortProcess) bool* aAbortProcess)
{ {
@@ -99,7 +99,7 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// Check whether X-Frame-Options permits us to load this content in an // Check whether X-Frame-Options permits us to load this content in an
// iframe and abort the load (unless we've disabled x-frame-options // iframe and abort the load (unless we've disabled x-frame-options
// checking). // checking).
if (!CheckFrameOptions(request)) { if (!CheckFrameOptions(aRequest)) {
*aAbortProcess = true; *aAbortProcess = true;
return NS_OK; return NS_OK;
} }
@@ -108,13 +108,13 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// determine if the channel has just been retargeted to us... // determine if the channel has just been retargeted to us...
nsLoadFlags loadFlags = 0; nsLoadFlags loadFlags = 0;
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request); nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
if (aOpenedChannel) if (aOpenedChannel) {
aOpenedChannel->GetLoadFlags(&loadFlags); aOpenedChannel->GetLoadFlags(&loadFlags);
}
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
{
// XXX: Why does this not stop the content too? // XXX: Why does this not stop the content too?
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK); mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
@@ -125,20 +125,19 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// create new viewer since the one we already have is capable of // create new viewer since the one we already have is capable of
// rendering multipart jpeg correctly (see bug 625012) // rendering multipart jpeg correctly (see bug 625012)
nsCOMPtr<nsIChannel> baseChannel; nsCOMPtr<nsIChannel> baseChannel;
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(request)) { if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
mpchan->GetBaseChannel(getter_AddRefs(baseChannel)); mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
} }
bool reuseCV = baseChannel bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
&& baseChannel == mExistingJPEGRequest nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
&& nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
if (mExistingJPEGStreamListener && reuseCV) { if (mExistingJPEGStreamListener && reuseCV) {
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener); nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
copy.forget(aContentHandler); copy.forget(aContentHandler);
rv = NS_OK; rv = NS_OK;
} else { } else {
rv = mDocShell->CreateContentViewer(aContentType, request, aContentHandler); rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
if (NS_SUCCEEDED(rv) && reuseCV) { if (NS_SUCCEEDED(rv) && reuseCV) {
mExistingJPEGStreamListener = *aContentHandler; mExistingJPEGStreamListener = *aContentHandler;
} else { } else {
@@ -147,9 +146,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
mExistingJPEGRequest = baseChannel; mExistingJPEGRequest = baseChannel;
} }
if (rv == NS_ERROR_REMOTE_XUL) { if (rv == NS_ERROR_REMOTE_XUL) {
request->Cancel(rv); aRequest->Cancel(rv);
*aAbortProcess = true; *aAbortProcess = true;
return NS_OK; return NS_OK;
} }
@@ -161,8 +159,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
} }
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) { if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow() nsCOMPtr<nsIDOMWindow> domWindow =
: nullptr; mDocShell ? mDocShell->GetWindow() : nullptr;
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE); NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus(); domWindow->Focus();
} }
@@ -199,10 +197,7 @@ nsDSURIContentListener::IsPreferred(const char* aContentType,
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top // and someone didn't EXPLICITLY set a nsIURIContentListener at the top
// of our docshell chain, then we'll now always attempt to process the // of our docshell chain, then we'll now always attempt to process the
// content ourselves... // content ourselves...
return CanHandleContent(aContentType, return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
true,
aDesiredContentType,
aCanHandle);
} }
NS_IMETHODIMP NS_IMETHODIMP
@@ -249,17 +244,15 @@ nsDSURIContentListener::SetLoadCookie(nsISupports * aLoadCookie)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDSURIContentListener::GetParentContentListener(nsIURIContentListener** nsDSURIContentListener::GetParentContentListener(
aParentListener) nsIURIContentListener** aParentListener)
{
if (mWeakParentContentListener)
{ {
if (mWeakParentContentListener) {
nsCOMPtr<nsIURIContentListener> tempListener = nsCOMPtr<nsIURIContentListener> tempListener =
do_QueryReferent(mWeakParentContentListener); do_QueryReferent(mWeakParentContentListener);
*aParentListener = tempListener; *aParentListener = tempListener;
NS_IF_ADDREF(*aParentListener); NS_IF_ADDREF(*aParentListener);
} } else {
else {
*aParentListener = mParentContentListener; *aParentListener = mParentContentListener;
NS_IF_ADDREF(*aParentListener); NS_IF_ADDREF(*aParentListener);
} }
@@ -267,43 +260,42 @@ nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDSURIContentListener::SetParentContentListener(nsIURIContentListener* nsDSURIContentListener::SetParentContentListener(
aParentListener) nsIURIContentListener* aParentListener)
{
if (aParentListener)
{ {
if (aParentListener) {
// Store the parent listener as a weak ref. Parents not supporting // Store the parent listener as a weak ref. Parents not supporting
// nsISupportsWeakReference assert but may still be used. // nsISupportsWeakReference assert but may still be used.
mParentContentListener = nullptr; mParentContentListener = nullptr;
mWeakParentContentListener = do_GetWeakReference(aParentListener); mWeakParentContentListener = do_GetWeakReference(aParentListener);
if (!mWeakParentContentListener) if (!mWeakParentContentListener) {
{
mParentContentListener = aParentListener; mParentContentListener = aParentListener;
} }
} } else {
else
{
mWeakParentContentListener = nullptr; mWeakParentContentListener = nullptr;
mParentContentListener = nullptr; mParentContentListener = nullptr;
} }
return NS_OK; return NS_OK;
} }
bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChannel, bool
const nsAString& policy) { nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
const nsAString& aPolicy)
{
static const char allowFrom[] = "allow-from"; static const char allowFrom[] = "allow-from";
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1; const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
bool isAllowFrom = bool isAllowFrom =
StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom); StringHead(aPolicy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
// return early if header does not have one of the values with meaning // return early if header does not have one of the values with meaning
if (!policy.LowerCaseEqualsLiteral("deny") && if (!aPolicy.LowerCaseEqualsLiteral("deny") &&
!policy.LowerCaseEqualsLiteral("sameorigin") && !aPolicy.LowerCaseEqualsLiteral("sameorigin") &&
!isAllowFrom) !isAllowFrom) {
return true; return true;
}
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
httpChannel->GetURI(getter_AddRefs(uri)); aHttpChannel->GetURI(getter_AddRefs(uri));
// XXXkhuey when does this happen? Is returning true safe here? // XXXkhuey when does this happen? Is returning true safe here?
if (!mDocShell) { if (!mDocShell) {
@@ -316,8 +308,9 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// the document must never be framed. // the document must never be framed.
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow(); nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
// If we don't have DOMWindow there is no risk of clickjacking // If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow) if (!thisWindow) {
return true; return true;
}
// GetScriptableTop, not GetTop, because we want this to respect // GetScriptableTop, not GetTop, because we want this to respect
// <iframe mozbrowser> boundaries. // <iframe mozbrowser> boundaries.
@@ -325,17 +318,18 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
thisWindow->GetScriptableTop(getter_AddRefs(topWindow)); thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
// if the document is in the top window, it's not in a frame. // if the document is in the top window, it's not in a frame.
if (thisWindow == topWindow) if (thisWindow == topWindow) {
return true; return true;
}
// Find the top docshell in our parent chain that doesn't have the system // Find the top docshell in our parent chain that doesn't have the system
// principal and use it for the principal comparison. Finding the top // principal and use it for the principal comparison. Finding the top
// content-type docshell doesn't work because some chrome documents are // content-type docshell doesn't work because some chrome documents are
// loaded in content docshells (see bug 593387). // loaded in content docshells (see bug 593387).
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(do_QueryInterface( nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(
static_cast<nsIDocShell*> (mDocShell))); do_QueryInterface(static_cast<nsIDocShell*>(mDocShell)));
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem, nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
curDocShellItem = thisDocShellItem; nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = thisDocShellItem;
nsCOMPtr<nsIDocument> topDoc; nsCOMPtr<nsIDocument> topDoc;
nsresult rv; nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> ssm = nsCOMPtr<nsIScriptSecurityManager> ssm =
@@ -347,9 +341,9 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// Traverse up the parent chain and stop when we see a docshell whose // Traverse up the parent chain and stop when we see a docshell whose
// parent has a system principal, or a docshell corresponding to // parent has a system principal, or a docshell corresponding to
// <iframe mozbrowser>. // <iframe mozbrowser>.
while (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) && while (NS_SUCCEEDED(
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
parentDocShellItem) { parentDocShellItem) {
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem); nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
if (curDocShell && curDocShell->GetIsBrowserOrApp()) { if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
break; break;
@@ -358,13 +352,13 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
bool system = false; bool system = false;
topDoc = parentDocShellItem->GetDocument(); topDoc = parentDocShellItem->GetDocument();
if (topDoc) { if (topDoc) {
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(), if (NS_SUCCEEDED(
&system)) && system) { ssm->IsSystemPrincipal(topDoc->NodePrincipal(), &system)) &&
system) {
// Found a system-principled doc: last docshell was top. // Found a system-principled doc: last docshell was top.
break; break;
} }
} } else {
else {
return false; return false;
} }
curDocShellItem = parentDocShellItem; curDocShellItem = parentDocShellItem;
@@ -372,13 +366,14 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If this document has the top non-SystemPrincipal docshell it is not being // If this document has the top non-SystemPrincipal docshell it is not being
// framed or it is being framed by a chrome document, which we allow. // framed or it is being framed by a chrome document, which we allow.
if (curDocShellItem == thisDocShellItem) if (curDocShellItem == thisDocShellItem) {
return true; return true;
}
// If the value of the header is DENY, and the previous condition is // If the value of the header is DENY, and the previous condition is
// not met (current docshell is not the top docshell), prohibit the // not met (current docshell is not the top docshell), prohibit the
// load. // load.
if (policy.LowerCaseEqualsLiteral("deny")) { if (aPolicy.LowerCaseEqualsLiteral("deny")) {
ReportXFOViolation(curDocShellItem, uri, eDENY); ReportXFOViolation(curDocShellItem, uri, eDENY);
return false; return false;
} }
@@ -389,7 +384,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the // If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
// parent chain must be from the same origin as this document. // parent chain must be from the same origin as this document.
if (policy.LowerCaseEqualsLiteral("sameorigin")) { if (aPolicy.LowerCaseEqualsLiteral("sameorigin")) {
rv = ssm->CheckSameOriginURI(uri, topUri, true); rv = ssm->CheckSameOriginURI(uri, topUri, true);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN); ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
@@ -400,16 +395,16 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If the X-Frame-Options value is "allow-from [uri]", then the top // If the X-Frame-Options value is "allow-from [uri]", then the top
// frame in the parent chain must be from that origin // frame in the parent chain must be from that origin
if (isAllowFrom) { if (isAllowFrom) {
if (policy.Length() == allowFromLen || if (aPolicy.Length() == allowFromLen ||
(policy[allowFromLen] != ' ' && (aPolicy[allowFromLen] != ' ' &&
policy[allowFromLen] != '\t')) { aPolicy[allowFromLen] != '\t')) {
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM); ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
return false; return false;
} }
rv = NS_NewURI(getter_AddRefs(uri), rv = NS_NewURI(getter_AddRefs(uri), Substring(aPolicy, allowFromLen));
Substring(policy, allowFromLen)); if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
return false; return false;
}
rv = ssm->CheckSameOriginURI(uri, topUri, true); rv = ssm->CheckSameOriginURI(uri, topUri, true);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@@ -424,10 +419,11 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// Check if X-Frame-Options permits this document to be loaded as a subdocument. // Check if X-Frame-Options permits this document to be loaded as a subdocument.
// This will iterate through and check any number of X-Frame-Options policies // This will iterate through and check any number of X-Frame-Options policies
// in the request (comma-separated in a header, multiple headers, etc). // in the request (comma-separated in a header, multiple headers, etc).
bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request) bool
nsDSURIContentListener::CheckFrameOptions(nsIRequest* aRequest)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIChannel> chan = do_QueryInterface(request); nsCOMPtr<nsIChannel> chan = do_QueryInterface(aRequest);
if (!chan) { if (!chan) {
return true; return true;
} }
@@ -436,9 +432,10 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
if (!httpChannel) { if (!httpChannel) {
// check if it is hiding in a multipart channel // check if it is hiding in a multipart channel
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel)); rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return false; return false;
} }
}
if (!httpChannel) { if (!httpChannel) {
return true; return true;
@@ -450,8 +447,9 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue); NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
// if no header value, there's nothing to do. // if no header value, there's nothing to do.
if (xfoHeaderValue.IsEmpty()) if (xfoHeaderValue.IsEmpty()) {
return true; return true;
}
// iterate through all the header values (usually there's only one, but can // iterate through all the header values (usually there's only one, but can
// be many. If any want to deny the load, deny the load. // be many. If any want to deny the load, deny the load.
@@ -483,42 +481,49 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell"); MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow(); nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
if (!topOuterWindow) if (!topOuterWindow) {
return; return;
}
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?"); NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow(); nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
if (!topInnerWindow) if (!topInnerWindow) {
return; return;
}
nsCOMPtr<nsIURI> topURI; nsCOMPtr<nsIURI> topURI;
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument(); nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI)); nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return; return;
}
if (!topURI) if (!topURI) {
return; return;
}
nsCString topURIString; nsCString topURIString;
nsCString thisURIString; nsCString thisURIString;
rv = topURI->GetSpec(topURIString); rv = topURI->GetSpec(topURIString);
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return; return;
}
rv = aThisURI->GetSpec(thisURIString); rv = aThisURI->GetSpec(thisURIString);
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return; return;
}
nsCOMPtr<nsIConsoleService> consoleService = nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID); do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIScriptError> errorObject = nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
if (!consoleService || !errorObject) if (!consoleService || !errorObject) {
return; return;
}
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: "); nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
msg.Append(NS_ConvertUTF8toUTF16(thisURIString)); msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
@@ -541,8 +546,9 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
nsIScriptError::errorFlag, nsIScriptError::errorFlag,
"X-Frame-Options", "X-Frame-Options",
topInnerWindow->WindowID()); topInnerWindow->WindowID());
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return; return;
}
consoleService->LogMessage(errorObject); consoleService->LogMessage(errorObject);
} }

View File

@@ -16,12 +16,12 @@ class nsIWebNavigationInfo;
class nsIHttpChannel; class nsIHttpChannel;
class nsAString; class nsAString;
class nsDSURIContentListener MOZ_FINAL : class nsDSURIContentListener MOZ_FINAL
public nsIURIContentListener, : public nsIURIContentListener
public nsSupportsWeakReference , public nsSupportsWeakReference
{ {
friend class nsDocShell; friend class nsDocShell;
public: public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIURICONTENTLISTENER NS_DECL_NSIURICONTENTLISTENER
@@ -32,7 +32,8 @@ protected:
explicit nsDSURIContentListener(nsDocShell* aDocShell); explicit nsDSURIContentListener(nsDocShell* aDocShell);
virtual ~nsDSURIContentListener(); virtual ~nsDSURIContentListener();
void DropDocShellreference() { void DropDocShellReference()
{
mDocShell = nullptr; mDocShell = nullptr;
mExistingJPEGRequest = nullptr; mExistingJPEGRequest = nullptr;
mExistingJPEGStreamListener = nullptr; mExistingJPEGStreamListener = nullptr;
@@ -40,11 +41,12 @@ protected:
// Determine if X-Frame-Options allows content to be framed // Determine if X-Frame-Options allows content to be framed
// as a subdocument // as a subdocument
bool CheckFrameOptions(nsIRequest* request); bool CheckFrameOptions(nsIRequest* aRequest);
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel, bool CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
const nsAString& policy); const nsAString& aPolicy);
enum XFOHeader { enum XFOHeader
{
eDENY, eDENY,
eSAMEORIGIN, eSAMEORIGIN,
eALLOWFROM eALLOWFROM
@@ -53,6 +55,7 @@ protected:
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem, void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
nsIURI* aThisURI, nsIURI* aThisURI,
XFOHeader aHeader); XFOHeader aHeader);
protected: protected:
nsDocShell* mDocShell; nsDocShell* mDocShell;
// Hack to handle multipart images without creating a new viewer // Hack to handle multipart images without creating a new viewer

View File

@@ -39,13 +39,10 @@ static bool sFixupKeywords = true;
nsDefaultURIFixup::nsDefaultURIFixup() nsDefaultURIFixup::nsDefaultURIFixup()
{ {
/* member initializers and constructor code */
} }
nsDefaultURIFixup::~nsDefaultURIFixup() nsDefaultURIFixup::~nsDefaultURIFixup()
{ {
/* destructor code */
} }
/* nsIURI createExposableURI (in nsIURI aURI); */ /* nsIURI createExposableURI (in nsIURI aURI); */
@@ -62,8 +59,7 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
aURI->GetUserPass(userPass); aURI->GetUserPass(userPass);
// most of the time we can just AddRef and return // most of the time we can just AddRef and return
if (!isWyciwyg && userPass.IsEmpty()) if (!isWyciwyg && userPass.IsEmpty()) {
{
*aReturn = aURI; *aReturn = aURI;
NS_ADDREF(*aReturn); NS_ADDREF(*aReturn);
return NS_OK; return NS_OK;
@@ -71,28 +67,26 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
// Rats, we have to massage the URI // Rats, we have to massage the URI
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
if (isWyciwyg) if (isWyciwyg) {
{
nsAutoCString path; nsAutoCString path;
nsresult rv = aURI->GetPath(path); nsresult rv = aURI->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
uint32_t pathLength = path.Length(); uint32_t pathLength = path.Length();
if (pathLength <= 2) if (pathLength <= 2) {
{
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Path is of the form "//123/http://foo/bar", with a variable number of digits. // Path is of the form "//123/http://foo/bar", with a variable number of
// To figure out where the "real" URL starts, search path for a '/', starting at // digits. To figure out where the "real" URL starts, search path for a '/',
// the third character. // starting at the third character.
int32_t slashIndex = path.FindChar('/', 2); int32_t slashIndex = path.FindChar('/', 2);
if (slashIndex == kNotFound) if (slashIndex == kNotFound) {
{
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Get the charset of the original URI so we can pass it to our fixed up URI. // Get the charset of the original URI so we can pass it to our fixed up
// URI.
nsAutoCString charset; nsAutoCString charset;
aURI->GetOriginCharset(charset); aURI->GetOriginCharset(charset);
@@ -100,17 +94,14 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
Substring(path, slashIndex + 1, pathLength - slashIndex - 1), Substring(path, slashIndex + 1, pathLength - slashIndex - 1),
charset.get()); charset.get());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} } else {
else
{
// clone the URI so zapping user:pass doesn't change the original // clone the URI so zapping user:pass doesn't change the original
nsresult rv = aURI->Clone(getter_AddRefs(uri)); nsresult rv = aURI->Clone(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
// hide user:pass unless overridden by pref // hide user:pass unless overridden by pref
if (Preferences::GetBool("browser.fixup.hide_user_pass", true)) if (Preferences::GetBool("browser.fixup.hide_user_pass", true)) {
{
uri->SetUserPass(EmptyCString()); uri->SetUserPass(EmptyCString());
} }
@@ -122,7 +113,8 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
/* nsIURI createFixupURI (in nsAUTF8String aURIText, in unsigned long aFixupFlags); */ /* nsIURI createFixupURI (in nsAUTF8String aURIText, in unsigned long aFixupFlags); */
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, uint32_t aFixupFlags, nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI,
uint32_t aFixupFlags,
nsIInputStream** aPostData, nsIURI** aURI) nsIInputStream** aPostData, nsIURI** aURI)
{ {
nsCOMPtr<nsIURIFixupInfo> fixupInfo; nsCOMPtr<nsIURIFixupInfo> fixupInfo;
@@ -135,8 +127,10 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, uint32_t aFixupF
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixupFlags, nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI,
nsIInputStream **aPostData, nsIURIFixupInfo **aInfo) uint32_t aFixupFlags,
nsIInputStream** aPostData,
nsIURIFixupInfo** aInfo)
{ {
NS_ENSURE_ARG(!aStringURI.IsEmpty()); NS_ENSURE_ARG(!aStringURI.IsEmpty());
@@ -154,7 +148,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
nsRefPtr<nsDefaultURIFixupInfo> info = new nsDefaultURIFixupInfo(uriString); nsRefPtr<nsDefaultURIFixupInfo> info = new nsDefaultURIFixupInfo(uriString);
NS_ADDREF(*aInfo = info); NS_ADDREF(*aInfo = info);
nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); nsCOMPtr<nsIIOService> ioService =
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString scheme; nsAutoCString scheme;
ioService->ExtractScheme(aStringURI, scheme); ioService->ExtractScheme(aStringURI, scheme);
@@ -163,8 +158,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// after it. The easiest way to do that is to call this method again with the // after it. The easiest way to do that is to call this method again with the
// "view-source:" lopped off and then prepend it again afterwards. // "view-source:" lopped off and then prepend it again afterwards.
if (scheme.LowerCaseEqualsLiteral("view-source")) if (scheme.LowerCaseEqualsLiteral("view-source")) {
{
nsCOMPtr<nsIURIFixupInfo> uriInfo; nsCOMPtr<nsIURIFixupInfo> uriInfo;
uint32_t newFixupFlags = aFixupFlags & ~FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP; uint32_t newFixupFlags = aFixupFlags & ~FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
@@ -173,25 +167,25 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
uriString.Length() - uriString.Length() -
(sizeof("view-source:") - 1)), (sizeof("view-source:") - 1)),
newFixupFlags, aPostData, getter_AddRefs(uriInfo)); newFixupFlags, aPostData, getter_AddRefs(uriInfo));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
nsAutoCString spec; nsAutoCString spec;
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
uriInfo->GetPreferredURI(getter_AddRefs(uri)); uriInfo->GetPreferredURI(getter_AddRefs(uri));
if (!uri) if (!uri) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
uri->GetSpec(spec); uri->GetSpec(spec);
uriString.AssignLiteral("view-source:"); uriString.AssignLiteral("view-source:");
uriString.Append(spec); uriString.Append(spec);
} } else {
else {
// Check for if it is a file URL // Check for if it is a file URL
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
FileURIFixup(uriString, getter_AddRefs(uri)); FileURIFixup(uriString, getter_AddRefs(uri));
// NB: FileURIFixup only returns a URI if it had to fix the protocol to // NB: FileURIFixup only returns a URI if it had to fix the protocol to
// do so, so passing in file:///foo/bar will not hit this path: // do so, so passing in file:///foo/bar will not hit this path:
if (uri) if (uri) {
{
uri.swap(info->mFixedURI); uri.swap(info->mFixedURI);
info->mPreferredURI = info->mFixedURI; info->mPreferredURI = info->mFixedURI;
info->mFixupChangedProtocol = true; info->mFixupChangedProtocol = true;
@@ -199,8 +193,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
} }
#if defined(XP_WIN) #if defined(XP_WIN)
// Not a file URL, so translate '\' to '/' for convenience in the common protocols // Not a file URL, so translate '\' to '/' for convenience in the common
// e.g. catch // protocols. E.g. catch
// //
// http:\\broken.com\address // http:\\broken.com\address
// http:\\broken.com/blah // http:\\broken.com/blah
@@ -215,8 +209,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
if (scheme.IsEmpty() || if (scheme.IsEmpty() ||
scheme.LowerCaseEqualsLiteral("http") || scheme.LowerCaseEqualsLiteral("http") ||
scheme.LowerCaseEqualsLiteral("https") || scheme.LowerCaseEqualsLiteral("https") ||
scheme.LowerCaseEqualsLiteral("ftp")) scheme.LowerCaseEqualsLiteral("ftp")) {
{
// Walk the string replacing backslashes with forward slashes until // Walk the string replacing backslashes with forward slashes until
// the end is reached, or a question mark, or a hash, or a forward // the end is reached, or a question mark, or a hash, or a forward
// slash. The forward slash test is to stop before trampling over // slash. The forward slash test is to stop before trampling over
@@ -227,10 +220,12 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
uriString.BeginWriting(start); uriString.BeginWriting(start);
uriString.EndWriting(end); uriString.EndWriting(end);
while (start != end) { while (start != end) {
if (*start == '?' || *start == '#' || *start == '/') if (*start == '?' || *start == '#' || *start == '/') {
break; break;
if (*start == '\\') }
if (*start == '\\') {
*start = '/'; *start = '/';
}
++start; ++start;
} }
} }
@@ -248,7 +243,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
rv = Preferences::AddBoolVarCache(&sDNSFirstForSingleWords, rv = Preferences::AddBoolVarCache(&sDNSFirstForSingleWords,
"browser.fixup.dns_first_for_single_words", "browser.fixup.dns_first_for_single_words",
sDNSFirstForSingleWords); sDNSFirstForSingleWords);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"browser.fixup.dns_first_for_single_words\""); MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"browser.fixup.dns_first_for_single_words\"");
rv = Preferences::AddBoolVarCache(&sFixupKeywords, "keyword.enabled", rv = Preferences::AddBoolVarCache(&sFixupKeywords, "keyword.enabled",
sFixupKeywords); sFixupKeywords);
@@ -258,7 +254,6 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// Fix up common scheme typos. // Fix up common scheme typos.
if (sFixTypos && (aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) { if (sFixTypos && (aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) {
// Fast-path for common cases. // Fast-path for common cases.
if (scheme.IsEmpty() || if (scheme.IsEmpty() ||
scheme.LowerCaseEqualsLiteral("http") || scheme.LowerCaseEqualsLiteral("http") ||
@@ -321,7 +316,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID); do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
if (extProtService) { if (extProtService) {
bool handlerExists = false; bool handlerExists = false;
rv = extProtService->ExternalProtocolHandlerExists(scheme.get(), &handlerExists); rv = extProtService->ExternalProtocolHandlerExists(scheme.get(),
&handlerExists);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@@ -337,8 +333,9 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
if (info->mFixedURI) { if (info->mFixedURI) {
if (!info->mPreferredURI) { if (!info->mPreferredURI) {
if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI) if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI) {
info->mFixupCreatedAlternateURI = MakeAlternateURI(info->mFixedURI); info->mFixupCreatedAlternateURI = MakeAlternateURI(info->mFixedURI);
}
info->mPreferredURI = info->mFixedURI; info->mPreferredURI = info->mFixedURI;
} }
return NS_OK; return NS_OK;
@@ -354,8 +351,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// ://totallybroken.url.com // ://totallybroken.url.com
// //shorthand.url.com // //shorthand.url.com
// //
if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://"))) if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://"))) {
{
uriString = StringTail(uriString, uriString.Length() - 3); uriString = StringTail(uriString, uriString.Length() - 3);
inputHadDuffProtocol = true; inputHadDuffProtocol = true;
} else if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("//"))) { } else if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("//"))) {
@@ -392,14 +388,13 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// be whitelisted? // be whitelisted?
if (info->mFixedURI) { if (info->mFixedURI) {
if (aFixupFlags & FIXUP_FLAG_REQUIRE_WHITELISTED_HOST) { if (aFixupFlags & FIXUP_FLAG_REQUIRE_WHITELISTED_HOST) {
nsAutoCString asciiHost; nsAutoCString asciiHost;
if (NS_SUCCEEDED(info->mFixedURI->GetAsciiHost(asciiHost)) && if (NS_SUCCEEDED(info->mFixedURI->GetAsciiHost(asciiHost)) &&
!asciiHost.IsEmpty()) { !asciiHost.IsEmpty()) {
uint32_t dotLoc = uint32_t(asciiHost.FindChar('.')); uint32_t dotLoc = uint32_t(asciiHost.FindChar('.'));
if ((dotLoc == uint32_t(kNotFound) || dotLoc == asciiHost.Length() - 1)) { if ((dotLoc == uint32_t(kNotFound) ||
dotLoc == asciiHost.Length() - 1)) {
if (IsDomainWhitelisted(asciiHost, dotLoc)) { if (IsDomainWhitelisted(asciiHost, dotLoc)) {
info->mPreferredURI = info->mFixedURI; info->mPreferredURI = info->mFixedURI;
} }
@@ -423,7 +418,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
return rv; return rv;
} }
NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword, NS_IMETHODIMP
nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
nsIInputStream** aPostData, nsIInputStream** aPostData,
nsIURIFixupInfo** aInfo) nsIURIFixupInfo** aInfo)
{ {
@@ -451,7 +447,8 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
ipc::OptionalInputStreamParams postData; ipc::OptionalInputStreamParams postData;
ipc::OptionalURIParams uri; ipc::OptionalURIParams uri;
nsAutoString providerName; nsAutoString providerName;
if (!contentChild->SendKeywordToURI(keyword, &providerName, &postData, &uri)) { if (!contentChild->SendKeywordToURI(keyword, &providerName, &postData,
&uri)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@@ -473,7 +470,8 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
#ifdef MOZ_TOOLKIT_SEARCH #ifdef MOZ_TOOLKIT_SEARCH
// Try falling back to the search service's default search engine // Try falling back to the search service's default search engine
nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1"); nsCOMPtr<nsIBrowserSearchService> searchSvc =
do_GetService("@mozilla.org/browser/search-service;1");
if (searchSvc) { if (searchSvc) {
nsCOMPtr<nsISearchEngine> defaultEngine; nsCOMPtr<nsISearchEngine> defaultEngine;
searchSvc->GetDefaultEngine(getter_AddRefs(defaultEngine)); searchSvc->GetDefaultEngine(getter_AddRefs(defaultEngine));
@@ -482,9 +480,11 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
nsAutoString responseType; nsAutoString responseType;
// We allow default search plugins to specify alternate // We allow default search plugins to specify alternate
// parameters that are specific to keyword searches. // parameters that are specific to keyword searches.
NS_NAMED_LITERAL_STRING(mozKeywordSearch, "application/x-moz-keywordsearch"); NS_NAMED_LITERAL_STRING(mozKeywordSearch,
"application/x-moz-keywordsearch");
bool supportsResponseType = false; bool supportsResponseType = false;
defaultEngine->SupportsResponseType(mozKeywordSearch, &supportsResponseType); defaultEngine->SupportsResponseType(mozKeywordSearch,
&supportsResponseType);
if (supportsResponseType) { if (supportsResponseType) {
responseType.Assign(mozKeywordSearch); responseType.Assign(mozKeywordSearch);
} }
@@ -527,7 +527,8 @@ nsDefaultURIFixup::TryKeywordFixupForURIInfo(const nsACString & aURIString,
nsIInputStream** aPostData) nsIInputStream** aPostData)
{ {
nsCOMPtr<nsIURIFixupInfo> keywordInfo; nsCOMPtr<nsIURIFixupInfo> keywordInfo;
nsresult rv = KeywordToURI(aURIString, aPostData, getter_AddRefs(keywordInfo)); nsresult rv = KeywordToURI(aURIString, aPostData,
getter_AddRefs(keywordInfo));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
keywordInfo->GetKeywordProviderName(aFixupInfo->mKeywordProviderName); keywordInfo->GetKeywordProviderName(aFixupInfo->mKeywordProviderName);
keywordInfo->GetKeywordAsSent(aFixupInfo->mKeywordAsSent); keywordInfo->GetKeywordAsSent(aFixupInfo->mKeywordAsSent);
@@ -536,14 +537,13 @@ nsDefaultURIFixup::TryKeywordFixupForURIInfo(const nsACString & aURIString,
return rv; return rv;
} }
bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI) bool
{ nsDefaultURIFixup::MakeAlternateURI(nsIURI* aURI)
if (!Preferences::GetRootBranch())
{ {
if (!Preferences::GetRootBranch()) {
return false; return false;
} }
if (!Preferences::GetBool("browser.fixup.alternate.enabled", true)) if (!Preferences::GetBool("browser.fixup.alternate.enabled", true)) {
{
return false; return false;
} }
@@ -572,56 +572,46 @@ bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
oldHost.BeginReading(iter); oldHost.BeginReading(iter);
oldHost.EndReading(iterEnd); oldHost.EndReading(iterEnd);
while (iter != iterEnd) { while (iter != iterEnd) {
if (*iter == '.') if (*iter == '.') {
numDots++; numDots++;
}
++iter; ++iter;
} }
// Get the prefix and suffix to stick onto the new hostname. By default these // Get the prefix and suffix to stick onto the new hostname. By default these
// are www. & .com but they could be any other value, e.g. www. & .org // are www. & .com but they could be any other value, e.g. www. & .org
nsAutoCString prefix("www."); nsAutoCString prefix("www.");
nsAdoptingCString prefPrefix = nsAdoptingCString prefPrefix =
Preferences::GetCString("browser.fixup.alternate.prefix"); Preferences::GetCString("browser.fixup.alternate.prefix");
if (prefPrefix) if (prefPrefix) {
{
prefix.Assign(prefPrefix); prefix.Assign(prefPrefix);
} }
nsAutoCString suffix(".com"); nsAutoCString suffix(".com");
nsAdoptingCString prefSuffix = nsAdoptingCString prefSuffix =
Preferences::GetCString("browser.fixup.alternate.suffix"); Preferences::GetCString("browser.fixup.alternate.suffix");
if (prefSuffix) if (prefSuffix) {
{
suffix.Assign(prefSuffix); suffix.Assign(prefSuffix);
} }
if (numDots == 0) if (numDots == 0) {
{
newHost.Assign(prefix); newHost.Assign(prefix);
newHost.Append(oldHost); newHost.Append(oldHost);
newHost.Append(suffix); newHost.Append(suffix);
} } else if (numDots == 1) {
else if (numDots == 1)
{
if (!prefix.IsEmpty() && if (!prefix.IsEmpty() &&
oldHost.EqualsIgnoreCase(prefix.get(), prefix.Length())) { oldHost.EqualsIgnoreCase(prefix.get(), prefix.Length())) {
newHost.Assign(oldHost); newHost.Assign(oldHost);
newHost.Append(suffix); newHost.Append(suffix);
} } else if (!suffix.IsEmpty()) {
else if (!suffix.IsEmpty()) {
newHost.Assign(prefix); newHost.Assign(prefix);
newHost.Append(oldHost); newHost.Append(oldHost);
} } else {
else
{
// Do nothing // Do nothing
return false; return false;
} }
} } else {
else
{
// Do nothing // Do nothing
return false; return false;
} }
@@ -639,7 +629,8 @@ bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
* Check if the host name starts with ftp\d*\. and it's not directly followed * Check if the host name starts with ftp\d*\. and it's not directly followed
* by the tld. * by the tld.
*/ */
bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec) bool
nsDefaultURIFixup::IsLikelyFTP(const nsCString& aHostSpec)
{ {
bool likelyFTP = false; bool likelyFTP = false;
if (aHostSpec.EqualsIgnoreCase("ftp", 3)) { if (aHostSpec.EqualsIgnoreCase("ftp", 3)) {
@@ -649,13 +640,11 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
aHostSpec.EndReading(end); aHostSpec.EndReading(end);
iter.advance(3); // move past the "ftp" part iter.advance(3); // move past the "ftp" part
while (iter != end) while (iter != end) {
{
if (*iter == '.') { if (*iter == '.') {
// now make sure the name has at least one more dot in it // now make sure the name has at least one more dot in it
++iter; ++iter;
while (iter != end) while (iter != end) {
{
if (*iter == '.') { if (*iter == '.') {
likelyFTP = true; likelyFTP = true;
break; break;
@@ -663,8 +652,7 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
++iter; ++iter;
} }
break; break;
} } else if (!nsCRT::IsAsciiDigit(*iter)) {
else if (!nsCRT::IsAsciiDigit(*iter)) {
break; break;
} }
++iter; ++iter;
@@ -673,45 +661,43 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
return likelyFTP; return likelyFTP;
} }
nsresult nsDefaultURIFixup::FileURIFixup(const nsACString& aStringURI, nsresult
nsIURI** aURI) nsDefaultURIFixup::FileURIFixup(const nsACString& aStringURI, nsIURI** aURI)
{ {
nsAutoCString uriSpecOut; nsAutoCString uriSpecOut;
nsresult rv = ConvertFileToStringURI(aStringURI, uriSpecOut); nsresult rv = ConvertFileToStringURI(aStringURI, uriSpecOut);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv)) {
{
// if this is file url, uriSpecOut is already in FS charset // if this is file url, uriSpecOut is already in FS charset
if(NS_SUCCEEDED(NS_NewURI(aURI, uriSpecOut.get(), nullptr))) if (NS_SUCCEEDED(NS_NewURI(aURI, uriSpecOut.get(), nullptr))) {
return NS_OK; return NS_OK;
} }
}
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn, nsresult
nsCString& aOut) nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
nsCString& aResult)
{ {
bool attemptFixup = false; bool attemptFixup = false;
#if defined(XP_WIN) #if defined(XP_WIN)
// Check for \ in the url-string or just a drive (PC) // Check for \ in the url-string or just a drive (PC)
if (kNotFound != aIn.FindChar('\\') || if (kNotFound != aIn.FindChar('\\') ||
(aIn.Length() == 2 && (aIn.Last() == ':' || aIn.Last() == '|'))) (aIn.Length() == 2 && (aIn.Last() == ':' || aIn.Last() == '|'))) {
{
attemptFixup = true; attemptFixup = true;
} }
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
// Check if it starts with / (UNIX) // Check if it starts with / (UNIX)
if(aIn.First() == '/') if (aIn.First() == '/') {
{
attemptFixup = true; attemptFixup = true;
} }
#else #else
// Do nothing (All others for now) // Do nothing (All others for now)
#endif #endif
if (attemptFixup) if (attemptFixup) {
{
// Test if this is a valid path by trying to create a local file // Test if this is a valid path by trying to create a local file
// object. The URL of that is returned if successful. // object. The URL of that is returned if successful.
@@ -726,8 +712,8 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
// in order to really fix the problem, we need to change the // in order to really fix the problem, we need to change the
// nsICmdLineService interface to use wstring to pass paramenters // nsICmdLineService interface to use wstring to pass paramenters
// instead of string since path name and other argument could be // instead of string since path name and other argument could be
// in non ascii.(see bug 87127) Since it is too risky to make interface change right // in non ascii.(see bug 87127) Since it is too risky to make interface
// now, we decide not to do so now. // change right now, we decide not to do so now.
// Therefore, the aIn we receive here maybe already in damage form // Therefore, the aIn we receive here maybe already in damage form
// (e.g. treat every bytes as ISO-8859-1 and cast up to char16_t // (e.g. treat every bytes as ISO-8859-1 and cast up to char16_t
// while the real data could be in file system charset ) // while the real data could be in file system charset )
@@ -750,16 +736,15 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
NS_ConvertUTF8toUTF16 in(aIn); NS_ConvertUTF8toUTF16 in(aIn);
if (PossiblyByteExpandedFileName(in)) { if (PossiblyByteExpandedFileName(in)) {
// removes high byte // removes high byte
rv = NS_NewNativeLocalFile(NS_LossyConvertUTF16toASCII(in), false, getter_AddRefs(filePath)); rv = NS_NewNativeLocalFile(NS_LossyConvertUTF16toASCII(in), false,
} getter_AddRefs(filePath));
else { } else {
// input is unicode // input is unicode
rv = NS_NewLocalFile(in, false, getter_AddRefs(filePath)); rv = NS_NewLocalFile(in, false, getter_AddRefs(filePath));
} }
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv)) {
{ NS_GetURLSpecFromFile(filePath, aResult);
NS_GetURLSpecFromFile(filePath, aOut);
return NS_OK; return NS_OK;
} }
} }
@@ -767,7 +752,6 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsresult nsresult
nsDefaultURIFixup::FixupURIProtocol(const nsACString& aURIString, nsDefaultURIFixup::FixupURIProtocol(const nsACString& aURIString,
nsDefaultURIFixupInfo* aFixupInfo, nsDefaultURIFixupInfo* aFixupInfo,
@@ -791,26 +775,28 @@ nsDefaultURIFixup::FixupURIProtocol(const nsACString & aURIString,
(firstDelim != -1 && schemeDelim > firstDelim)) { (firstDelim != -1 && schemeDelim > firstDelim)) {
// find host name // find host name
int32_t hostPos = uriString.FindCharInSet("/:?#"); int32_t hostPos = uriString.FindCharInSet("/:?#");
if (hostPos == -1) if (hostPos == -1) {
hostPos = uriString.Length(); hostPos = uriString.Length();
}
// extract host name // extract host name
nsAutoCString hostSpec; nsAutoCString hostSpec;
uriString.Left(hostSpec, hostPos); uriString.Left(hostSpec, hostPos);
// insert url spec corresponding to host name // insert url spec corresponding to host name
if (IsLikelyFTP(hostSpec)) if (IsLikelyFTP(hostSpec)) {
uriString.InsertLiteral("ftp://", 0); uriString.InsertLiteral("ftp://", 0);
else } else {
uriString.InsertLiteral("http://", 0); uriString.InsertLiteral("http://", 0);
}
aFixupInfo->mFixupChangedProtocol = true; aFixupInfo->mFixupChangedProtocol = true;
} // end if checkprotocol } // end if checkprotocol
return NS_NewURI(aURI, uriString, nullptr); return NS_NewURI(aURI, uriString, nullptr);
} }
bool
bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl) nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString& aUrl)
{ {
// Oh dear, the protocol is invalid. Test if the protocol might // Oh dear, the protocol is invalid. Test if the protocol might
// actually be a url without a protocol: // actually be a url without a protocol:
@@ -844,36 +830,30 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
aUrl.EndReading(iterEnd); aUrl.EndReading(iterEnd);
nsACString::const_iterator iter = iterBegin; nsACString::const_iterator iter = iterBegin;
while (iter != iterEnd) while (iter != iterEnd) {
{
uint32_t chunkSize = 0; uint32_t chunkSize = 0;
// Parse a chunk of the address // Parse a chunk of the address
while (iter != iterEnd && while (iter != iterEnd &&
(*iter == '-' || (*iter == '-' ||
nsCRT::IsAsciiAlpha(*iter) || nsCRT::IsAsciiAlpha(*iter) ||
nsCRT::IsAsciiDigit(*iter))) nsCRT::IsAsciiDigit(*iter))) {
{
++chunkSize; ++chunkSize;
++iter; ++iter;
} }
if (chunkSize == 0 || iter == iterEnd) if (chunkSize == 0 || iter == iterEnd) {
{
return false; return false;
} }
if (*iter == ':') if (*iter == ':') {
{
// Go onto checking the for the digits // Go onto checking the for the digits
break; break;
} }
if (*iter != '.') if (*iter != '.') {
{
// Whatever it is, it ain't a hostname! // Whatever it is, it ain't a hostname!
return false; return false;
} }
++iter; ++iter;
} }
if (iter == iterEnd) if (iter == iterEnd) {
{
// No point continuing since there is no colon // No point continuing since there is no colon
return false; return false;
} }
@@ -883,25 +863,18 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
// next forward slash (or end of string) // next forward slash (or end of string)
uint32_t digitCount = 0; uint32_t digitCount = 0;
while (iter != iterEnd && digitCount <= 5) while (iter != iterEnd && digitCount <= 5) {
{ if (nsCRT::IsAsciiDigit(*iter)) {
if (nsCRT::IsAsciiDigit(*iter))
{
digitCount++; digitCount++;
} } else if (*iter == '/') {
else if (*iter == '/')
{
break; break;
} } else {
else
{
// Whatever it is, it ain't a port! // Whatever it is, it ain't a port!
return false; return false;
} }
++iter; ++iter;
} }
if (digitCount == 0 || digitCount > 5) if (digitCount == 0 || digitCount > 5) {
{
// No digits or more digits than a port would have. // No digits or more digits than a port would have.
return false; return false;
} }
@@ -910,7 +883,8 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
return true; return true;
} }
bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn) bool
nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
{ {
// XXXXX HACK XXXXX : please don't copy this code. // XXXXX HACK XXXXX : please don't copy this code.
// There are cases where aIn contains the locale byte chars padded to short // There are cases where aIn contains the locale byte chars padded to short
@@ -922,10 +896,10 @@ bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
nsReadingIterator<char16_t> iterEnd; nsReadingIterator<char16_t> iterEnd;
aIn.BeginReading(iter); aIn.BeginReading(iter);
aIn.EndReading(iterEnd); aIn.EndReading(iterEnd);
while (iter != iterEnd) while (iter != iterEnd) {
{ if (*iter >= 0x0080 && *iter <= 0x00FF) {
if (*iter >= 0x0080 && *iter <= 0x00FF)
return true; return true;
}
++iter; ++iter;
} }
return false; return false;
@@ -1010,7 +984,8 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
firstSpaceLoc = pos; firstSpaceLoc = pos;
} else if (*iter == '?' && firstQMarkLoc == uint32_t(kNotFound)) { } else if (*iter == '?' && firstQMarkLoc == uint32_t(kNotFound)) {
firstQMarkLoc = pos; firstQMarkLoc = pos;
} else if ((*iter == '\'' || *iter == '"') && firstQuoteLoc == uint32_t(kNotFound)) { } else if ((*iter == '\'' || *iter == '"') &&
firstQuoteLoc == uint32_t(kNotFound)) {
firstQuoteLoc = pos; firstQuoteLoc = pos;
} else if (*iter == '[') { } else if (*iter == '[') {
lastLSBracketLoc = pos; lastLSBracketLoc = pos;
@@ -1035,11 +1010,13 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsAutoCString asciiHost; nsAutoCString asciiHost;
nsAutoCString host; nsAutoCString host;
bool isValidAsciiHost = aFixupInfo->mFixedURI && bool isValidAsciiHost =
aFixupInfo->mFixedURI &&
NS_SUCCEEDED(aFixupInfo->mFixedURI->GetAsciiHost(asciiHost)) && NS_SUCCEEDED(aFixupInfo->mFixedURI->GetAsciiHost(asciiHost)) &&
!asciiHost.IsEmpty(); !asciiHost.IsEmpty();
bool isValidHost = aFixupInfo->mFixedURI && bool isValidHost =
aFixupInfo->mFixedURI &&
NS_SUCCEEDED(aFixupInfo->mFixedURI->GetHost(host)) && NS_SUCCEEDED(aFixupInfo->mFixedURI->GetHost(host)) &&
!host.IsEmpty(); !host.IsEmpty();
@@ -1073,44 +1050,52 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsresult rv = NS_OK; nsresult rv = NS_OK;
// We do keyword lookups if a space or quote preceded the dot, colon // We do keyword lookups if a space or quote preceded the dot, colon
// or question mark (or if the latter is not found, or if the input starts with a question mark) // or question mark (or if the latter is not found, or if the input starts
// with a question mark)
if (((firstSpaceLoc < firstDotLoc || firstQuoteLoc < firstDotLoc) && if (((firstSpaceLoc < firstDotLoc || firstQuoteLoc < firstDotLoc) &&
(firstSpaceLoc < firstColonLoc || firstQuoteLoc < firstColonLoc) && (firstSpaceLoc < firstColonLoc || firstQuoteLoc < firstColonLoc) &&
(firstSpaceLoc < firstQMarkLoc || firstQuoteLoc < firstQMarkLoc)) || firstQMarkLoc == 0) { (firstSpaceLoc < firstQMarkLoc || firstQuoteLoc < firstQMarkLoc)) ||
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData); firstQMarkLoc == 0) {
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
// ... or when the host is the same as asciiHost and there are no // ... or when the host is the same as asciiHost and there are no
// characters from [a-z][A-Z] // characters from [a-z][A-Z]
} else if (isValidAsciiHost && isValidHost && !hasAsciiAlpha && } else if (isValidAsciiHost && isValidHost && !hasAsciiAlpha &&
host.EqualsIgnoreCase(asciiHost.get())) { host.EqualsIgnoreCase(asciiHost.get())) {
if (!sDNSFirstForSingleWords) { if (!sDNSFirstForSingleWords) {
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData); rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
} }
} }
// ... or if there is no question mark or colon, and there is either no // ... or if there is no question mark or colon, and there is either no
// dot, or exactly 1 and it is the first or last character of the input: // dot, or exactly 1 and it is the first or last character of the input:
else if ((firstDotLoc == uint32_t(kNotFound) || else if ((firstDotLoc == uint32_t(kNotFound) ||
(foundDots == 1 && (firstDotLoc == 0 || firstDotLoc == aURIString.Length() - 1))) && (foundDots == 1 && (firstDotLoc == 0 ||
firstColonLoc == uint32_t(kNotFound) && firstQMarkLoc == uint32_t(kNotFound)) { firstDotLoc == aURIString.Length() - 1))) &&
firstColonLoc == uint32_t(kNotFound) &&
firstQMarkLoc == uint32_t(kNotFound)) {
if (isValidAsciiHost && IsDomainWhitelisted(asciiHost, firstDotLoc)) { if (isValidAsciiHost && IsDomainWhitelisted(asciiHost, firstDotLoc)) {
return NS_OK; return NS_OK;
} }
// ... unless there are no dots, and a slash, and alpha characters, and this is a valid host: // ... unless there are no dots, and a slash, and alpha characters, and
if (firstDotLoc == uint32_t(kNotFound) && lastSlashLoc != uint32_t(kNotFound) && // this is a valid host:
if (firstDotLoc == uint32_t(kNotFound) &&
lastSlashLoc != uint32_t(kNotFound) &&
hasAsciiAlpha && isValidAsciiHost) { hasAsciiAlpha && isValidAsciiHost) {
return NS_OK; return NS_OK;
} }
// If we get here, we don't have a valid URI, or we did but the // If we get here, we don't have a valid URI, or we did but the
// host is not whitelisted, so we do a keyword search *anyway*: // host is not whitelisted, so we do a keyword search *anyway*:
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData); rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
} }
return rv; return rv;
} }
bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost, bool
nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
const uint32_t aDotLoc) const uint32_t aDotLoc)
{ {
if (sDNSFirstForSingleWords) { if (sDNSFirstForSingleWords) {
@@ -1132,29 +1117,26 @@ bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
return Preferences::GetBool(pref.get(), false); return Preferences::GetBool(pref.get(), false);
} }
nsresult
nsresult NS_NewURIFixup(nsIURIFixup **aURIFixup) NS_NewURIFixup(nsIURIFixup** aURIFixup)
{ {
nsDefaultURIFixup* fixup = new nsDefaultURIFixup; nsDefaultURIFixup* fixup = new nsDefaultURIFixup;
if (fixup == nullptr) if (!fixup) {
{
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return fixup->QueryInterface(NS_GET_IID(nsIURIFixup), (void**)aURIFixup); return fixup->QueryInterface(NS_GET_IID(nsIURIFixup), (void**)aURIFixup);
} }
/* Implementation of nsIURIFixupInfo */ /* Implementation of nsIURIFixupInfo */
NS_IMPL_ISUPPORTS(nsDefaultURIFixupInfo, nsIURIFixupInfo) NS_IMPL_ISUPPORTS(nsDefaultURIFixupInfo, nsIURIFixupInfo)
nsDefaultURIFixupInfo::nsDefaultURIFixupInfo(const nsACString& aOriginalInput): nsDefaultURIFixupInfo::nsDefaultURIFixupInfo(const nsACString& aOriginalInput)
mFixupChangedProtocol(false), : mFixupChangedProtocol(false)
mFixupCreatedAlternateURI(false) , mFixupCreatedAlternateURI(false)
{ {
mOriginalInput = aOriginalInput; mOriginalInput = aOriginalInput;
} }
nsDefaultURIFixupInfo::~nsDefaultURIFixupInfo() nsDefaultURIFixupInfo::~nsDefaultURIFixupInfo()
{ {
} }
@@ -1191,36 +1173,36 @@ nsDefaultURIFixupInfo::GetFixedURI(nsIURI** aFixedURI)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixupInfo::GetKeywordProviderName(nsAString& aOut) nsDefaultURIFixupInfo::GetKeywordProviderName(nsAString& aResult)
{ {
aOut = mKeywordProviderName; aResult = mKeywordProviderName;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixupInfo::GetKeywordAsSent(nsAString& aOut) nsDefaultURIFixupInfo::GetKeywordAsSent(nsAString& aResult)
{ {
aOut = mKeywordAsSent; aResult = mKeywordAsSent;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixupInfo::GetFixupChangedProtocol(bool* aOut) nsDefaultURIFixupInfo::GetFixupChangedProtocol(bool* aResult)
{ {
*aOut = mFixupChangedProtocol; *aResult = mFixupChangedProtocol;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixupInfo::GetFixupCreatedAlternateURI(bool* aOut) nsDefaultURIFixupInfo::GetFixupCreatedAlternateURI(bool* aResult)
{ {
*aOut = mFixupCreatedAlternateURI; *aResult = mFixupCreatedAlternateURI;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDefaultURIFixupInfo::GetOriginalInput(nsACString& aInput) nsDefaultURIFixupInfo::GetOriginalInput(nsACString& aResult)
{ {
aInput = mOriginalInput; aResult = mOriginalInput;
return NS_OK; return NS_OK;
} }

View File

@@ -26,7 +26,7 @@ protected:
private: private:
/* additional members */ /* additional members */
nsresult FileURIFixup(const nsACString& aStringURI, nsIURI** aURI); nsresult FileURIFixup(const nsACString& aStringURI, nsIURI** aURI);
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aOut); nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aResult);
nsresult FixupURIProtocol(const nsACString& aIn, nsresult FixupURIProtocol(const nsACString& aIn,
nsDefaultURIFixupInfo* aFixupInfo, nsDefaultURIFixupInfo* aFixupInfo,
nsIURI** aURI); nsIURI** aURI);

File diff suppressed because it is too large Load Diff

View File

@@ -94,7 +94,8 @@ class ProfilerMarkerTracing;
/* load types were moved to nsDocShellLoadTypes.h */ /* load types were moved to nsDocShellLoadTypes.h */
/* internally used ViewMode types */ /* internally used ViewMode types */
enum ViewMode { enum ViewMode
{
viewNormal = 0x0, viewNormal = 0x0,
viewSource = 0x1 viewSource = 0x1
}; };
@@ -123,34 +124,36 @@ protected:
virtual ~nsRefreshTimer(); virtual ~nsRefreshTimer();
}; };
typedef enum { enum eCharsetReloadState
{
eCharsetReloadInit, eCharsetReloadInit,
eCharsetReloadRequested, eCharsetReloadRequested,
eCharsetReloadStopOrigional eCharsetReloadStopOrigional
} eCharsetReloadState; };
//***************************************************************************** //*****************************************************************************
//*** nsDocShell //*** nsDocShell
//***************************************************************************** //*****************************************************************************
class nsDocShell MOZ_FINAL : public nsDocLoader, class nsDocShell MOZ_FINAL
public nsIDocShell, : public nsDocLoader
public nsIWebNavigation, , public nsIDocShell
public nsIBaseWindow, , public nsIWebNavigation
public nsIScrollable, , public nsIBaseWindow
public nsITextScroll, , public nsIScrollable
public nsIDocCharset, , public nsITextScroll
public nsIContentViewerContainer, , public nsIDocCharset
public nsIRefreshURI, , public nsIContentViewerContainer
public nsIWebProgressListener, , public nsIRefreshURI
public nsIWebPageDescriptor, , public nsIWebProgressListener
public nsIAuthPromptProvider, , public nsIWebPageDescriptor
public nsILoadContext, , public nsIAuthPromptProvider
public nsIWebShellServices, , public nsILoadContext
public nsILinkHandler, , public nsIWebShellServices
public nsIClipboardCommands, , public nsILinkHandler
public nsIDOMStorageManager, , public nsIClipboardCommands
public mozilla::SupportsWeakPtr<nsDocShell> , public nsIDOMStorageManager
, public mozilla::SupportsWeakPtr<nsDocShell>
{ {
friend class nsDSURIContentListener; friend class nsDSURIContentListener;
@@ -214,7 +217,8 @@ public:
NS_IMETHOD OnLeaveLink() MOZ_OVERRIDE; NS_IMETHOD OnLeaveLink() MOZ_OVERRIDE;
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType); nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType); uint32_t ConvertDocShellLoadInfoToLoadType(
nsDocShellInfoLoadType aDocShellLoadType);
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
// are shared with nsIDocShell (appID, etc.) and can't be declared twice. // are shared with nsIDocShell (appID, etc.) and can't be declared twice.
@@ -271,6 +275,7 @@ public:
// Global counter for how many docShells are currently recording profile // Global counter for how many docShells are currently recording profile
// timeline markers // timeline markers
static unsigned long gProfileTimelineRecordingsCount; static unsigned long gProfileTimelineRecordingsCount;
protected: protected:
// Object Management // Object Management
virtual ~nsDocShell(); virtual ~nsDocShell();
@@ -284,10 +289,12 @@ protected:
nsIURI* aBaseURI, nsIURI* aBaseURI,
bool aTryToSaveOldPresentation = true); bool aTryToSaveOldPresentation = true);
nsresult CreateContentViewer(const char* aContentType, nsresult CreateContentViewer(const char* aContentType,
nsIRequest * request, nsIStreamListener ** aContentHandler); nsIRequest* aRequest,
nsIStreamListener** aContentHandler);
nsresult NewContentViewerObj(const char* aContentType, nsresult NewContentViewerObj(const char* aContentType,
nsIRequest * request, nsILoadGroup * aLoadGroup, nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
nsIStreamListener ** aContentHandler, nsIContentViewer ** aViewer); nsIStreamListener** aContentHandler,
nsIContentViewer** aViewer);
nsresult SetupNewViewer(nsIContentViewer* aNewViewer); nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
void SetupReferrerFromChannel(nsIChannel* aChannel); void SetupReferrerFromChannel(nsIChannel* aChannel);
@@ -316,14 +323,14 @@ protected:
const nsAString& aFileName, const nsAString& aFileName,
nsIInputStream* aPostData, nsIInputStream* aPostData,
nsIInputStream* aHeadersData, nsIInputStream* aHeadersData,
bool firstParty, bool aFirstParty,
nsIDocShell** aDocShell, nsIDocShell** aDocShell,
nsIRequest** aRequest, nsIRequest** aRequest,
bool aIsNewWindowTarget, bool aIsNewWindowTarget,
bool aBypassClassifier, bool aBypassClassifier,
bool aForceAllowCookies, bool aForceAllowCookies,
const nsAString& aSrcdoc, const nsAString& aSrcdoc,
nsIURI * baseURI, nsIURI* aBaseURI,
nsContentPolicyType aContentPolicyType); nsContentPolicyType aContentPolicyType);
nsresult AddHeadersToChannel(nsIInputStream* aHeadersData, nsresult AddHeadersToChannel(nsIInputStream* aHeadersData,
nsIChannel* aChannel); nsIChannel* aChannel);
@@ -331,7 +338,7 @@ protected:
nsIURILoader* aURILoader, nsIURILoader* aURILoader,
bool aBypassClassifier); bool aBypassClassifier);
nsresult ScrollToAnchor(nsACString & curHash, nsACString & newHash, nsresult ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash,
uint32_t aLoadType); uint32_t aLoadType);
// Returns true if would have called FireOnLocationChange, // Returns true if would have called FireOnLocationChange,
@@ -359,7 +366,7 @@ protected:
bool aCloneSHChildren); bool aCloneSHChildren);
void SetReferrerURI(nsIURI* aURI); void SetReferrerURI(nsIURI* aURI);
void SetReferrerPolicy(uint32_t referrerPolicy); void SetReferrerPolicy(uint32_t aReferrerPolicy);
// Session History // Session History
bool ShouldAddToSessionHistory(nsIURI* aURI); bool ShouldAddToSessionHistory(nsIURI* aURI);
@@ -377,7 +384,7 @@ protected:
bool aCloneChildren); bool aCloneChildren);
nsresult AddChildSHEntryInternal(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry, nsresult AddChildSHEntryInternal(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
int32_t aChildOffset, uint32_t loadType, int32_t aChildOffset, uint32_t aLoadType,
bool aCloneChildren); bool aCloneChildren);
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType); nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
@@ -399,8 +406,7 @@ protected:
nsISHEntry** aDestEntry); nsISHEntry** aDestEntry);
// Child-walking callback for CloneAndReplace // Child-walking callback for CloneAndReplace
static nsresult CloneAndReplaceChild(nsISHEntry *aEntry, static nsresult CloneAndReplaceChild(nsISHEntry* aEntry, nsDocShell* aShell,
nsDocShell *aShell,
int32_t aChildIndex, void* aData); int32_t aChildIndex, void* aData);
nsresult GetRootSessionHistory(nsISHistory** aReturn); nsresult GetRootSessionHistory(nsISHistory** aReturn);
@@ -423,8 +429,7 @@ protected:
void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry); void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry);
// Child-walking callback for SetHistoryEntry // Child-walking callback for SetHistoryEntry
static nsresult SetChildHistoryEntry(nsISHEntry *aEntry, static nsresult SetChildHistoryEntry(nsISHEntry* aEntry, nsDocShell* aShell,
nsDocShell *aShell,
int32_t aEntryIndex, void* aData); int32_t aEntryIndex, void* aData);
// Callback prototype for WalkHistoryEntries. // Callback prototype for WalkHistoryEntries.
@@ -550,11 +555,10 @@ protected:
nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer); nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
static inline uint32_t static inline uint32_t PRTimeToSeconds(PRTime aTimeUsec)
PRTimeToSeconds(PRTime t_usec)
{ {
PRTime usec_per_sec = PR_USEC_PER_SEC; PRTime usecPerSec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec); return uint32_t(aTimeUsec /= usecPerSec);
} }
inline bool UseErrorPages() inline bool UseErrorPages()
@@ -575,7 +579,7 @@ protected:
// Sets the current document's current state object to the given SHEntry's // Sets the current document's current state object to the given SHEntry's
// state object. The current state object is eventually given to the page // state object. The current state object is eventually given to the page
// in the PopState event. // in the PopState event.
nsresult SetDocCurrentStateObj(nsISHEntry *shEntry); nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
nsresult CheckLoadingPermissions(); nsresult CheckLoadingPermissions();
@@ -648,8 +652,8 @@ protected:
nsresult BeginRestoreChildren(); nsresult BeginRestoreChildren();
// Method to get our current position and size without flushing // Method to get our current position and size without flushing
void DoGetPositionAndSize(int32_t * x, int32_t * y, int32_t * cx, void DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
int32_t * cy); int32_t* aHeight);
// Call this when a URI load is handed to us (via OnLinkClick or // Call this when a URI load is handed to us (via OnLinkClick or
// InternalLoad). This makes sure that we're not inside unload, or that if // InternalLoad). This makes sure that we're not inside unload, or that if
@@ -662,8 +666,8 @@ protected:
nsIDOMStorageManager* TopSessionStorageManager(); nsIDOMStorageManager* TopSessionStorageManager();
// helpers for executing commands // helpers for executing commands
nsresult GetControllerForCommand(const char *inCommand, nsresult GetControllerForCommand(const char* aCommand,
nsIController** outController); nsIController** aResult);
nsresult EnsureCommandHandler(); nsresult EnsureCommandHandler();
nsIChannel* GetCurrentDocChannel(); nsIChannel* GetCurrentDocChannel();
@@ -678,9 +682,11 @@ protected:
bool DoAppRedirectIfNeeded(nsIURI* aURI, bool DoAppRedirectIfNeeded(nsIURI* aURI,
nsIDocShellLoadInfo* aLoadInfo, nsIDocShellLoadInfo* aLoadInfo,
bool aFirstParty); bool aFirstParty);
protected: protected:
nsresult GetCurScrollPos(int32_t scrollOrientation, int32_t * curPos); nsresult GetCurScrollPos(int32_t aScrollOrientation, int32_t* aCurPos);
nsresult SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos); nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
int32_t aCurVerticalPos);
// Override the parent setter from nsDocLoader // Override the parent setter from nsDocLoader
virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) MOZ_OVERRIDE; virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) MOZ_OVERRIDE;
@@ -695,22 +701,24 @@ protected:
public: public:
// Event type dispatched by RestorePresentation // Event type dispatched by RestorePresentation
class RestorePresentationEvent : public nsRunnable { class RestorePresentationEvent : public nsRunnable
{
public: public:
NS_DECL_NSIRUNNABLE NS_DECL_NSIRUNNABLE
explicit RestorePresentationEvent(nsDocShell *ds) : mDocShell(ds) {} explicit RestorePresentationEvent(nsDocShell* aDs) : mDocShell(aDs) {}
void Revoke() { mDocShell = nullptr; } void Revoke() { mDocShell = nullptr; }
private: private:
nsRefPtr<nsDocShell> mDocShell; nsRefPtr<nsDocShell> mDocShell;
}; };
protected:
protected:
bool JustStartedNetworkLoad(); bool JustStartedNetworkLoad();
nsresult CreatePrincipalFromReferrer(nsIURI* aReferrer, nsresult CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** outPrincipal); nsIPrincipal** aResult);
enum FrameType { enum FrameType
{
eFrameTypeRegular, eFrameTypeRegular,
eFrameTypeBrowser, eFrameTypeBrowser,
eFrameTypeApp eFrameTypeApp
@@ -852,7 +860,8 @@ protected:
// parent across the content boundary has allowfullscreen=true in all its // parent across the content boundary has allowfullscreen=true in all its
// containing iframes. mFullscreenAllowed defaults to CHECK_ATTRIBUTES and // containing iframes. mFullscreenAllowed defaults to CHECK_ATTRIBUTES and
// is set otherwise when docshells which are content boundaries are created. // is set otherwise when docshells which are content boundaries are created.
enum FullscreenAllowedState { enum FullscreenAllowedState
{
CHECK_ATTRIBUTES, CHECK_ATTRIBUTES,
PARENT_ALLOWS, PARENT_ALLOWS,
PARENT_PROHIBITS PARENT_PROHIBITS
@@ -953,6 +962,7 @@ protected:
nsString mPaymentRequestId; nsString mPaymentRequestId;
nsString GetInheritedPaymentRequestId(); nsString GetInheritedPaymentRequestId();
private: private:
nsCString mForcedCharset; nsCString mForcedCharset;
nsCString mParentCharset; nsCString mParentCharset;
@@ -981,10 +991,11 @@ private:
nsresult DoFindItemWithName(const char16_t* aName, nsresult DoFindItemWithName(const char16_t* aName,
nsISupports* aRequestor, nsISupports* aRequestor,
nsIDocShellTreeItem* aOriginalRequestor, nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** _retval); nsIDocShellTreeItem** aResult);
// Notify consumers of a search being loaded through the observer service: // Notify consumers of a search being loaded through the observer service:
void MaybeNotifyKeywordSearchLoading(const nsString &aProvider, const nsString &aKeyword); void MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
const nsString& aKeyword);
#ifdef DEBUG #ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks // We're counting the number of |nsDocShells| to help find leaks
@@ -992,9 +1003,10 @@ private:
#endif /* DEBUG */ #endif /* DEBUG */
public: public:
class InterfaceRequestorProxy : public nsIInterfaceRequestor { class InterfaceRequestorProxy : public nsIInterfaceRequestor
{
public: public:
explicit InterfaceRequestorProxy(nsIInterfaceRequestor* p); explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor);
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIINTERFACEREQUESTOR

View File

@@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsDocShellEditorData.h" #include "nsDocShellEditorData.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
@@ -14,14 +13,8 @@
#include "nsIEditingSession.h" #include "nsIEditingSession.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
/*--------------------------------------------------------------------------- nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell)
: mDocShell(aOwningDocShell)
nsDocShellEditorData
----------------------------------------------------------------------------*/
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
: mDocShell(inOwningDocShell)
, mMakeEditable(false) , mMakeEditable(false)
, mIsDetached(false) , mIsDetached(false)
, mDetachedMakeEditable(false) , mDetachedMakeEditable(false)
@@ -30,12 +23,6 @@ nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
NS_ASSERTION(mDocShell, "Where is my docShell?"); NS_ASSERTION(mDocShell, "Where is my docShell?");
} }
/*---------------------------------------------------------------------------
~nsDocShellEditorData
----------------------------------------------------------------------------*/
nsDocShellEditorData::~nsDocShellEditorData() nsDocShellEditorData::~nsDocShellEditorData()
{ {
TearDownEditor(); TearDownEditor();
@@ -52,133 +39,94 @@ nsDocShellEditorData::TearDownEditor()
mIsDetached = false; mIsDetached = false;
} }
/*---------------------------------------------------------------------------
MakeEditable
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::MakeEditable(bool inWaitForUriLoad) nsDocShellEditorData::MakeEditable(bool aInWaitForUriLoad)
{ {
if (mMakeEditable) if (mMakeEditable) {
return NS_OK; return NS_OK;
}
// if we are already editable, and are getting turned off, // if we are already editable, and are getting turned off,
// nuke the editor. // nuke the editor.
if (mEditor) if (mEditor) {
{
NS_WARNING("Destroying existing editor on frame"); NS_WARNING("Destroying existing editor on frame");
mEditor->PreDestroy(false); mEditor->PreDestroy(false);
mEditor = nullptr; mEditor = nullptr;
} }
if (inWaitForUriLoad) if (aInWaitForUriLoad) {
mMakeEditable = true; mMakeEditable = true;
}
return NS_OK; return NS_OK;
} }
/*---------------------------------------------------------------------------
GetEditable
----------------------------------------------------------------------------*/
bool bool
nsDocShellEditorData::GetEditable() nsDocShellEditorData::GetEditable()
{ {
return mMakeEditable || (mEditor != nullptr); return mMakeEditable || (mEditor != nullptr);
} }
/*---------------------------------------------------------------------------
CreateEditor
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::CreateEditor() nsDocShellEditorData::CreateEditor()
{ {
nsCOMPtr<nsIEditingSession> editingSession; nsCOMPtr<nsIEditingSession> editingSession;
nsresult rv = GetEditingSession(getter_AddRefs(editingSession)); nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDOMWindow> domWindow = nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr; mDocShell ? mDocShell->GetWindow() : nullptr;
rv = editingSession->SetupEditorOnWindow(domWindow); rv = editingSession->SetupEditorOnWindow(domWindow);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
return NS_OK; return NS_OK;
} }
/*---------------------------------------------------------------------------
GetEditingSession
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::GetEditingSession(nsIEditingSession **outEditingSession) nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult)
{ {
nsresult rv = EnsureEditingSession(); nsresult rv = EnsureEditingSession();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*outEditingSession = mEditingSession); NS_ADDREF(*aResult = mEditingSession);
return NS_OK; return NS_OK;
} }
/*---------------------------------------------------------------------------
GetEditor
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::GetEditor(nsIEditor **outEditor) nsDocShellEditorData::GetEditor(nsIEditor** aResult)
{ {
NS_ENSURE_ARG_POINTER(outEditor); NS_ENSURE_ARG_POINTER(aResult);
NS_IF_ADDREF(*outEditor = mEditor); NS_IF_ADDREF(*aResult = mEditor);
return NS_OK; return NS_OK;
} }
/*---------------------------------------------------------------------------
SetEditor
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::SetEditor(nsIEditor *inEditor) nsDocShellEditorData::SetEditor(nsIEditor* aEditor)
{ {
// destroy any editor that we have. Checks for equality are // destroy any editor that we have. Checks for equality are
// necessary to ensure that assigment into the nsCOMPtr does // necessary to ensure that assigment into the nsCOMPtr does
// not temporarily reduce the refCount of the editor to zero // not temporarily reduce the refCount of the editor to zero
if (mEditor.get() != inEditor) if (mEditor.get() != aEditor) {
{ if (mEditor) {
if (mEditor)
{
mEditor->PreDestroy(false); mEditor->PreDestroy(false);
mEditor = nullptr; mEditor = nullptr;
} }
mEditor = inEditor; // owning addref mEditor = aEditor; // owning addref
if (!mEditor) if (!mEditor) {
mMakeEditable = false; mMakeEditable = false;
} }
}
return NS_OK; return NS_OK;
} }
// This creates the editing session on the content docShell that owns 'this'.
/*---------------------------------------------------------------------------
EnsureEditingSession
This creates the editing session on the content docShell that owns
'this'.
----------------------------------------------------------------------------*/
nsresult nsresult
nsDocShellEditorData::EnsureEditingSession() nsDocShellEditorData::EnsureEditingSession()
{ {
@@ -187,8 +135,7 @@ nsDocShellEditorData::EnsureEditingSession()
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!mEditingSession) if (!mEditingSession) {
{
mEditingSession = mEditingSession =
do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv); do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv);
} }
@@ -214,8 +161,9 @@ nsDocShellEditorData::DetachFromWindow()
nsCOMPtr<nsIDOMDocument> domDoc; nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc)); domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc); nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
if (htmlDoc) if (htmlDoc) {
mDetachedEditingState = htmlDoc->GetEditingState(); mDetachedEditingState = htmlDoc->GetEditingState();
}
mDocShell = nullptr; mDocShell = nullptr;
@@ -238,8 +186,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
nsCOMPtr<nsIDOMDocument> domDoc; nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc)); domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc); nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
if (htmlDoc) if (htmlDoc) {
htmlDoc->SetEditingState(mDetachedEditingState); htmlDoc->SetEditingState(mDetachedEditingState);
}
return NS_OK; return NS_OK;
} }

View File

@@ -19,23 +19,21 @@ class nsIEditor;
class nsDocShellEditorData class nsDocShellEditorData
{ {
public: public:
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
explicit nsDocShellEditorData(nsIDocShell* inOwningDocShell);
~nsDocShellEditorData(); ~nsDocShellEditorData();
nsresult MakeEditable(bool inWaitForUriLoad); nsresult MakeEditable(bool aWaitForUriLoad);
bool GetEditable(); bool GetEditable();
nsresult CreateEditor(); nsresult CreateEditor();
nsresult GetEditingSession(nsIEditingSession **outEditingSession); nsresult GetEditingSession(nsIEditingSession** aResult);
nsresult GetEditor(nsIEditor **outEditor); nsresult GetEditor(nsIEditor** aResult);
nsresult SetEditor(nsIEditor *inEditor); nsresult SetEditor(nsIEditor* aEditor);
void TearDownEditor(); void TearDownEditor();
nsresult DetachFromWindow(); nsresult DetachFromWindow();
nsresult ReattachToWindow(nsIDocShell* aDocShell); nsresult ReattachToWindow(nsIDocShell* aDocShell);
bool WaitingForLoad() const { return mMakeEditable; } bool WaitingForLoad() const { return mMakeEditable; }
protected: protected:
nsresult EnsureEditingSession(); nsresult EnsureEditingSession();
// The doc shell that owns us. Weak ref, since it always outlives us. // The doc shell that owns us. Weak ref, since it always outlives us.
@@ -63,5 +61,4 @@ protected:
}; };
#endif // nsDocShellEditorData_h__ #endif // nsDocShellEditorData_h__

View File

@@ -4,17 +4,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsDocShellEnumerator.h" #include "nsDocShellEnumerator.h"
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
nsDocShellEnumerator::nsDocShellEnumerator(int32_t inEnumerationDirection) nsDocShellEnumerator::nsDocShellEnumerator(int32_t aEnumerationDirection)
: mRootItem(nullptr) : mRootItem(nullptr)
, mCurIndex(0) , mCurIndex(0)
, mDocShellType(nsIDocShellTreeItem::typeAll) , mDocShellType(nsIDocShellTreeItem::typeAll)
, mArrayValid(false) , mArrayValid(false)
, mEnumerationDirection(inEnumerationDirection) , mEnumerationDirection(aEnumerationDirection)
{ {
} }
@@ -24,15 +23,17 @@ nsDocShellEnumerator::~nsDocShellEnumerator()
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator) NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
/* nsISupports getNext (); */ /* nsISupports getNext (); */
NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem) NS_IMETHODIMP
nsDocShellEnumerator::GetNext(nsISupports** aResult)
{ {
NS_ENSURE_ARG_POINTER(outCurItem); NS_ENSURE_ARG_POINTER(aResult);
*outCurItem = nullptr; *aResult = nullptr;
nsresult rv = EnsureDocShellArray(); nsresult rv = EnsureDocShellArray();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
if (mCurIndex >= mItemArray.Length()) { if (mCurIndex >= mItemArray.Length()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@@ -40,24 +41,29 @@ NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
// post-increment is important here // post-increment is important here
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv); nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
item.forget(outCurItem); item.forget(aResult);
return rv; return rv;
} }
/* boolean hasMoreElements (); */ /* boolean hasMoreElements (); */
NS_IMETHODIMP nsDocShellEnumerator::HasMoreElements(bool *outHasMore) NS_IMETHODIMP
nsDocShellEnumerator::HasMoreElements(bool* aResult)
{ {
NS_ENSURE_ARG_POINTER(outHasMore); NS_ENSURE_ARG_POINTER(aResult);
*outHasMore = false; *aResult = false;
nsresult rv = EnsureDocShellArray(); nsresult rv = EnsureDocShellArray();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
*outHasMore = (mCurIndex < mItemArray.Length()); *aResult = (mCurIndex < mItemArray.Length());
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem) nsresult
nsDocShellEnumerator::GetEnumerationRootItem(
nsIDocShellTreeItem** aEnumerationRootItem)
{ {
NS_ENSURE_ARG_POINTER(aEnumerationRootItem); NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem); nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
@@ -65,37 +71,42 @@ nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEn
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem) nsresult
nsDocShellEnumerator::SetEnumerationRootItem(
nsIDocShellTreeItem* aEnumerationRootItem)
{ {
mRootItem = do_GetWeakReference(aEnumerationRootItem); mRootItem = do_GetWeakReference(aEnumerationRootItem);
ClearState(); ClearState();
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::GetEnumDocShellType(int32_t *aEnumerationItemType) nsresult
nsDocShellEnumerator::GetEnumDocShellType(int32_t* aEnumerationItemType)
{ {
NS_ENSURE_ARG_POINTER(aEnumerationItemType); NS_ENSURE_ARG_POINTER(aEnumerationItemType);
*aEnumerationItemType = mDocShellType; *aEnumerationItemType = mDocShellType;
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType) nsresult
nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
{ {
mDocShellType = aEnumerationItemType; mDocShellType = aEnumerationItemType;
ClearState(); ClearState();
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::First() nsresult
nsDocShellEnumerator::First()
{ {
mCurIndex = 0; mCurIndex = 0;
return EnsureDocShellArray(); return EnsureDocShellArray();
} }
nsresult nsDocShellEnumerator::EnsureDocShellArray() nsresult
{ nsDocShellEnumerator::EnsureDocShellArray()
if (!mArrayValid)
{ {
if (!mArrayValid) {
mArrayValid = true; mArrayValid = true;
return BuildDocShellArray(mItemArray); return BuildDocShellArray(mItemArray);
} }
@@ -103,7 +114,8 @@ nsresult nsDocShellEnumerator::EnsureDocShellArray()
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::ClearState() nsresult
nsDocShellEnumerator::ClearState()
{ {
mItemArray.Clear(); mItemArray.Clear();
mArrayValid = false; mArrayValid = false;
@@ -111,67 +123,85 @@ nsresult nsDocShellEnumerator::ClearState()
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray) nsresult
nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray)
{ {
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
inItemArray.Clear(); aItemArray.Clear();
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem); nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
return BuildArrayRecursive(item, inItemArray); return BuildArrayRecursive(item, aItemArray);
} }
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) nsresult
nsDocShellForwardsEnumerator::BuildArrayRecursive(
nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray)
{ {
nsresult rv; nsresult rv;
// add this item to the array // add this item to the array
if (mDocShellType == nsIDocShellTreeItem::typeAll || if (mDocShellType == nsIDocShellTreeItem::typeAll ||
inItem->ItemType() == mDocShellType) { aItem->ItemType() == mDocShellType) {
if (!inItemArray.AppendElement(do_GetWeakReference(inItem))) if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
}
int32_t numChildren; int32_t numChildren;
rv = inItem->GetChildCount(&numChildren); rv = aItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
for (int32_t i = 0; i < numChildren; ++i) for (int32_t i = 0; i < numChildren; ++i) {
{
nsCOMPtr<nsIDocShellTreeItem> curChild; nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = inItem->GetChildAt(i, getter_AddRefs(curChild)); rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
rv = BuildArrayRecursive(curChild, inItemArray); rv = BuildArrayRecursive(curChild, aItemArray);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
} }
return NS_OK; return NS_OK;
} }
nsresult
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) nsDocShellBackwardsEnumerator::BuildArrayRecursive(
nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray)
{ {
nsresult rv; nsresult rv;
int32_t numChildren; int32_t numChildren;
rv = inItem->GetChildCount(&numChildren); rv = aItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
for (int32_t i = numChildren - 1; i >= 0; --i) for (int32_t i = numChildren - 1; i >= 0; --i) {
{
nsCOMPtr<nsIDocShellTreeItem> curChild; nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = inItem->GetChildAt(i, getter_AddRefs(curChild)); rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
rv = BuildArrayRecursive(curChild, inItemArray); rv = BuildArrayRecursive(curChild, aItemArray);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) {
return rv;
}
} }
// add this item to the array // add this item to the array
if (mDocShellType == nsIDocShellTreeItem::typeAll || if (mDocShellType == nsIDocShellTreeItem::typeAll ||
inItem->ItemType() == mDocShellType) { aItem->ItemType() == mDocShellType) {
if (!inItemArray.AppendElement(do_GetWeakReference(inItem))) if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
}
return NS_OK; return NS_OK;
} }

View File

@@ -32,8 +32,8 @@ class nsIDocShellTreeItem;
class nsDocShellEnumerator : public nsISimpleEnumerator class nsDocShellEnumerator : public nsISimpleEnumerator
{ {
protected: protected:
enum
enum { {
enumerateForwards, enumerateForwards,
enumerateBackwards enumerateBackwards
}; };
@@ -41,8 +41,7 @@ protected:
virtual ~nsDocShellEnumerator(); virtual ~nsDocShellEnumerator();
public: public:
explicit nsDocShellEnumerator(int32_t aEnumerationDirection);
explicit nsDocShellEnumerator(int32_t inEnumerationDirection);
// nsISupports // nsISupports
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@@ -51,7 +50,6 @@ public:
NS_DECL_NSISIMPLEENUMERATOR NS_DECL_NSISIMPLEENUMERATOR
public: public:
nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem); nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem); nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
@@ -61,15 +59,14 @@ public:
nsresult First(); nsresult First();
protected: protected:
nsresult EnsureDocShellArray(); nsresult EnsureDocShellArray();
nsresult ClearState(); nsresult ClearState();
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray); nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray);
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0; virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray) = 0;
protected: protected:
nsWeakPtr mRootItem; // weak ref! nsWeakPtr mRootItem; // weak ref!
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
@@ -81,33 +78,31 @@ protected:
const int8_t mEnumerationDirection; const int8_t mEnumerationDirection;
}; };
class nsDocShellForwardsEnumerator : public nsDocShellEnumerator class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
{ {
public: public:
nsDocShellForwardsEnumerator() nsDocShellForwardsEnumerator()
: nsDocShellEnumerator(enumerateForwards) : nsDocShellEnumerator(enumerateForwards)
{ {
} }
protected: protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray); nsTArray<nsWeakPtr>& aItemArray);
}; };
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
{ {
public: public:
nsDocShellBackwardsEnumerator() nsDocShellBackwardsEnumerator()
: nsDocShellEnumerator(enumerateBackwards) : nsDocShellEnumerator(enumerateBackwards)
{ {
} }
protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray); protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray);
}; };
#endif // nsDocShellEnumerator_h___ #endif // nsDocShellEnumerator_h___

View File

@@ -17,12 +17,12 @@
//***************************************************************************** //*****************************************************************************
nsDocShellLoadInfo::nsDocShellLoadInfo() nsDocShellLoadInfo::nsDocShellLoadInfo()
: mInheritOwner(false), : mInheritOwner(false)
mOwnerIsExplicit(false), , mOwnerIsExplicit(false)
mSendReferrer(true), , mSendReferrer(true)
mReferrerPolicy(mozilla::net::RP_Default), , mReferrerPolicy(mozilla::net::RP_Default)
mLoadType(nsIDocShellLoadInfo::loadNormal), , mLoadType(nsIDocShellLoadInfo::loadNormal)
mIsSrcdocLoad(false) , mIsSrcdocLoad(false)
{ {
} }
@@ -46,7 +46,8 @@ NS_INTERFACE_MAP_END
// nsDocShellLoadInfo::nsIDocShellLoadInfo // nsDocShellLoadInfo::nsIDocShellLoadInfo
//***************************************************************************** //*****************************************************************************
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer) NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
{ {
NS_ENSURE_ARG_POINTER(aReferrer); NS_ENSURE_ARG_POINTER(aReferrer);
@@ -55,13 +56,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer) NS_IMETHODIMP
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
{ {
mReferrer = aReferrer; mReferrer = aReferrer;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner) NS_IMETHODIMP
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
{ {
NS_ENSURE_ARG_POINTER(aOwner); NS_ENSURE_ARG_POINTER(aOwner);
@@ -70,13 +73,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetOwner(nsISupports* aOwner) NS_IMETHODIMP
nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
{ {
mOwner = aOwner; mOwner = aOwner;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner) NS_IMETHODIMP
nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
{ {
NS_ENSURE_ARG_POINTER(aInheritOwner); NS_ENSURE_ARG_POINTER(aInheritOwner);
@@ -84,25 +89,29 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner) NS_IMETHODIMP
nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
{ {
mInheritOwner = aInheritOwner; mInheritOwner = aInheritOwner;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit) NS_IMETHODIMP
nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
{ {
*aOwnerIsExplicit = mOwnerIsExplicit; *aOwnerIsExplicit = mOwnerIsExplicit;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit) NS_IMETHODIMP
nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
{ {
mOwnerIsExplicit = aOwnerIsExplicit; mOwnerIsExplicit = aOwnerIsExplicit;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType) NS_IMETHODIMP
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
{ {
NS_ENSURE_ARG_POINTER(aLoadType); NS_ENSURE_ARG_POINTER(aLoadType);
@@ -110,13 +119,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType) NS_IMETHODIMP
nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
{ {
mLoadType = aLoadType; mLoadType = aLoadType;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry) NS_IMETHODIMP
nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
{ {
NS_ENSURE_ARG_POINTER(aSHEntry); NS_ENSURE_ARG_POINTER(aSHEntry);
@@ -125,13 +136,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry) NS_IMETHODIMP
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
{ {
mSHEntry = aSHEntry; mSHEntry = aSHEntry;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget) NS_IMETHODIMP
nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
{ {
NS_ENSURE_ARG_POINTER(aTarget); NS_ENSURE_ARG_POINTER(aTarget);
@@ -140,13 +153,13 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetTarget(const char16_t* aTarget) NS_IMETHODIMP
nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
{ {
mTarget.Assign(aTarget); mTarget.Assign(aTarget);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult) nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult)
{ {
@@ -158,7 +171,6 @@ nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream) nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
{ {
@@ -167,20 +179,23 @@ nsDocShellLoadInfo::SetPostDataStream(nsIInputStream *aStream)
} }
/* attribute nsIInputStream headersStream; */ /* attribute nsIInputStream headersStream; */
NS_IMETHODIMP nsDocShellLoadInfo::GetHeadersStream(nsIInputStream * *aHeadersStream) NS_IMETHODIMP
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
{ {
NS_ENSURE_ARG_POINTER(aHeadersStream); NS_ENSURE_ARG_POINTER(aHeadersStream);
*aHeadersStream = mHeadersStream; *aHeadersStream = mHeadersStream;
NS_IF_ADDREF(*aHeadersStream); NS_IF_ADDREF(*aHeadersStream);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetHeadersStream(nsIInputStream * aHeadersStream) NS_IMETHODIMP
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
{ {
mHeadersStream = aHeadersStream; mHeadersStream = aHeadersStream;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer) NS_IMETHODIMP
nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
{ {
NS_ENSURE_ARG_POINTER(aSendReferrer); NS_ENSURE_ARG_POINTER(aSendReferrer);
@@ -188,44 +203,53 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer) NS_IMETHODIMP
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
{ {
mSendReferrer = aSendReferrer; mSendReferrer = aSendReferrer;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrerPolicy(nsDocShellInfoReferrerPolicy* aReferrerPolicy) NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrerPolicy(
nsDocShellInfoReferrerPolicy* aReferrerPolicy)
{ {
*aReferrerPolicy = mReferrerPolicy; *aReferrerPolicy = mReferrerPolicy;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrerPolicy(nsDocShellInfoReferrerPolicy aReferrerPolicy) NS_IMETHODIMP
nsDocShellLoadInfo::SetReferrerPolicy(
nsDocShellInfoReferrerPolicy aReferrerPolicy)
{ {
mReferrerPolicy = aReferrerPolicy; mReferrerPolicy = aReferrerPolicy;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad) NS_IMETHODIMP
nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
{ {
*aIsSrcdocLoad = mIsSrcdocLoad; *aIsSrcdocLoad = mIsSrcdocLoad;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetSrcdocData(nsAString &aSrcdocData) NS_IMETHODIMP
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData)
{ {
aSrcdocData = mSrcdocData; aSrcdocData = mSrcdocData;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetSrcdocData(const nsAString &aSrcdocData) NS_IMETHODIMP
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
{ {
mSrcdocData = aSrcdocData; mSrcdocData = aSrcdocData;
mIsSrcdocLoad = true; mIsSrcdocLoad = true;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell) NS_IMETHODIMP
nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
{ {
MOZ_ASSERT(aSourceDocShell); MOZ_ASSERT(aSourceDocShell);
nsCOMPtr<nsIDocShell> result = mSourceDocShell; nsCOMPtr<nsIDocShell> result = mSourceDocShell;
@@ -233,13 +257,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShel
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell) NS_IMETHODIMP
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
{ {
mSourceDocShell = aSourceDocShell; mSourceDocShell = aSourceDocShell;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI) NS_IMETHODIMP
nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
{ {
NS_ENSURE_ARG_POINTER(aBaseURI); NS_ENSURE_ARG_POINTER(aBaseURI);
@@ -248,16 +274,9 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI) NS_IMETHODIMP
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
{ {
mBaseURI = aBaseURI; mBaseURI = aBaseURI;
return NS_OK; return NS_OK;
} }
//*****************************************************************************
// nsDocShellLoadInfo: Helpers
//*****************************************************************************
//*****************************************************************************
// nsDocShellLoadInfo: Accessors
//*****************************************************************************

View File

@@ -7,7 +7,6 @@
#ifndef nsDocShellLoadInfo_h__ #ifndef nsDocShellLoadInfo_h__
#define nsDocShellLoadInfo_h__ #define nsDocShellLoadInfo_h__
// Helper Classes // Helper Classes
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h" #include "nsString.h"

View File

@@ -32,15 +32,14 @@
LOAD_FLAGS_ALLOW_POPUPS | \ LOAD_FLAGS_ALLOW_POPUPS | \
0xffff0000) 0xffff0000)
/* load types are legal combinations of load commands and flags /* load types are legal combinations of load commands and flags
* *
* NOTE: * NOTE:
* Remember to update the IsValidLoadType function below if you change this * Remember to update the IsValidLoadType function below if you change this
* enum to ensure bad flag combinations will be rejected. * enum to ensure bad flag combinations will be rejected.
*/ */
enum LoadType { enum LoadType
{
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE), LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY), LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL), LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
@@ -71,10 +70,10 @@ enum LoadType {
// NOTE: Adding a new value? Remember to update IsValidLoadType! // NOTE: Adding a new value? Remember to update IsValidLoadType!
}; };
static inline bool IsValidLoadType(uint32_t aLoadType) static inline bool
{ IsValidLoadType(uint32_t aLoadType)
switch (aLoadType)
{ {
switch (aLoadType) {
case LOAD_NORMAL: case LOAD_NORMAL:
case LOAD_NORMAL_REPLACE: case LOAD_NORMAL_REPLACE:
case LOAD_NORMAL_EXTERNAL: case LOAD_NORMAL_EXTERNAL:

View File

@@ -11,7 +11,6 @@ nsTransferableHookData::nsTransferableHookData()
{ {
} }
nsTransferableHookData::~nsTransferableHookData() nsTransferableHookData::~nsTransferableHookData()
{ {
} }
@@ -29,11 +28,11 @@ nsTransferableHookData::AddClipboardDragDropHooks(
NS_ENSURE_ARG(aOverrides); NS_ENSURE_ARG(aOverrides);
// don't let a hook be added more than once // don't let a hook be added more than once
if (mHookList.IndexOfObject(aOverrides) == -1) if (mHookList.IndexOfObject(aOverrides) == -1) {
{ if (!mHookList.AppendObject(aOverrides)) {
if (!mHookList.AppendObject(aOverrides))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
}
return NS_OK; return NS_OK;
} }
@@ -43,8 +42,9 @@ nsTransferableHookData::RemoveClipboardDragDropHooks(
nsIClipboardDragDropHooks* aOverrides) nsIClipboardDragDropHooks* aOverrides)
{ {
NS_ENSURE_ARG(aOverrides); NS_ENSURE_ARG(aOverrides);
if (!mHookList.RemoveObject(aOverrides)) if (!mHookList.RemoveObject(aOverrides)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
return NS_OK; return NS_OK;
} }

View File

@@ -29,8 +29,9 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
nsCOMPtr<nsIGlobalHistory2> history = nsCOMPtr<nsIGlobalHistory2> history =
do_GetService("@mozilla.org/browser/global-history;2"); do_GetService("@mozilla.org/browser/global-history;2");
if (!history) if (!history) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
}
bool visited; bool visited;
nsresult rv = history->IsVisited(aSource, &visited); nsresult rv = history->IsVisited(aSource, &visited);
@@ -42,9 +43,10 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
if (!visited) { if (!visited) {
nsCOMPtr<nsIObserverService> os = nsCOMPtr<nsIObserverService> os =
do_GetService("@mozilla.org/observer-service;1"); do_GetService("@mozilla.org/observer-service;1");
if (os) if (os) {
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr); os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
} }
}
return NS_OK; return NS_OK;
} }

View File

@@ -22,7 +22,8 @@ class nsString;
/** /**
* Interface used for handling clicks on links * Interface used for handling clicks on links
*/ */
class nsILinkHandler : public nsISupports { class nsILinkHandler : public nsISupports
{
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)

View File

@@ -27,13 +27,13 @@ public:
* Called when an async panning/zooming transform has started being applied * Called when an async panning/zooming transform has started being applied
* and passed the scroll offset * and passed the scroll offset
*/ */
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint scrollPos){}; virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint aScrollPos) {};
/** /**
* Called when an async panning/zooming transform is no longer applied * Called when an async panning/zooming transform is no longer applied
* and passed the scroll offset * and passed the scroll offset
*/ */
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint scrollPos){}; virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint aScrollPos) {};
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)

View File

@@ -16,7 +16,8 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class nsIWebShellServices : public nsISupports { class nsIWebShellServices : public nsISupports
{
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
@@ -29,7 +30,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
/* Use this macro when declaring classes that implement this interface. */ /* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIWEBSHELLSERVICES \ #define NS_DECL_NSIWEBSHELLSERVICES \
NS_IMETHOD ReloadDocument(const char *aCharset=nullptr, int32_t aSource=kCharsetUninitialized) MOZ_OVERRIDE; \ NS_IMETHOD ReloadDocument(const char* aCharset = nullptr, \
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE; \ int32_t aSource = kCharsetUninitialized) MOZ_OVERRIDE; \
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE;
#endif /* nsIWebShellServices_h___ */ #endif /* nsIWebShellServices_h___ */

View File

@@ -55,7 +55,8 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
// there's no need to try and find a plugin to handle it. // there's no need to try and find a plugin to handle it.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav)); nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
bool allowed; bool allowed;
if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) { if (docShell &&
NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
return NS_OK; return NS_OK;
} }
@@ -84,7 +85,6 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
{ {
NS_PRECONDITION(aIsSupported, "Null out param?"); NS_PRECONDITION(aIsSupported, "Null out param?");
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED; nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory = nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
@@ -109,8 +109,7 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
// contractid. // contractid.
if (imgLoader::SupportImageWithMimeType(aType.get())) { if (imgLoader::SupportImageWithMimeType(aType.get())) {
*aIsSupported = nsIWebNavigationInfo::IMAGE; *aIsSupported = nsIWebNavigationInfo::IMAGE;
} } else {
else {
*aIsSupported = nsIWebNavigationInfo::OTHER; *aIsSupported = nsIWebNavigationInfo::OTHER;
} }
break; break;