summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/Node.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-16 14:56:46 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-16 14:57:30 +0200
commitb297e0fa5c217c9467033b7c8b46891a52870120 (patch)
tree43fc14689295e9e64f2719d05aad94e3049f6cd7 /Source/WebCore/dom/Node.cpp
parent69d517dbfa69903d8593cc1737f0474b21e3251e (diff)
downloadqtwebkit-b297e0fa5c217c9467033b7c8b46891a52870120.tar.gz
Revert "Imported WebKit commit 0dc6cd75e1d4836eaffbb520be96fac4847cc9d2 (http://svn.webkit.org/repository/webkit/trunk@131300)"
This reverts commit 5466563f4b5b6b86523e3f89bb7f77e5b5270c78. Caused OOM issues on some CI machines :(
Diffstat (limited to 'Source/WebCore/dom/Node.cpp')
-rw-r--r--Source/WebCore/dom/Node.cpp117
1 files changed, 51 insertions, 66 deletions
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 97600d8b0..8ab3352f6 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -191,7 +191,7 @@ void Node::dumpStatistics()
Element* element = static_cast<Element*>(node);
HashMap<String, size_t>::AddResult result = perTagCount.add(element->tagName(), 1);
if (!result.isNewEntry)
- result.iterator->value++;
+ result.iterator->second++;
if (ElementAttributeData* attributeData = element->attributeData()) {
attributes += attributeData->length();
@@ -279,7 +279,7 @@ void Node::dumpStatistics()
printf("Element tag name distibution:\n");
for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTagCount.end(); ++it)
- printf(" Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value);
+ printf(" Number of <%s> tags: %zu\n", it->first.utf8().data(), it->second);
printf("Attributes:\n");
printf(" Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes, sizeof(Attribute));
@@ -410,14 +410,11 @@ Node::~Node()
if (hasRareData())
clearRareData();
- if (hasEventTargetData())
- clearEventTargetData();
-
if (renderer())
detach();
Document* doc = m_document;
- if (AXObjectCache::accessibilityEnabled() && doc && doc->axObjectCacheExists() && !isContainerNode())
+ if (AXObjectCache::accessibilityEnabled() && doc && doc->axObjectCacheExists())
doc->axObjectCache()->remove(this);
if (m_previous)
@@ -515,7 +512,7 @@ void Node::clearRareData()
NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap();
NodeRareData::NodeRareDataMap::iterator it = dataMap.find(this);
ASSERT(it != dataMap.end());
- delete it->value;
+ delete it->second;
dataMap.remove(it);
}
clearFlag(HasRareDataFlag);
@@ -2070,7 +2067,7 @@ FloatPoint Node::convertToPage(const FloatPoint& p) const
{
// If there is a renderer, just ask it to do the conversion
if (renderer())
- return renderer()->localToAbsolute(p, UseTransforms);
+ return renderer()->localToAbsolute(p, false, true);
// Otherwise go up the tree looking for a renderer
Element *parent = ancestorElement();
@@ -2085,7 +2082,7 @@ FloatPoint Node::convertFromPage(const FloatPoint& p) const
{
// If there is a renderer, just ask it to do the conversion
if (renderer())
- return renderer()->absoluteToLocal(p, UseTransforms);
+ return renderer()->absoluteToLocal(p, false, true);
// Otherwise go up the tree looking for a renderer
Element *parent = ancestorElement();
@@ -2276,18 +2273,18 @@ void NodeListsNodeData::invalidateCaches(const QualifiedName* attrName)
{
NodeListAtomicNameCacheMap::const_iterator atomicNameCacheEnd = m_atomicNameCaches.end();
for (NodeListAtomicNameCacheMap::const_iterator it = m_atomicNameCaches.begin(); it != atomicNameCacheEnd; ++it)
- it->value->invalidateCache(attrName);
+ it->second->invalidateCache(attrName);
NodeListNameCacheMap::const_iterator nameCacheEnd = m_nameCaches.end();
for (NodeListNameCacheMap::const_iterator it = m_nameCaches.begin(); it != nameCacheEnd; ++it)
- it->value->invalidateCache(attrName);
+ it->second->invalidateCache(attrName);
if (attrName)
return;
TagNodeListCacheNS::iterator tagCacheEnd = m_tagNodeListCacheNS.end();
for (TagNodeListCacheNS::iterator it = m_tagNodeListCacheNS.begin(); it != tagCacheEnd; ++it)
- it->value->invalidateCache();
+ it->second->invalidateCache();
}
void Node::getSubresourceURLs(ListHashSet<KURL>& urls) const
@@ -2412,32 +2409,14 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
return tryRemoveEventListener(this, eventType, listener, useCapture);
}
-typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap;
-
-static EventTargetDataMap& eventTargetDataMap()
-{
- DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ());
- return map;
-}
-
EventTargetData* Node::eventTargetData()
{
- return hasEventTargetData() ? eventTargetDataMap().get(this) : 0;
+ return hasRareData() ? rareData()->eventTargetData() : 0;
}
EventTargetData* Node::ensureEventTargetData()
{
- if (hasEventTargetData())
- return eventTargetDataMap().get(this);
- setHasEventTargetData(true);
- EventTargetData* data = new EventTargetData;
- eventTargetDataMap().set(this, adoptPtr(data));
- return data;
-}
-
-void Node::clearEventTargetData()
-{
- eventTargetDataMap().remove(this);
+ return ensureRareData()->ensureEventTargetData();
}
#if ENABLE(MUTATION_OBSERVERS)
@@ -2451,18 +2430,32 @@ HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry(
return hasRareData() ? rareData()->transientMutationObserverRegistry() : 0;
}
-template<typename Registry>
-static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, Registry* registry, Node* target, MutationObserver::MutationType type, const QualifiedName* attributeName)
+void Node::collectMatchingObserversForMutation(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, Node* fromNode, MutationObserver::MutationType type, const QualifiedName* attributeName)
{
- if (!registry)
- return;
- for (typename Registry::iterator iter = registry->begin(); iter != registry->end(); ++iter) {
- const MutationObserverRegistration& registration = **iter;
- if (registration.shouldReceiveMutationFrom(target, type, attributeName)) {
- MutationRecordDeliveryOptions deliveryOptions = registration.deliveryOptions();
- HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration.observer(), deliveryOptions);
- if (!result.isNewEntry)
- result.iterator->value |= deliveryOptions;
+ ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName);
+ if (Vector<OwnPtr<MutationObserverRegistration> >* registry = fromNode->mutationObserverRegistry()) {
+ const size_t size = registry->size();
+ for (size_t i = 0; i < size; ++i) {
+ MutationObserverRegistration* registration = registry->at(i).get();
+ if (registration->shouldReceiveMutationFrom(this, type, attributeName)) {
+ MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions();
+ HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration->observer(), deliveryOptions);
+ if (!result.isNewEntry)
+ result.iterator->second |= deliveryOptions;
+
+ }
+ }
+ }
+
+ if (HashSet<MutationObserverRegistration*>* transientRegistry = fromNode->transientMutationObserverRegistry()) {
+ for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) {
+ MutationObserverRegistration* registration = *iter;
+ if (registration->shouldReceiveMutationFrom(this, type, attributeName)) {
+ MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions();
+ HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration->observer(), deliveryOptions);
+ if (!result.isNewEntry)
+ result.iterator->second |= deliveryOptions;
+ }
}
}
}
@@ -2470,31 +2463,23 @@ static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*
void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const QualifiedName* attributeName)
{
ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName);
- collectMatchingObserversForMutation(observers, mutationObserverRegistry(), this, type, attributeName);
- collectMatchingObserversForMutation(observers, transientMutationObserverRegistry(), this, type, attributeName);
- for (Node* node = parentNode(); node; node = node->parentNode()) {
- collectMatchingObserversForMutation(observers, node->mutationObserverRegistry(), this, type, attributeName);
- collectMatchingObserversForMutation(observers, node->transientMutationObserverRegistry(), this, type, attributeName);
- }
+ collectMatchingObserversForMutation(observers, this, type, attributeName);
+ for (Node* node = parentNode(); node; node = node->parentNode())
+ collectMatchingObserversForMutation(observers, node, type, attributeName);
}
-void Node::registerMutationObserver(MutationObserver* observer, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter)
+MutationObserverRegistration* Node::registerMutationObserver(PassRefPtr<MutationObserver> observer)
{
- MutationObserverRegistration* registration = 0;
Vector<OwnPtr<MutationObserverRegistration> >* registry = ensureRareData()->ensureMutationObserverRegistry();
for (size_t i = 0; i < registry->size(); ++i) {
- if (registry->at(i)->observer() == observer) {
- registration = registry->at(i).get();
- registration->resetObservation(options, attributeFilter);
- }
- }
-
- if (!registration) {
- registry->append(MutationObserverRegistration::create(observer, this, options, attributeFilter));
- registration = registry->last().get();
+ if (registry->at(i)->observer() == observer)
+ return registry->at(i).get();
}
- document()->addMutationObserverTypes(registration->mutationTypes());
+ OwnPtr<MutationObserverRegistration> registration = MutationObserverRegistration::create(observer, this);
+ MutationObserverRegistration* registrationPtr = registration.get();
+ registry->append(registration.release());
+ return registrationPtr;
}
void Node::unregisterMutationObserver(MutationObserverRegistration* registration)
@@ -2550,7 +2535,7 @@ void Node::notifyMutationObserversNodeWillDetach()
void Node::handleLocalEvents(Event* event)
{
- if (!hasEventTargetData())
+ if (!hasRareData() || !rareData()->eventTargetData())
return;
if (disabled() && event->isMouseEvent())
@@ -2579,7 +2564,7 @@ void Node::dispatchSubtreeModifiedEvent()
if (isInShadowTree())
return;
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
+ ASSERT(!eventDispatchForbidden());
if (!document()->hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER))
return;
@@ -2589,21 +2574,21 @@ void Node::dispatchSubtreeModifiedEvent()
void Node::dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Node> oldFocusedNode)
{
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
+ ASSERT(!eventDispatchForbidden());
ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(UIEvent::create(eventType, true, false, document()->defaultView(), 0), oldFocusedNode));
}
void Node::dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Node> newFocusedNode)
{
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
+ ASSERT(!eventDispatchForbidden());
ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(UIEvent::create(eventType, true, false, document()->defaultView(), 0), newFocusedNode));
}
bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent)
{
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
+ ASSERT(!eventDispatchForbidden());
RefPtr<UIEvent> event = UIEvent::create(eventNames().DOMActivateEvent, true, true, document()->defaultView(), detail);
event->setUnderlyingEvent(underlyingEvent);
dispatchScopedEvent(event);