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

Unified Diff: third_party/WebKit/Source/core/dom/Document.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 829e3b3faa55811409cef1770422e02e4a5a54e8..ca1ee1e1153cf75966e472cae99e65fc87446542 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -4593,7 +4593,8 @@ void Document::AddMutationEventListenerTypeIfEnabled(
AddListenerType(listener_type);
}
-void Document::AddListenerTypeIfNeeded(const AtomicString& event_type) {
+void Document::AddListenerTypeIfNeeded(const AtomicString& event_type,
+ EventTarget& event_target) {
if (event_type == EventTypeNames::DOMSubtreeModified) {
UseCounter::Count(*this, UseCounter::kDOMSubtreeModifiedEvent);
AddMutationEventListenerTypeIfEnabled(DOMSUBTREEMODIFIED_LISTENER);
@@ -4630,6 +4631,15 @@ void Document::AddListenerTypeIfNeeded(const AtomicString& event_type) {
AddListenerType(TRANSITIONEND_LISTENER);
} else if (event_type == EventTypeNames::scroll) {
AddListenerType(SCROLL_LISTENER);
+ } else if (event_type == EventTypeNames::load) {
+ if (Node* node = event_target.ToNode()) {
+ if (isHTMLStyleElement(*node)) {
+ AddListenerType(LOAD_LISTENER_AT_CAPTURE_PHASE_OR_AT_STYLE_ELEMENT);
+ return;
+ }
+ }
+ if (event_target.HasCapturingEventListeners(event_type))
+ AddListenerType(LOAD_LISTENER_AT_CAPTURE_PHASE_OR_AT_STYLE_ELEMENT);
}
}

Powered by Google App Engine
This is Rietveld 408576698