diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/parser/HTMLConstructionSite.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/parser/HTMLConstructionSite.h')
-rw-r--r-- | Source/WebCore/html/parser/HTMLConstructionSite.h | 113 |
1 files changed, 52 insertions, 61 deletions
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 <wtf/Noncopyable.h> -#include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> +#include <wtf/SetForScope.h> #include <wtf/Vector.h> 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<ContainerNode>(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<CustomElementConstructionData> insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&&); + void insertCustomElement(Ref<Element>&&, const AtomicString& localName, Vector<Attribute>&&); + 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<HTMLStackItem> createElementFromSavedToken(HTMLStackItem*); + Ref<HTMLStackItem> createElementFromSavedToken(HTMLStackItem&); bool shouldFosterParent() const; - void fosterParent(PassRefPtr<Node>); + void fosterParent(Ref<Node>&&); - bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const; + std::optional<unsigned> 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<HTMLFormElement> takeForm(); + RefPtr<HTMLFormElement> 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<bool> 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<HTMLConstructionSiteTask, 1> TaskQueue; - void setCompatibilityMode(Document::CompatibilityMode); + void setCompatibilityMode(DocumentCompatibilityMode); void setCompatibilityModeFromDoctype(const String& name, const String& publicId, const String& systemId); - void attachLater(ContainerNode* parent, PassRefPtr<Node> child, bool selfClosing = false); + void attachLater(ContainerNode& parent, Ref<Node>&& child, bool selfClosing = false); void findFosterSite(HTMLConstructionSiteTask&); - PassRefPtr<Element> createHTMLElement(AtomicHTMLToken*); - PassRefPtr<Element> createElement(AtomicHTMLToken*, const AtomicString& namespaceURI); + RefPtr<Element> createHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&, JSCustomElementInterface**); + Ref<Element> createHTMLElement(AtomicHTMLToken&); + Ref<Element> 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<HTMLStackItem> m_head; RefPtr<HTMLFormElement> m_form; @@ -229,5 +222,3 @@ private: }; } // namespace WebCore - -#endif |