Chromium Code Reviews| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 #include "core/events/EventDispatchMediator.h" | 60 #include "core/events/EventDispatchMediator.h" |
| 61 #include "core/events/EventDispatcher.h" | 61 #include "core/events/EventDispatcher.h" |
| 62 #include "core/events/EventListener.h" | 62 #include "core/events/EventListener.h" |
| 63 #include "core/events/GestureEvent.h" | 63 #include "core/events/GestureEvent.h" |
| 64 #include "core/events/KeyboardEvent.h" | 64 #include "core/events/KeyboardEvent.h" |
| 65 #include "core/events/MouseEvent.h" | 65 #include "core/events/MouseEvent.h" |
| 66 #include "core/events/TextEvent.h" | 66 #include "core/events/TextEvent.h" |
| 67 #include "core/events/TouchEvent.h" | 67 #include "core/events/TouchEvent.h" |
| 68 #include "core/events/UIEvent.h" | 68 #include "core/events/UIEvent.h" |
| 69 #include "core/events/WheelEvent.h" | 69 #include "core/events/WheelEvent.h" |
| 70 #include "core/frame/EventHandlerRegistry.h" | |
| 71 #include "core/frame/LocalFrame.h" | 70 #include "core/frame/LocalFrame.h" |
| 72 #include "core/frame/Settings.h" | 71 #include "core/frame/Settings.h" |
| 73 #include "core/html/HTMLAnchorElement.h" | 72 #include "core/html/HTMLAnchorElement.h" |
| 74 #include "core/html/HTMLStyleElement.h" | 73 #include "core/html/HTMLStyleElement.h" |
| 75 #include "core/page/EventHandler.h" | 74 #include "core/page/EventHandler.h" |
| 76 #include "core/page/Page.h" | 75 #include "core/page/Page.h" |
| 77 #include "core/rendering/RenderBox.h" | 76 #include "core/rendering/RenderBox.h" |
| 78 #include "platform/EventDispatchForbiddenScope.h" | 77 #include "platform/EventDispatchForbiddenScope.h" |
| 79 #include "platform/Partitions.h" | 78 #include "platform/Partitions.h" |
| 80 #include "platform/TraceEvent.h" | 79 #include "platform/TraceEvent.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 void Node::willBeDeletedFromDocument() | 278 void Node::willBeDeletedFromDocument() |
| 280 { | 279 { |
| 281 if (!isTreeScopeInitialized()) | 280 if (!isTreeScopeInitialized()) |
| 282 return; | 281 return; |
| 283 | 282 |
| 284 Document& document = this->document(); | 283 Document& document = this->document(); |
| 285 | 284 |
| 286 if (hasEventTargetData()) | 285 if (hasEventTargetData()) |
| 287 clearEventTargetData(); | 286 clearEventTargetData(); |
| 288 | 287 |
| 289 if (document.frameHost()) | |
| 290 document.frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers(* this); | |
| 291 | |
| 292 document.markers().removeMarkers(this); | 288 document.markers().removeMarkers(this); |
| 293 } | 289 } |
| 294 #endif | 290 #endif |
| 295 | 291 |
| 296 NodeRareData* Node::rareData() const | 292 NodeRareData* Node::rareData() const |
| 297 { | 293 { |
| 298 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); | 294 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); |
| 299 return static_cast<NodeRareData*>(m_data.m_rareData); | 295 return static_cast<NodeRareData*>(m_data.m_rareData); |
| 300 } | 296 } |
| 301 | 297 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 } | 562 } |
| 567 | 563 |
| 568 void Node::traceStyleChange(StyleChangeType changeType) | 564 void Node::traceStyleChange(StyleChangeType changeType) |
| 569 { | 565 { |
| 570 static const unsigned kMinLoggedSize = 100; | 566 static const unsigned kMinLoggedSize = 100; |
| 571 unsigned nodeCount = styledSubtreeSize(); | 567 unsigned nodeCount = styledSubtreeSize(); |
| 572 if (nodeCount < kMinLoggedSize) | 568 if (nodeCount < kMinLoggedSize) |
| 573 return; | 569 return; |
| 574 | 570 |
| 575 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("style.debug"), | 571 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("style.debug"), |
| 576 "Node::setNeedsStyleRecalc", TRACE_EVENT_SCOPE_PROCESS, | 572 "Node::setNeedsStyleRecalc", TRACE_EVENT_SCOPE_PROCESS, |
| 577 "data", jsonObjectForStyleInvalidation(nodeCount, this) | 573 "data", jsonObjectForStyleInvalidation(nodeCount, this) |
| 578 ); | 574 ); |
| 579 } | 575 } |
| 580 | 576 |
| 581 void Node::traceStyleChangeIfNeeded(StyleChangeType changeType) | 577 void Node::traceStyleChangeIfNeeded(StyleChangeType changeType) |
| 582 { | 578 { |
| 583 // TRACE_EVENT_CATEGORY_GROUP_ENABLED macro loads a global static bool into our local bool. | 579 // TRACE_EVENT_CATEGORY_GROUP_ENABLED macro loads a global static bool into our local bool. |
| 584 bool styleTracingEnabled; | 580 bool styleTracingEnabled; |
| 585 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("style.debug"), &styleTracingEnabled); | 581 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("style.debug"), &styleTracingEnabled); |
| 586 if (UNLIKELY(styleTracingEnabled)) | 582 if (UNLIKELY(styleTracingEnabled)) |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; | 1368 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; |
| 1373 if (!listenerMap.isEmpty()) { | 1369 if (!listenerMap.isEmpty()) { |
| 1374 Vector<AtomicString> types = listenerMap.eventTypes(); | 1370 Vector<AtomicString> types = listenerMap.eventTypes(); |
| 1375 for (unsigned i = 0; i < types.size(); ++i) | 1371 for (unsigned i = 0; i < types.size(); ++i) |
| 1376 document().addListenerTypeIfNeeded(types[i]); | 1372 document().addListenerTypeIfNeeded(types[i]); |
| 1377 } | 1373 } |
| 1378 } | 1374 } |
| 1379 | 1375 |
| 1380 oldDocument.markers().removeMarkers(this); | 1376 oldDocument.markers().removeMarkers(this); |
| 1381 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); | 1377 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); |
| 1382 if (oldDocument.frameHost() && !document().frameHost()) | |
| 1383 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*t his); | |
| 1384 else if (document().frameHost() && !oldDocument.frameHost()) | |
| 1385 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*thi s); | |
| 1386 else if (oldDocument.frameHost() != document().frameHost()) | |
| 1387 EventHandlerRegistry::didMoveBetweenFrameHosts(*this, oldDocument.frameH ost(), document().frameHost()); | |
| 1388 | 1378 |
| 1389 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { | 1379 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { |
| 1390 for (size_t i = 0; i < registry->size(); ++i) { | 1380 for (size_t i = 0; i < registry->size(); ++i) { |
| 1391 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); | 1381 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); |
| 1392 } | 1382 } |
| 1393 } | 1383 } |
| 1394 | 1384 |
| 1395 if (HashSet<RawPtr<MutationObserverRegistration> >* transientRegistry = tran sientMutationObserverRegistry()) { | 1385 if (HashSet<RawPtr<MutationObserverRegistration> >* transientRegistry = tran sientMutationObserverRegistry()) { |
| 1396 for (HashSet<RawPtr<MutationObserverRegistration> >::iterator iter = tra nsientRegistry->begin(); iter != transientRegistry->end(); ++iter) { | 1386 for (HashSet<RawPtr<MutationObserverRegistration> >::iterator iter = tra nsientRegistry->begin(); iter != transientRegistry->end(); ++iter) { |
| 1397 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1387 document().addMutationObserverTypes((*iter)->mutationTypes()); |
| 1398 } | 1388 } |
| 1399 } | 1389 } |
| 1400 } | 1390 } |
| 1401 | 1391 |
| 1402 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1392 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) |
| 1403 { | 1393 { |
| 1404 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) | 1394 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) |
| 1405 return false; | 1395 return false; |
| 1406 | 1396 |
| 1407 Document& document = targetNode->document(); | 1397 Document& document = targetNode->document(); |
| 1408 document.addListenerTypeIfNeeded(eventType); | 1398 document.addListenerTypeIfNeeded(eventType); |
| 1409 if (document.frameHost()) | |
| 1410 document.frameHost()->eventHandlerRegistry().didAddEventHandler(*targetN ode, eventType); | |
| 1411 | 1399 |
| 1412 return true; | 1400 return true; |
| 1413 } | 1401 } |
| 1414 | 1402 |
| 1415 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) | 1403 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) |
| 1416 { | 1404 { |
| 1417 return tryAddEventListener(this, eventType, listener, useCapture); | 1405 return tryAddEventListener(this, eventType, listener, useCapture); |
| 1418 } | 1406 } |
| 1419 | 1407 |
| 1420 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) | 1408 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) |
| 1421 { | 1409 { |
| 1422 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) | 1410 return targetNode->EventTarget::removeEventListener(eventType, listener, use Capture); |
|
rafaelw
2014/11/10 20:31:21
PTAL
abarth-chromium
2014/11/10 21:03:42
Seems fine.
| |
| 1423 return false; | |
| 1424 | |
| 1425 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of | |
| 1426 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861 | |
| 1427 Document& document = targetNode->document(); | |
| 1428 if (document.frameHost()) | |
| 1429 document.frameHost()->eventHandlerRegistry().didRemoveEventHandler(*targ etNode, eventType); | |
| 1430 | |
| 1431 return true; | |
| 1432 } | 1411 } |
| 1433 | 1412 |
| 1434 bool Node::removeEventListener(const AtomicString& eventType, PassRefPtr<EventLi stener> listener, bool useCapture) | 1413 bool Node::removeEventListener(const AtomicString& eventType, PassRefPtr<EventLi stener> listener, bool useCapture) |
| 1435 { | 1414 { |
| 1436 return tryRemoveEventListener(this, eventType, listener, useCapture); | 1415 return tryRemoveEventListener(this, eventType, listener, useCapture); |
| 1437 } | 1416 } |
| 1438 | 1417 |
| 1439 void Node::removeAllEventListeners() | 1418 void Node::removeAllEventListeners() |
| 1440 { | 1419 { |
| 1441 if (hasEventListeners() && document().frameHost()) | |
| 1442 document().frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers (*this); | |
| 1443 EventTarget::removeAllEventListeners(); | 1420 EventTarget::removeAllEventListeners(); |
| 1444 } | 1421 } |
| 1445 | 1422 |
| 1446 void Node::removeAllEventListenersRecursively() | 1423 void Node::removeAllEventListenersRecursively() |
| 1447 { | 1424 { |
| 1448 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 1425 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
| 1449 node->removeAllEventListeners(); | 1426 node->removeAllEventListeners(); |
| 1450 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) | 1427 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) |
| 1451 root->removeAllEventListenersRecursively(); | 1428 root->removeAllEventListenersRecursively(); |
| 1452 } | 1429 } |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1899 node->showTreeForThis(); | 1876 node->showTreeForThis(); |
| 1900 } | 1877 } |
| 1901 | 1878 |
| 1902 void showNodePath(const blink::Node* node) | 1879 void showNodePath(const blink::Node* node) |
| 1903 { | 1880 { |
| 1904 if (node) | 1881 if (node) |
| 1905 node->showNodePathForThis(); | 1882 node->showNodePathForThis(); |
| 1906 } | 1883 } |
| 1907 | 1884 |
| 1908 #endif | 1885 #endif |
| OLD | NEW |