OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 { | 2069 { |
2070 if (!hasRareData()) | 2070 if (!hasRareData()) |
2071 return 0; | 2071 return 0; |
2072 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 2072 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
2073 if (!data) | 2073 if (!data) |
2074 return 0; | 2074 return 0; |
2075 return &data->transientRegistry; | 2075 return &data->transientRegistry; |
2076 } | 2076 } |
2077 | 2077 |
2078 template<typename Registry> | 2078 template<typename Registry> |
2079 static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*
, MutationRecordDeliveryOptions>& observers, Registry* registry, Node* target, M
utationObserver::MutationType type, const QualifiedName* attributeName) | 2079 static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*
, MutationRecordDeliveryOptions>& observers, Registry* registry, Node& target, M
utationObserver::MutationType type, const QualifiedName* attributeName) |
2080 { | 2080 { |
2081 if (!registry) | 2081 if (!registry) |
2082 return; | 2082 return; |
2083 for (typename Registry::iterator iter = registry->begin(); iter != registry-
>end(); ++iter) { | 2083 for (typename Registry::iterator iter = registry->begin(); iter != registry-
>end(); ++iter) { |
2084 const MutationObserverRegistration& registration = **iter; | 2084 const MutationObserverRegistration& registration = **iter; |
2085 if (registration.shouldReceiveMutationFrom(target, type, attributeName))
{ | 2085 if (registration.shouldReceiveMutationFrom(target, type, attributeName))
{ |
2086 MutationRecordDeliveryOptions deliveryOptions = registration.deliver
yOptions(); | 2086 MutationRecordDeliveryOptions deliveryOptions = registration.deliver
yOptions(); |
2087 HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult
result = observers.add(registration.observer(), deliveryOptions); | 2087 HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult
result = observers.add(®istration.observer(), deliveryOptions); |
2088 if (!result.isNewEntry) | 2088 if (!result.isNewEntry) |
2089 result.storedValue->value |= deliveryOptions; | 2089 result.storedValue->value |= deliveryOptions; |
2090 } | 2090 } |
2091 } | 2091 } |
2092 } | 2092 } |
2093 | 2093 |
2094 void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, Mutat
ionRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const
QualifiedName* attributeName) | 2094 void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, Mutat
ionRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const
QualifiedName* attributeName) |
2095 { | 2095 { |
2096 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); | 2096 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); |
2097 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), t
his, type, attributeName); | 2097 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *
this, type, attributeName); |
2098 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), this, type, attributeName); | 2098 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), *this, type, attributeName); |
2099 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2099 for (Node* node = parentNode(); node; node = node->parentNode()) { |
2100 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), this, type, attributeName); | 2100 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); |
2101 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), this, type, attributeName); | 2101 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); |
2102 } | 2102 } |
2103 } | 2103 } |
2104 | 2104 |
2105 void Node::registerMutationObserver(MutationObserver* observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) | 2105 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) |
2106 { | 2106 { |
2107 MutationObserverRegistration* registration = 0; | 2107 MutationObserverRegistration* registration = 0; |
2108 Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().e
nsureMutationObserverData().registry; | 2108 Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().e
nsureMutationObserverData().registry; |
2109 for (size_t i = 0; i < registry.size(); ++i) { | 2109 for (size_t i = 0; i < registry.size(); ++i) { |
2110 if (registry[i]->observer() == observer) { | 2110 if (®istry[i]->observer() == &observer) { |
2111 registration = registry[i].get(); | 2111 registration = registry[i].get(); |
2112 registration->resetObservation(options, attributeFilter); | 2112 registration->resetObservation(options, attributeFilter); |
2113 } | 2113 } |
2114 } | 2114 } |
2115 | 2115 |
2116 if (!registration) { | 2116 if (!registration) { |
2117 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 2117 registry.append(MutationObserverRegistration::create(observer, *this, op
tions, attributeFilter)); |
2118 registration = registry.last().get(); | 2118 registration = registry.last().get(); |
2119 } | 2119 } |
2120 | 2120 |
2121 document().addMutationObserverTypes(registration->mutationTypes()); | 2121 document().addMutationObserverTypes(registration->mutationTypes()); |
2122 } | 2122 } |
2123 | 2123 |
2124 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 2124 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
2125 { | 2125 { |
2126 Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRe
gistry(); | 2126 Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRe
gistry(); |
2127 ASSERT(registry); | 2127 ASSERT(registry); |
(...skipping 30 matching lines...) Expand all Loading... |
2158 | 2158 |
2159 void Node::notifyMutationObserversNodeWillDetach() | 2159 void Node::notifyMutationObserversNodeWillDetach() |
2160 { | 2160 { |
2161 if (!document().hasMutationObservers()) | 2161 if (!document().hasMutationObservers()) |
2162 return; | 2162 return; |
2163 | 2163 |
2164 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2164 for (Node* node = parentNode(); node; node = node->parentNode()) { |
2165 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->muta
tionObserverRegistry()) { | 2165 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->muta
tionObserverRegistry()) { |
2166 const size_t size = registry->size(); | 2166 const size_t size = registry->size(); |
2167 for (size_t i = 0; i < size; ++i) | 2167 for (size_t i = 0; i < size; ++i) |
2168 registry->at(i)->observedSubtreeNodeWillDetach(this); | 2168 registry->at(i)->observedSubtreeNodeWillDetach(*this); |
2169 } | 2169 } |
2170 | 2170 |
2171 if (HashSet<MutationObserverRegistration*>* transientRegistry = node->tr
ansientMutationObserverRegistry()) { | 2171 if (HashSet<MutationObserverRegistration*>* transientRegistry = node->tr
ansientMutationObserverRegistry()) { |
2172 for (HashSet<MutationObserverRegistration*>::iterator iter = transie
ntRegistry->begin(); iter != transientRegistry->end(); ++iter) | 2172 for (HashSet<MutationObserverRegistration*>::iterator iter = transie
ntRegistry->begin(); iter != transientRegistry->end(); ++iter) |
2173 (*iter)->observedSubtreeNodeWillDetach(this); | 2173 (*iter)->observedSubtreeNodeWillDetach(*this); |
2174 } | 2174 } |
2175 } | 2175 } |
2176 } | 2176 } |
2177 | 2177 |
2178 void Node::handleLocalEvents(Event* event) | 2178 void Node::handleLocalEvents(Event* event) |
2179 { | 2179 { |
2180 if (!hasEventTargetData()) | 2180 if (!hasEventTargetData()) |
2181 return; | 2181 return; |
2182 | 2182 |
2183 if (isDisabledFormControl(this) && event->isMouseEvent()) | 2183 if (isDisabledFormControl(this) && event->isMouseEvent()) |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2557 node->showTreeForThis(); | 2557 node->showTreeForThis(); |
2558 } | 2558 } |
2559 | 2559 |
2560 void showNodePath(const WebCore::Node* node) | 2560 void showNodePath(const WebCore::Node* node) |
2561 { | 2561 { |
2562 if (node) | 2562 if (node) |
2563 node->showNodePathForThis(); | 2563 node->showNodePathForThis(); |
2564 } | 2564 } |
2565 | 2565 |
2566 #endif | 2566 #endif |
OLD | NEW |