| Index: third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp b/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp
|
| index 3abfbc33959cc7cff27a2791e66d3d42d53c30b1..5cd3a039773c73553e14a2af40967536c6949e8a 100644
|
| --- a/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp
|
| +++ b/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp
|
| @@ -31,6 +31,9 @@
|
| #include "core/dom/MutationObserverInterestGroup.h"
|
| #include "core/dom/MutationRecord.h"
|
| #include "core/dom/StyleEngine.h"
|
| +#include "core/dom/custom/CustomElement.h"
|
| +#include "core/dom/custom/CustomElementDefinition.h"
|
| +#include "core/dom/custom/CustomElementLifecycleCallbacks.h"
|
| #include "core/inspector/InspectorInstrumentation.h"
|
| #include "platform/RuntimeEnabledFeatures.h"
|
|
|
| @@ -38,6 +41,11 @@ namespace blink {
|
|
|
| namespace {
|
|
|
| +static bool isCustomElementWithAttributeChangedCallback(Element* element)
|
| +{
|
| + return element->isUpgradedCustomElement() && element->customElementDefinition()->callbacks()->hasCallback(CustomElementLifecycleCallbacks::AttributeChangedCallback);
|
| +}
|
| +
|
| class StyleAttributeMutationScope {
|
| WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope);
|
| STACK_ALLOCATED();
|
| @@ -57,18 +65,17 @@ public:
|
| if (!s_currentDecl->parentElement())
|
| return;
|
|
|
| - bool shouldReadOldValue = false;
|
| -
|
| m_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr);
|
| - if (m_mutationRecipients && m_mutationRecipients->isOldValueRequested())
|
| - shouldReadOldValue = true;
|
|
|
| - AtomicString oldValue;
|
| + bool shouldReadOldValue =
|
| + (m_mutationRecipients && m_mutationRecipients->isOldValueRequested())
|
| + || isCustomElementWithAttributeChangedCallback(s_currentDecl->parentElement());
|
| +
|
| if (shouldReadOldValue)
|
| - oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::styleAttr);
|
| + m_oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::styleAttr);
|
|
|
| if (m_mutationRecipients) {
|
| - AtomicString requestedOldValue = m_mutationRecipients->isOldValueRequested() ? oldValue : nullAtom;
|
| + AtomicString requestedOldValue = m_mutationRecipients->isOldValueRequested() ? m_oldValue : nullAtom;
|
| m_mutation = MutationRecord::createAttributes(s_currentDecl->parentElement(), HTMLNames::styleAttr, requestedOldValue);
|
| }
|
| }
|
| @@ -79,9 +86,12 @@ public:
|
| if (s_scopeCount)
|
| return;
|
|
|
| - if (m_mutation && s_shouldDeliver)
|
| + if (s_shouldDeliver && m_mutation)
|
| m_mutationRecipients->enqueueMutationRecord(m_mutation);
|
|
|
| + if (s_shouldDeliver && isCustomElementWithAttributeChangedCallback(s_currentDecl->parentElement()))
|
| + CustomElement::attributeDidChange(s_currentDecl->parentElement(), HTMLNames::styleAttr.localName(), m_oldValue, s_currentDecl->parentElement()->getAttribute(HTMLNames::styleAttr));
|
| +
|
| s_shouldDeliver = false;
|
|
|
| // We have to clear internal state before calling Inspector's code.
|
| @@ -114,6 +124,7 @@ private:
|
|
|
| OwnPtrWillBeMember<MutationObserverInterestGroup> m_mutationRecipients;
|
| RefPtrWillBeMember<MutationRecord> m_mutation;
|
| + AtomicString m_oldValue;
|
| };
|
|
|
| unsigned StyleAttributeMutationScope::s_scopeCount = 0;
|
|
|