String CSSStyleDeclaration::getPropertyPriority(const String& propertyName)
{
    int propID = cssPropertyID(propertyName);
    if (!propID)
        return String();
    return getPropertyPriority(propID) ? "important" : "";
}
Example #2
0
void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property)
{
    ASSERT(!m_iteratorCount);

    // Only add properties that have no !important counterpart present
    if (!getPropertyPriority(property.id()) || property.isImportant()) {
        removeProperty(property.id(), false);
        m_properties.append(property);
    }
}
void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty* const* properties, int numProperties)
{
    for (int i = 0; i < numProperties; ++i) {
        // Only add properties that have no !important counterpart present
        if (!getPropertyPriority(properties[i]->id()) || properties[i]->isImportant()) {
            removeProperty(properties[i]->id(), false);
            ASSERT(properties[i]);
            m_values.append(*properties[i]);
            if (properties[i]->value()->isVariableDependentValue())
                m_variableDependentValueCount++;
        }
    }
    // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
    // a notifyChanged argument to this function to follow the model of other functions in this class.
}
void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty* const* properties, int numProperties)
{
    ASSERT(!m_iteratorCount);
    
    m_properties.reserveCapacity(numProperties);
    
    for (int i = 0; i < numProperties; ++i) {
        // Only add properties that have no !important counterpart present
        if (!getPropertyPriority(properties[i]->id()) || properties[i]->isImportant()) {
            removeProperty(properties[i]->id(), false);
            ASSERT(properties[i]);
            m_properties.append(*properties[i]);
        }
    }
    // FIXME: This probably should have a call to setNeedsStyleRecalc() if something changed. We may also wish to add
    // a notifyChanged argument to this function to follow the model of other functions in this class.
}
CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CSSProperty* const * properties, int numProperties)
    : CSSStyleDeclaration(parent)
    , m_node(0)
    , m_strictParsing(!parent || parent->useStrictParsing())
#ifndef NDEBUG
    , m_iteratorCount(0)
#endif
{
    m_properties.reserveInitialCapacity(numProperties);
    HashSet<int> candidates;
    for (int i = 0; i < numProperties; ++i) {
        const CSSProperty *property = properties[i];
        ASSERT(property);
        if (candidates.contains(property->id()))
            removeProperty(properties[i]->id(), false);
        m_properties.append(*property);
        if (!getPropertyPriority(property->id()) && !property->isImportant())
            candidates.add(property->id());
    }
}