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 a2ce75170ba209a48736ae5d9649a8cf49ea315b..8d8dff7df82100494cac119e3f737d513ef0ac1a 100644 |
--- a/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp |
+++ b/third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp |
@@ -34,6 +34,8 @@ |
#include "core/dom/MutationRecord.h" |
#include "core/dom/StyleChangeReason.h" |
#include "core/dom/StyleEngine.h" |
+#include "core/dom/custom/CustomElement.h" |
+#include "core/dom/custom/CustomElementDefinition.h" |
#include "core/inspector/InspectorInstrumentation.h" |
#include "platform/RuntimeEnabledFeatures.h" |
@@ -41,6 +43,15 @@ namespace blink { |
namespace { |
+static CustomElementDefinition* definitionIfStyleChangedCallback(Element* element) |
+{ |
+ if (!element || element->getCustomElementState() != CustomElementState::Custom) |
dominicc (has gone to gerrit)
2016/07/22 01:14:01
I'm guessing if it is worth doing here, it is wort
|
+ return nullptr; |
+ CustomElementDefinition* definition = CustomElement::definitionForElement(*element); |
+ DCHECK(definition); |
+ return definition->hasStyleAttributeChangedCallback() ? definition : nullptr; |
+} |
+ |
class StyleAttributeMutationScope { |
WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope); |
STACK_ALLOCATED(); |
@@ -65,13 +76,14 @@ public: |
m_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr); |
if (m_mutationRecipients && m_mutationRecipients->isOldValueRequested()) |
dominicc (has gone to gerrit)
2016/07/22 01:14:01
I wonder if this is clearer by simply declaring
b
|
shouldReadOldValue = true; |
+ else if (definitionIfStyleChangedCallback(s_currentDecl->parentElement())) |
+ shouldReadOldValue = true; |
- AtomicString oldValue; |
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); |
} |
} |
@@ -82,10 +94,19 @@ public: |
if (s_scopeCount) |
return; |
- if (m_mutation && s_shouldDeliver) |
- m_mutationRecipients->enqueueMutationRecord(m_mutation); |
+ if (s_shouldDeliver) { |
+ if (m_mutation) |
+ m_mutationRecipients->enqueueMutationRecord(m_mutation); |
+ |
+ Element* element = s_currentDecl->parentElement(); |
+ if (CustomElementDefinition* definition = definitionIfStyleChangedCallback(element)) { |
+ definition->enqueueAttributeChangedCallback(element, |
+ HTMLNames::styleAttr, m_oldValue, |
+ element->getAttribute(HTMLNames::styleAttr)); |
+ } |
- s_shouldDeliver = false; |
+ s_shouldDeliver = false; |
+ } |
// We have to clear internal state before calling Inspector's code. |
AbstractPropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDecl; |
@@ -117,6 +138,7 @@ private: |
Member<MutationObserverInterestGroup> m_mutationRecipients; |
Member<MutationRecord> m_mutation; |
+ AtomicString m_oldValue; |
}; |
unsigned StyleAttributeMutationScope::s_scopeCount = 0; |