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/HTMLLIElement.cpp | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'Source/WebCore/html/HTMLLIElement.cpp') diff --git a/Source/WebCore/html/HTMLLIElement.cpp b/Source/WebCore/html/HTMLLIElement.cpp index ab2df915c..e40dde949 100644 --- a/Source/WebCore/html/HTMLLIElement.cpp +++ b/Source/WebCore/html/HTMLLIElement.cpp @@ -26,7 +26,10 @@ #include "Attribute.h" #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" +#include "ElementAncestorIterator.h" #include "HTMLNames.h" +#include "HTMLOListElement.h" +#include "HTMLUListElement.h" #include "RenderListItem.h" namespace WebCore { @@ -40,14 +43,14 @@ HTMLLIElement::HTMLLIElement(const QualifiedName& tagName, Document& document) setHasCustomStyleResolveCallbacks(); } -PassRefPtr HTMLLIElement::create(Document& document) +Ref HTMLLIElement::create(Document& document) { - return adoptRef(new HTMLLIElement(liTag, document)); + return adoptRef(*new HTMLLIElement(liTag, document)); } -PassRefPtr HTMLLIElement::create(const QualifiedName& tagName, Document& document) +Ref HTMLLIElement::create(const QualifiedName& tagName, Document& document) { - return adoptRef(new HTMLLIElement(tagName, document)); + return adoptRef(*new HTMLLIElement(tagName, document)); } bool HTMLLIElement::isPresentationAttribute(const QualifiedName& name) const @@ -87,39 +90,37 @@ void HTMLLIElement::parseAttribute(const QualifiedName& name, const AtomicString void HTMLLIElement::didAttachRenderers() { - if (!renderer() || !renderer()->isListItem()) + if (!is(renderer())) return; - RenderListItem* listItemRenderer = toRenderListItem(renderer()); - - // Find the enclosing list node. - Element* listNode = 0; - Element* current = this; - while (!listNode) { - current = current->parentElement(); - if (!current) + auto& listItemRenderer = downcast(*renderer()); + + // Check if there is an enclosing list. + bool isInList = false; + for (auto& ancestor : ancestorsOfType(*this)) { + if (is(ancestor) || is(ancestor)) { + isInList = true; break; - if (current->hasTagName(ulTag) || current->hasTagName(olTag)) - listNode = current; + } } // If we are not in a list, tell the renderer so it can position us inside. // We don't want to change our style to say "inside" since that would affect nested nodes. - if (!listNode) - listItemRenderer->setNotInList(true); + if (!isInList) + listItemRenderer.setNotInList(true); - parseValue(fastGetAttribute(valueAttr)); + parseValue(attributeWithoutSynchronization(valueAttr)); } inline void HTMLLIElement::parseValue(const AtomicString& value) { - ASSERT(renderer() && renderer()->isListItem()); + ASSERT(renderer()); bool valueOK; int requestedValue = value.toInt(&valueOK); if (valueOK) - toRenderListItem(renderer())->setExplicitValue(requestedValue); + downcast(*renderer()).setExplicitValue(requestedValue); else - toRenderListItem(renderer())->clearExplicitValue(); + downcast(*renderer()).clearExplicitValue(); } } -- cgit v1.2.1