Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "core/css/CSSCustomPropertyDeclaration.h" | 27 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 28 #include "core/css/CSSKeyframesRule.h" | 28 #include "core/css/CSSKeyframesRule.h" |
| 29 #include "core/css/CSSStyleSheet.h" | 29 #include "core/css/CSSStyleSheet.h" |
| 30 #include "core/css/StylePropertySet.h" | 30 #include "core/css/StylePropertySet.h" |
| 31 #include "core/css/parser/CSSVariableParser.h" | 31 #include "core/css/parser/CSSVariableParser.h" |
| 32 #include "core/dom/Element.h" | 32 #include "core/dom/Element.h" |
| 33 #include "core/dom/MutationObserverInterestGroup.h" | 33 #include "core/dom/MutationObserverInterestGroup.h" |
| 34 #include "core/dom/MutationRecord.h" | 34 #include "core/dom/MutationRecord.h" |
| 35 #include "core/dom/StyleChangeReason.h" | 35 #include "core/dom/StyleChangeReason.h" |
| 36 #include "core/dom/StyleEngine.h" | 36 #include "core/dom/StyleEngine.h" |
| 37 #include "core/dom/custom/CustomElement.h" | |
| 38 #include "core/dom/custom/CustomElementDefinition.h" | |
| 37 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
| 38 #include "platform/RuntimeEnabledFeatures.h" | 40 #include "platform/RuntimeEnabledFeatures.h" |
| 39 | 41 |
| 40 namespace blink { | 42 namespace blink { |
| 41 | 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 46 static CustomElementDefinition* definitionIfStyleChangedCallback(Element* elemen t) | |
| 47 { | |
| 48 if (!element || element->getCustomElementState() != CustomElementState::Cust om) | |
|
dominicc (has gone to gerrit)
2016/07/22 01:14:01
I'm guessing if it is worth doing here, it is wort
| |
| 49 return nullptr; | |
| 50 CustomElementDefinition* definition = CustomElement::definitionForElement(*e lement); | |
| 51 DCHECK(definition); | |
| 52 return definition->hasStyleAttributeChangedCallback() ? definition : nullptr ; | |
| 53 } | |
| 54 | |
| 44 class StyleAttributeMutationScope { | 55 class StyleAttributeMutationScope { |
| 45 WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope); | 56 WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope); |
| 46 STACK_ALLOCATED(); | 57 STACK_ALLOCATED(); |
| 47 public: | 58 public: |
| 48 StyleAttributeMutationScope(AbstractPropertySetCSSStyleDeclaration* decl) | 59 StyleAttributeMutationScope(AbstractPropertySetCSSStyleDeclaration* decl) |
| 49 { | 60 { |
| 50 ++s_scopeCount; | 61 ++s_scopeCount; |
| 51 | 62 |
| 52 if (s_scopeCount != 1) { | 63 if (s_scopeCount != 1) { |
| 53 ASSERT(s_currentDecl == decl); | 64 ASSERT(s_currentDecl == decl); |
| 54 return; | 65 return; |
| 55 } | 66 } |
| 56 | 67 |
| 57 ASSERT(!s_currentDecl); | 68 ASSERT(!s_currentDecl); |
| 58 s_currentDecl = decl; | 69 s_currentDecl = decl; |
| 59 | 70 |
| 60 if (!s_currentDecl->parentElement()) | 71 if (!s_currentDecl->parentElement()) |
| 61 return; | 72 return; |
| 62 | 73 |
| 63 bool shouldReadOldValue = false; | 74 bool shouldReadOldValue = false; |
| 64 | 75 |
| 65 m_mutationRecipients = MutationObserverInterestGroup::createForAttribute sMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr); | 76 m_mutationRecipients = MutationObserverInterestGroup::createForAttribute sMutation(*s_currentDecl->parentElement(), HTMLNames::styleAttr); |
| 66 if (m_mutationRecipients && m_mutationRecipients->isOldValueRequested()) | 77 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
| |
| 67 shouldReadOldValue = true; | 78 shouldReadOldValue = true; |
| 79 else if (definitionIfStyleChangedCallback(s_currentDecl->parentElement() )) | |
| 80 shouldReadOldValue = true; | |
| 68 | 81 |
| 69 AtomicString oldValue; | |
| 70 if (shouldReadOldValue) | 82 if (shouldReadOldValue) |
| 71 oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::s tyleAttr); | 83 m_oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames: :styleAttr); |
| 72 | 84 |
| 73 if (m_mutationRecipients) { | 85 if (m_mutationRecipients) { |
| 74 AtomicString requestedOldValue = m_mutationRecipients->isOldValueReq uested() ? oldValue : nullAtom; | 86 AtomicString requestedOldValue = m_mutationRecipients->isOldValueReq uested() ? m_oldValue : nullAtom; |
| 75 m_mutation = MutationRecord::createAttributes(s_currentDecl->parentE lement(), HTMLNames::styleAttr, requestedOldValue); | 87 m_mutation = MutationRecord::createAttributes(s_currentDecl->parentE lement(), HTMLNames::styleAttr, requestedOldValue); |
| 76 } | 88 } |
| 77 } | 89 } |
| 78 | 90 |
| 79 ~StyleAttributeMutationScope() | 91 ~StyleAttributeMutationScope() |
| 80 { | 92 { |
| 81 --s_scopeCount; | 93 --s_scopeCount; |
| 82 if (s_scopeCount) | 94 if (s_scopeCount) |
| 83 return; | 95 return; |
| 84 | 96 |
| 85 if (m_mutation && s_shouldDeliver) | 97 if (s_shouldDeliver) { |
| 86 m_mutationRecipients->enqueueMutationRecord(m_mutation); | 98 if (m_mutation) |
| 99 m_mutationRecipients->enqueueMutationRecord(m_mutation); | |
| 87 | 100 |
| 88 s_shouldDeliver = false; | 101 Element* element = s_currentDecl->parentElement(); |
| 102 if (CustomElementDefinition* definition = definitionIfStyleChangedCa llback(element)) { | |
| 103 definition->enqueueAttributeChangedCallback(element, | |
| 104 HTMLNames::styleAttr, m_oldValue, | |
| 105 element->getAttribute(HTMLNames::styleAttr)); | |
| 106 } | |
| 107 | |
| 108 s_shouldDeliver = false; | |
| 109 } | |
| 89 | 110 |
| 90 // We have to clear internal state before calling Inspector's code. | 111 // We have to clear internal state before calling Inspector's code. |
| 91 AbstractPropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDe cl; | 112 AbstractPropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDe cl; |
| 92 s_currentDecl = 0; | 113 s_currentDecl = 0; |
| 93 | 114 |
| 94 if (!s_shouldNotifyInspector) | 115 if (!s_shouldNotifyInspector) |
| 95 return; | 116 return; |
| 96 | 117 |
| 97 s_shouldNotifyInspector = false; | 118 s_shouldNotifyInspector = false; |
| 98 if (localCopyStyleDecl->parentElement()) | 119 if (localCopyStyleDecl->parentElement()) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 110 } | 131 } |
| 111 | 132 |
| 112 private: | 133 private: |
| 113 static unsigned s_scopeCount; | 134 static unsigned s_scopeCount; |
| 114 static AbstractPropertySetCSSStyleDeclaration* s_currentDecl; | 135 static AbstractPropertySetCSSStyleDeclaration* s_currentDecl; |
| 115 static bool s_shouldNotifyInspector; | 136 static bool s_shouldNotifyInspector; |
| 116 static bool s_shouldDeliver; | 137 static bool s_shouldDeliver; |
| 117 | 138 |
| 118 Member<MutationObserverInterestGroup> m_mutationRecipients; | 139 Member<MutationObserverInterestGroup> m_mutationRecipients; |
| 119 Member<MutationRecord> m_mutation; | 140 Member<MutationRecord> m_mutation; |
| 141 AtomicString m_oldValue; | |
| 120 }; | 142 }; |
| 121 | 143 |
| 122 unsigned StyleAttributeMutationScope::s_scopeCount = 0; | 144 unsigned StyleAttributeMutationScope::s_scopeCount = 0; |
| 123 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe cl = 0; | 145 AbstractPropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDe cl = 0; |
| 124 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; | 146 bool StyleAttributeMutationScope::s_shouldNotifyInspector = false; |
| 125 bool StyleAttributeMutationScope::s_shouldDeliver = false; | 147 bool StyleAttributeMutationScope::s_shouldDeliver = false; |
| 126 | 148 |
| 127 } // namespace | 149 } // namespace |
| 128 | 150 |
| 129 DEFINE_TRACE(PropertySetCSSStyleDeclaration) | 151 DEFINE_TRACE(PropertySetCSSStyleDeclaration) |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 return m_parentElement ? &m_parentElement->document().elementSheet() : nullp tr; | 396 return m_parentElement ? &m_parentElement->document().elementSheet() : nullp tr; |
| 375 } | 397 } |
| 376 | 398 |
| 377 DEFINE_TRACE(InlineCSSStyleDeclaration) | 399 DEFINE_TRACE(InlineCSSStyleDeclaration) |
| 378 { | 400 { |
| 379 visitor->trace(m_parentElement); | 401 visitor->trace(m_parentElement); |
| 380 AbstractPropertySetCSSStyleDeclaration::trace(visitor); | 402 AbstractPropertySetCSSStyleDeclaration::trace(visitor); |
| 381 } | 403 } |
| 382 | 404 |
| 383 } // namespace blink | 405 } // namespace blink |
| OLD | NEW |