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/HTMLElementStack.h | 102 ++++++++++++-------------- 1 file changed, 48 insertions(+), 54 deletions(-) (limited to 'Source/WebCore/html/parser/HTMLElementStack.h') diff --git a/Source/WebCore/html/parser/HTMLElementStack.h b/Source/WebCore/html/parser/HTMLElementStack.h index a2c4f54de..a32d2f55e 100644 --- a/Source/WebCore/html/parser/HTMLElementStack.h +++ b/Source/WebCore/html/parser/HTMLElementStack.h @@ -24,8 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HTMLElementStack_h -#define HTMLElementStack_h +#pragma once #include "HTMLStackItem.h" #include @@ -35,7 +34,6 @@ namespace WebCore { class ContainerNode; -class DocumentFragment; class Element; class QualifiedName; @@ -44,31 +42,34 @@ class QualifiedName; class HTMLElementStack { WTF_MAKE_NONCOPYABLE(HTMLElementStack); WTF_MAKE_FAST_ALLOCATED; public: - HTMLElementStack(); + HTMLElementStack() = default; ~HTMLElementStack(); class ElementRecord { WTF_MAKE_NONCOPYABLE(ElementRecord); WTF_MAKE_FAST_ALLOCATED; public: - ElementRecord(PassRefPtr, std::unique_ptr); + ElementRecord(Ref&&, std::unique_ptr); ~ElementRecord(); - Element* element() const { return m_item->element(); } - ContainerNode* node() const { return m_item->node(); } + Element& element() const { return m_item->element(); } + ContainerNode& node() const { return m_item->node(); } const AtomicString& namespaceURI() const { return m_item->namespaceURI(); } - PassRefPtr stackItem() const { return m_item; } - void replaceElement(PassRefPtr); + HTMLStackItem& stackItem() { return m_item.get(); } + const HTMLStackItem& stackItem() const { return m_item.get(); } - bool isAbove(ElementRecord*) const; + void replaceElement(Ref&&); + + bool isAbove(ElementRecord&) const; ElementRecord* next() const { return m_next.get(); } + private: friend class HTMLElementStack; - std::unique_ptr releaseNext() { return std::move(m_next); } - void setNext(std::unique_ptr next) { m_next = std::move(next); } + std::unique_ptr releaseNext() { return WTFMove(m_next); } + void setNext(std::unique_ptr next) { m_next = WTFMove(next); } - RefPtr m_item; + Ref m_item; std::unique_ptr m_next; }; @@ -76,45 +77,42 @@ public: // Inlining this function is a (small) performance win on the parsing // benchmark. - Element* top() const + Element& top() const { - ASSERT(m_top->element()); return m_top->element(); } - ContainerNode* topNode() const + ContainerNode& topNode() const { - ASSERT(m_top->node()); return m_top->node(); } - HTMLStackItem* topStackItem() const + HTMLStackItem& topStackItem() const { - ASSERT(m_top->stackItem()); - return m_top->stackItem().get(); + return m_top->stackItem(); } HTMLStackItem* oneBelowTop() const; - ElementRecord* topRecord() const; - ElementRecord* find(Element*) const; - ElementRecord* furthestBlockForFormattingElement(Element*) const; + ElementRecord& topRecord() const; + ElementRecord* find(Element&) const; + ElementRecord* furthestBlockForFormattingElement(Element&) const; ElementRecord* topmost(const AtomicString& tagName) const; - void insertAbove(PassRefPtr, ElementRecord*); + void insertAbove(Ref&&, ElementRecord&); - void push(PassRefPtr); - void pushRootNode(PassRefPtr); - void pushHTMLHtmlElement(PassRefPtr); - void pushHTMLHeadElement(PassRefPtr); - void pushHTMLBodyElement(PassRefPtr); + void push(Ref&&); + void pushRootNode(Ref&&); + void pushHTMLHtmlElement(Ref&&); + void pushHTMLHeadElement(Ref&&); + void pushHTMLBodyElement(Ref&&); void pop(); void popUntil(const AtomicString& tagName); - void popUntil(Element*); + void popUntil(Element&); void popUntilPopped(const AtomicString& tagName); void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.localName()); } - void popUntilPopped(Element*); + void popUntilPopped(Element&); void popUntilNumberedHeaderElementPopped(); void popUntilTableScopeMarker(); // "clear the stack back to a table context" in the spec. void popUntilTableBodyScopeMarker(); // "clear the stack back to a table body context" in the spec. @@ -124,16 +122,16 @@ public: void popHTMLBodyElement(); void popAll(); - static bool isMathMLTextIntegrationPoint(HTMLStackItem*); - static bool isHTMLIntegrationPoint(HTMLStackItem*); + static bool isMathMLTextIntegrationPoint(HTMLStackItem&); + static bool isHTMLIntegrationPoint(HTMLStackItem&); - void remove(Element*); - void removeHTMLHeadElement(Element*); + void remove(Element&); + void removeHTMLHeadElement(Element&); - bool contains(Element*) const; + bool contains(Element&) const; bool contains(const AtomicString& tagName) const; - bool inScope(Element*) const; + bool inScope(Element&) const; bool inScope(const AtomicString& tagName) const; bool inScope(const QualifiedName&) const; bool inListItemScope(const AtomicString& tagName) const; @@ -149,24 +147,22 @@ public: bool hasOnlyOneElement() const; bool secondElementIsHTMLBodyElement() const; -#if ENABLE(TEMPLATE_ELEMENT) bool hasTemplateInHTMLScope() const; -#endif - Element* htmlElement() const; - Element* headElement() const; - Element* bodyElement() const; - - ContainerNode* rootNode() const; + Element& htmlElement() const; + Element& headElement() const; + Element& bodyElement() const; + + ContainerNode& rootNode() const; -#ifndef NDEBUG +#if ENABLE(TREE_DEBUGGING) void show(); #endif private: - void pushCommon(PassRefPtr); - void pushRootNodeCommon(PassRefPtr); + void pushCommon(Ref&&); + void pushRootNodeCommon(Ref&&); void popCommon(); - void removeNonTopCommon(Element*); + void removeNonTopCommon(Element&); std::unique_ptr m_top; @@ -175,12 +171,10 @@ private: // FIXME: We don't currently require type-specific information about // these elements so we haven't yet bothered to plumb the types all the // way down through createElement, etc. - ContainerNode* m_rootNode; - Element* m_headElement; - Element* m_bodyElement; - unsigned m_stackDepth; + ContainerNode* m_rootNode { nullptr }; + Element* m_headElement { nullptr }; + Element* m_bodyElement { nullptr }; + unsigned m_stackDepth { 0 }; }; } // namespace WebCore - -#endif // HTMLElementStack_h -- cgit v1.2.1