Example #1
0
void RenderListItem::updateListMarkerNumbers()
{
    // If distribution recalc is needed, updateListMarkerNumber will be re-invoked
    // after distribution is calculated.
    if (node()->document().childNeedsDistributionRecalc())
        return;

    Node* listNode = enclosingList(this);
    ASSERT(listNode);

    bool isListReversed = false;
    HTMLOListElement* oListElement = isHTMLOListElement(listNode) ? toHTMLOListElement(listNode) : 0;
    if (oListElement) {
        oListElement->itemCountChanged();
        isListReversed = oListElement->isReversed();
    }

    // FIXME: The n^2 protection below doesn't help if the elements were inserted after the
    // the list had already been displayed.

    // Avoid an O(n^2) walk over the children below when they're all known to be attaching.
    if (listNode->needsAttach())
        return;

    for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, this); item; item = previousOrNextItem(isListReversed, listNode, item)) {
        if (!item->m_isValueUpToDate) {
            // If an item has been marked for update before, we can safely
            // assume that all the following ones have too.
            // This gives us the opportunity to stop here and avoid
            // marking the same nodes again.
            break;
        }
        item->updateValue();
    }
}
Example #2
0
void RenderListItem::updateItemValuesForOrderedList(const HTMLOListElement* listNode)
{
    ASSERT(listNode);

    for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, listItem))
        listItem->updateValue();
}
void RenderListItem::updateListMarkerNumbers()
{
    Node* listNode = enclosingList(this);
    ASSERT(listNode && listNode->renderer());
    if (!listNode || !listNode->renderer())
        return;

    RenderObject* list = listNode->renderer();
    RenderObject* child = nextInPreOrder(list);
    while (child) {
        if (child->node() && isList(child->node())) {
            // We've found a nested, independent list: nothing to do here.
            child = child->nextInPreOrderAfterChildren(list);
            continue;
        }

        if (child->isListItem()) {
            RenderListItem* item = toRenderListItem(child);

            if (!item->m_isValueUpToDate) {
                // If an item has been marked for update before, we can safely
                // assume that all the following ones have too.
                // This gives us the opportunity to stop here and avoid
                // marking the same nodes again.
                break;
            }

            item->updateValue();
        }

        child = child->nextInPreOrder(list);
    }
}
void RenderListItem::updateListMarkerNumbers()
{
    Node* listNode = enclosingList(this);
    // The list node can be the shadow root which has no renderer.
    ASSERT(listNode);
    if (!listNode)
        return;

    bool isListReversed = false;
    HTMLOListElement* oListElement = (listNode && listNode->hasTagName(olTag)) ? toHTMLOListElement(listNode) : 0;
    if (oListElement) {
        oListElement->itemCountChanged();
        isListReversed = oListElement->isReversed();
    }
    for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, this); item; item = previousOrNextItem(isListReversed, listNode, item)) {
        if (!item->m_isValueUpToDate) {
            // If an item has been marked for update before, we can safely
            // assume that all the following ones have too.
            // This gives us the opportunity to stop here and avoid
            // marking the same nodes again.
            break;
        }
        item->updateValue();
    }
}
// Returns the text associated with a list marker if this node is contained within a list item.
String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, const VisiblePosition& visiblePositionStart) const
{
    // If the range does not contain the start of the line, the list marker text should not be included.
    if (!isStartOfLine(visiblePositionStart))
        return String();

    RenderListItem* listItem = renderListItemContainerForNode(node);
    if (!listItem)
        return String();
        
    // If this is in a list item, we need to manually add the text for the list marker 
    // because a RenderListMarker does not have a Node equivalent and thus does not appear
    // when iterating text.
    const String& markerText = listItem->markerText();
    if (markerText.isEmpty())
        return String();
                
    // Append text, plus the period that follows the text.
    // FIXME: Not all list marker styles are followed by a period, but this
    // sounds much better when there is a synthesized pause because of a period.
    Vector<UChar> resultVector;
    resultVector.append(markerText.characters(), markerText.length());
    resultVector.append('.');
    resultVector.append(' ');
    
    return String::adopt(resultVector);
}
Example #6
0
void HTMLLIElement::attach()
{
    assert(!attached());

    HTMLElement::attach();

    if (renderer() && renderer()->style()->display() == LIST_ITEM) {
        RenderListItem *render = static_cast<RenderListItem*>(renderer());
        
        // Find the enclosing list node.
        Node* listNode = 0;
        Node* n = this;
        while (!listNode && (n = n->parentNode())) {
            if (n->hasTagName(ulTag) || n->hasTagName(olTag))
                listNode = n;
        }
        
        // 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)
            render->setNotInList(true);

        // If we had a value attr.
        if (m_isValued)
            render->setValue(m_requestedValue);
    }
}
Example #7
0
void HTMLLIElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == valueAttr) {
        m_isValued = true;
        m_requestedValue = !attr->isNull() ? attr->value().toInt() : 0;

        if (renderer() && renderer()->isListItem()) {
            RenderListItem* list = static_cast<RenderListItem*>(renderer());
            // ### work out what to do when attribute removed - use default of some sort?
            list->setValue(m_requestedValue);
        }
    } else if (attr->name() == typeAttr) {
        if (attr->value() == "a")
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ALPHA);
        else if (attr->value() == "A")
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ALPHA);
        else if (attr->value() == "i")
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ROMAN);
        else if (attr->value() == "I")
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ROMAN);
        else if (attr->value() == "1")
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_DECIMAL);
        else
            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, attr->value());
    } else
        HTMLElement::parseMappedAttribute(attr);
}
Example #8
0
void RenderListItem::updateListMarkerNumbers()
{
    // If distribution recalc is needed, updateListMarkerNumber will be re-invoked
    // after distribution is calculated.
    if (node()->document().childNeedsDistributionRecalc())
        return;

    Node* listNode = enclosingList(this);
    // The list node can be the shadow root which has no renderer.
    ASSERT(listNode);
    if (!listNode)
        return;

    bool isListReversed = false;
    HTMLOListElement* oListElement = isHTMLOListElement(listNode) ? toHTMLOListElement(listNode) : 0;
    if (oListElement) {
        oListElement->itemCountChanged();
        isListReversed = oListElement->isReversed();
    }
    for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, this); item; item = previousOrNextItem(isListReversed, listNode, item)) {
        if (!item->m_isValueUpToDate) {
            // If an item has been marked for update before, we can safely
            // assume that all the following ones have too.
            // This gives us the opportunity to stop here and avoid
            // marking the same nodes again.
            break;
        }
        item->updateValue();
    }
}
Example #9
0
void RenderListItem::explicitValueChanged()
{
    if (m_marker)
        m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
    Node* listNode = enclosingList(this);
    for (RenderListItem* item = this; item; item = nextListItem(listNode, item))
        item->updateValue();
}
Example #10
0
void RenderListItem::explicitValueChanged()
{
    if (m_marker)
        m_marker->setNeedsLayoutAndPrefWidthsRecalc();
    Node* listNode = enclosingList(this);
    RenderObject* listRenderer = 0;
    if (listNode)
        listRenderer = listNode->renderer();
    for (RenderListItem* item = this; item; item = nextListItem(listRenderer, item))
        item->updateValue();
}
Example #11
0
void RenderListItem::explicitValueChanged()
{
    if (m_marker)
        m_marker->setNeedsLayoutAndPrefWidthsRecalc();

    updateValue();
    Element* listNode = enclosingList(*this);
    if (!listNode)
        return;
    for (RenderListItem* item = nextListItem(*listNode, *this); item; item = nextListItem(*listNode, *item))
        item->updateValue();
}
Example #12
0
// Returns the text associated with a list marker if this node is contained within a list item.
String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, const VisiblePosition& visiblePositionStart) const
{
    // If the range does not contain the start of the line, the list marker text should not be included.
    if (!isStartOfLine(visiblePositionStart))
        return String();

    RenderListItem* listItem = renderListItemContainerForNode(node);
    if (!listItem)
        return String();
        
    // If this is in a list item, we need to manually add the text for the list marker 
    // because a RenderListMarker does not have a Node equivalent and thus does not appear
    // when iterating text.
    return listItem->markerTextWithSuffix();
}
Example #13
0
void RenderListItem::explicitValueChanged()
{
    if (m_marker)
        m_marker->setNeedsLayoutAndPrefWidthsRecalc();
    Node* listNode = enclosingList(this);
    RenderObject* listRenderer = 0;
    if (listNode)
        listRenderer = listNode->renderer();
    for (RenderObject* renderer = this; renderer; renderer = renderer->nextInPreOrder(listRenderer))
        if (renderer->isListItem()) {
            RenderListItem* item = toRenderListItem(renderer);
            if (!item->m_hasExplicitValue) {
                item->setIsValueUpToDate(false);
                if (RenderListMarker* marker = item->m_marker)
                    marker->setNeedsLayoutAndPrefWidthsRecalc();
            }
        }
}
Example #14
0
void RenderListItem::calcValue()
{
    if (m_predefVal != -1)
        m_value = m_predefVal;
    else {
        Node* list = enclosingList(node());
        RenderListItem* item = previousListItem(list, this);
        if (item) {
            // FIXME: This recurses to a possible depth of the length of the list.
            // That's not good -- we need to change this to an iterative algorithm.
            if (item->value() == -1)
                item->calcValue();
            m_value = item->value() + 1;
        } else if (list && list->hasTagName(olTag))
            m_value = static_cast<HTMLOListElement*>(list)->start();
        else
            m_value = 1;
    }
}
Example #15
0
void RenderListItem::updateListMarkerNumbers()
{
    Element* listNode = enclosingList(*this);
    // The list node can be the shadow root which has no renderer.
    if (!listNode)
        return;

    bool isListReversed = false;
    if (is<HTMLOListElement>(*listNode)) {
        HTMLOListElement& oListElement = downcast<HTMLOListElement>(*listNode);
        oListElement.itemCountChanged();
        isListReversed = oListElement.isReversed();
    }
    for (RenderListItem* item = previousOrNextItem(isListReversed, *listNode, *this); item; item = previousOrNextItem(isListReversed, *listNode, *item)) {
        if (!item->m_isValueUpToDate) {
            // If an item has been marked for update before, we can safely
            // assume that all the following ones have too.
            // This gives us the opportunity to stop here and avoid
            // marking the same nodes again.
            break;
        }
        item->updateValue();
    }
}
Example #16
0
void HTMLOListElement::updateItemValues()
{
    for (RenderListItem* listItem = RenderListItem::nextListItem(renderer()); listItem; listItem = RenderListItem::nextListItem(renderer(), listItem))
        listItem->updateValue();
}