summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/parser/HTMLElementStack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/parser/HTMLElementStack.cpp')
-rw-r--r--Source/WebCore/html/parser/HTMLElementStack.cpp381
1 files changed, 176 insertions, 205 deletions
diff --git a/Source/WebCore/html/parser/HTMLElementStack.cpp b/Source/WebCore/html/parser/HTMLElementStack.cpp
index 2aaf6db92..705703efc 100644
--- a/Source/WebCore/html/parser/HTMLElementStack.cpp
+++ b/Source/WebCore/html/parser/HTMLElementStack.cpp
@@ -36,138 +36,118 @@ namespace WebCore {
using namespace HTMLNames;
-
namespace {
-inline bool isRootNode(HTMLStackItem* item)
-{
- return item->isDocumentFragmentNode()
- || item->hasTagName(htmlTag);
-}
-
-inline bool isScopeMarker(HTMLStackItem* item)
-{
- return item->hasTagName(appletTag)
- || item->hasTagName(captionTag)
- || item->hasTagName(marqueeTag)
- || item->hasTagName(objectTag)
- || isHTMLTableElement(item->node())
- || item->hasTagName(tdTag)
- || item->hasTagName(thTag)
- || item->hasTagName(MathMLNames::miTag)
- || item->hasTagName(MathMLNames::moTag)
- || item->hasTagName(MathMLNames::mnTag)
- || item->hasTagName(MathMLNames::msTag)
- || item->hasTagName(MathMLNames::mtextTag)
- || item->hasTagName(MathMLNames::annotation_xmlTag)
- || item->hasTagName(SVGNames::foreignObjectTag)
- || item->hasTagName(SVGNames::descTag)
- || item->hasTagName(SVGNames::titleTag)
-#if ENABLE(TEMPLATE_ELEMENT)
- || item->hasTagName(templateTag)
-#endif
+inline bool isRootNode(HTMLStackItem& item)
+{
+ return item.isDocumentFragment() || item.hasTagName(htmlTag);
+}
+
+inline bool isScopeMarker(HTMLStackItem& item)
+{
+ return item.hasTagName(appletTag)
+ || item.hasTagName(captionTag)
+ || item.hasTagName(marqueeTag)
+ || item.hasTagName(objectTag)
+ || is<HTMLTableElement>(item.node())
+ || item.hasTagName(tdTag)
+ || item.hasTagName(thTag)
+ || item.hasTagName(MathMLNames::miTag)
+ || item.hasTagName(MathMLNames::moTag)
+ || item.hasTagName(MathMLNames::mnTag)
+ || item.hasTagName(MathMLNames::msTag)
+ || item.hasTagName(MathMLNames::mtextTag)
+ || item.hasTagName(MathMLNames::annotation_xmlTag)
+ || item.hasTagName(SVGNames::foreignObjectTag)
+ || item.hasTagName(SVGNames::descTag)
+ || item.hasTagName(SVGNames::titleTag)
+ || item.hasTagName(templateTag)
|| isRootNode(item);
}
-inline bool isListItemScopeMarker(HTMLStackItem* item)
+inline bool isListItemScopeMarker(HTMLStackItem& item)
{
return isScopeMarker(item)
- || item->hasTagName(olTag)
- || item->hasTagName(ulTag);
+ || item.hasTagName(olTag)
+ || item.hasTagName(ulTag);
}
-inline bool isTableScopeMarker(HTMLStackItem* item)
+inline bool isTableScopeMarker(HTMLStackItem& item)
{
- return isHTMLTableElement(item->node())
-#if ENABLE(TEMPLATE_ELEMENT)
- || item->hasTagName(templateTag)
-#endif
+ return is<HTMLTableElement>(item.node())
+ || item.hasTagName(templateTag)
|| isRootNode(item);
}
-inline bool isTableBodyScopeMarker(HTMLStackItem* item)
+inline bool isTableBodyScopeMarker(HTMLStackItem& item)
{
- return item->hasTagName(tbodyTag)
- || item->hasTagName(tfootTag)
- || item->hasTagName(theadTag)
-#if ENABLE(TEMPLATE_ELEMENT)
- || item->hasTagName(templateTag)
-#endif
+ return item.hasTagName(tbodyTag)
+ || item.hasTagName(tfootTag)
+ || item.hasTagName(theadTag)
+ || item.hasTagName(templateTag)
|| isRootNode(item);
}
-inline bool isTableRowScopeMarker(HTMLStackItem* item)
+inline bool isTableRowScopeMarker(HTMLStackItem& item)
{
- return item->hasTagName(trTag)
-#if ENABLE(TEMPLATE_ELEMENT)
- || item->hasTagName(templateTag)
-#endif
+ return item.hasTagName(trTag)
+ || item.hasTagName(templateTag)
|| isRootNode(item);
}
-inline bool isForeignContentScopeMarker(HTMLStackItem* item)
+inline bool isForeignContentScopeMarker(HTMLStackItem& item)
{
return HTMLElementStack::isMathMLTextIntegrationPoint(item)
|| HTMLElementStack::isHTMLIntegrationPoint(item)
- || item->isInHTMLNamespace();
+ || isInHTMLNamespace(item);
}
-inline bool isButtonScopeMarker(HTMLStackItem* item)
+inline bool isButtonScopeMarker(HTMLStackItem& item)
{
return isScopeMarker(item)
- || item->hasTagName(buttonTag);
+ || item.hasTagName(buttonTag);
}
-inline bool isSelectScopeMarker(HTMLStackItem* item)
+inline bool isSelectScopeMarker(HTMLStackItem& item)
{
- return !isHTMLOptGroupElement(item->node()) && !isHTMLOptionElement(item->node());
+ return !is<HTMLOptGroupElement>(item.node()) && !is<HTMLOptionElement>(item.node());
}
}
-HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<HTMLStackItem> item, std::unique_ptr<ElementRecord> next)
- : m_item(item)
- , m_next(std::move(next))
+HTMLElementStack::ElementRecord::ElementRecord(Ref<HTMLStackItem>&& item, std::unique_ptr<ElementRecord> next)
+ : m_item(WTFMove(item))
+ , m_next(WTFMove(next))
{
- ASSERT(m_item);
}
HTMLElementStack::ElementRecord::~ElementRecord()
{
}
-void HTMLElementStack::ElementRecord::replaceElement(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::ElementRecord::replaceElement(Ref<HTMLStackItem>&& item)
{
- ASSERT(item);
- ASSERT(!m_item || m_item->isElementNode());
+ ASSERT(m_item->isElement());
// FIXME: Should this call finishParsingChildren?
- m_item = item;
+ m_item = WTFMove(item);
}
-bool HTMLElementStack::ElementRecord::isAbove(ElementRecord* other) const
+bool HTMLElementStack::ElementRecord::isAbove(ElementRecord& other) const
{
- for (ElementRecord* below = next(); below; below = below->next()) {
- if (below == other)
+ for (auto* below = next(); below; below = below->next()) {
+ if (below == &other)
return true;
}
return false;
}
-HTMLElementStack::HTMLElementStack()
- : m_rootNode(0)
- , m_headElement(0)
- , m_bodyElement(0)
- , m_stackDepth(0)
-{
-}
-
HTMLElementStack::~HTMLElementStack()
{
}
bool HTMLElementStack::hasOnlyOneElement() const
{
- return !topRecord()->next();
+ return !topRecord().next();
}
bool HTMLElementStack::secondElementIsHTMLBodyElement() const
@@ -184,39 +164,39 @@ bool HTMLElementStack::secondElementIsHTMLBodyElement() const
void HTMLElementStack::popHTMLHeadElement()
{
- ASSERT(top() == m_headElement);
- m_headElement = 0;
+ ASSERT(&top() == m_headElement);
+ m_headElement = nullptr;
popCommon();
}
void HTMLElementStack::popHTMLBodyElement()
{
- ASSERT(top() == m_bodyElement);
- m_bodyElement = 0;
+ ASSERT(&top() == m_bodyElement);
+ m_bodyElement = nullptr;
popCommon();
}
void HTMLElementStack::popAll()
{
- m_rootNode = 0;
- m_headElement = 0;
- m_bodyElement = 0;
+ m_rootNode = nullptr;
+ m_headElement = nullptr;
+ m_bodyElement = nullptr;
m_stackDepth = 0;
while (m_top) {
- topNode()->finishParsingChildren();
+ topNode().finishParsingChildren();
m_top = m_top->releaseNext();
}
}
void HTMLElementStack::pop()
{
- ASSERT(!topStackItem()->hasTagName(HTMLNames::headTag));
+ ASSERT(!topStackItem().hasTagName(HTMLNames::headTag));
popCommon();
}
void HTMLElementStack::popUntil(const AtomicString& tagName)
{
- while (!topStackItem()->matchesHTMLTag(tagName)) {
+ while (!topStackItem().matchesHTMLTag(tagName)) {
// pop() will ASSERT if a <body>, <head> or <html> will be popped.
pop();
}
@@ -230,18 +210,18 @@ void HTMLElementStack::popUntilPopped(const AtomicString& tagName)
void HTMLElementStack::popUntilNumberedHeaderElementPopped()
{
- while (!topStackItem()->isNumberedHeaderElement())
+ while (!isNumberedHeaderElement(topStackItem()))
pop();
pop();
}
-void HTMLElementStack::popUntil(Element* element)
+void HTMLElementStack::popUntil(Element& element)
{
- while (top() != element)
+ while (&top() != &element)
pop();
}
-void HTMLElementStack::popUntilPopped(Element* element)
+void HTMLElementStack::popUntilPopped(Element& element)
{
popUntil(element);
pop();
@@ -269,34 +249,30 @@ void HTMLElementStack::popUntilTableRowScopeMarker()
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#mathml-text-integration-point
-bool HTMLElementStack::isMathMLTextIntegrationPoint(HTMLStackItem* item)
+bool HTMLElementStack::isMathMLTextIntegrationPoint(HTMLStackItem& item)
{
- if (!item->isElementNode())
- return false;
- return item->hasTagName(MathMLNames::miTag)
- || item->hasTagName(MathMLNames::moTag)
- || item->hasTagName(MathMLNames::mnTag)
- || item->hasTagName(MathMLNames::msTag)
- || item->hasTagName(MathMLNames::mtextTag);
+ return item.hasTagName(MathMLNames::miTag)
+ || item.hasTagName(MathMLNames::moTag)
+ || item.hasTagName(MathMLNames::mnTag)
+ || item.hasTagName(MathMLNames::msTag)
+ || item.hasTagName(MathMLNames::mtextTag);
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#html-integration-point
-bool HTMLElementStack::isHTMLIntegrationPoint(HTMLStackItem* item)
+bool HTMLElementStack::isHTMLIntegrationPoint(HTMLStackItem& item)
{
- if (!item->isElementNode())
- return false;
- if (item->hasTagName(MathMLNames::annotation_xmlTag)) {
- Attribute* encodingAttr = item->getAttributeItem(MathMLNames::encodingAttr);
+ if (item.hasTagName(MathMLNames::annotation_xmlTag)) {
+ const Attribute* encodingAttr = item.findAttribute(MathMLNames::encodingAttr);
if (encodingAttr) {
const String& encoding = encodingAttr->value();
- return equalIgnoringCase(encoding, "text/html")
- || equalIgnoringCase(encoding, "application/xhtml+xml");
+ return equalLettersIgnoringASCIICase(encoding, "text/html")
+ || equalLettersIgnoringASCIICase(encoding, "application/xhtml+xml");
}
return false;
}
- return item->hasTagName(SVGNames::foreignObjectTag)
- || item->hasTagName(SVGNames::descTag)
- || item->hasTagName(SVGNames::titleTag);
+ return item.hasTagName(SVGNames::foreignObjectTag)
+ || item.hasTagName(SVGNames::descTag)
+ || item.hasTagName(SVGNames::titleTag);
}
void HTMLElementStack::popUntilForeignContentScopeMarker()
@@ -305,81 +281,79 @@ void HTMLElementStack::popUntilForeignContentScopeMarker()
pop();
}
-void HTMLElementStack::pushRootNode(PassRefPtr<HTMLStackItem> rootItem)
+void HTMLElementStack::pushRootNode(Ref<HTMLStackItem>&& rootItem)
{
- ASSERT(rootItem->isDocumentFragmentNode());
- pushRootNodeCommon(rootItem);
+ ASSERT(rootItem->isDocumentFragment());
+ pushRootNodeCommon(WTFMove(rootItem));
}
-void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::pushHTMLHtmlElement(Ref<HTMLStackItem>&& item)
{
ASSERT(item->hasTagName(HTMLNames::htmlTag));
- pushRootNodeCommon(item);
+ pushRootNodeCommon(WTFMove(item));
}
-void HTMLElementStack::pushRootNodeCommon(PassRefPtr<HTMLStackItem> rootItem)
+void HTMLElementStack::pushRootNodeCommon(Ref<HTMLStackItem>&& rootItem)
{
ASSERT(!m_top);
ASSERT(!m_rootNode);
- m_rootNode = rootItem->node();
- pushCommon(rootItem);
+ m_rootNode = &rootItem->node();
+ pushCommon(WTFMove(rootItem));
}
-void HTMLElementStack::pushHTMLHeadElement(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::pushHTMLHeadElement(Ref<HTMLStackItem>&& item)
{
ASSERT(item->hasTagName(HTMLNames::headTag));
ASSERT(!m_headElement);
- m_headElement = item->element();
- pushCommon(item);
+ m_headElement = &item->element();
+ pushCommon(WTFMove(item));
}
-void HTMLElementStack::pushHTMLBodyElement(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::pushHTMLBodyElement(Ref<HTMLStackItem>&& item)
{
ASSERT(item->hasTagName(HTMLNames::bodyTag));
ASSERT(!m_bodyElement);
- m_bodyElement = item->element();
- pushCommon(item);
+ m_bodyElement = &item->element();
+ pushCommon(WTFMove(item));
}
-void HTMLElementStack::push(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::push(Ref<HTMLStackItem>&& item)
{
ASSERT(!item->hasTagName(HTMLNames::htmlTag));
ASSERT(!item->hasTagName(HTMLNames::headTag));
ASSERT(!item->hasTagName(HTMLNames::bodyTag));
ASSERT(m_rootNode);
- pushCommon(item);
+ pushCommon(WTFMove(item));
}
-void HTMLElementStack::insertAbove(PassRefPtr<HTMLStackItem> item, ElementRecord* recordBelow)
+void HTMLElementStack::insertAbove(Ref<HTMLStackItem>&& item, ElementRecord& recordBelow)
{
- ASSERT(item);
- ASSERT(recordBelow);
ASSERT(m_top);
ASSERT(!item->hasTagName(HTMLNames::htmlTag));
ASSERT(!item->hasTagName(HTMLNames::headTag));
ASSERT(!item->hasTagName(HTMLNames::bodyTag));
ASSERT(m_rootNode);
- if (recordBelow == m_top.get()) {
- push(item);
+ if (&recordBelow == m_top.get()) {
+ push(item.copyRef());
return;
}
- for (ElementRecord* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove->next()) {
- if (recordAbove->next() != recordBelow)
+ for (auto* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove->next()) {
+ if (recordAbove->next() != &recordBelow)
continue;
- m_stackDepth++;
- recordAbove->setNext(std::make_unique<ElementRecord>(item, recordAbove->releaseNext()));
- recordAbove->next()->element()->beginParsingChildren();
+ ++m_stackDepth;
+ recordAbove->setNext(std::make_unique<ElementRecord>(WTFMove(item), recordAbove->releaseNext()));
+ recordAbove->next()->element().beginParsingChildren();
return;
}
ASSERT_NOT_REACHED();
}
-HTMLElementStack::ElementRecord* HTMLElementStack::topRecord() const
+auto HTMLElementStack::topRecord() const -> ElementRecord&
{
ASSERT(m_top);
- return m_top.get();
+ return *m_top;
}
HTMLStackItem* HTMLElementStack::oneBelowTop() const
@@ -387,51 +361,51 @@ HTMLStackItem* HTMLElementStack::oneBelowTop() const
// We should never call this if there are fewer than 2 elements on the stack.
ASSERT(m_top);
ASSERT(m_top->next());
- if (m_top->next()->stackItem()->isElementNode())
- return m_top->next()->stackItem().get();
- return 0;
+ if (m_top->next()->stackItem().isElement())
+ return &m_top->next()->stackItem();
+ return nullptr;
}
-void HTMLElementStack::removeHTMLHeadElement(Element* element)
+void HTMLElementStack::removeHTMLHeadElement(Element& element)
{
- ASSERT(m_headElement == element);
- if (m_top->element() == element) {
+ ASSERT(m_headElement == &element);
+ if (&m_top->element() == &element) {
popHTMLHeadElement();
return;
}
- m_headElement = 0;
+ m_headElement = nullptr;
removeNonTopCommon(element);
}
-void HTMLElementStack::remove(Element* element)
+void HTMLElementStack::remove(Element& element)
{
- ASSERT(!element->hasTagName(HTMLNames::headTag));
- if (m_top->element() == element) {
+ ASSERT(!element.hasTagName(HTMLNames::headTag));
+ if (&m_top->element() == &element) {
pop();
return;
}
removeNonTopCommon(element);
}
-HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const
+auto HTMLElementStack::find(Element& element) const -> ElementRecord*
{
- for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
- if (pos->node() == element)
- return pos;
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ if (&record->node() == &element)
+ return record;
}
- return 0;
+ return nullptr;
}
-HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString& tagName) const
+auto HTMLElementStack::topmost(const AtomicString& tagName) const -> ElementRecord*
{
- for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
- if (pos->stackItem()->matchesHTMLTag(tagName))
- return pos;
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ if (record->stackItem().matchesHTMLTag(tagName))
+ return record;
}
- return 0;
+ return nullptr;
}
-bool HTMLElementStack::contains(Element* element) const
+bool HTMLElementStack::contains(Element& element) const
{
return !!find(element);
}
@@ -441,12 +415,11 @@ bool HTMLElementStack::contains(const AtomicString& tagName) const
return !!topmost(tagName);
}
-template <bool isMarker(HTMLStackItem*)>
-bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag)
+template <bool isMarker(HTMLStackItem&)> bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag)
{
- for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) {
- HTMLStackItem* item = pos->stackItem().get();
- if (item->matchesHTMLTag(targetTag))
+ for (auto* record = top; record; record = record->next()) {
+ auto& item = record->stackItem();
+ if (item.matchesHTMLTag(targetTag))
return true;
if (isMarker(item))
return false;
@@ -457,9 +430,9 @@ bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& tar
bool HTMLElementStack::hasNumberedHeaderElementInScope() const
{
- for (ElementRecord* record = m_top.get(); record; record = record->next()) {
- HTMLStackItem* item = record->stackItem().get();
- if (item->isNumberedHeaderElement())
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ auto& item = record->stackItem();
+ if (isNumberedHeaderElement(item))
return true;
if (isScopeMarker(item))
return false;
@@ -468,11 +441,11 @@ bool HTMLElementStack::hasNumberedHeaderElementInScope() const
return false;
}
-bool HTMLElementStack::inScope(Element* targetElement) const
+bool HTMLElementStack::inScope(Element& targetElement) const
{
- for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
- HTMLStackItem* item = pos->stackItem().get();
- if (item->node() == targetElement)
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ auto& item = record->stackItem();
+ if (&item.node() == &targetElement)
return true;
if (isScopeMarker(item))
return false;
@@ -531,93 +504,91 @@ bool HTMLElementStack::inSelectScope(const QualifiedName& tagName) const
return inSelectScope(tagName.localName());
}
-#if ENABLE(TEMPLATE_ELEMENT)
bool HTMLElementStack::hasTemplateInHTMLScope() const
{
return inScopeCommon<isRootNode>(m_top.get(), templateTag.localName());
}
-#endif
-Element* HTMLElementStack::htmlElement() const
+Element& HTMLElementStack::htmlElement() const
{
- ASSERT(m_rootNode);
- return toElement(m_rootNode);
+ return downcast<Element>(rootNode());
}
-Element* HTMLElementStack::headElement() const
+Element& HTMLElementStack::headElement() const
{
ASSERT(m_headElement);
- return m_headElement;
+ return *m_headElement;
}
-Element* HTMLElementStack::bodyElement() const
+Element& HTMLElementStack::bodyElement() const
{
ASSERT(m_bodyElement);
- return m_bodyElement;
+ return *m_bodyElement;
}
-ContainerNode* HTMLElementStack::rootNode() const
+ContainerNode& HTMLElementStack::rootNode() const
{
ASSERT(m_rootNode);
- return m_rootNode;
+ return *m_rootNode;
}
-void HTMLElementStack::pushCommon(PassRefPtr<HTMLStackItem> item)
+void HTMLElementStack::pushCommon(Ref<HTMLStackItem>&& item)
{
ASSERT(m_rootNode);
- m_stackDepth++;
- m_top = std::make_unique<ElementRecord>(item, std::move(m_top));
+ ++m_stackDepth;
+ m_top = std::make_unique<ElementRecord>(WTFMove(item), WTFMove(m_top));
}
void HTMLElementStack::popCommon()
{
- ASSERT(!topStackItem()->hasTagName(HTMLNames::htmlTag));
- ASSERT(!topStackItem()->hasTagName(HTMLNames::headTag) || !m_headElement);
- ASSERT(!topStackItem()->hasTagName(HTMLNames::bodyTag) || !m_bodyElement);
- top()->finishParsingChildren();
+ ASSERT(!topStackItem().hasTagName(HTMLNames::htmlTag));
+ ASSERT(!topStackItem().hasTagName(HTMLNames::headTag) || !m_headElement);
+ ASSERT(!topStackItem().hasTagName(HTMLNames::bodyTag) || !m_bodyElement);
+
+ top().finishParsingChildren();
m_top = m_top->releaseNext();
- m_stackDepth--;
+ --m_stackDepth;
}
-void HTMLElementStack::removeNonTopCommon(Element* element)
+void HTMLElementStack::removeNonTopCommon(Element& element)
{
- ASSERT(!element->hasTagName(HTMLNames::htmlTag));
- ASSERT(!element->hasTagName(HTMLNames::bodyTag));
- ASSERT(top() != element);
- for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
- if (pos->next()->element() == element) {
+ ASSERT(!element.hasTagName(HTMLNames::htmlTag));
+ ASSERT(!element.hasTagName(HTMLNames::bodyTag));
+ ASSERT(&top() != &element);
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ if (&record->next()->element() == &element) {
// FIXME: Is it OK to call finishParsingChildren()
// when the children aren't actually finished?
- element->finishParsingChildren();
- pos->setNext(pos->next()->releaseNext());
- m_stackDepth--;
+ element.finishParsingChildren();
+ record->setNext(record->next()->releaseNext());
+ --m_stackDepth;
return;
}
}
ASSERT_NOT_REACHED();
}
-HTMLElementStack::ElementRecord* HTMLElementStack::furthestBlockForFormattingElement(Element* formattingElement) const
+auto HTMLElementStack::furthestBlockForFormattingElement(Element& formattingElement) const -> ElementRecord*
{
- ElementRecord* furthestBlock = 0;
- for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
- if (pos->element() == formattingElement)
+ ElementRecord* furthestBlock = nullptr;
+ for (auto* record = m_top.get(); record; record = record->next()) {
+ if (&record->element() == &formattingElement)
return furthestBlock;
- if (pos->stackItem()->isSpecialNode())
- furthestBlock = pos;
+ if (isSpecialNode(record->stackItem()))
+ furthestBlock = record;
}
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
-#ifndef NDEBUG
+#if ENABLE(TREE_DEBUGGING)
void HTMLElementStack::show()
{
- for (ElementRecord* record = m_top.get(); record; record = record->next())
- record->element()->showNode();
+ for (auto* record = m_top.get(); record; record = record->next())
+ record->element().showNode();
}
#endif