ExceptionOr<void> PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority)
{
    StyleAttributeMutationScope mutationScope(this);
    
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (isCustomPropertyName(propertyName))
        propertyID = CSSPropertyCustom;
    if (!propertyID)
        return { };

    if (!willMutate())
        return { };

    bool important = equalIgnoringASCIICase(priority, "important");
    if (!important && !priority.isEmpty())
        return { };

    bool changed;
    if (propertyID == CSSPropertyCustom)
        changed = m_propertySet->setCustomProperty(propertyName, value, important, cssParserContext());
    else
        changed = m_propertySet->setProperty(propertyID, value, important, cssParserContext());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed) {
        // CSS DOM requires raising SYNTAX_ERR of parsing failed, but this is too dangerous for compatibility,
        // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
        mutationScope.enqueueMutationRecord();
    }

    return { };
}
void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
{
#if ENABLE(MUTATION_OBSERVERS)
    StyleAttributeMutationScope mutationScope(this);
#endif
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (!propertyID)
        return;

    bool important = priority.find("important", 0, false) != notFound;

    willMutate();

    ec = 0;
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed) {
        // CSS DOM requires raising SYNTAX_ERR of parsing failed, but this is too dangerous for compatibility,
        // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
#if ENABLE(MUTATION_OBSERVERS)
        mutationScope.enqueueMutationRecord();
#endif
    }
}
void PropertySetCSSStyleDeclaration::clearVariables(ExceptionState&)
{
    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
    StyleAttributeMutationScope mutationScope(this);
    willMutate();
    bool changed = m_propertySet->clearVariables();
    didMutate(changed ? PropertyChanged : NoChanges);
    if (changed)
        mutationScope.enqueueMutationRecord();
}
void PropertySetCSSStyleDeclaration::setVariableValue(const AtomicString& name, const String& value, ExceptionState&)
{
    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
    StyleAttributeMutationScope mutationScope(this);
    willMutate();
    bool changed = m_propertySet->setVariableValue(name, value);
    didMutate(changed ? PropertyChanged : NoChanges);
    if (changed)
        mutationScope.enqueueMutationRecord();
}
bool PropertySetCSSStyleDeclaration::removeVariable(const AtomicString& name)
{
    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
    StyleAttributeMutationScope mutationScope(this);
    willMutate();
    bool changed = m_propertySet->removeVariable(name);
    didMutate(changed ? PropertyChanged : NoChanges);
    if (changed)
        mutationScope.enqueueMutationRecord();
    return changed;
}
Exemplo n.º 6
0
void AbstractPropertySetCSSStyleDeclaration::setCSSText(const String& text,
                                                        ExceptionState&) {
  StyleAttributeMutationScope mutationScope(this);
  willMutate();

  propertySet().parseDeclarationList(text, contextStyleSheet());

  didMutate(PropertyChanged);

  mutationScope.enqueueMutationRecord();
}
void AbstractPropertySetCSSStyleDeclaration::setCSSText(const String& text, ExceptionState& exceptionState)
{
    StyleAttributeMutationScope mutationScope(this);
    willMutate();

    // FIXME: Detect syntax errors and set exceptionState.
    propertySet().parseDeclaration(text, contextStyleSheet());

    didMutate(PropertyChanged);

    mutationScope.enqueueMutationRecord();
}
void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionState&)
{
    StyleAttributeMutationScope mutationScope(this);
    willMutate();

    bool changed = propertySet().setProperty(propertyID, value, important, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
}
void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode&)
{
    StyleAttributeMutationScope mutationScope(this);
    if (!willMutate())
        return;

    bool changed = m_propertySet->parseDeclaration(text, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    mutationScope.enqueueMutationRecord();    
}
ExceptionOr<void> PropertySetCSSStyleDeclaration::setCssText(const String& text)
{
    StyleAttributeMutationScope mutationScope(this);
    if (!willMutate())
        return { };

    bool changed = m_propertySet->parseDeclaration(text, cssParserContext());

    didMutate(changed ? PropertyChanged : NoChanges);

    mutationScope.enqueueMutationRecord();
    return { };
}
Exemplo n.º 11
0
void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
{
    StyleAttributeMutationScope mutationScope(this);
    willMutate();

    ec = 0;
    // FIXME: Detect syntax errors and set ec.
    m_propertySet->parseDeclaration(text, contextStyleSheet());

    didMutate(PropertyChanged);

    mutationScope.enqueueMutationRecord();    
}
ExceptionOr<bool> PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important)
{ 
    StyleAttributeMutationScope mutationScope(this);
    if (!willMutate())
        return false;

    bool changed = m_propertySet->setProperty(propertyID, value, important, cssParserContext());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
    return changed;
}
void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec)
{ 
    StyleAttributeMutationScope mutationScope(this);
    if (!willMutate())
        return;

    ec = 0;
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
}
String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionState& exceptionState)
{
    StyleAttributeMutationScope mutationScope(this);
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (!propertyID)
        return String();

    willMutate();

    String result;
    bool changed = propertySet().removeProperty(propertyID, &result);

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
    return result;
}
Exemplo n.º 15
0
void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec)
{ 
#if ENABLE(MUTATION_OBSERVERS)
    StyleAttributeMutationScope mutationScope(this);
#endif
    willMutate();

    ec = 0;
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed) {
#if ENABLE(MUTATION_OBSERVERS)
        mutationScope.enqueueMutationRecord();
#endif
    }
}
String PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
{
    StyleAttributeMutationScope mutationScope(this);
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (!propertyID)
        return String();

    if (!willMutate())
        return String();

    ec = 0;
    String result;
    bool changed = m_propertySet->removeProperty(propertyID, &result);

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
    return result;
}
ExceptionOr<String> PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName)
{
    StyleAttributeMutationScope mutationScope(this);
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (isCustomPropertyName(propertyName))
        propertyID = CSSPropertyCustom;
    if (!propertyID)
        return String();

    if (!willMutate())
        return String();

    String result;
    bool changed = propertyID != CSSPropertyCustom ? m_propertySet->removeProperty(propertyID, &result) : m_propertySet->removeCustomProperty(propertyName, &result);

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed)
        mutationScope.enqueueMutationRecord();
    return WTFMove(result);
}
Exemplo n.º 18
0
void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionState& exceptionState)
{
    StyleAttributeMutationScope mutationScope(this);
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (!propertyID)
        return;

    bool important = priority.find("important", 0, false) != kNotFound;

    willMutate();

    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());

    didMutate(changed ? PropertyChanged : NoChanges);

    if (changed) {
        // CSS DOM requires raising SyntaxError of parsing failed, but this is too dangerous for compatibility,
        // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
        mutationScope.enqueueMutationRecord();
    }
}
Exemplo n.º 19
0
DISABLE_CFI_PERF
void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(
    CSSPropertyID unresolvedProperty,
    const String& customPropertyName,
    const String& value,
    bool important,
    ExceptionState&) {
  StyleAttributeMutationScope mutationScope(this);
  willMutate();

  bool didChange = false;
  if (unresolvedProperty == CSSPropertyVariable) {
    bool isAnimationTainted = isKeyframeStyle();
    didChange =
        propertySet()
            .setProperty(AtomicString(customPropertyName), value, important,
                         contextStyleSheet(), isAnimationTainted)
            .didChange;
  } else {
    didChange = propertySet()
                    .setProperty(unresolvedProperty, value, important,
                                 contextStyleSheet())
                    .didChange;
  }

  didMutate(didChange ? PropertyChanged : NoChanges);

  if (!didChange)
    return;

  Element* parent = parentElement();
  if (parent)
    parent->document().styleEngine().attributeChangedForElement(
        HTMLNames::styleAttr, *parent);
  mutationScope.enqueueMutationRecord();
}