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

Unified Diff: third_party/WebKit/Source/core/html/HTMLStyleElement.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/html/HTMLStyleElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp b/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
index 349287aed4bc887a2a296dfffab347247ad03620..c2ca8114c9bde6d76d3d923334f2a3bf2b04989a 100644
--- a/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
@@ -107,9 +107,13 @@ const AtomicString& HTMLStyleElement::type() const {
void HTMLStyleElement::DispatchPendingEvent(
std::unique_ptr<IncrementLoadEventDelayCount> count) {
- DispatchEvent(Event::Create(loaded_sheet_ ? EventTypeNames::load
- : EventTypeNames::error));
-
+ if (loaded_sheet_) {
+ if (GetDocument().HasListenerType(
+ Document::LOAD_LISTENER_AT_CAPTURE_PHASE_OR_AT_STYLE_ELEMENT))
+ DispatchEvent(Event::Create(EventTypeNames::load));
+ } else {
+ DispatchEvent(Event::Create(EventTypeNames::error));
+ }
// Checks Document's load event synchronously here for performance.
// This is safe because dispatchPendingEvent() is called asynchronously.
count->ClearAndCheckLoadEvent();

Powered by Google App Engine
This is Rietveld 408576698