2001-05-17 09:20:51 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2001-05-17 09:20:51 +04:00
|
|
|
|
2006-03-31 12:00:42 +04:00
|
|
|
/*
|
|
|
|
* A class that handles loading and evaluation of <script> elements.
|
|
|
|
*/
|
|
|
|
|
2001-05-17 09:20:51 +04:00
|
|
|
#ifndef __nsScriptLoader_h__
|
|
|
|
#define __nsScriptLoader_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2004-07-07 02:52:03 +04:00
|
|
|
#include "nsIScriptElement.h"
|
2003-07-12 02:47:17 +04:00
|
|
|
#include "nsCOMArray.h"
|
2007-09-28 19:15:07 +04:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2001-05-17 09:20:51 +04:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIStreamLoader.h"
|
2014-11-18 16:46:43 +03:00
|
|
|
#include "mozilla/net/ReferrerPolicy.h"
|
2001-05-17 09:20:51 +04:00
|
|
|
|
|
|
|
class nsScriptLoadRequest;
|
2013-03-18 19:38:19 +04:00
|
|
|
class nsIURI;
|
2001-05-17 09:20:51 +04:00
|
|
|
|
2014-04-25 18:11:56 +04:00
|
|
|
namespace JS {
|
|
|
|
class SourceBufferHolder;
|
|
|
|
}
|
|
|
|
|
2014-07-03 22:12:03 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class AutoJSAPI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-17 09:20:51 +04:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
// Script loader implementation
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2014-08-27 22:26:48 +04:00
|
|
|
class nsScriptLoader MOZ_FINAL : public nsIStreamLoaderObserver
|
2001-05-17 09:20:51 +04:00
|
|
|
{
|
2014-05-21 21:08:12 +04:00
|
|
|
class MOZ_STACK_CLASS AutoCurrentScriptUpdater
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoCurrentScriptUpdater(nsScriptLoader* aScriptLoader,
|
|
|
|
nsIScriptElement* aCurrentScript)
|
|
|
|
: mOldScript(aScriptLoader->mCurrentScript)
|
|
|
|
, mScriptLoader(aScriptLoader)
|
|
|
|
{
|
|
|
|
mScriptLoader->mCurrentScript = aCurrentScript;
|
|
|
|
}
|
|
|
|
~AutoCurrentScriptUpdater()
|
|
|
|
{
|
|
|
|
mScriptLoader->mCurrentScript.swap(mOldScript);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIScriptElement> mOldScript;
|
|
|
|
nsScriptLoader* mScriptLoader;
|
|
|
|
};
|
|
|
|
|
2010-09-01 15:41:12 +04:00
|
|
|
friend class nsScriptRequestProcessor;
|
2014-05-21 21:08:12 +04:00
|
|
|
friend class AutoCurrentScriptUpdater;
|
|
|
|
|
2001-05-17 09:20:51 +04:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit nsScriptLoader(nsIDocument* aDocument);
|
2001-05-17 09:20:51 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLOADEROBSERVER
|
|
|
|
|
2006-11-04 08:45:02 +03:00
|
|
|
/**
|
|
|
|
* The loader maintains a weak reference to the document with
|
|
|
|
* which it is initialized. This call forces the reference to
|
|
|
|
* be dropped.
|
|
|
|
*/
|
|
|
|
void DropDocumentReference()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mDocument = nullptr;
|
2006-11-04 08:45:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an observer for all scripts loaded through this loader.
|
|
|
|
*
|
|
|
|
* @param aObserver observer for all script processing.
|
|
|
|
*/
|
|
|
|
nsresult AddObserver(nsIScriptLoaderObserver* aObserver)
|
|
|
|
{
|
|
|
|
return mObservers.AppendObject(aObserver) ? NS_OK :
|
|
|
|
NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an observer.
|
|
|
|
*
|
|
|
|
* @param aObserver observer to be removed
|
|
|
|
*/
|
|
|
|
void RemoveObserver(nsIScriptLoaderObserver* aObserver)
|
|
|
|
{
|
|
|
|
mObservers.RemoveObject(aObserver);
|
|
|
|
}
|
2013-12-31 20:30:07 +04:00
|
|
|
|
2006-11-04 08:45:02 +03:00
|
|
|
/**
|
|
|
|
* Process a script element. This will include both loading the
|
|
|
|
* source of the element if it is not inline and evaluating
|
|
|
|
* the script itself.
|
|
|
|
*
|
|
|
|
* If the script is an inline script that can be executed immediately
|
|
|
|
* (i.e. there are no other scripts pending) then ScriptAvailable
|
|
|
|
* and ScriptEvaluated will be called before the function returns.
|
|
|
|
*
|
2011-11-16 11:50:18 +04:00
|
|
|
* If true is returned the script could not be executed immediately.
|
|
|
|
* In this case ScriptAvailable is guaranteed to be called at a later
|
|
|
|
* point (as well as possibly ScriptEvaluated).
|
2006-11-04 08:45:02 +03:00
|
|
|
*
|
|
|
|
* @param aElement The element representing the script to be loaded and
|
|
|
|
* evaluated.
|
|
|
|
*/
|
2011-11-16 11:50:18 +04:00
|
|
|
bool ProcessScriptElement(nsIScriptElement* aElement);
|
2006-11-04 08:45:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the currently executing script. This is useful if you want to
|
|
|
|
* generate a unique key based on the currently executing script.
|
|
|
|
*/
|
|
|
|
nsIScriptElement* GetCurrentScript()
|
|
|
|
{
|
|
|
|
return mCurrentScript;
|
|
|
|
}
|
|
|
|
|
2010-09-06 11:41:26 +04:00
|
|
|
nsIScriptElement* GetCurrentParserInsertedScript()
|
|
|
|
{
|
|
|
|
return mCurrentParserInsertedScript;
|
|
|
|
}
|
|
|
|
|
2006-11-04 08:45:02 +03:00
|
|
|
/**
|
|
|
|
* Whether the loader is enabled or not.
|
|
|
|
* When disabled, processing of new script elements is disabled.
|
2011-11-16 11:50:18 +04:00
|
|
|
* Any call to ProcessScriptElement() will return false. Note that
|
|
|
|
* this DOES NOT disable currently loading or executing scripts.
|
2006-11-04 08:45:02 +03:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetEnabled()
|
2006-11-04 08:45:02 +03:00
|
|
|
{
|
|
|
|
return mEnabled;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetEnabled(bool aEnabled)
|
2006-11-04 08:45:02 +03:00
|
|
|
{
|
2007-01-09 04:07:29 +03:00
|
|
|
if (!mEnabled && aEnabled) {
|
|
|
|
ProcessPendingRequestsAsync();
|
|
|
|
}
|
2006-11-04 08:45:02 +03:00
|
|
|
mEnabled = aEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add/remove blocker. Blockers will stop scripts from executing, but not
|
|
|
|
* from loading.
|
|
|
|
*/
|
|
|
|
void AddExecuteBlocker()
|
|
|
|
{
|
2008-03-15 02:08:57 +03:00
|
|
|
++mBlockerCount;
|
2006-11-04 08:45:02 +03:00
|
|
|
}
|
|
|
|
void RemoveExecuteBlocker()
|
|
|
|
{
|
|
|
|
if (!--mBlockerCount) {
|
2008-03-15 02:08:57 +03:00
|
|
|
ProcessPendingRequestsAsync();
|
2006-11-04 08:45:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 18:11:56 +04:00
|
|
|
/**
|
|
|
|
* Convert the given buffer to a UTF-16 string.
|
|
|
|
* @param aChannel Channel corresponding to the data. May be null.
|
|
|
|
* @param aData The data to convert
|
|
|
|
* @param aLength Length of the data
|
|
|
|
* @param aHintCharset Hint for the character set (e.g., from a charset
|
|
|
|
* attribute). May be the empty string.
|
|
|
|
* @param aDocument Document which the data is loaded for. Must not be
|
|
|
|
* null.
|
2014-07-22 08:43:21 +04:00
|
|
|
* @param aBufOut [out] char16_t array allocated by ConvertToUTF16 and
|
2014-04-25 18:11:56 +04:00
|
|
|
* containing data converted to unicode. Caller must
|
|
|
|
* js_free() this data when no longer needed.
|
|
|
|
* @param aLengthOut [out] Length of array returned in aBufOut in number
|
2014-07-22 08:43:21 +04:00
|
|
|
* of char16_t code units.
|
2014-04-25 18:11:56 +04:00
|
|
|
*/
|
|
|
|
static nsresult ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
|
|
|
|
uint32_t aLength,
|
|
|
|
const nsAString& aHintCharset,
|
|
|
|
nsIDocument* aDocument,
|
2014-07-22 08:43:21 +04:00
|
|
|
char16_t*& aBufOut, size_t& aLengthOut);
|
2014-04-25 18:11:56 +04:00
|
|
|
|
2007-01-09 04:07:29 +03:00
|
|
|
/**
|
|
|
|
* Processes any pending requests that are ready for processing.
|
|
|
|
*/
|
|
|
|
void ProcessPendingRequests();
|
|
|
|
|
2009-02-11 17:51:37 +03:00
|
|
|
/**
|
|
|
|
* Check whether it's OK to load a script from aURI in
|
|
|
|
* aDocument.
|
|
|
|
*/
|
|
|
|
static nsresult ShouldLoadScript(nsIDocument* aDocument,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString &aType);
|
|
|
|
|
2008-07-26 06:42:12 +04:00
|
|
|
/**
|
|
|
|
* Starts deferring deferred scripts and puts them in the mDeferredRequests
|
|
|
|
* queue instead.
|
|
|
|
*/
|
|
|
|
void BeginDeferringScripts()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mDeferEnabled = true;
|
2009-01-15 22:49:20 +03:00
|
|
|
if (mDocument) {
|
|
|
|
mDocument->BlockOnload();
|
|
|
|
}
|
2008-07-26 06:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-08 09:55:05 +04:00
|
|
|
* Notifies the script loader that parsing is done. If aTerminated is true,
|
|
|
|
* this will drop any pending scripts that haven't run yet. Otherwise, it
|
|
|
|
* will stops deferring scripts and immediately processes the
|
|
|
|
* mDeferredRequests queue.
|
2008-07-26 06:42:12 +04:00
|
|
|
*
|
2009-07-08 09:55:05 +04:00
|
|
|
* WARNING: This function will synchronously execute content scripts, so be
|
2008-07-26 06:42:12 +04:00
|
|
|
* prepared that the world might change around you.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
void ParsingComplete(bool aTerminated);
|
2008-07-26 06:42:12 +04:00
|
|
|
|
2009-01-15 04:25:21 +03:00
|
|
|
/**
|
|
|
|
* Returns the number of pending scripts, deferred or not.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t HasPendingOrCurrentScripts()
|
2009-01-15 04:25:21 +03:00
|
|
|
{
|
2010-09-01 15:41:12 +04:00
|
|
|
return mCurrentScript || mParserBlockingRequest;
|
2009-01-15 04:25:21 +03:00
|
|
|
}
|
|
|
|
|
2008-10-01 10:48:47 +04:00
|
|
|
/**
|
|
|
|
* Adds aURI to the preload list and starts loading it.
|
|
|
|
*
|
|
|
|
* @param aURI The URI of the external script.
|
|
|
|
* @param aCharset The charset parameter for the script.
|
|
|
|
* @param aType The type parameter for the script.
|
2012-03-10 20:13:52 +04:00
|
|
|
* @param aCrossOrigin The crossorigin attribute for the script.
|
|
|
|
* Void if not present.
|
2012-12-05 03:06:29 +04:00
|
|
|
* @param aScriptFromHead Whether or not the script was a child of head
|
2008-10-01 10:48:47 +04:00
|
|
|
*/
|
|
|
|
virtual void PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
2012-03-10 20:13:52 +04:00
|
|
|
const nsAString &aType,
|
2012-12-05 03:06:29 +04:00
|
|
|
const nsAString &aCrossOrigin,
|
2014-11-18 16:46:43 +03:00
|
|
|
bool aScriptFromHead,
|
|
|
|
const mozilla::net::ReferrerPolicy aReferrerPolicy);
|
2008-10-01 10:48:47 +04:00
|
|
|
|
2013-09-12 03:42:09 +04:00
|
|
|
/**
|
|
|
|
* Process a request that was deferred so that the script could be compiled
|
|
|
|
* off thread.
|
|
|
|
*/
|
2013-12-06 00:55:31 +04:00
|
|
|
nsresult ProcessOffThreadRequest(nsScriptLoadRequest *aRequest,
|
|
|
|
void **aOffThreadToken);
|
2013-09-12 03:42:09 +04:00
|
|
|
|
2014-10-01 16:13:53 +04:00
|
|
|
bool AddPendingChildLoader(nsScriptLoader* aChild) {
|
|
|
|
return mPendingChildLoaders.AppendElement(aChild) != nullptr;
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:41:12 +04:00
|
|
|
private:
|
2014-06-25 06:09:15 +04:00
|
|
|
virtual ~nsScriptLoader();
|
|
|
|
|
2012-01-20 15:16:27 +04:00
|
|
|
/**
|
|
|
|
* Unblocks the creator parser of the parser-blocking scripts.
|
|
|
|
*/
|
|
|
|
void UnblockParser(nsScriptLoadRequest* aParserBlockingRequest);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronously resumes the creator parser of the parser-blocking scripts.
|
|
|
|
*/
|
|
|
|
void ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest);
|
|
|
|
|
|
|
|
|
2008-11-19 10:05:05 +03:00
|
|
|
/**
|
|
|
|
* Helper function to check the content policy for a given request.
|
|
|
|
*/
|
2009-02-11 17:51:37 +03:00
|
|
|
static nsresult CheckContentPolicy(nsIDocument* aDocument,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsIURI *aURI,
|
|
|
|
const nsAString &aType);
|
2008-11-19 10:05:05 +03:00
|
|
|
|
2008-10-01 10:48:47 +04:00
|
|
|
/**
|
|
|
|
* Start a load for aRequest's URI.
|
|
|
|
*/
|
2012-12-05 03:06:29 +04:00
|
|
|
nsresult StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
|
|
|
|
bool aScriptFromHead);
|
2008-10-01 10:48:47 +04:00
|
|
|
|
2007-01-09 04:07:29 +03:00
|
|
|
/**
|
2009-01-15 22:49:20 +03:00
|
|
|
* Process any pending requests asynchronously (i.e. off an event) if there
|
2007-01-09 04:07:29 +03:00
|
|
|
* are any. Note that this is a no-op if there aren't any currently pending
|
|
|
|
* requests.
|
2009-01-15 22:49:20 +03:00
|
|
|
*
|
|
|
|
* This function is virtual to allow cross-library calls to SetEnabled()
|
2007-01-09 04:07:29 +03:00
|
|
|
*/
|
2007-01-09 05:02:39 +03:00
|
|
|
virtual void ProcessPendingRequestsAsync();
|
2007-01-09 04:07:29 +03:00
|
|
|
|
2007-09-28 19:15:07 +04:00
|
|
|
/**
|
|
|
|
* If true, the loader is ready to execute scripts, and so are all its
|
|
|
|
* ancestors. If the loader itself is ready but some ancestor is not, this
|
|
|
|
* function will add an execute blocker and ask the ancestor to remove it
|
|
|
|
* once it becomes ready.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ReadyToExecuteScripts();
|
2007-09-28 19:15:07 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether just this loader is ready to execute scripts.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SelfReadyToExecuteScripts()
|
2006-11-04 08:45:02 +03:00
|
|
|
{
|
2007-01-09 04:07:29 +03:00
|
|
|
return mEnabled && !mBlockerCount;
|
2006-11-04 08:45:02 +03:00
|
|
|
}
|
|
|
|
|
2013-09-12 03:42:09 +04:00
|
|
|
nsresult AttemptAsyncScriptParse(nsScriptLoadRequest* aRequest);
|
|
|
|
nsresult ProcessRequest(nsScriptLoadRequest* aRequest,
|
|
|
|
void **aOffThreadToken = nullptr);
|
2001-05-17 09:20:51 +04:00
|
|
|
void FireScriptAvailable(nsresult aResult,
|
2006-11-04 08:45:02 +03:00
|
|
|
nsScriptLoadRequest* aRequest);
|
2001-05-17 09:20:51 +04:00
|
|
|
void FireScriptEvaluated(nsresult aResult,
|
|
|
|
nsScriptLoadRequest* aRequest);
|
|
|
|
nsresult EvaluateScript(nsScriptLoadRequest* aRequest,
|
2014-04-25 18:11:56 +04:00
|
|
|
JS::SourceBufferHolder& aSrcBuf,
|
2013-09-12 03:42:09 +04:00
|
|
|
void **aOffThreadToken);
|
|
|
|
|
2013-12-31 20:30:07 +04:00
|
|
|
already_AddRefed<nsIScriptGlobalObject> GetScriptGlobalObject();
|
2014-07-03 22:12:03 +04:00
|
|
|
void FillCompileOptionsForRequest(const mozilla::dom::AutoJSAPI &jsapi,
|
|
|
|
nsScriptLoadRequest *aRequest,
|
2013-11-26 20:47:52 +04:00
|
|
|
JS::Handle<JSObject *> aScopeChain,
|
2013-09-12 03:42:09 +04:00
|
|
|
JS::CompileOptions *aOptions);
|
2001-05-17 09:20:51 +04:00
|
|
|
|
2006-11-04 08:45:02 +03:00
|
|
|
nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
|
|
|
|
nsIStreamLoader* aLoader,
|
|
|
|
nsresult aStatus,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aStringLen,
|
|
|
|
const uint8_t* aString);
|
2005-12-02 07:32:18 +03:00
|
|
|
|
2014-04-12 13:02:21 +04:00
|
|
|
void AddDeferRequest(nsScriptLoadRequest* aRequest);
|
|
|
|
bool MaybeRemovedDeferRequests();
|
|
|
|
|
2001-05-17 09:20:51 +04:00
|
|
|
nsIDocument* mDocument; // [WEAK]
|
2003-07-12 02:47:17 +04:00
|
|
|
nsCOMArray<nsIScriptLoaderObserver> mObservers;
|
2010-10-13 11:12:55 +04:00
|
|
|
nsTArray<nsRefPtr<nsScriptLoadRequest> > mNonAsyncExternalScriptInsertedRequests;
|
2010-09-20 16:12:06 +04:00
|
|
|
nsTArray<nsRefPtr<nsScriptLoadRequest> > mAsyncRequests;
|
|
|
|
nsTArray<nsRefPtr<nsScriptLoadRequest> > mDeferRequests;
|
2010-10-27 11:18:24 +04:00
|
|
|
nsTArray<nsRefPtr<nsScriptLoadRequest> > mXSLTRequests;
|
2010-09-20 16:12:06 +04:00
|
|
|
nsRefPtr<nsScriptLoadRequest> mParserBlockingRequest;
|
2008-10-01 10:48:47 +04:00
|
|
|
|
|
|
|
// In mRequests, the additional information here is stored by the element.
|
|
|
|
struct PreloadInfo {
|
|
|
|
nsRefPtr<nsScriptLoadRequest> mRequest;
|
|
|
|
nsString mCharset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PreloadRequestComparator {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool Equals(const PreloadInfo &aPi, nsScriptLoadRequest * const &aRequest)
|
2008-10-01 10:48:47 +04:00
|
|
|
const
|
|
|
|
{
|
|
|
|
return aRequest == aPi.mRequest;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct PreloadURIComparator {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool Equals(const PreloadInfo &aPi, nsIURI * const &aURI) const;
|
2008-10-01 10:48:47 +04:00
|
|
|
};
|
|
|
|
nsTArray<PreloadInfo> mPreloads;
|
|
|
|
|
2005-06-07 23:21:05 +04:00
|
|
|
nsCOMPtr<nsIScriptElement> mCurrentScript;
|
2010-09-06 11:41:26 +04:00
|
|
|
nsCOMPtr<nsIScriptElement> mCurrentParserInsertedScript;
|
2007-09-28 19:15:07 +04:00
|
|
|
// XXXbz do we want to cycle-collect these or something? Not sure.
|
|
|
|
nsTArray< nsRefPtr<nsScriptLoader> > mPendingChildLoaders;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mBlockerCount;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mEnabled;
|
|
|
|
bool mDeferEnabled;
|
|
|
|
bool mDocumentParsingDone;
|
2014-04-12 13:02:21 +04:00
|
|
|
bool mBlockingDOMContentLoaded;
|
2001-05-17 09:20:51 +04:00
|
|
|
};
|
|
|
|
|
2011-08-11 00:53:14 +04:00
|
|
|
class nsAutoScriptLoaderDisabler
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit nsAutoScriptLoaderDisabler(nsIDocument* aDoc)
|
2011-08-11 00:53:14 +04:00
|
|
|
{
|
|
|
|
mLoader = aDoc->ScriptLoader();
|
|
|
|
mWasEnabled = mLoader->GetEnabled();
|
|
|
|
if (mWasEnabled) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mLoader->SetEnabled(false);
|
2011-08-11 00:53:14 +04:00
|
|
|
}
|
|
|
|
}
|
2013-12-31 20:30:07 +04:00
|
|
|
|
2011-08-11 00:53:14 +04:00
|
|
|
~nsAutoScriptLoaderDisabler()
|
|
|
|
{
|
|
|
|
if (mWasEnabled) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mLoader->SetEnabled(true);
|
2011-08-11 00:53:14 +04:00
|
|
|
}
|
|
|
|
}
|
2013-12-31 20:30:07 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mWasEnabled;
|
2011-08-11 00:53:14 +04:00
|
|
|
nsRefPtr<nsScriptLoader> mLoader;
|
|
|
|
};
|
|
|
|
|
2001-05-17 09:20:51 +04:00
|
|
|
#endif //__nsScriptLoader_h__
|