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
    }
}
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 CSSStyleSheet::didMutateRules()
{
    ASSERT(m_contents->isMutable());
    ASSERT(m_contents->clientSize() <= 1);

    didMutate(PartialRuleUpdate);
}
void CSSStyleSheet::clearOwnerNode()
{
    didMutate(EntireStyleSheetUpdate);
    if (m_ownerNode)
        m_contents->unregisterClient(this);
    m_ownerNode = nullptr;
}
Esempio n. 5
0
void CSSStyleSheet::setDisabled(bool disabled) {
  if (disabled == m_isDisabled)
    return;
  m_isDisabled = disabled;

  didMutate();
}
void CSSStyleSheet::didMutateRules()
{
    ASSERT(m_contents->isMutable());
    ASSERT(m_contents->hasOneClient());

    didMutate();
}
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();
}
void PropertySetCSSStyleDeclaration::clearVariables(ExceptionState&)
{
    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
    StyleAttributeMutationScope mutationScope(this);
    willMutate();
    bool changed = m_propertySet->clearVariables();
    didMutate(changed ? PropertyChanged : NoChanges);
    if (changed)
        mutationScope.enqueueMutationRecord();
}
Esempio n. 9
0
void AbstractPropertySetCSSStyleDeclaration::setCSSText(const String& text,
                                                        ExceptionState&) {
  StyleAttributeMutationScope mutationScope(this);
  willMutate();

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

  didMutate(PropertyChanged);

  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;
}
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 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 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();    
}
Esempio n. 14
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<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 { };
}
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;
}
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);
}
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();
    }
}
Esempio n. 23
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();
}
Esempio n. 24
0
void CSSStyleSheet::didMutateRuleFromCSSStyleDeclaration()
{
    ASSERT(m_contents->isMutable());
    ASSERT(m_contents->hasOneClient());
    didMutate();
}
Esempio n. 25
0
void CSSStyleSheet::didMutateRules() {
  DCHECK(m_contents->isMutable());
  DCHECK_LE(m_contents->clientSize(), 1u);

  didMutate(PartialRuleUpdate);
}