summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/parser/HTMLElementStack.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/parser/HTMLElementStack.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/parser/HTMLElementStack.h')
-rw-r--r--Source/WebCore/html/parser/HTMLElementStack.h102
1 files changed, 48 insertions, 54 deletions
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 <wtf/Forward.h>
@@ -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<HTMLStackItem>, std::unique_ptr<ElementRecord>);
+ ElementRecord(Ref<HTMLStackItem>&&, std::unique_ptr<ElementRecord>);
~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<HTMLStackItem> stackItem() const { return m_item; }
- void replaceElement(PassRefPtr<HTMLStackItem>);
+ HTMLStackItem& stackItem() { return m_item.get(); }
+ const HTMLStackItem& stackItem() const { return m_item.get(); }
- bool isAbove(ElementRecord*) const;
+ void replaceElement(Ref<HTMLStackItem>&&);
+
+ bool isAbove(ElementRecord&) const;
ElementRecord* next() const { return m_next.get(); }
+
private:
friend class HTMLElementStack;
- std::unique_ptr<ElementRecord> releaseNext() { return std::move(m_next); }
- void setNext(std::unique_ptr<ElementRecord> next) { m_next = std::move(next); }
+ std::unique_ptr<ElementRecord> releaseNext() { return WTFMove(m_next); }
+ void setNext(std::unique_ptr<ElementRecord> next) { m_next = WTFMove(next); }
- RefPtr<HTMLStackItem> m_item;
+ Ref<HTMLStackItem> m_item;
std::unique_ptr<ElementRecord> 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<HTMLStackItem>, ElementRecord*);
+ void insertAbove(Ref<HTMLStackItem>&&, ElementRecord&);
- void push(PassRefPtr<HTMLStackItem>);
- void pushRootNode(PassRefPtr<HTMLStackItem>);
- void pushHTMLHtmlElement(PassRefPtr<HTMLStackItem>);
- void pushHTMLHeadElement(PassRefPtr<HTMLStackItem>);
- void pushHTMLBodyElement(PassRefPtr<HTMLStackItem>);
+ void push(Ref<HTMLStackItem>&&);
+ void pushRootNode(Ref<HTMLStackItem>&&);
+ void pushHTMLHtmlElement(Ref<HTMLStackItem>&&);
+ void pushHTMLHeadElement(Ref<HTMLStackItem>&&);
+ void pushHTMLBodyElement(Ref<HTMLStackItem>&&);
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<HTMLStackItem>);
- void pushRootNodeCommon(PassRefPtr<HTMLStackItem>);
+ void pushCommon(Ref<HTMLStackItem>&&);
+ void pushRootNodeCommon(Ref<HTMLStackItem>&&);
void popCommon();
- void removeNonTopCommon(Element*);
+ void removeNonTopCommon(Element&);
std::unique_ptr<ElementRecord> 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