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

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

Issue 2125683002: Add option to force document level passive event listeners as a runtime feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 options.setPassive(false); 192 options.setPassive(false);
193 return; 193 return;
194 } 194 }
195 195
196 if (LocalDOMWindow* executingWindow = this->executingWindow()) { 196 if (LocalDOMWindow* executingWindow = this->executingWindow()) {
197 if (options.hasPassive()) { 197 if (options.hasPassive()) {
198 UseCounter::count(executingWindow->document(), options.passive() ? U seCounter::AddEventListenerPassiveTrue : UseCounter::AddEventListenerPassiveFals e); 198 UseCounter::count(executingWindow->document(), options.passive() ? U seCounter::AddEventListenerPassiveTrue : UseCounter::AddEventListenerPassiveFals e);
199 } 199 }
200 } 200 }
201 201
202 if (RuntimeEnabledFeatures::passiveDocumentEventListenersEnabled()) {
203 if (!options.hasPassive()) {
204 if (Node* node = toNode()) {
205 if (node->isDocumentNode() || node->document().documentElement() == node || node->document().body() == node) {
206 options.setPassive(true);
207 return;
208 }
209 } else if (toLocalDOMWindow()) {
210 options.setPassive(true);
211 return;
212 }
213 }
214 }
215
202 if (Settings* settings = windowSettings(executingWindow())) { 216 if (Settings* settings = windowSettings(executingWindow())) {
203 switch (settings->passiveListenerDefault()) { 217 switch (settings->passiveListenerDefault()) {
204 case PassiveListenerDefault::False: 218 case PassiveListenerDefault::False:
205 if (!options.hasPassive()) 219 if (!options.hasPassive())
206 options.setPassive(false); 220 options.setPassive(false);
207 break; 221 break;
208 case PassiveListenerDefault::True: 222 case PassiveListenerDefault::True:
209 if (!options.hasPassive()) 223 if (!options.hasPassive())
210 options.setPassive(true); 224 options.setPassive(true);
211 break; 225 break;
212 case PassiveListenerDefault::ForceAllTrue: 226 case PassiveListenerDefault::ForceAllTrue:
213 options.setPassive(true); 227 options.setPassive(true);
214 break; 228 break;
215 case PassiveListenerDefault::DocumentTrue:
216 if (!options.hasPassive()) {
217 if (Node* node = toNode()) {
218 if (node->isDocumentNode() || node->document().documentEleme nt() == node || node->document().body() == node) {
219 options.setPassive(true);
220 }
221 } else if (toLocalDOMWindow()) {
222 options.setPassive(true);
223 }
224 }
225 break;
226 } 229 }
227 } else { 230 } else {
228 if (!options.hasPassive()) 231 if (!options.hasPassive())
229 options.setPassive(false); 232 options.setPassive(false);
230 } 233 }
231 } 234 }
232 235
233 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) 236 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
234 { 237 {
235 AddEventListenerOptions options; 238 AddEventListenerOptions options;
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 // they have one less listener to invoke. 651 // they have one less listener to invoke.
649 if (d->firingEventIterators) { 652 if (d->firingEventIterators) {
650 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 653 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
651 d->firingEventIterators->at(i).iterator = 0; 654 d->firingEventIterators->at(i).iterator = 0;
652 d->firingEventIterators->at(i).end = 0; 655 d->firingEventIterators->at(i).end = 0;
653 } 656 }
654 } 657 }
655 } 658 }
656 659
657 } // namespace blink 660 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698