Files
palemoon27/parser/html/nsHtml5TreeBuilderHSupplement.h
T
roytam1 2ddfe368e1 import changes from `dev' branch of rmottola/Arctic-Fox:
- bug 1215748 - use llvm-dsymutil for mac builds. r=mshal (a217006d89)
- warnings (31ea43d0d8)
- Bug 1175154 - Unit tests for IAC on 3.0. r=ferjm (12c424bab3)
- Bug 1219543 - Part 1: isRunningOnCompositor flag is now a member of AnimationProperty. r=bbirtles (85bc668501)
- Bug 1219543 - Part 2: Avoid the period that mIsRunningOnCompositor is false between restyling and building display list. r=bbirtles (597e46d479)
- Bug 1219543 - Part 3: MutationObserver should disconnect when the test is finished. r=bbirtles (70c26a266e)
- Bug 1214148 - patch 1 - propagation from the nested iframe back to the toplevel iframe, r=alwu (b42002f43a)
- Bug 1214148 - patch 2 - from toplevel iframe to the nested iframe, r=alwu (7b07fe5399)
- Bug 1214148 - patch 3 - correct window for nested iframes, r=alwu (27ee08caf1)
- Bug 1166910 - put referrer attribute behind pref in webidl, r=bz (93e421fa1b)
- Bug 1187357 - rename referrer attribute to referrerpolicy. r=hsivonen (70c67f5def)
- Bug 1187357 - Generated code for renaming referrer to referrerpolicy in html parser. r=hsivonen (738de3f278)
- Bug 1221341. Snap box shadow clip rect to device pixels. r=mstange (b63b783714)
- Bug 1228634 - Implement Element.getAttributeNames, r=peterv (4594d9c14c)
- Bug 1216193. Implement webkitMatchesSelector. r=khuey (39742b7e0b)
- Bug 1134648, handle dynamic changes to rel=dns-prefetch, r=bz (e27638080e)
- Bug 1229962 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in parser/html/; r=hsivonen (75de6314f1)
- Bug 1226437 - Speculative CSP should set speculative referrer policy instead of actual referrer policy. r=sicking (f7dfd3fd18)
- Bug 1227554 - Default to NullPrincipal if doc is not available within expatdriver. r=bz (336a562965)
- Bug 1215781 - Use MOZ_UTF16 to generate sTagUnicodeTable. r=mrbkap (eca371a36b)
- Bug 1082598 - Part 5: Fix NPAPI for Skia update. r=jrmuizel (25c4d080ab)
- Bug 1183828 - Remove 'nsWindow::GetNativeData not implemented for this type' warning. r=roc (0a60404b57)
- Bug 1224445 - Add NS_NATIVE_OPENGL_CONTEXT handling to nsWindow::GetNativeData() r=mwu (ee35844be4)
- Bug 1179632 part.1 native IME context should not be stored in InputContext but should be able to retrieve with nsIWidget::GetNativeData() r=smaug (5f1804bb72)
- Bug 1179632 part.2 WidgetCompositionEvent should store NativeIMEContext which caused the event and PuppetWidget should store it for GetNativeIMEContext() r=smaug, sr=smaug (e00ca78e3f)
- Bug 1179632 part.3 TabParent::RecvEndIMEComposition() shouldn't return true with aNoCompositionEvent when there is no widget r=smaug (ee065ed491)
- Bug 1179632 part.4 Clean up the code to request IME to commit composition across process boundary r=smaug (9567c4dc57)
- Bug 1179632 part.5 WidgetCompositionEvent::mNativeIMEContext should be used at looking for a TextComposition instance for a WidgetCompositionEvent r=smaug (f4e27ec28c)
- Bug 1179632 part.6 KeyboardEvent.isComposing shouldn't expose IME state on different document r=smaug (ca8b8a6a02)
- Bug 1227544 - Scaling on 720p devices is broken. r=timdream (cb89af839f)
2023-06-13 15:52:32 +08:00

249 lines
7.1 KiB
C++

/* 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/. */
#define NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH 512
private:
nsHtml5OplessBuilder* mBuilder;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// If mBuilder is not null, the tree op machinery is not in use and
// the fields below aren't in use, either.
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nsHtml5Highlighter* mViewSource;
nsTArray<nsHtml5TreeOperation> mOpQueue;
nsTArray<nsHtml5SpeculativeLoad> mSpeculativeLoadQueue;
nsAHtml5TreeOpSink* mOpSink;
mozilla::UniquePtr<nsIContent*[]> mHandles;
int32_t mHandlesUsed;
nsTArray<mozilla::UniquePtr<nsIContent*[]>> mOldHandles;
nsHtml5TreeOpStage* mSpeculativeLoadStage;
nsresult mBroken;
bool mCurrentHtmlScriptIsAsyncOrDefer;
bool mPreventScriptExecution;
#ifdef DEBUG
bool mActive;
#endif
// DocumentModeHandler
/**
* Tree builder uses this to report quirkiness of the document
*/
void documentMode(nsHtml5DocumentMode m);
nsIContentHandle* getDocumentFragmentForTemplate(nsIContentHandle* aTemplate);
nsIContentHandle* getFormPointerForContext(nsIContentHandle* aContext);
/**
* Using nsIContent** instead of nsIContent* is the parser deals with DOM
* nodes in a way that works off the main thread. Non-main-thread code
* can't refcount or otherwise touch nsIContent objects in any way.
* Yet, the off-the-main-thread code needs to have a way to hold onto a
* particular node and repeatedly operate on the same node.
*
* The way this works is that the off-the-main-thread code has an
* nsIContent** for each DOM node and a given nsIContent** is only ever
* actually dereferenced into an actual nsIContent* on the main thread.
* When the off-the-main-thread code requests a new node, it gets an
* nsIContent** immediately and a tree op is enqueued for later allocating
* an actual nsIContent object and writing a pointer to it into the memory
* location pointed to by the nsIContent**.
*
* Since tree ops are in a queue, the node creating tree op will always
* run before tree ops that try to further operate on the node that the
* nsIContent** is a handle to.
*
* On-the-main-thread parts of the parser use nsIContent* instead of
* nsIContent**. Since both cases share the same parser core, the parser
* core casts both to nsIContentHandle*.
*/
nsIContentHandle* AllocateContentHandle();
void accumulateCharactersForced(const char16_t* aBuf, int32_t aStart, int32_t aLength)
{
accumulateCharacters(aBuf, aStart, aLength);
}
void MarkAsBrokenAndRequestSuspension(nsresult aRv)
{
mBuilder->MarkAsBroken(aRv);
requestSuspension();
}
void MarkAsBrokenFromPortability(nsresult aRv);
public:
explicit nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder);
nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
nsHtml5TreeOpStage* aStage);
~nsHtml5TreeBuilder();
void StartPlainTextViewSource(const nsAutoString& aTitle);
void StartPlainText();
void StartPlainTextBody();
bool HasScript();
void SetOpSink(nsAHtml5TreeOpSink* aOpSink)
{
mOpSink = aOpSink;
}
void ClearOps()
{
mOpQueue.Clear();
}
bool Flush(bool aDiscretionary = false);
void FlushLoads();
void SetDocumentCharset(nsACString& aCharset, int32_t aCharsetSource);
void StreamEnded();
void NeedsCharsetSwitchTo(const nsACString& aEncoding,
int32_t aSource,
int32_t aLineNumber);
void MaybeComplainAboutCharset(const char* aMsgId,
bool aError,
int32_t aLineNumber);
void AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine);
void DropHandles();
void SetPreventScriptExecution(bool aPrevent)
{
mPreventScriptExecution = aPrevent;
}
bool HasBuilder()
{
return mBuilder;
}
/**
* Makes sure the buffers are large enough to be able to tokenize aLength
* UTF-16 code units before having to make the buffers larger.
*
* @param aLength the number of UTF-16 code units to be tokenized before the
* next call to this method.
* @return true if successful; false if out of memory
*/
bool EnsureBufferSpace(size_t aLength);
void EnableViewSource(nsHtml5Highlighter* aHighlighter);
void errStrayStartTag(nsIAtom* aName);
void errStrayEndTag(nsIAtom* aName);
void errUnclosedElements(int32_t aIndex, nsIAtom* aName);
void errUnclosedElementsImplied(int32_t aIndex, nsIAtom* aName);
void errUnclosedElementsCell(int32_t aIndex);
void errStrayDoctype();
void errAlmostStandardsDoctype();
void errQuirkyDoctype();
void errNonSpaceInTrailer();
void errNonSpaceAfterFrameset();
void errNonSpaceInFrameset();
void errNonSpaceAfterBody();
void errNonSpaceInColgroupInFragment();
void errNonSpaceInNoscriptInHead();
void errFooBetweenHeadAndBody(nsIAtom* aName);
void errStartTagWithoutDoctype();
void errNoSelectInTableScope();
void errStartSelectWhereEndSelectExpected();
void errStartTagWithSelectOpen(nsIAtom* aName);
void errBadStartTagInHead(nsIAtom* aName);
void errImage();
void errIsindex();
void errFooSeenWhenFooOpen(nsIAtom* aName);
void errHeadingWhenHeadingOpen();
void errFramesetStart();
void errNoCellToClose();
void errStartTagInTable(nsIAtom* aName);
void errFormWhenFormOpen();
void errTableSeenWhileTableOpen();
void errStartTagInTableBody(nsIAtom* aName);
void errEndTagSeenWithoutDoctype();
void errEndTagAfterBody();
void errEndTagSeenWithSelectOpen(nsIAtom* aName);
void errGarbageInColgroup();
void errEndTagBr();
void errNoElementToCloseButEndTagSeen(nsIAtom* aName);
void errHtmlStartTagInForeignContext(nsIAtom* aName);
void errTableClosedWhileCaptionOpen();
void errNoTableRowToClose();
void errNonSpaceInTable();
void errUnclosedChildrenInRuby();
void errStartTagSeenWithoutRuby(nsIAtom* aName);
void errSelfClosing();
void errNoCheckUnclosedElementsOnStack();
void errEndTagDidNotMatchCurrentOpenElement(nsIAtom* aName, nsIAtom* aOther);
void errEndTagViolatesNestingRules(nsIAtom* aName);
void errEndWithUnclosedElements(nsIAtom* aName);
void MarkAsBroken(nsresult aRv);
/**
* Checks if this parser is broken. Returns a non-NS_OK (i.e. non-0)
* value if broken.
*/
nsresult IsBroken()
{
return mBroken;
}