From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/html/parser/HTMLConstructionSite.h | 113 ++++++++++------------ 1 file changed, 52 insertions(+), 61 deletions(-) (limited to 'Source/WebCore/html/parser/HTMLConstructionSite.h') diff --git a/Source/WebCore/html/parser/HTMLConstructionSite.h b/Source/WebCore/html/parser/HTMLConstructionSite.h index acd4c823e..96e64cfc7 100644 --- a/Source/WebCore/html/parser/HTMLConstructionSite.h +++ b/Source/WebCore/html/parser/HTMLConstructionSite.h @@ -24,15 +24,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HTMLConstructionSite_h -#define HTMLConstructionSite_h +#pragma once #include "FragmentScriptingPermission.h" #include "HTMLElementStack.h" #include "HTMLFormattingElementList.h" #include -#include #include +#include #include namespace WebCore { @@ -42,7 +41,7 @@ struct HTMLConstructionSiteTask { Insert, InsertAlreadyParsedChild, Reparent, - TakeAllChildren, + TakeAllChildrenAndReparent, }; explicit HTMLConstructionSiteTask(Operation op) @@ -56,7 +55,7 @@ struct HTMLConstructionSiteTask { // It's sort of ugly, but we store the |oldParent| in the |child| field // of the task so that we don't bloat the HTMLConstructionSiteTask // object in the common case of the Insert operation. - return toContainerNode(child.get()); + return downcast(child.get()); } Operation operation; @@ -81,9 +80,11 @@ enum WhitespaceMode { }; class AtomicHTMLToken; +struct CustomElementConstructionData; class Document; class Element; class HTMLFormElement; +class JSCustomElementInterface; class HTMLConstructionSite { WTF_MAKE_NONCOPYABLE(HTMLConstructionSite); @@ -92,120 +93,112 @@ public: HTMLConstructionSite(DocumentFragment&, ParserContentPolicy, unsigned maximumDOMTreeDepth); ~HTMLConstructionSite(); - void detach(); void executeQueuedTasks(); void setDefaultCompatibilityMode(); void finishedParsing(); - void insertDoctype(AtomicHTMLToken*); - void insertComment(AtomicHTMLToken*); - void insertCommentOnDocument(AtomicHTMLToken*); - void insertCommentOnHTMLHtmlElement(AtomicHTMLToken*); - void insertHTMLElement(AtomicHTMLToken*); - void insertSelfClosingHTMLElement(AtomicHTMLToken*); - void insertFormattingElement(AtomicHTMLToken*); - void insertHTMLHeadElement(AtomicHTMLToken*); - void insertHTMLBodyElement(AtomicHTMLToken*); - void insertHTMLFormElement(AtomicHTMLToken*, bool isDemoted = false); - void insertScriptElement(AtomicHTMLToken*); + void insertDoctype(AtomicHTMLToken&&); + void insertComment(AtomicHTMLToken&&); + void insertCommentOnDocument(AtomicHTMLToken&&); + void insertCommentOnHTMLHtmlElement(AtomicHTMLToken&&); + void insertHTMLElement(AtomicHTMLToken&&); + std::unique_ptr insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&&); + void insertCustomElement(Ref&&, const AtomicString& localName, Vector&&); + void insertSelfClosingHTMLElement(AtomicHTMLToken&&); + void insertFormattingElement(AtomicHTMLToken&&); + void insertHTMLHeadElement(AtomicHTMLToken&&); + void insertHTMLBodyElement(AtomicHTMLToken&&); + void insertHTMLFormElement(AtomicHTMLToken&&, bool isDemoted = false); + void insertScriptElement(AtomicHTMLToken&&); void insertTextNode(const String&, WhitespaceMode = WhitespaceUnknown); - void insertForeignElement(AtomicHTMLToken*, const AtomicString& namespaceURI); + void insertForeignElement(AtomicHTMLToken&&, const AtomicString& namespaceURI); - void insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken*); - void insertHTMLHtmlStartTagInBody(AtomicHTMLToken*); - void insertHTMLBodyStartTagInBody(AtomicHTMLToken*); + void insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken&&); + void insertHTMLHtmlStartTagInBody(AtomicHTMLToken&&); + void insertHTMLBodyStartTagInBody(AtomicHTMLToken&&); void reparent(HTMLElementStack::ElementRecord& newParent, HTMLElementStack::ElementRecord& child); - void reparent(HTMLElementStack::ElementRecord& newParent, HTMLStackItem& child); // insertAlreadyParsedChild assumes that |child| has already been parsed (i.e., we're just // moving it around in the tree rather than parsing it for the first time). That means // this function doesn't call beginParsingChildren / finishParsingChildren. void insertAlreadyParsedChild(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& child); - void takeAllChildren(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& oldParent); + void takeAllChildrenAndReparent(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& oldParent); - PassRefPtr createElementFromSavedToken(HTMLStackItem*); + Ref createElementFromSavedToken(HTMLStackItem&); bool shouldFosterParent() const; - void fosterParent(PassRefPtr); + void fosterParent(Ref&&); - bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const; + std::optional indexOfFirstUnopenFormattingElement() const; void reconstructTheActiveFormattingElements(); void generateImpliedEndTags(); void generateImpliedEndTagsWithExclusion(const AtomicString& tagName); - bool inQuirksMode(); + bool inQuirksMode() { return m_inQuirksMode; } bool isEmpty() const { return !m_openElements.stackDepth(); } - HTMLElementStack::ElementRecord* currentElementRecord() const { return m_openElements.topRecord(); } - Element* currentElement() const { return m_openElements.top(); } - ContainerNode* currentNode() const { return m_openElements.topNode(); } - HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem(); } + Element& currentElement() const { return m_openElements.top(); } + ContainerNode& currentNode() const { return m_openElements.topNode(); } + HTMLStackItem& currentStackItem() const { return m_openElements.topStackItem(); } HTMLStackItem* oneBelowTop() const { return m_openElements.oneBelowTop(); } Document& ownerDocumentForCurrentNode(); - bool insideTemplateElement(); - HTMLElementStack* openElements() const { return &m_openElements; } - HTMLFormattingElementList* activeFormattingElements() const { return &m_activeFormattingElements; } - bool currentIsRootNode() { return m_openElements.topNode() == m_openElements.rootNode(); } + HTMLElementStack& openElements() const { return m_openElements; } + HTMLFormattingElementList& activeFormattingElements() const { return m_activeFormattingElements; } + bool currentIsRootNode() { return &m_openElements.topNode() == &m_openElements.rootNode(); } - Element* head() const { return m_head->element(); } + Element& head() const { return m_head->element(); } HTMLStackItem* headStackItem() const { return m_head.get(); } void setForm(HTMLFormElement*); HTMLFormElement* form() const { return m_form.get(); } - PassRefPtr takeForm(); + RefPtr takeForm(); ParserContentPolicy parserContentPolicy() { return m_parserContentPolicy; } -#if PLATFORM(IOS) - bool isTelephoneNumberParsingEnabled() { return m_document->isTelephoneNumberParsingEnabled(); } +#if ENABLE(TELEPHONE_NUMBER_DETECTION) + bool isTelephoneNumberParsingEnabled() { return m_document.isTelephoneNumberParsingEnabled(); } #endif class RedirectToFosterParentGuard { WTF_MAKE_NONCOPYABLE(RedirectToFosterParentGuard); public: - RedirectToFosterParentGuard(HTMLConstructionSite& tree) - : m_tree(tree) - , m_wasRedirectingBefore(tree.m_redirectAttachToFosterParent) - { - m_tree.m_redirectAttachToFosterParent = true; - } - - ~RedirectToFosterParentGuard() - { - m_tree.m_redirectAttachToFosterParent = m_wasRedirectingBefore; - } + explicit RedirectToFosterParentGuard(HTMLConstructionSite& tree) + : m_redirectAttachToFosterParentChange(tree.m_redirectAttachToFosterParent, true) + { } private: - HTMLConstructionSite& m_tree; - bool m_wasRedirectingBefore; + SetForScope m_redirectAttachToFosterParentChange; }; + static bool isFormattingTag(const AtomicString&); + private: // In the common case, this queue will have only one task because most // tokens produce only one DOM mutation. typedef Vector TaskQueue; - void setCompatibilityMode(Document::CompatibilityMode); + void setCompatibilityMode(DocumentCompatibilityMode); void setCompatibilityModeFromDoctype(const String& name, const String& publicId, const String& systemId); - void attachLater(ContainerNode* parent, PassRefPtr child, bool selfClosing = false); + void attachLater(ContainerNode& parent, Ref&& child, bool selfClosing = false); void findFosterSite(HTMLConstructionSiteTask&); - PassRefPtr createHTMLElement(AtomicHTMLToken*); - PassRefPtr createElement(AtomicHTMLToken*, const AtomicString& namespaceURI); + RefPtr createHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&, JSCustomElementInterface**); + Ref createHTMLElement(AtomicHTMLToken&); + Ref createElement(AtomicHTMLToken&, const AtomicString& namespaceURI); - void mergeAttributesFromTokenIntoElement(AtomicHTMLToken*, Element*); + void mergeAttributesFromTokenIntoElement(AtomicHTMLToken&&, Element&); void dispatchDocumentElementAvailableIfNeeded(); - Document* m_document; + Document& m_document; // This is the root ContainerNode to which the parser attaches all newly // constructed nodes. It points to a DocumentFragment when parsing fragments // and a Document in all other cases. - ContainerNode* m_attachmentRoot; + ContainerNode& m_attachmentRoot; RefPtr m_head; RefPtr m_form; @@ -229,5 +222,3 @@ private: }; } // namespace WebCore - -#endif -- cgit v1.2.1