Chromium Code Reviews| 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()) { |
| 560 if (executingWindow->top()) | 569 if (executingWindow->top()) |
|
bokan
2016/08/05 15:34:25
I know you didn't add this but I think this is wro
| |
| 561 UseCounter::count(executingWindow->document(), UseCounter::SubFr ameBeforeUnloadFired); | 570 UseCounter::count(executingWindow->document(), UseCounter::SubFr ameBeforeUnloadFired); |
| 562 UseCounter::count(executingWindow->document(), UseCounter::DocumentB eforeUnloadFired); | |
| 563 } | 571 } |
| 564 } else if (event->type() == EventTypeNames::unload) { | 572 } else if (checkTypeThenUseCount(event, EventTypeNames::unload, UseCounter:: DocumentUnloadFired)) { |
| 565 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 573 } else if (checkTypeThenUseCount(event, EventTypeNames::DOMFocusIn, UseCount er::DOMFocusInOutEvent)) { |
| 566 UseCounter::count(executingWindow->document(), UseCounter::DocumentU nloadFired); | 574 } else if (checkTypeThenUseCount(event, EventTypeNames::DOMFocusOut, UseCoun ter::DOMFocusInOutEvent)) { |
| 567 } else if (event->type() == EventTypeNames::DOMFocusIn || event->type() == E ventTypeNames::DOMFocusOut) { | 575 } else if (checkTypeThenUseCount(event, EventTypeNames::focusin, UseCounter: :FocusInOutEvent)) { |
| 568 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 576 } else if (checkTypeThenUseCount(event, EventTypeNames::focusout, UseCounter ::FocusInOutEvent)) { |
| 569 UseCounter::count(executingWindow->document(), UseCounter::DOMFocusI nOutEvent); | 577 } else if (checkTypeThenUseCount(event, EventTypeNames::textInput, UseCounte r::TextInputFired)) { |
| 570 } else if (event->type() == EventTypeNames::focusin || event->type() == Even tTypeNames::focusout) { | 578 } else if (checkTypeThenUseCount(event, EventTypeNames::touchstart, UseCount er::TouchStartFired)) { |
| 571 if (LocalDOMWindow* executingWindow = this->executingWindow()) | 579 } else if (checkTypeThenUseCount(event, EventTypeNames::mousedown, UseCounte r::MouseDownFired)) { |
| 572 UseCounter::count(executingWindow->document(), UseCounter::FocusInOu tEvent); | 580 } 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()) { | 581 if (LocalDOMWindow* executingWindow = this->executingWindow()) { |
| 584 if (event->isPointerEvent() && static_cast<PointerEvent*>(event)->po interType() == "touch") | 582 if (static_cast<PointerEvent*>(event)->pointerType() == "touch") |
| 585 UseCounter::count(executingWindow->document(), UseCounter::Point erDownFiredForTouch); | 583 UseCounter::count(executingWindow->document(), UseCounter::Point erDownFiredForTouch); |
| 586 UseCounter::count(executingWindow->document(), UseCounter::PointerDo wnFired); | |
| 587 } | 584 } |
| 588 } | 585 } |
| 589 | 586 |
| 590 ExecutionContext* context = getExecutionContext(); | 587 ExecutionContext* context = getExecutionContext(); |
| 591 if (!context) | 588 if (!context) |
| 592 return false; | 589 return false; |
| 593 | 590 |
| 594 size_t i = 0; | 591 size_t i = 0; |
| 595 size_t size = entry.size(); | 592 size_t size = entry.size(); |
| 596 if (!d->firingEventIterators) | 593 if (!d->firingEventIterators) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 // they have one less listener to invoke. | 691 // they have one less listener to invoke. |
| 695 if (d->firingEventIterators) { | 692 if (d->firingEventIterators) { |
| 696 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 693 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 697 d->firingEventIterators->at(i).iterator = 0; | 694 d->firingEventIterators->at(i).iterator = 0; |
| 698 d->firingEventIterators->at(i).end = 0; | 695 d->firingEventIterators->at(i).end = 0; |
| 699 } | 696 } |
| 700 } | 697 } |
| 701 } | 698 } |
| 702 | 699 |
| 703 } // namespace blink | 700 } // namespace blink |
| OLD | NEW |