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

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

Issue 2030243004: Set Event.composed flag correctly for some of UA UIEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Created 4 years, 6 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) 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
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 isScoped(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
54 Event::Event() 37 Event::Event()
55 : Event("", false, false) 38 : Event("", false, false)
56 { 39 {
57 m_wasInitialized = false; 40 m_wasInitialized = false;
58 } 41 }
59 42
60 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g) 43 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, double platformTimeStamp)
61 : Event(eventType, canBubbleArg, cancelableArg, !isScoped(eventType), monoto nicallyIncreasingTime()) 44 : Event(eventType, canBubbleArg, cancelableArg, ComposedMode::Scoped, platfo rmTimeStamp)
62 { 45 {
63 } 46 }
64 47
65 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, double platformTimeStamp) 48 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode)
66 : Event(eventType, canBubbleArg, cancelableArg, !isScoped(eventType), platfo rmTimeStamp) 49 : Event(eventType, canBubbleArg, cancelableArg, composedMode, monotonicallyI ncreasingTime())
67 { 50 {
68 } 51 }
69 52
70 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, bool composed, double platformTimeStamp) 53 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode, double platformTimeStamp)
71 : m_type(eventType) 54 : m_type(eventType)
72 , m_canBubble(canBubbleArg) 55 , m_canBubble(canBubbleArg)
73 , m_cancelable(cancelableArg) 56 , m_cancelable(cancelableArg)
74 , m_composed(composed) 57 , m_composed(composedMode == ComposedMode::Composed)
75 , m_propagationStopped(false) 58 , m_propagationStopped(false)
76 , m_immediatePropagationStopped(false) 59 , m_immediatePropagationStopped(false)
77 , m_defaultPrevented(false) 60 , m_defaultPrevented(false)
78 , m_defaultHandled(false) 61 , m_defaultHandled(false)
79 , m_cancelBubble(false) 62 , m_cancelBubble(false)
80 , m_wasInitialized(true) 63 , m_wasInitialized(true)
81 , m_isTrusted(false) 64 , m_isTrusted(false)
82 , m_handlingPassive(false) 65 , m_handlingPassive(false)
83 , m_eventPhase(0) 66 , m_eventPhase(0)
84 , m_currentTarget(nullptr) 67 , m_currentTarget(nullptr)
85 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) 68 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
86 , m_platformTimeStamp(platformTimeStamp) 69 , m_platformTimeStamp(platformTimeStamp)
87 { 70 {
88 } 71 }
89 72
90 Event::Event(const AtomicString& eventType, const EventInit& initializer) 73 Event::Event(const AtomicString& eventType, const EventInit& initializer)
91 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali zer.composed(), monotonicallyIncreasingTime()) 74 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali zer.composed() ? ComposedMode::Composed : ComposedMode::Scoped, monotonicallyInc reasingTime())
92 { 75 {
93 } 76 }
94 77
95 Event::~Event() 78 Event::~Event()
96 { 79 {
97 } 80 }
98 81
99 bool Event::isScopedInV0() const 82 bool Event::isScopedInV0() const
100 { 83 {
101 return isTrusted() && isScoped(m_type); 84 // WebKit never allowed selectstart event to cross the the shadow DOM bounda ry.
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);
102 } 98 }
103 99
104 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg) 100 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg)
105 { 101 {
106 initEvent(eventTypeArg, canBubbleArg, cancelableArg, nullptr); 102 initEvent(eventTypeArg, canBubbleArg, cancelableArg, nullptr);
107 } 103 }
108 104
109 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget) 105 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget)
110 { 106 {
111 if (isBeingDispatched()) 107 if (isBeingDispatched())
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 355
360 DEFINE_TRACE(Event) 356 DEFINE_TRACE(Event)
361 { 357 {
362 visitor->trace(m_currentTarget); 358 visitor->trace(m_currentTarget);
363 visitor->trace(m_target); 359 visitor->trace(m_target);
364 visitor->trace(m_underlyingEvent); 360 visitor->trace(m_underlyingEvent);
365 visitor->trace(m_eventPath); 361 visitor->trace(m_eventPath);
366 } 362 }
367 363
368 } // namespace blink 364 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | third_party/WebKit/Source/core/events/FocusEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698