| OLD | NEW |
| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // TODO(dtapuska): Should we really do counting here for these events | 538 // TODO(dtapuska): Should we really do counting here for these events |
| 539 // if we really didn't fire a listener? For example having a bubbling | 539 // if we really didn't fire a listener? For example having a bubbling |
| 540 // listener on an event that doesn't bubble likely records a UMA | 540 // listener on an event that doesn't bubble likely records a UMA |
| 541 // metric where it probably shouldn't because it was never fired. | 541 // metric where it probably shouldn't because it was never fired. |
| 542 // See https://crbug.com/612829 | 542 // See https://crbug.com/612829 |
| 543 Editor::countEvent(getExecutionContext(), event); | 543 Editor::countEvent(getExecutionContext(), event); |
| 544 countLegacyEvents(legacyTypeName, listenersVector, legacyListenersVector); | 544 countLegacyEvents(legacyTypeName, listenersVector, legacyListenersVector); |
| 545 return dispatchEventResult(*event); | 545 return dispatchEventResult(*event); |
| 546 } | 546 } |
| 547 | 547 |
| 548 bool EventTarget::checkTypeThenUseCount( |
| 549 const Event* event, const AtomicString& eventTypeToCount, const UseCounter::
Feature feature) |
| 550 { |
| 551 if (event->type() == eventTypeToCount) { |
| 552 if (LocalDOMWindow* executingWindow = this->executingWindow()) |
| 553 UseCounter::count(executingWindow->document(), feature); |
| 554 return true; |
| 555 } |
| 556 return false; |
| 557 } |
| 558 |
| 548 bool EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
enerVector& entry) | 559 bool EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
enerVector& entry) |
| 549 { | 560 { |
| 550 // Fire all listeners registered for this event. Don't fire listeners remove
d | 561 // Fire all listeners registered for this event. Don't fire listeners remove
d |
| 551 // during event dispatch. Also, don't fire event listeners added during even
t | 562 // during event dispatch. Also, don't fire event listeners added during even
t |
| 552 // dispatch. Conveniently, all new event listeners will be added after or at | 563 // dispatch. Conveniently, all new event listeners will be added after or at |
| 553 // index |size|, so iterating up to (but not including) |size| naturally exc
ludes | 564 // index |size|, so iterating up to (but not including) |size| naturally exc
ludes |
| 554 // new event listeners. | 565 // new event listeners. |
| 555 // | |
| 556 // TODO(mustaq): This code needs to be refactored, crbug.com/629601 | |
| 557 | 566 |
| 558 if (event->type() == EventTypeNames::beforeunload) { | 567 if (checkTypeThenUseCount(event, EventTypeNames::beforeunload, UseCounter::D
ocumentBeforeUnloadFired)) { |
| 559 if (LocalDOMWindow* executingWindow = this->executingWindow()) { | 568 if (LocalDOMWindow* executingWindow = this->executingWindow()) { |
| 569 // TODO(mustaq): Is the |if| condition correct? crbug.com/635029 |
| 560 if (executingWindow->top()) | 570 if (executingWindow->top()) |
| 561 UseCounter::count(executingWindow->document(), UseCounter::SubFr
ameBeforeUnloadFired); | 571 UseCounter::count(executingWindow->document(), UseCounter::SubFr
ameBeforeUnloadFired); |
| 562 UseCounter::count(executingWindow->document(), UseCounter::DocumentB
eforeUnloadFired); | |
| 563 } | 572 } |
| 564 } else if (event->type() == EventTypeNames::unload) { | 573 } else if (checkTypeThenUseCount(event, EventTypeNames::unload, UseCounter::
DocumentUnloadFired)) { |
| 565 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 574 } else if (checkTypeThenUseCount(event, EventTypeNames::DOMFocusIn, UseCount
er::DOMFocusInOutEvent)) { |
| 566 UseCounter::count(executingWindow->document(), UseCounter::DocumentU
nloadFired); | 575 } else if (checkTypeThenUseCount(event, EventTypeNames::DOMFocusOut, UseCoun
ter::DOMFocusInOutEvent)) { |
| 567 } else if (event->type() == EventTypeNames::DOMFocusIn || event->type() == E
ventTypeNames::DOMFocusOut) { | 576 } else if (checkTypeThenUseCount(event, EventTypeNames::focusin, UseCounter:
:FocusInOutEvent)) { |
| 568 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 577 } else if (checkTypeThenUseCount(event, EventTypeNames::focusout, UseCounter
::FocusInOutEvent)) { |
| 569 UseCounter::count(executingWindow->document(), UseCounter::DOMFocusI
nOutEvent); | 578 } else if (checkTypeThenUseCount(event, EventTypeNames::textInput, UseCounte
r::TextInputFired)) { |
| 570 } else if (event->type() == EventTypeNames::focusin || event->type() == Even
tTypeNames::focusout) { | 579 } else if (checkTypeThenUseCount(event, EventTypeNames::touchstart, UseCount
er::TouchStartFired)) { |
| 571 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 580 } else if (checkTypeThenUseCount(event, EventTypeNames::mousedown, UseCounte
r::MouseDownFired)) { |
| 572 UseCounter::count(executingWindow->document(), UseCounter::FocusInOu
tEvent); | 581 } else if (checkTypeThenUseCount(event, EventTypeNames::pointerdown, UseCoun
ter::PointerDownFired)) { |
| 573 } else if (event->type() == EventTypeNames::textInput) { | |
| 574 if (LocalDOMWindow* executingWindow = this->executingWindow()) | |
| 575 UseCounter::count(executingWindow->document(), UseCounter::TextInput
Fired); | |
| 576 } else if (event->type() == EventTypeNames::touchstart) { | |
| 577 if (LocalDOMWindow* executingWindow = this->executingWindow()) | |
| 578 UseCounter::count(executingWindow->document(), UseCounter::TouchStar
tFired); | |
| 579 } else if (event->type() == EventTypeNames::mousedown) { | |
| 580 if (LocalDOMWindow* executingWindow = this->executingWindow()) | |
| 581 UseCounter::count(executingWindow->document(), UseCounter::MouseDown
Fired); | |
| 582 } else if (event->type() == EventTypeNames::pointerdown) { | |
| 583 if (LocalDOMWindow* executingWindow = this->executingWindow()) { | 582 if (LocalDOMWindow* executingWindow = this->executingWindow()) { |
| 584 if (event->isPointerEvent() && static_cast<PointerEvent*>(event)->po
interType() == "touch") | 583 if (static_cast<PointerEvent*>(event)->pointerType() == "touch") |
| 585 UseCounter::count(executingWindow->document(), UseCounter::Point
erDownFiredForTouch); | 584 UseCounter::count(executingWindow->document(), UseCounter::Point
erDownFiredForTouch); |
| 586 UseCounter::count(executingWindow->document(), UseCounter::PointerDo
wnFired); | |
| 587 } | 585 } |
| 588 } | 586 } |
| 589 | 587 |
| 590 ExecutionContext* context = getExecutionContext(); | 588 ExecutionContext* context = getExecutionContext(); |
| 591 if (!context) | 589 if (!context) |
| 592 return false; | 590 return false; |
| 593 | 591 |
| 594 size_t i = 0; | 592 size_t i = 0; |
| 595 size_t size = entry.size(); | 593 size_t size = entry.size(); |
| 596 if (!d->firingEventIterators) | 594 if (!d->firingEventIterators) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 // they have one less listener to invoke. | 692 // they have one less listener to invoke. |
| 695 if (d->firingEventIterators) { | 693 if (d->firingEventIterators) { |
| 696 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 694 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 697 d->firingEventIterators->at(i).iterator = 0; | 695 d->firingEventIterators->at(i).iterator = 0; |
| 698 d->firingEventIterators->at(i).end = 0; | 696 d->firingEventIterators->at(i).end = 0; |
| 699 } | 697 } |
| 700 } | 698 } |
| 701 } | 699 } |
| 702 | 700 |
| 703 } // namespace blink | 701 } // namespace blink |
| OLD | NEW |