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

Side by Side 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, 7 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) 2003, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved.
6 * (C) 2007 Rob Buis (buis@kde.org) 6 * (C) 2007 Rob Buis (buis@kde.org)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const AtomicString& HTMLStyleElement::media() const { 100 const AtomicString& HTMLStyleElement::media() const {
101 return getAttribute(mediaAttr); 101 return getAttribute(mediaAttr);
102 } 102 }
103 103
104 const AtomicString& HTMLStyleElement::type() const { 104 const AtomicString& HTMLStyleElement::type() const {
105 return getAttribute(typeAttr); 105 return getAttribute(typeAttr);
106 } 106 }
107 107
108 void HTMLStyleElement::DispatchPendingEvent( 108 void HTMLStyleElement::DispatchPendingEvent(
109 std::unique_ptr<IncrementLoadEventDelayCount> count) { 109 std::unique_ptr<IncrementLoadEventDelayCount> count) {
110 DispatchEvent(Event::Create(loaded_sheet_ ? EventTypeNames::load 110 if (loaded_sheet_) {
111 : EventTypeNames::error)); 111 if (GetDocument().HasListenerType(
112 112 Document::LOAD_LISTENER_AT_CAPTURE_PHASE_OR_AT_STYLE_ELEMENT))
113 DispatchEvent(Event::Create(EventTypeNames::load));
114 } else {
115 DispatchEvent(Event::Create(EventTypeNames::error));
116 }
113 // Checks Document's load event synchronously here for performance. 117 // Checks Document's load event synchronously here for performance.
114 // This is safe because dispatchPendingEvent() is called asynchronously. 118 // This is safe because dispatchPendingEvent() is called asynchronously.
115 count->ClearAndCheckLoadEvent(); 119 count->ClearAndCheckLoadEvent();
116 } 120 }
117 121
118 void HTMLStyleElement::NotifyLoadedSheetAndAllCriticalSubresources( 122 void HTMLStyleElement::NotifyLoadedSheetAndAllCriticalSubresources(
119 LoadedSheetErrorStatus error_status) { 123 LoadedSheetErrorStatus error_status) {
120 bool is_load_event = error_status == kNoErrorLoadingSubresource; 124 bool is_load_event = error_status == kNoErrorLoadingSubresource;
121 if (fired_load_ && is_load_event) 125 if (fired_load_ && is_load_event)
122 return; 126 return;
(...skipping 18 matching lines...) Expand all
141 if (CSSStyleSheet* style_sheet = sheet()) 145 if (CSSStyleSheet* style_sheet = sheet())
142 style_sheet->setDisabled(set_disabled); 146 style_sheet->setDisabled(set_disabled);
143 } 147 }
144 148
145 DEFINE_TRACE(HTMLStyleElement) { 149 DEFINE_TRACE(HTMLStyleElement) {
146 StyleElement::Trace(visitor); 150 StyleElement::Trace(visitor);
147 HTMLElement::Trace(visitor); 151 HTMLElement::Trace(visitor);
148 } 152 }
149 153
150 } // namespace blink 154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698