| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "core/events/EventTarget.h" | 27 #include "core/events/EventTarget.h" |
| 28 #include "core/frame/HostsUsingFeatures.h" | 28 #include "core/frame/HostsUsingFeatures.h" |
| 29 #include "core/frame/UseCounter.h" | 29 #include "core/frame/UseCounter.h" |
| 30 #include "core/svg/SVGElement.h" | 30 #include "core/svg/SVGElement.h" |
| 31 #include "core/timing/DOMWindowPerformance.h" | 31 #include "core/timing/DOMWindowPerformance.h" |
| 32 #include "core/timing/Performance.h" | 32 #include "core/timing/Performance.h" |
| 33 #include "wtf/CurrentTime.h" | 33 #include "wtf/CurrentTime.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 static bool isEventTypeScopedInV0(const AtomicString& eventType) |
| 38 { |
| 39 // WebKit never allowed selectstart event to cross the the shadow DOM bounda
ry. |
| 40 // Changing this breaks existing sites. |
| 41 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. |
| 42 return eventType == EventTypeNames::abort |
| 43 || eventType == EventTypeNames::change |
| 44 || eventType == EventTypeNames::error |
| 45 || eventType == EventTypeNames::load |
| 46 || eventType == EventTypeNames::reset |
| 47 || eventType == EventTypeNames::resize |
| 48 || eventType == EventTypeNames::scroll |
| 49 || eventType == EventTypeNames::select |
| 50 || eventType == EventTypeNames::selectstart |
| 51 || eventType == EventTypeNames::slotchange; |
| 52 } |
| 53 |
| 37 Event::Event() | 54 Event::Event() |
| 38 : Event("", false, false) | 55 : Event("", false, false) |
| 39 { | 56 { |
| 40 m_wasInitialized = false; | 57 m_wasInitialized = false; |
| 41 } | 58 } |
| 42 | 59 |
| 43 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, double platformTimeStamp) | 60 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, double platformTimeStamp) |
| 44 : Event(eventType, canBubbleArg, cancelableArg, ComposedMode::Scoped, platfo
rmTimeStamp) | 61 : Event(eventType, canBubbleArg, cancelableArg, ComposedMode::Scoped, platfo
rmTimeStamp) |
| 45 { | 62 { |
| 46 } | 63 } |
| 47 | 64 |
| 48 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, ComposedMode composedMode) | 65 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, ComposedMode composedMode) |
| 49 : Event(eventType, canBubbleArg, cancelableArg, composedMode, monotonicallyI
ncreasingTime()) | 66 : Event(eventType, canBubbleArg, cancelableArg, composedMode, monotonicallyI
ncreasingTime()) |
| 50 { | 67 { |
| 51 } | 68 } |
| 52 | 69 |
| 53 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, ComposedMode composedMode, double platformTimeStamp) | 70 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
g, ComposedMode composedMode, double platformTimeStamp) |
| 54 : m_type(eventType) | 71 : m_type(eventType) |
| 55 , m_canBubble(canBubbleArg) | 72 , m_canBubble(canBubbleArg) |
| 56 , m_cancelable(cancelableArg) | 73 , m_cancelable(cancelableArg) |
| 57 , m_composed(composedMode == ComposedMode::Composed) | 74 , m_composed(composedMode == ComposedMode::Composed) |
| 75 , m_isEventTypeScopedInV0(isEventTypeScopedInV0(eventType)) |
| 58 , m_propagationStopped(false) | 76 , m_propagationStopped(false) |
| 59 , m_immediatePropagationStopped(false) | 77 , m_immediatePropagationStopped(false) |
| 60 , m_defaultPrevented(false) | 78 , m_defaultPrevented(false) |
| 61 , m_defaultHandled(false) | 79 , m_defaultHandled(false) |
| 62 , m_cancelBubble(false) | 80 , m_cancelBubble(false) |
| 63 , m_wasInitialized(true) | 81 , m_wasInitialized(true) |
| 64 , m_isTrusted(false) | 82 , m_isTrusted(false) |
| 65 , m_handlingPassive(false) | 83 , m_handlingPassive(false) |
| 66 , m_eventPhase(0) | 84 , m_eventPhase(0) |
| 67 , m_currentTarget(nullptr) | 85 , m_currentTarget(nullptr) |
| 68 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) | 86 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) |
| 69 , m_platformTimeStamp(platformTimeStamp) | 87 , m_platformTimeStamp(platformTimeStamp) |
| 70 { | 88 { |
| 71 } | 89 } |
| 72 | 90 |
| 73 Event::Event(const AtomicString& eventType, const EventInit& initializer) | 91 Event::Event(const AtomicString& eventType, const EventInit& initializer) |
| 74 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali
zer.composed() ? ComposedMode::Composed : ComposedMode::Scoped, monotonicallyInc
reasingTime()) | 92 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali
zer.composed() ? ComposedMode::Composed : ComposedMode::Scoped, monotonicallyInc
reasingTime()) |
| 75 { | 93 { |
| 76 } | 94 } |
| 77 | 95 |
| 78 Event::~Event() | 96 Event::~Event() |
| 79 { | 97 { |
| 80 } | 98 } |
| 81 | 99 |
| 82 bool Event::isScopedInV0() const | 100 bool Event::isScopedInV0() const |
| 83 { | 101 { |
| 84 // WebKit never allowed selectstart event to cross the the shadow DOM bounda
ry. | 102 return isTrusted() && m_isEventTypeScopedInV0; |
| 85 // Changing this breaks existing sites. | |
| 86 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. | |
| 87 return isTrusted() | |
| 88 && (m_type == EventTypeNames::abort | |
| 89 || m_type == EventTypeNames::change | |
| 90 || m_type == EventTypeNames::error | |
| 91 || m_type == EventTypeNames::load | |
| 92 || m_type == EventTypeNames::reset | |
| 93 || m_type == EventTypeNames::resize | |
| 94 || m_type == EventTypeNames::scroll | |
| 95 || m_type == EventTypeNames::select | |
| 96 || m_type == EventTypeNames::selectstart | |
| 97 || m_type == EventTypeNames::slotchange); | |
| 98 } | 103 } |
| 99 | 104 |
| 100 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
cancelableArg) | 105 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
cancelableArg) |
| 101 { | 106 { |
| 102 initEvent(eventTypeArg, canBubbleArg, cancelableArg, nullptr); | 107 initEvent(eventTypeArg, canBubbleArg, cancelableArg, nullptr); |
| 103 } | 108 } |
| 104 | 109 |
| 105 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
cancelableArg, EventTarget* relatedTarget) | 110 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
cancelableArg, EventTarget* relatedTarget) |
| 106 { | 111 { |
| 107 if (isBeingDispatched()) | 112 if (isBeingDispatched()) |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 360 |
| 356 DEFINE_TRACE(Event) | 361 DEFINE_TRACE(Event) |
| 357 { | 362 { |
| 358 visitor->trace(m_currentTarget); | 363 visitor->trace(m_currentTarget); |
| 359 visitor->trace(m_target); | 364 visitor->trace(m_target); |
| 360 visitor->trace(m_underlyingEvent); | 365 visitor->trace(m_underlyingEvent); |
| 361 visitor->trace(m_eventPath); | 366 visitor->trace(m_eventPath); |
| 362 } | 367 } |
| 363 | 368 |
| 364 } // namespace blink | 369 } // namespace blink |
| OLD | NEW |