Beispiel #1
0
bool HTMLElementStack::ElementRecord::isAbove(ElementRecord* other) const {
  for (ElementRecord* below = next(); below; below = below->next()) {
    if (below == other)
      return true;
  }
  return false;
}
HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString& tagName) const
{
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        if (pos->stackItem()->matchesHTMLTag(tagName))
            return pos;
    }
    return nullptr;
}
HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const
{
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        if (pos->node() == element)
            return pos;
    }
    return nullptr;
}
Beispiel #4
0
HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString& tagName) const
{
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        if (pos->stackItem()->hasLocalName(tagName))
            return pos;
    }
    return 0;
}
Beispiel #5
0
bool HTMLElementStack::inScope(Element* targetElement) const {
  for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
    HTMLStackItem* item = pos->stackItem();
    if (item->node() == targetElement)
      return true;
    if (isScopeMarker(item))
      return false;
  }
  ASSERT_NOT_REACHED();  // <html> is always on the stack and is a scope marker.
  return false;
}
Beispiel #6
0
bool HTMLElementStack::hasNumberedHeaderElementInScope() const {
  for (ElementRecord* record = m_top.get(); record; record = record->next()) {
    HTMLStackItem* item = record->stackItem();
    if (item->isNumberedHeaderElement())
      return true;
    if (isScopeMarker(item))
      return false;
  }
  ASSERT_NOT_REACHED();  // <html> is always on the stack and is a scope marker.
  return false;
}
HTMLElementStack::ElementRecord* HTMLElementStack::furthestBlockForFormattingElement(Element* formattingElement) const
{
    ElementRecord* furthestBlock = 0;
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        if (pos->element() == formattingElement)
            return furthestBlock;
        if (pos->stackItem()->isSpecialNode())
            furthestBlock = pos;
    }
    ASSERT_NOT_REACHED();
    return nullptr;
}
bool HTMLElementStack::inScope(Element* targetElement) const
{
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        Element* element = pos->element();
        if (element == targetElement)
            return true;
        if (isScopeMarker(element))
            return false;
    }
    ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker.
    return false;
}
bool HTMLElementStack::hasOnlyHTMLElementsInScope() const
{
    for (ElementRecord* record = m_top.get(); record; record = record->next()) {
        Element* element = record->element();
        if (element->namespaceURI() != xhtmlNamespaceURI)
            return false;
        if (isScopeMarker(element))
            return true;
    }
    ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker.
    return true;
}
Beispiel #10
0
bool HTMLElementStack::hasNumberedHeaderElementInScope() const
{
    for (ElementRecord* record = m_top.get(); record; record = record->next()) {
        ContainerNode* node = record->node();
        if (isNumberedHeaderElement(node))
            return true;
        if (isScopeMarker(node))
            return false;
    }
    ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker.
    return false;
}
Beispiel #11
0
void HTMLElementStack::removeNonTopCommon(Element* element)
{
    ASSERT(top() != element);
    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
        if (pos->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--;
            return;
        }
    }
    ASSERT_NOT_REACHED();
}
void HTMLElementStack::insertAbove(PassRefPtrWillBeRawPtr<HTMLStackItem> item, ElementRecord* recordBelow)
{
    ASSERT(item);
    ASSERT(recordBelow);
    ASSERT(m_top);
    ASSERT(!item->hasTagName(htmlTag));
    ASSERT(!item->hasTagName(headTag));
    ASSERT(!item->hasTagName(bodyTag));
    ASSERT(m_rootNode);
    if (recordBelow == m_top) {
        push(item);
        return;
    }

    for (ElementRecord* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove->next()) {
        if (recordAbove->next() != recordBelow)
            continue;

        m_stackDepth++;
        recordAbove->setNext(adoptPtrWillBeNoop(new ElementRecord(item, recordAbove->releaseNext())));
        recordAbove->next()->element()->beginParsingChildren();
        return;
    }
    ASSERT_NOT_REACHED();
}
void HTMLElementStack::insertAbove(PassRefPtr<Element> element, ElementRecord* recordBelow)
{
    ASSERT(element);
    ASSERT(recordBelow);
    ASSERT(m_top);
    ASSERT(!element->hasTagName(HTMLNames::htmlTag));
    ASSERT(!element->hasTagName(HTMLNames::headTag));
    ASSERT(!element->hasTagName(HTMLNames::bodyTag));
    ASSERT(m_htmlElement);
    if (recordBelow == m_top) {
        push(element);
        return;
    }

    for (ElementRecord* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove->next()) {
        if (recordAbove->next() != recordBelow)
            continue;

        recordAbove->setNext(adoptPtr(new ElementRecord(element, recordAbove->releaseNext())));
        recordAbove->next()->element()->beginParsingChildren();
        return;
    }
    ASSERT_NOT_REACHED();
}
void HTMLElementStack::show()
{
    for (ElementRecord* record = m_top.get(); record; record = record->next())
        record->element()->showNode();
}
Beispiel #15
0
void HTMLElementStack::show() {
  for (ElementRecord* record = m_top.get(); record; record = record->next())
    LOG(INFO) << *record->element();
}