Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2833733002: Avoid firing load events on style elements if there is no listeners for that (Closed)
Patch Set: fix style Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 } 1860 }
1861 1861
1862 void Node::DidMoveToNewDocument(Document& old_document) { 1862 void Node::DidMoveToNewDocument(Document& old_document) {
1863 TreeScopeAdopter::EnsureDidMoveToNewDocumentWasCalled(old_document); 1863 TreeScopeAdopter::EnsureDidMoveToNewDocumentWasCalled(old_document);
1864 1864
1865 if (const EventTargetData* event_target_data = this->GetEventTargetData()) { 1865 if (const EventTargetData* event_target_data = this->GetEventTargetData()) {
1866 const EventListenerMap& listener_map = 1866 const EventListenerMap& listener_map =
1867 event_target_data->event_listener_map; 1867 event_target_data->event_listener_map;
1868 if (!listener_map.IsEmpty()) { 1868 if (!listener_map.IsEmpty()) {
1869 for (const auto& type : listener_map.EventTypes()) 1869 for (const auto& type : listener_map.EventTypes())
1870 GetDocument().AddListenerTypeIfNeeded(type); 1870 GetDocument().AddListenerTypeIfNeeded(type, *this);
1871 } 1871 }
1872 } 1872 }
1873 1873
1874 old_document.Markers().RemoveMarkersForNode(this); 1874 old_document.Markers().RemoveMarkersForNode(this);
1875 if (GetDocument().GetPage() && 1875 if (GetDocument().GetPage() &&
1876 GetDocument().GetPage() != old_document.GetPage()) { 1876 GetDocument().GetPage() != old_document.GetPage()) {
1877 GetDocument().GetPage()->GetEventHandlerRegistry().DidMoveIntoPage(*this); 1877 GetDocument().GetPage()->GetEventHandlerRegistry().DidMoveIntoPage(*this);
1878 } 1878 }
1879 1879
1880 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>* 1880 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>*
1881 registry = MutationObserverRegistry()) { 1881 registry = MutationObserverRegistry()) {
1882 for (const auto& registration : *registry) { 1882 for (const auto& registration : *registry) {
1883 GetDocument().AddMutationObserverTypes(registration->MutationTypes()); 1883 GetDocument().AddMutationObserverTypes(registration->MutationTypes());
1884 } 1884 }
1885 } 1885 }
1886 1886
1887 if (TransientMutationObserverRegistry()) { 1887 if (TransientMutationObserverRegistry()) {
1888 for (MutationObserverRegistration* registration : 1888 for (MutationObserverRegistration* registration :
1889 *TransientMutationObserverRegistry()) 1889 *TransientMutationObserverRegistry())
1890 GetDocument().AddMutationObserverTypes(registration->MutationTypes()); 1890 GetDocument().AddMutationObserverTypes(registration->MutationTypes());
1891 } 1891 }
1892 } 1892 }
1893 1893
1894 void Node::AddedEventListener(const AtomicString& event_type, 1894 void Node::AddedEventListener(const AtomicString& event_type,
1895 RegisteredEventListener& registered_listener) { 1895 RegisteredEventListener& registered_listener) {
1896 EventTarget::AddedEventListener(event_type, registered_listener); 1896 EventTarget::AddedEventListener(event_type, registered_listener);
1897 GetDocument().AddListenerTypeIfNeeded(event_type); 1897 GetDocument().AddListenerTypeIfNeeded(event_type, *this);
1898 if (Page* page = GetDocument().GetPage()) 1898 if (Page* page = GetDocument().GetPage())
1899 page->GetEventHandlerRegistry().DidAddEventHandler( 1899 page->GetEventHandlerRegistry().DidAddEventHandler(
1900 *this, event_type, registered_listener.Options()); 1900 *this, event_type, registered_listener.Options());
1901 } 1901 }
1902 1902
1903 void Node::RemovedEventListener( 1903 void Node::RemovedEventListener(
1904 const AtomicString& event_type, 1904 const AtomicString& event_type,
1905 const RegisteredEventListener& registered_listener) { 1905 const RegisteredEventListener& registered_listener) {
1906 EventTarget::RemovedEventListener(event_type, registered_listener); 1906 EventTarget::RemovedEventListener(event_type, registered_listener);
1907 // FIXME: Notify Document that the listener has vanished. We need to keep 1907 // FIXME: Notify Document that the listener has vanished. We need to keep
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 if (node) { 2567 if (node) {
2568 std::stringstream stream; 2568 std::stringstream stream;
2569 node->PrintNodePathTo(stream); 2569 node->PrintNodePathTo(stream);
2570 LOG(INFO) << stream.str(); 2570 LOG(INFO) << stream.str();
2571 } else { 2571 } else {
2572 LOG(INFO) << "Cannot showNodePath for <null>"; 2572 LOG(INFO) << "Cannot showNodePath for <null>";
2573 } 2573 }
2574 } 2574 }
2575 2575
2576 #endif 2576 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698