Modernize and streamline HTMLStackItem
[WebKit-https.git] / Source / WebCore / html / parser / HTMLFormattingElementList.cpp
index bd07ab1e0d6a32ac6e5f33e48061473ed4355e35..4ff6858f6faca498b600070cca2c2ffefae9da2b 100644 (file)
@@ -50,11 +50,11 @@ Element* HTMLFormattingElementList::closestElementInScopeWithName(const AtomicSt
     for (unsigned i = 1; i <= m_entries.size(); ++i) {
         const Entry& entry = m_entries[m_entries.size() - i];
         if (entry.isMarker())
-            return 0;
+            return nullptr;
         if (entry.stackItem()->matchesHTMLTag(targetName))
-            return entry.element();
+            return &entry.element();
     }
-    return 0;
+    return nullptr;
 }
 
 bool HTMLFormattingElementList::contains(Element* element)
@@ -82,9 +82,9 @@ HTMLFormattingElementList::Bookmark HTMLFormattingElementList::bookmarkFor(Eleme
 void HTMLFormattingElementList::swapTo(Element* oldElement, PassRefPtr<HTMLStackItem> newItem, const Bookmark& bookmark)
 {
     ASSERT(contains(oldElement));
-    ASSERT(!contains(newItem->element()));
+    ASSERT(!contains(&newItem->element()));
     if (!bookmark.hasBeenMoved()) {
-        ASSERT(bookmark.mark()->element() == oldElement);
+        ASSERT(&bookmark.mark()->element() == oldElement);
         bookmark.mark()->replaceElement(newItem);
         return;
     }
@@ -143,7 +143,7 @@ void HTMLFormattingElementList::tryToEnsureNoahsArkConditionQuickly(HTMLStackIte
             break;
 
         // Quickly reject obviously non-matching candidates.
-        HTMLStackItem* candidate = entry.stackItem().get();
+        HTMLStackItem* candidate = entry.stackItem();
         if (newItem->localName() != candidate->localName() || newItem->namespaceURI() != candidate->namespaceURI())
             continue;
         if (candidate->attributes().size() != newItemAttributeCount)
@@ -181,7 +181,7 @@ void HTMLFormattingElementList::ensureNoahsArkCondition(HTMLStackItem* newItem)
             ASSERT(newItem->attributes().size() == candidate->attributes().size());
             ASSERT(newItem->localName() == candidate->localName() && newItem->namespaceURI() == candidate->namespaceURI());
 
-            Attribute* candidateAttribute = candidate->getAttributeItem(attribute.name());
+            const Attribute* candidateAttribute = candidate->findAttribute(attribute.name());
             if (candidateAttribute && candidateAttribute->value() == attribute.value())
                 remainingCandidates.append(candidate);
         }
@@ -197,7 +197,7 @@ void HTMLFormattingElementList::ensureNoahsArkCondition(HTMLStackItem* newItem)
     // however, that we wil spin the loop more than once because of how the
     // formatting element list gets permuted.
     for (size_t i = kNoahsArkCapacity - 1; i < candidates.size(); ++i)
-        remove(candidates[i]->element());
+        remove(&candidates[i]->element());
 }
 
 #ifndef NDEBUG
@@ -209,7 +209,7 @@ void HTMLFormattingElementList::show()
         if (entry.isMarker())
             fprintf(stderr, "marker\n");
         else
-            entry.element()->showNode();
+            entry.element().showNode();
     }
 }