OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #include "bindings/core/v8/ExceptionState.h" | 25 #include "bindings/core/v8/ExceptionState.h" |
26 #include "core/HTMLNames.h" | 26 #include "core/HTMLNames.h" |
27 #include "core/css/CSSKeyframesRule.h" | 27 #include "core/css/CSSKeyframesRule.h" |
28 #include "core/css/CSSStyleSheet.h" | 28 #include "core/css/CSSStyleSheet.h" |
29 #include "core/css/StylePropertySet.h" | 29 #include "core/css/StylePropertySet.h" |
30 #include "core/dom/Element.h" | 30 #include "core/dom/Element.h" |
31 #include "core/dom/MutationObserverInterestGroup.h" | 31 #include "core/dom/MutationObserverInterestGroup.h" |
32 #include "core/dom/MutationRecord.h" | 32 #include "core/dom/MutationRecord.h" |
33 #include "core/dom/StyleEngine.h" | 33 #include "core/dom/StyleEngine.h" |
| 34 #include "core/dom/custom/CustomElement.h" |
| 35 #include "core/dom/custom/CustomElementDefinition.h" |
| 36 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" |
34 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
35 #include "platform/RuntimeEnabledFeatures.h" | 38 #include "platform/RuntimeEnabledFeatures.h" |
36 | 39 |
37 namespace blink { | 40 namespace blink { |
38 | 41 |
39 namespace { | 42 namespace { |
40 | 43 |
| 44 static bool isCustomElementWithAttributeChangedCallback(Element* element) |
| 45 { |
| 46 return element->isUpgradedCustomElement() && element->customElementDefinitio
n()->callbacks()->hasCallback(CustomElementLifecycleCallbacks::AttributeChangedC
allback); |
| 47 } |
| 48 |
41 class StyleAttributeMutationScope { | 49 class StyleAttributeMutationScope { |
42 WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope); | 50 WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope); |
43 STACK_ALLOCATED(); | 51 STACK_ALLOCATED(); |
44 public: | 52 public: |
45 StyleAttributeMutationScope(AbstractPropertySetCSSStyleDeclaration* decl) | 53 StyleAttributeMutationScope(AbstractPropertySetCSSStyleDeclaration* decl) |
46 { | 54 { |
47 ++s_scopeCount; | 55 ++s_scopeCount; |
48 | 56 |
49 if (s_scopeCount != 1) { | 57 if (s_scopeCount != 1) { |
50 ASSERT(s_currentDecl == decl); | 58 ASSERT(s_currentDecl == decl); |
51 return; | 59 return; |
52 } | 60 } |
53 | 61 |
54 ASSERT(!s_currentDecl); | 62 ASSERT(!s_currentDecl); |
55 s_currentDecl = decl; | 63 s_currentDecl = decl; |
56 | 64 |
57 if (!s_currentDecl->parentElement()) | 65 if (!s_currentDecl->parentElement()) |
58 return; | 66 return; |
59 | 67 |
60 bool shouldReadOldValue = false; | 68 m_mutationRecipients = MutationObserverInterestGroup::createForAttribute
sMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr); |
61 | 69 |
62 m_mutationRecipients = MutationObserverInterestGroup::createForAttribute
sMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr); | 70 bool shouldReadOldValue = |
63 if (m_mutationRecipients && m_mutationRecipients->isOldValueRequested()) | 71 (m_mutationRecipients && m_mutationRecipients->isOldValueRequested()
) |
64 shouldReadOldValue = true; | 72 || isCustomElementWithAttributeChangedCallback(s_currentDecl->parent
Element()); |
65 | 73 |
66 AtomicString oldValue; | |
67 if (shouldReadOldValue) | 74 if (shouldReadOldValue) |
68 oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::s
tyleAttr); | 75 m_oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames:
:styleAttr); |
69 | 76 |
70 if (m_mutationRecipients) { | 77 if (m_mutationRecipients) { |
71 AtomicString requestedOldValue = m_mutationRecipients->isOldValueReq
uested() ? oldValue : nullAtom; | 78 AtomicString requestedOldValue = m_mutationRecipients->isOldValueReq
uested() ? m_oldValue : nullAtom; |
72 m_mutation = MutationRecord::createAttributes(s_currentDecl->parentE
lement(), HTMLNames::styleAttr, requestedOldValue); | 79 m_mutation = MutationRecord::createAttributes(s_currentDecl->parentE
lement(), HTMLNames::styleAttr, requestedOldValue); |
73 } | 80 } |
74 } | 81 } |
75 | 82 |
76 ~StyleAttributeMutationScope() | 83 ~StyleAttributeMutationScope() |
77 { | 84 { |
78 --s_scopeCount; | 85 --s_scopeCount; |
79 if (s_scopeCount) | 86 if (s_scopeCount) |
80 return; | 87 return; |
81 | 88 |
82 if (m_mutation && s_shouldDeliver) | 89 if (s_shouldDeliver && m_mutation) |
83 m_mutationRecipients->enqueueMutationRecord(m_mutation); | 90 m_mutationRecipients->enqueueMutationRecord(m_mutation); |
84 | 91 |
| 92 if (s_shouldDeliver && isCustomElementWithAttributeChangedCallback(s_cur
rentDecl->parentElement())) |
| 93 CustomElement::attributeDidChange(s_currentDecl->parentElement(), HT
MLNames::styleAttr.localName(), m_oldValue, s_currentDecl->parentElement()->getA
ttribute(HTMLNames::styleAttr)); |
| 94 |
85 s_shouldDeliver = false; | 95 s_shouldDeliver = false; |
86 | 96 |
87 // We have to clear internal state before calling Inspector's code. | 97 // We have to clear internal state before calling Inspector's code. |
88 AbstractPropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDe
cl; | 98 AbstractPropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDe
cl; |
89 s_currentDecl = 0; | 99 s_currentDecl = 0; |
90 | 100 |
91 if (!s_shouldNotifyInspector) | 101 if (!s_shouldNotifyInspector) |
92 return; | 102 return; |
93 | 103 |
94 s_shouldNotifyInspector = false; | 104 s_shouldNotifyInspector = false; |
(...skipping 12 matching lines...) Expand all Loading... |
107 } | 117 } |
108 | 118 |
109 private: | 119 private: |
110 static unsigned s_scopeCount; | 120 static unsigned s_scopeCount; |
111 static AbstractPropertySetCSSStyleDeclaration* s_currentDecl; | 121 static AbstractPropertySetCSSStyleDeclaration* s_currentDecl; |
112 static bool s_shouldNotifyInspector; | 122 static bool s_shouldNotifyInspector; |
113 static bool s_shouldDeliver; | 123 static bool s_shouldDeliver; |
114 | 124 |
115 OwnPtrWillBeMember<MutationObserverInterestGroup> m_mutationRecipients; | 125 OwnPtrWillBeMember<MutationObserverInterestGroup> m_mutationRecipients; |
116 RefPtrWillBeMember<MutationRecord> m_mutation; | 126 RefPtrWillBeMember<MutationRecord> m_mutation; |
| 127 AtomicString m_oldValue; |
117 }; | 128 }; |
118 | 129 |
119 unsigned StyleAttributeMutationScope::s_scopeCount = 0; | 130 unsigned StyleAttributeMutationScope::s_scopeCount = 0; |
120 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe
cl = 0; | 131 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe
cl = 0; |
121 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; | 132 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; |
122 bool StyleAttributeMutationScope::s_shouldDeliver = false; | 133 bool StyleAttributeMutationScope::s_shouldDeliver = false; |
123 | 134 |
124 } // namespace | 135 } // namespace |
125 | 136 |
126 #if !ENABLE(OILPAN) | 137 #if !ENABLE(OILPAN) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 396 } |
386 #endif | 397 #endif |
387 | 398 |
388 DEFINE_TRACE(InlineCSSStyleDeclaration) | 399 DEFINE_TRACE(InlineCSSStyleDeclaration) |
389 { | 400 { |
390 visitor->trace(m_parentElement); | 401 visitor->trace(m_parentElement); |
391 AbstractPropertySetCSSStyleDeclaration::trace(visitor); | 402 AbstractPropertySetCSSStyleDeclaration::trace(visitor); |
392 } | 403 } |
393 | 404 |
394 } // namespace blink | 405 } // namespace blink |
OLD | NEW |