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

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

Issue 1563623002: Support registering and dispatching passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust comments in layout tests Created 4 years, 11 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 options.setPassive(false);
55 } 56 }
56 57
57 void setDefaultEventListenerOptions(EventListenerOptions& options) 58 void setDefaultEventListenerOptions(EventListenerOptions& options)
58 { 59 {
59 // The default for capture is based on whether the eventListenerOptions 60 // The default for capture is based on whether the eventListenerOptions
60 // runtime setting is enabled. That is 61 // runtime setting is enabled. That is
61 // addEventListener('type', function(e) {}, {}); 62 // addEventListener('type', function(e) {}, {});
62 // behaves differently under the setting. With the setting off 63 // behaves differently under the setting. With the setting off
63 // capture is true; with the setting on capture is false. 64 // capture is true; with the setting on capture is false.
64 if (!options.hasCapture()) 65 if (!options.hasCapture())
65 options.setCapture(!RuntimeEnabledFeatures::eventListenerOptionsEnabled( )); 66 options.setCapture(!RuntimeEnabledFeatures::eventListenerOptionsEnabled( ));
67 if (!options.hasPassive())
68 options.setPassive(false);
66 } 69 }
67 70
68 } // namespace 71 } // namespace
69 72
70 EventTargetData::EventTargetData() 73 EventTargetData::EventTargetData()
71 { 74 {
72 } 75 }
73 76
74 EventTargetData::~EventTargetData() 77 EventTargetData::~EventTargetData()
75 { 78 {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 424
422 // If stopImmediatePropagation has been called, we just break out immedi ately, without 425 // If stopImmediatePropagation has been called, we just break out immedi ately, without
423 // handling any more events on this target. 426 // handling any more events on this target.
424 if (event->immediatePropagationStopped()) 427 if (event->immediatePropagationStopped())
425 break; 428 break;
426 429
427 ExecutionContext* context = executionContext(); 430 ExecutionContext* context = executionContext();
428 if (!context) 431 if (!context)
429 break; 432 break;
430 433
434 event->setHandlingPassive(registeredListener.passive);
435
431 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa ndleEvent(this, event, registeredListener.listener.get(), registeredListener.use Capture); 436 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa ndleEvent(this, event, registeredListener.listener.get(), registeredListener.use Capture);
432 437
433 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli ng 438 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli ng
434 // event listeners, even though that violates some versions of the DOM s pec. 439 // event listeners, even though that violates some versions of the DOM s pec.
435 registeredListener.listener->handleEvent(context, event); 440 registeredListener.listener->handleEvent(context, event);
441 event->setHandlingPassive(false);
442
436 RELEASE_ASSERT(i <= size); 443 RELEASE_ASSERT(i <= size);
437 444
438 InspectorInstrumentation::didHandleEvent(cookie); 445 InspectorInstrumentation::didHandleEvent(cookie);
439 } 446 }
440 d->firingEventIterators->removeLast(); 447 d->firingEventIterators->removeLast();
441 } 448 }
442 449
443 EventListenerVector* EventTarget::getEventListeners(const AtomicString& eventTyp e) 450 EventListenerVector* EventTarget::getEventListeners(const AtomicString& eventTyp e)
444 { 451 {
445 EventTargetData* data = eventTargetData(); 452 EventTargetData* data = eventTargetData();
(...skipping 19 matching lines...) Expand all
465 // they have one less listener to invoke. 472 // they have one less listener to invoke.
466 if (d->firingEventIterators) { 473 if (d->firingEventIterators) {
467 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 474 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
468 d->firingEventIterators->at(i).iterator = 0; 475 d->firingEventIterators->at(i).iterator = 0;
469 d->firingEventIterators->at(i).end = 0; 476 d->firingEventIterators->at(i).end = 0;
470 } 477 }
471 } 478 }
472 } 479 }
473 480
474 } // namespace blink 481 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698