Beispiel #1
0
void ElementData::destroy()
{
    if (m_isUnique)
        delete toUniqueElementData(this);
    else
        delete toShareableElementData(this);
}
Beispiel #2
0
void ElementData::finalizeGarbageCollectedObject()
{
    if (m_isUnique)
        toUniqueElementData(this)->~UniqueElementData();
    else
        toShareableElementData(this)->~ShareableElementData();
}
Beispiel #3
0
void Element::cloneAttributesFromElement(const Element& other)
{
    other.synchronizeAllAttributes();
    if (!other.m_elementData) {
        m_elementData.clear();
        return;
    }

    const AtomicString& oldID = getIdAttribute();
    const AtomicString& newID = other.getIdAttribute();

    if (!oldID.isNull() || !newID.isNull())
        updateId(oldID, newID);

    // If 'other' has a mutable ElementData, convert it to an immutable one so we can share it between both elements.
    // We can only do this if there are no presentation attributes and sharing the data won't result in different case sensitivity of class or id.
    if (other.m_elementData->isUnique())
        const_cast<Element&>(other).m_elementData = toUniqueElementData(other.m_elementData)->makeShareableCopy();

    if (!other.m_elementData->isUnique())
        m_elementData = other.m_elementData;
    else
        m_elementData = other.m_elementData->makeUniqueCopy();

    AttributeCollection attributes = m_elementData->attributes();
    AttributeCollection::iterator end = attributes.end();
    for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
        attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedByCloning);
}
Beispiel #4
0
void ElementData::trace(Visitor* visitor)
{
    if (m_isUnique)
        toUniqueElementData(this)->traceAfterDispatch(visitor);
    else
        toShareableElementData(this)->traceAfterDispatch(visitor);
}
Beispiel #5
0
PassRefPtr<UniqueElementData> ElementData::makeUniqueCopy() const
{
    if (isUnique())
        return adoptRef(new UniqueElementData(toUniqueElementData(*this)));
    return adoptRef(new UniqueElementData(toShareableElementData(*this)));
}