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

Side by Side Diff: third_party/WebKit/Source/core/events/EventTarget.cpp

Issue 1922093003: Add AddEventListenerOptions addEventListenerOptions interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "wtf/Vector.h" 45 #include "wtf/Vector.h"
46 46
47 using namespace WTF; 47 using namespace WTF;
48 48
49 namespace blink { 49 namespace blink {
50 namespace { 50 namespace {
51 51
52 void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool us eCapture) 52 void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool us eCapture)
53 { 53 {
54 options.setCapture(useCapture); 54 options.setCapture(useCapture);
55 }
56
57 void setDefaultAddEventListenerOptionsLegacy(AddEventListenerOptions& options, b ool useCapture)
58 {
59 setDefaultEventListenerOptionsLegacy(options, useCapture);
55 options.setPassive(false); 60 options.setPassive(false);
56 } 61 }
57 62
58 void setDefaultEventListenerOptions(EventListenerOptions& options) 63 void setDefaultEventListenerOptions(EventListenerOptions& options)
59 { 64 {
60 // The default for capture is based on whether the eventListenerOptions 65 // The default for capture is based on whether the eventListenerOptions
61 // runtime setting is enabled. That is 66 // runtime setting is enabled. That is
62 // addEventListener('type', function(e) {}, {}); 67 // addEventListener('type', function(e) {}, {});
63 // behaves differently under the setting. With the setting off 68 // behaves differently under the setting. With the setting off
64 // capture is true; with the setting on capture is false. 69 // capture is true; with the setting on capture is false.
65 if (!options.hasCapture()) 70 if (!options.hasCapture())
66 options.setCapture(!RuntimeEnabledFeatures::eventListenerOptionsEnabled( )); 71 options.setCapture(!RuntimeEnabledFeatures::eventListenerOptionsEnabled( ));
72 }
73
74 void setDefaultAddEventListenerOptions(AddEventListenerOptions& options)
75 {
76 setDefaultEventListenerOptions(options);
67 if (!options.hasPassive()) 77 if (!options.hasPassive())
68 options.setPassive(false); 78 options.setPassive(false);
69 } 79 }
70 80
71 } // namespace 81 } // namespace
72 82
73 EventTargetData::EventTargetData() 83 EventTargetData::EventTargetData()
74 { 84 {
75 } 85 }
76 86
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 128
119 inline LocalDOMWindow* EventTarget::executingWindow() 129 inline LocalDOMWindow* EventTarget::executingWindow()
120 { 130 {
121 if (ExecutionContext* context = getExecutionContext()) 131 if (ExecutionContext* context = getExecutionContext())
122 return context->executingWindow(); 132 return context->executingWindow();
123 return nullptr; 133 return nullptr;
124 } 134 }
125 135
126 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) 136 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
127 { 137 {
128 EventListenerOptions options; 138 AddEventListenerOptions options;
129 setDefaultEventListenerOptionsLegacy(options, useCapture); 139 setDefaultAddEventListenerOptionsLegacy(options, useCapture);
130 return addEventListenerInternal(eventType, listener, options); 140 return addEventListenerInternal(eventType, listener, options);
131 } 141 }
132 142
133 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, const EventListenerOptionsOrBoolean& optionsUnion) 143 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptionsOrBoolean& optionsUnion)
134 { 144 {
135 if (optionsUnion.isBoolean()) 145 if (optionsUnion.isBoolean())
136 return addEventListener(eventType, listener, optionsUnion.getAsBoolean() ); 146 return addEventListener(eventType, listener, optionsUnion.getAsBoolean() );
137 if (optionsUnion.isEventListenerOptions()) { 147 if (optionsUnion.isAddEventListenerOptions()) {
138 EventListenerOptions options = optionsUnion.getAsEventListenerOptions(); 148 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti ons();
139 return addEventListener(eventType, listener, options); 149 return addEventListener(eventType, listener, options);
140 } 150 }
141 return addEventListener(eventType, listener); 151 return addEventListener(eventType, listener);
142 } 152 }
143 153
144 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, EventListenerOptions& options) 154 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, AddEventListenerOptions& options)
145 { 155 {
146 setDefaultEventListenerOptions(options); 156 setDefaultAddEventListenerOptions(options);
147 return addEventListenerInternal(eventType, listener, options); 157 return addEventListenerInternal(eventType, listener, options);
148 } 158 }
149 159
150 bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventL istener* listener, const EventListenerOptions& options) 160 bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventL istener* listener, const AddEventListenerOptions& options)
151 { 161 {
152 if (!listener) 162 if (!listener)
153 return false; 163 return false;
154 164
155 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 165 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
156 if (activityLogger) { 166 if (activityLogger) {
157 Vector<String> argv; 167 Vector<String> argv;
158 argv.append(toNode() ? toNode()->nodeName() : interfaceName()); 168 argv.append(toNode() ? toNode()->nodeName() : interfaceName());
159 argv.append(eventType); 169 argv.append(eventType);
160 activityLogger->logEvent("blinkAddEventListener", argv.size(), argv.data ()); 170 activityLogger->logEvent("blinkAddEventListener", argv.size(), argv.data ());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // they have one less listener to invoke. 514 // they have one less listener to invoke.
505 if (d->firingEventIterators) { 515 if (d->firingEventIterators) {
506 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 516 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
507 d->firingEventIterators->at(i).iterator = 0; 517 d->firingEventIterators->at(i).iterator = 0;
508 d->firingEventIterators->at(i).end = 0; 518 d->firingEventIterators->at(i).end = 0;
509 } 519 }
510 } 520 }
511 } 521 }
512 522
513 } // namespace blink 523 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.h ('k') | third_party/WebKit/Source/core/events/EventTarget.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698