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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSourceElement.cpp

Issue 2480523003: Remove EventSender from HTMLSourceElement (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSourceElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/html/HTMLSourceElement.h" 26 #include "core/html/HTMLSourceElement.h"
27 27
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/css/MediaList.h" 29 #include "core/css/MediaList.h"
30 #include "core/css/MediaQueryList.h" 30 #include "core/css/MediaQueryList.h"
31 #include "core/css/MediaQueryMatcher.h" 31 #include "core/css/MediaQueryMatcher.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/TaskRunnerHelper.h"
33 #include "core/events/Event.h" 34 #include "core/events/Event.h"
34 #include "core/events/EventSender.h"
35 #include "core/html/HTMLMediaElement.h" 35 #include "core/html/HTMLMediaElement.h"
36 #include "core/html/HTMLPictureElement.h" 36 #include "core/html/HTMLPictureElement.h"
37 37
38 #define SOURCE_LOG_LEVEL 3 38 #define SOURCE_LOG_LEVEL 3
39 39
40 namespace blink { 40 namespace blink {
41 41
42 using namespace HTMLNames; 42 using namespace HTMLNames;
43 43
44 static SourceEventSender& sourceErrorEventSender() {
45 DEFINE_STATIC_LOCAL(SourceEventSender, sharedErrorEventSender,
46 (SourceEventSender::create(EventTypeNames::error)));
47 return sharedErrorEventSender;
48 }
49
50 class HTMLSourceElement::Listener final : public MediaQueryListListener { 44 class HTMLSourceElement::Listener final : public MediaQueryListListener {
51 public: 45 public:
52 explicit Listener(HTMLSourceElement* element) : m_element(element) {} 46 explicit Listener(HTMLSourceElement* element) : m_element(element) {}
53 void notifyMediaQueryChanged() override { 47 void notifyMediaQueryChanged() override {
54 if (m_element) 48 if (m_element)
55 m_element->notifyMediaQueryChanged(); 49 m_element->notifyMediaQueryChanged();
56 } 50 }
57 51
58 void clearElement() { m_element = nullptr; } 52 void clearElement() { m_element = nullptr; }
59 DEFINE_INLINE_VIRTUAL_TRACE() { 53 DEFINE_INLINE_VIRTUAL_TRACE() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const AtomicString& HTMLSourceElement::type() const { 127 const AtomicString& HTMLSourceElement::type() const {
134 return getAttribute(typeAttr); 128 return getAttribute(typeAttr);
135 } 129 }
136 130
137 void HTMLSourceElement::setType(const AtomicString& type) { 131 void HTMLSourceElement::setType(const AtomicString& type) {
138 setAttribute(typeAttr, type); 132 setAttribute(typeAttr, type);
139 } 133 }
140 134
141 void HTMLSourceElement::scheduleErrorEvent() { 135 void HTMLSourceElement::scheduleErrorEvent() {
142 DVLOG(SOURCE_LOG_LEVEL) << "scheduleErrorEvent - " << (void*)this; 136 DVLOG(SOURCE_LOG_LEVEL) << "scheduleErrorEvent - " << (void*)this;
143 sourceErrorEventSender().dispatchEventSoon(this); 137
138 m_pendingErrorEvent =
139 TaskRunnerHelper::get(TaskType::DOMManipulation, &document())
140 ->postCancellableTask(
141 BLINK_FROM_HERE,
142 WTF::bind(&HTMLSourceElement::dispatchPendingEvent,
143 wrapPersistent(this)));
144 } 144 }
145 145
146 void HTMLSourceElement::cancelPendingErrorEvent() { 146 void HTMLSourceElement::cancelPendingErrorEvent() {
147 DVLOG(SOURCE_LOG_LEVEL) << "cancelPendingErrorEvent - " << (void*)this; 147 DVLOG(SOURCE_LOG_LEVEL) << "cancelPendingErrorEvent - " << (void*)this;
148 sourceErrorEventSender().cancelEvent(this); 148 m_pendingErrorEvent.cancel();
149 } 149 }
150 150
151 void HTMLSourceElement::dispatchPendingEvent(SourceEventSender* eventSender) { 151 void HTMLSourceElement::dispatchPendingEvent() {
152 DCHECK_EQ(eventSender, &sourceErrorEventSender());
153 DVLOG(SOURCE_LOG_LEVEL) << "dispatchPendingEvent - " << (void*)this; 152 DVLOG(SOURCE_LOG_LEVEL) << "dispatchPendingEvent - " << (void*)this;
154 dispatchEvent(Event::createCancelable(EventTypeNames::error)); 153 dispatchEvent(Event::createCancelable(EventTypeNames::error));
155 } 154 }
156 155
157 bool HTMLSourceElement::mediaQueryMatches() const { 156 bool HTMLSourceElement::mediaQueryMatches() const {
158 if (!m_mediaQueryList) 157 if (!m_mediaQueryList)
159 return true; 158 return true;
160 159
161 return m_mediaQueryList->matches(); 160 return m_mediaQueryList->matches();
162 } 161 }
(...skipping 22 matching lines...) Expand all
185 toHTMLPictureElement(parent)->sourceOrMediaChanged(); 184 toHTMLPictureElement(parent)->sourceOrMediaChanged();
186 } 185 }
187 186
188 DEFINE_TRACE(HTMLSourceElement) { 187 DEFINE_TRACE(HTMLSourceElement) {
189 visitor->trace(m_mediaQueryList); 188 visitor->trace(m_mediaQueryList);
190 visitor->trace(m_listener); 189 visitor->trace(m_listener);
191 HTMLElement::trace(visitor); 190 HTMLElement::trace(visitor);
192 } 191 }
193 192
194 } // namespace blink 193 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSourceElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698