2009-09-18 09:21:47 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is HTML Parser Gecko integration code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Henri Sivonen <hsivonen@iki.fi>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsHtml5TreeOpExecutor_h__
|
|
|
|
#define nsHtml5TreeOpExecutor_h__
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
#include "nsHtml5TreeOperation.h"
|
2010-02-26 09:18:38 +00:00
|
|
|
#include "nsHtml5SpeculativeLoad.h"
|
2009-09-18 09:21:47 +00:00
|
|
|
#include "nsHtml5PendingNotification.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsContentSink.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsHtml5DocumentMode.h"
|
|
|
|
#include "nsIScriptElement.h"
|
|
|
|
#include "nsIParser.h"
|
2009-09-21 13:18:20 +00:00
|
|
|
#include "nsAHtml5TreeOpSink.h"
|
|
|
|
#include "nsHtml5TreeOpStage.h"
|
2010-02-26 09:18:38 +00:00
|
|
|
#include "nsIURI.h"
|
2011-11-08 20:22:47 +00:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2012-05-23 12:55:13 +00:00
|
|
|
#include "mozilla/LinkedList.h"
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2011-09-04 10:49:29 +00:00
|
|
|
class nsHtml5Parser;
|
2009-09-18 09:21:47 +00:00
|
|
|
class nsHtml5TreeBuilder;
|
|
|
|
class nsHtml5Tokenizer;
|
|
|
|
class nsHtml5StreamParser;
|
|
|
|
|
|
|
|
typedef nsIContent* nsIContentPtr;
|
|
|
|
|
2009-11-06 13:06:48 +00:00
|
|
|
enum eHtml5FlushState {
|
|
|
|
eNotFlushing = 0, // not flushing
|
|
|
|
eInFlush = 1, // the Flush() method is on the call stack
|
|
|
|
eInDocUpdate = 2, // inside an update batch on the document
|
|
|
|
eNotifying = 3 // flushing pending append notifications
|
|
|
|
};
|
|
|
|
|
2009-09-25 17:11:02 +00:00
|
|
|
class nsHtml5TreeOpExecutor : public nsContentSink,
|
|
|
|
public nsIContentSink,
|
2012-05-23 12:55:13 +00:00
|
|
|
public nsAHtml5TreeOpSink,
|
|
|
|
public mozilla::LinkedListElement<nsHtml5TreeOpExecutor>
|
2009-09-18 09:21:47 +00:00
|
|
|
{
|
2010-02-26 09:18:38 +00:00
|
|
|
friend class nsHtml5FlushLoopGuard;
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
|
|
|
|
|
|
|
|
private:
|
2012-03-27 06:27:45 +00:00
|
|
|
static bool sExternalViewSource;
|
2010-01-14 13:58:27 +00:00
|
|
|
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
2009-09-18 09:21:47 +00:00
|
|
|
static PRUint32 sAppendBatchMaxSize;
|
|
|
|
static PRUint32 sAppendBatchSlotsExamined;
|
|
|
|
static PRUint32 sAppendBatchExaminations;
|
2010-02-26 09:18:38 +00:00
|
|
|
static PRUint32 sLongestTimeOffTheEventLoop;
|
|
|
|
static PRUint32 sTimesFlushLoopInterrupted;
|
2009-09-18 09:21:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether EOF needs to be suppressed
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mSuppressEOF;
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mReadingFromStage;
|
2009-09-18 09:21:47 +00:00
|
|
|
nsTArray<nsHtml5TreeOperation> mOpQueue;
|
|
|
|
nsTArray<nsIContentPtr> mElementsSeenInThisAppendBatch;
|
|
|
|
nsTArray<nsHtml5PendingNotification> mPendingNotifications;
|
|
|
|
nsHtml5StreamParser* mStreamParser;
|
2012-03-23 14:44:06 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIContent> > mOwnedElements;
|
2009-09-21 11:43:43 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
/**
|
|
|
|
* URLs already preloaded/preloading.
|
|
|
|
*/
|
2011-11-08 20:22:47 +00:00
|
|
|
nsTHashtable<nsCStringHashKey> mPreloadedURLs;
|
2010-02-26 09:18:38 +00:00
|
|
|
|
2010-07-26 11:18:43 +00:00
|
|
|
nsCOMPtr<nsIURI> mSpeculationBaseURI;
|
|
|
|
|
2010-07-30 10:15:38 +00:00
|
|
|
nsCOMPtr<nsIURI> mViewSourceBaseURI;
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
/**
|
2009-10-12 13:08:04 +00:00
|
|
|
* Whether the parser has started
|
2009-09-18 09:21:47 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mStarted;
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5TreeOpStage mStage;
|
2009-10-15 11:29:11 +00:00
|
|
|
|
2009-11-06 13:06:48 +00:00
|
|
|
eHtml5FlushState mFlushState;
|
2009-10-30 08:31:57 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mRunFlushLoopOnStack;
|
2010-02-26 09:18:38 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mCallContinueInterruptedParsingIfEnabled;
|
2010-02-26 09:18:38 +00:00
|
|
|
|
2011-09-28 12:45:17 +00:00
|
|
|
/**
|
2012-03-21 12:39:25 +00:00
|
|
|
* Non-NS_OK if this parser should refuse to process any more input.
|
|
|
|
* For example, the parser needs to be marked as broken if it drops some
|
|
|
|
* input due to a memory allocation failure. In such a case, the whole
|
|
|
|
* parser needs to be marked as broken, because some input has been lost
|
|
|
|
* and parsing more input could lead to a DOM where pieces of HTML source
|
2011-09-28 12:45:17 +00:00
|
|
|
* that weren't supposed to become scripts become scripts.
|
2012-03-21 12:39:25 +00:00
|
|
|
*
|
|
|
|
* Since NS_OK is actually 0, zeroing operator new takes care of
|
|
|
|
* initializing this.
|
2011-09-28 12:45:17 +00:00
|
|
|
*/
|
2012-03-21 12:39:25 +00:00
|
|
|
nsresult mBroken;
|
2011-09-28 12:45:17 +00:00
|
|
|
|
2012-03-24 11:34:42 +00:00
|
|
|
/**
|
|
|
|
* Whether this executor has already complained about matters related
|
|
|
|
* to character encoding declarations.
|
|
|
|
*/
|
|
|
|
bool mAlreadyComplainedAboutCharset;
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
public:
|
|
|
|
|
2012-01-20 12:03:49 +00:00
|
|
|
nsHtml5TreeOpExecutor(bool aRunsToCompletion = false);
|
2009-09-18 09:21:47 +00:00
|
|
|
virtual ~nsHtml5TreeOpExecutor();
|
|
|
|
|
|
|
|
// nsIContentSink
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unimplemented. For interface compat only.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD WillParse();
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2012-03-21 12:39:25 +00:00
|
|
|
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emits EOF.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD DidBuildModel(bool aTerminated);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Forwards to nsContentSink
|
|
|
|
*/
|
|
|
|
NS_IMETHOD WillInterrupt();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unimplemented. For interface compat only.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD WillResume();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the parser.
|
|
|
|
*/
|
2012-01-20 11:16:27 +00:00
|
|
|
NS_IMETHOD SetParser(nsParserBase* aParser);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* No-op for backwards compat.
|
|
|
|
*/
|
|
|
|
virtual void FlushPendingNotifications(mozFlushType aType);
|
|
|
|
|
|
|
|
/**
|
2010-03-09 12:39:32 +00:00
|
|
|
* Don't call. For interface compat only.
|
2009-09-18 09:21:47 +00:00
|
|
|
*/
|
2010-03-09 12:39:32 +00:00
|
|
|
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) {
|
|
|
|
NS_NOTREACHED("No one should call this.");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the document.
|
|
|
|
*/
|
|
|
|
virtual nsISupports *GetTarget();
|
2011-05-12 16:07:42 +00:00
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
// nsContentSink methods
|
|
|
|
virtual void UpdateChildCounts();
|
|
|
|
virtual nsresult FlushTags();
|
2010-02-26 09:18:38 +00:00
|
|
|
virtual void ContinueInterruptedParsingAsync();
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
/**
|
|
|
|
* Sets up style sheet load / parse
|
|
|
|
*/
|
|
|
|
void UpdateStyleSheet(nsIContent* aElement);
|
|
|
|
|
|
|
|
// Getters and setters for fields from nsContentSink
|
|
|
|
nsIDocument* GetDocument() {
|
|
|
|
return mDocument;
|
|
|
|
}
|
|
|
|
nsNodeInfoManager* GetNodeInfoManager() {
|
|
|
|
return mNodeInfoManager;
|
|
|
|
}
|
|
|
|
nsIDocShell* GetDocShell() {
|
|
|
|
return mDocShell;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsScriptExecuting() {
|
2009-09-18 09:21:47 +00:00
|
|
|
return IsScriptExecutingImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetNodeInfoManager(nsNodeInfoManager* aManager) {
|
|
|
|
mNodeInfoManager = aManager;
|
|
|
|
}
|
|
|
|
|
2010-03-09 12:39:32 +00:00
|
|
|
// Not from interface
|
|
|
|
|
|
|
|
void SetDocumentCharsetAndSource(nsACString& aCharset, PRInt32 aCharsetSource);
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
void SetStreamParser(nsHtml5StreamParser* aStreamParser) {
|
|
|
|
mStreamParser = aStreamParser;
|
|
|
|
}
|
|
|
|
|
2009-10-28 13:48:37 +00:00
|
|
|
void InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState, PRInt32 aLine);
|
2009-09-21 13:18:20 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsScriptEnabled();
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2010-11-01 10:50:01 +00:00
|
|
|
/**
|
|
|
|
* Enables the fragment mode.
|
|
|
|
*
|
|
|
|
* @param aPreventScriptExecution if true, scripts are prevented from
|
|
|
|
* executing; don't set to false when parsing a fragment directly into
|
|
|
|
* a document--only when parsing to an actual DOM fragment
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
void EnableFragmentMode(bool aPreventScriptExecution) {
|
2010-11-01 10:50:01 +00:00
|
|
|
mPreventScriptExecution = aPreventScriptExecution;
|
2009-11-06 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
2011-11-16 07:38:51 +00:00
|
|
|
void PreventScriptExecution() {
|
|
|
|
mPreventScriptExecution = true;
|
|
|
|
}
|
|
|
|
|
2012-01-20 12:03:49 +00:00
|
|
|
bool BelongsToStringParser() {
|
|
|
|
return mRunsToCompletion;
|
2009-11-06 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 12:45:17 +00:00
|
|
|
/**
|
|
|
|
* Marks this parser as broken and tells the stream parser (if any) to
|
|
|
|
* terminate.
|
2012-03-21 12:39:25 +00:00
|
|
|
*
|
|
|
|
* @return aReason for convenience
|
2011-09-28 12:45:17 +00:00
|
|
|
*/
|
2012-03-21 12:39:25 +00:00
|
|
|
nsresult MarkAsBroken(nsresult aReason);
|
2011-09-28 12:45:17 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-21 12:39:25 +00:00
|
|
|
* Checks if this parser is broken. Returns a non-NS_OK (i.e. non-0)
|
|
|
|
* value if broken.
|
2011-09-28 12:45:17 +00:00
|
|
|
*/
|
2012-03-21 12:39:25 +00:00
|
|
|
inline nsresult IsBroken() {
|
2011-09-28 12:45:17 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
return mBroken;
|
|
|
|
}
|
|
|
|
|
2009-10-30 08:31:57 +00:00
|
|
|
inline void BeginDocUpdate() {
|
2009-11-06 13:06:48 +00:00
|
|
|
NS_PRECONDITION(mFlushState == eInFlush, "Tried to double-open update.");
|
2009-10-30 08:31:57 +00:00
|
|
|
NS_PRECONDITION(mParser, "Started update without parser.");
|
2009-11-06 13:06:48 +00:00
|
|
|
mFlushState = eInDocUpdate;
|
2009-10-30 08:31:57 +00:00
|
|
|
mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void EndDocUpdate() {
|
2010-01-05 12:37:05 +00:00
|
|
|
NS_PRECONDITION(mFlushState != eNotifying, "mFlushState out of sync");
|
|
|
|
if (mFlushState == eInDocUpdate) {
|
2009-11-06 13:06:48 +00:00
|
|
|
FlushPendingAppendNotifications();
|
|
|
|
mFlushState = eInFlush;
|
2010-01-05 12:37:05 +00:00
|
|
|
mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
|
2009-10-30 08:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
void PostPendingAppendNotification(nsIContent* aParent, nsIContent* aChild) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool newParent = true;
|
2009-09-18 09:21:47 +00:00
|
|
|
const nsIContentPtr* first = mElementsSeenInThisAppendBatch.Elements();
|
|
|
|
const nsIContentPtr* last = first + mElementsSeenInThisAppendBatch.Length() - 1;
|
|
|
|
for (const nsIContentPtr* iter = last; iter >= first; --iter) {
|
2010-01-14 13:58:27 +00:00
|
|
|
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
2009-09-18 09:21:47 +00:00
|
|
|
sAppendBatchSlotsExamined++;
|
|
|
|
#endif
|
|
|
|
if (*iter == aParent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
newParent = false;
|
2009-09-18 09:21:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-04-30 13:12:06 +00:00
|
|
|
if (aChild->IsElement()) {
|
2009-09-18 09:21:47 +00:00
|
|
|
mElementsSeenInThisAppendBatch.AppendElement(aChild);
|
|
|
|
}
|
|
|
|
mElementsSeenInThisAppendBatch.AppendElement(aParent);
|
|
|
|
if (newParent) {
|
|
|
|
mPendingNotifications.AppendElement(aParent);
|
|
|
|
}
|
2010-01-14 13:58:27 +00:00
|
|
|
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
2009-09-18 09:21:47 +00:00
|
|
|
sAppendBatchExaminations++;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlushPendingAppendNotifications() {
|
2009-11-06 13:06:48 +00:00
|
|
|
NS_PRECONDITION(mFlushState == eInDocUpdate, "Notifications flushed outside update");
|
|
|
|
mFlushState = eNotifying;
|
2009-09-18 09:21:47 +00:00
|
|
|
const nsHtml5PendingNotification* start = mPendingNotifications.Elements();
|
|
|
|
const nsHtml5PendingNotification* end = start + mPendingNotifications.Length();
|
|
|
|
for (nsHtml5PendingNotification* iter = (nsHtml5PendingNotification*)start; iter < end; ++iter) {
|
|
|
|
iter->Fire();
|
|
|
|
}
|
|
|
|
mPendingNotifications.Clear();
|
2010-01-14 13:58:27 +00:00
|
|
|
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
2009-09-18 09:21:47 +00:00
|
|
|
if (mElementsSeenInThisAppendBatch.Length() > sAppendBatchMaxSize) {
|
|
|
|
sAppendBatchMaxSize = mElementsSeenInThisAppendBatch.Length();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mElementsSeenInThisAppendBatch.Clear();
|
2010-01-05 12:37:05 +00:00
|
|
|
NS_ASSERTION(mFlushState == eNotifying, "mFlushState out of sync");
|
2009-11-06 13:06:48 +00:00
|
|
|
mFlushState = eInDocUpdate;
|
2009-09-18 09:21:47 +00:00
|
|
|
}
|
2009-10-12 13:08:04 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool HaveNotified(nsIContent* aNode) {
|
2009-11-17 08:52:30 +00:00
|
|
|
NS_PRECONDITION(aNode, "HaveNotified called with null argument.");
|
2009-10-12 13:08:04 +00:00
|
|
|
const nsHtml5PendingNotification* start = mPendingNotifications.Elements();
|
|
|
|
const nsHtml5PendingNotification* end = start + mPendingNotifications.Length();
|
|
|
|
for (;;) {
|
2009-11-17 08:52:30 +00:00
|
|
|
nsIContent* parent = aNode->GetParent();
|
2009-10-12 13:08:04 +00:00
|
|
|
if (!parent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2009-10-12 13:08:04 +00:00
|
|
|
}
|
|
|
|
for (nsHtml5PendingNotification* iter = (nsHtml5PendingNotification*)start; iter < end; ++iter) {
|
|
|
|
if (iter->Contains(parent)) {
|
2009-11-17 08:52:30 +00:00
|
|
|
return iter->HaveNotifiedIndex(parent->IndexOf(aNode));
|
2009-10-12 13:08:04 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-17 08:52:30 +00:00
|
|
|
aNode = parent;
|
2009-10-12 13:08:04 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2010-02-22 12:17:33 +00:00
|
|
|
void StartLayout();
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2010-03-15 12:04:42 +00:00
|
|
|
void SetDocumentMode(nsHtml5DocumentMode m);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
nsresult Init(nsIDocument* aDoc, nsIURI* aURI,
|
|
|
|
nsISupports* aContainer, nsIChannel* aChannel);
|
2010-02-26 09:18:38 +00:00
|
|
|
|
|
|
|
void FlushSpeculativeLoads();
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
void RunFlushLoop();
|
|
|
|
|
|
|
|
void FlushDocumentWrite();
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
void MaybeSuspend();
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
|
2012-03-24 11:34:42 +00:00
|
|
|
void NeedsCharsetSwitchTo(const char* aEncoding,
|
|
|
|
PRInt32 aSource,
|
|
|
|
PRUint32 aLineNumber);
|
|
|
|
|
|
|
|
void MaybeComplainAboutCharset(const char* aMsgId,
|
|
|
|
bool aError,
|
|
|
|
PRUint32 aLineNumber);
|
|
|
|
|
|
|
|
void ComplainAboutBogusProtocolCharset(nsIDocument* aDoc);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsComplete() {
|
2009-10-12 13:08:04 +00:00
|
|
|
return !mParser;
|
2009-09-18 09:21:47 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasStarted() {
|
2009-10-12 13:08:04 +00:00
|
|
|
return mStarted;
|
2009-09-18 09:21:47 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsFlushing() {
|
2009-11-06 13:06:48 +00:00
|
|
|
return mFlushState >= eInFlush;
|
2009-10-15 11:29:11 +00:00
|
|
|
}
|
2010-02-26 09:18:38 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsInFlushLoop() {
|
2010-02-26 09:18:38 +00:00
|
|
|
return mRunFlushLoopOnStack;
|
|
|
|
}
|
|
|
|
#endif
|
2009-10-15 11:29:11 +00:00
|
|
|
|
2009-11-06 13:06:48 +00:00
|
|
|
void RunScript(nsIContent* aScriptElement);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
|
|
|
void Reset();
|
2009-09-21 11:43:43 +00:00
|
|
|
|
|
|
|
inline void HoldElement(nsIContent* aContent) {
|
2012-03-23 14:44:06 +00:00
|
|
|
mOwnedElements.AppendElement(aContent);
|
2009-09-21 11:43:43 +00:00
|
|
|
}
|
2010-04-21 11:54:40 +00:00
|
|
|
|
2011-08-01 07:48:24 +00:00
|
|
|
void DropHeldElements();
|
2009-09-21 11:43:43 +00:00
|
|
|
|
2009-09-21 13:18:20 +00:00
|
|
|
/**
|
|
|
|
* Flush the operations from the tree operations from the argument
|
2010-02-26 09:18:38 +00:00
|
|
|
* queue unconditionally. (This is for the main thread case.)
|
2009-09-21 13:18:20 +00:00
|
|
|
*/
|
2009-11-17 08:52:30 +00:00
|
|
|
virtual void MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue);
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
nsHtml5TreeOpStage* GetStage() {
|
2009-09-21 13:18:20 +00:00
|
|
|
return &mStage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartReadingFromStage() {
|
2011-10-17 14:59:28 +00:00
|
|
|
mReadingFromStage = true;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StreamEnded();
|
2009-09-18 09:21:47 +00:00
|
|
|
|
2009-10-12 13:08:04 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void AssertStageEmpty() {
|
|
|
|
mStage.AssertEmpty();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-30 10:15:38 +00:00
|
|
|
nsIURI* GetViewSourceBaseURI();
|
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
void PreloadScript(const nsAString& aURL,
|
|
|
|
const nsAString& aCharset,
|
2012-03-10 16:13:52 +00:00
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aCrossOrigin);
|
2010-02-26 09:18:38 +00:00
|
|
|
|
|
|
|
void PreloadStyle(const nsAString& aURL, const nsAString& aCharset);
|
|
|
|
|
2011-07-29 18:30:00 +00:00
|
|
|
void PreloadImage(const nsAString& aURL, const nsAString& aCrossOrigin);
|
2010-02-26 09:18:38 +00:00
|
|
|
|
2010-07-26 11:18:43 +00:00
|
|
|
void SetSpeculationBase(const nsAString& aURL);
|
|
|
|
|
2012-03-27 06:27:45 +00:00
|
|
|
static void InitializeStatics();
|
|
|
|
|
2009-09-21 13:18:20 +00:00
|
|
|
private:
|
2011-09-04 10:49:29 +00:00
|
|
|
nsHtml5Parser* GetParser();
|
2009-09-21 13:18:20 +00:00
|
|
|
|
2012-03-27 06:27:45 +00:00
|
|
|
bool IsExternalViewSource();
|
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
/**
|
|
|
|
* Get a nsIURI for an nsString if the URL hasn't been preloaded yet.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIURI> ConvertIfNotPreloadedYet(const nsAString& aURL);
|
|
|
|
|
2009-09-18 09:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsHtml5TreeOpExecutor_h__
|