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 14 matching lines...) Expand all Loading... | |
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 * | 29 * |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "core/events/EventTarget.h" | 33 #include "core/events/EventTarget.h" |
34 | 34 |
35 #include "EventTypeNames.h" | |
36 #include "HTMLNames.h" | |
35 #include "RuntimeEnabledFeatures.h" | 37 #include "RuntimeEnabledFeatures.h" |
36 #include "bindings/v8/ExceptionState.h" | 38 #include "bindings/v8/ExceptionState.h" |
37 #include "core/dom/ExceptionCode.h" | 39 #include "core/dom/ExceptionCode.h" |
38 #include "core/dom/NoEventDispatchAssertion.h" | 40 #include "core/dom/NoEventDispatchAssertion.h" |
39 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
40 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
41 #include "core/frame/DOMWindow.h" | 43 #include "core/frame/DOMWindow.h" |
44 #include "core/frame/UseCounter.h" | |
42 #include "wtf/StdLibExtras.h" | 45 #include "wtf/StdLibExtras.h" |
43 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
44 | 47 |
45 using namespace WTF; | 48 using namespace WTF; |
46 | 49 |
47 namespace WebCore { | 50 namespace WebCore { |
48 | 51 |
49 EventTargetData::EventTargetData() | 52 EventTargetData::EventTargetData() |
50 { | 53 { |
51 } | 54 } |
(...skipping 21 matching lines...) Expand all Loading... | |
73 return 0; | 76 return 0; |
74 } | 77 } |
75 | 78 |
76 inline DOMWindow* EventTarget::executingWindow() | 79 inline DOMWindow* EventTarget::executingWindow() |
77 { | 80 { |
78 if (ExecutionContext* context = executionContext()) | 81 if (ExecutionContext* context = executionContext()) |
79 return context->executingWindow(); | 82 return context->executingWindow(); |
80 return 0; | 83 return 0; |
81 } | 84 } |
82 | 85 |
86 static void countByObjectType(const EventTarget* eventTarget, UseCounter::Featur e featureOnInput, UseCounter::Feature featureOnTextArea, UseCounter::Feature fea tureOnContentEditable, UseCounter::Feature featureOnNonNode) | |
87 { | |
88 UseCounter::Feature feature = featureOnNonNode; | |
89 if (const Node* node = const_cast<EventTarget*>(eventTarget)->toNode()) { | |
90 if (node->hasTagName(HTMLNames::inputTag)) | |
91 feature = featureOnInput; | |
92 else if (node->hasTagName(HTMLNames::textareaTag)) | |
93 feature = featureOnTextArea; | |
94 else | |
95 feature = featureOnContentEditable; | |
96 } | |
97 if (ExecutionContext* context = eventTarget->executionContext()) | |
98 UseCounter::count(context, feature); | |
99 } | |
100 | |
83 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<Eve ntListener> listener, bool useCapture) | 101 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<Eve ntListener> listener, bool useCapture) |
84 { | 102 { |
85 // FIXME: listener null check should throw TypeError (and be done in | 103 // FIXME: listener null check should throw TypeError (and be done in |
86 // generated bindings), but breaks legacy content. http://crbug.com/249598 | 104 // generated bindings), but breaks legacy content. http://crbug.com/249598 |
87 if (!listener) | 105 if (!listener) |
88 return false; | 106 return false; |
107 | |
108 if (eventType == EventTypeNames::textInput) { | |
tkent
2014/06/10 08:19:59
EventTarget is a generic interface, and I feel add
yosin_UTC9
2014/06/11 00:48:20
Done.
| |
109 countByObjectType(this, UseCounter::TextInputEventOnInput, | |
110 UseCounter::TextInputEventOnTextArea, | |
111 UseCounter::TextInputEventOnContentEditable, | |
112 UseCounter::TextInputEventOnNotNode); | |
113 } else if (eventType == EventTypeNames::webkitBeforeTextInserted) { | |
114 countByObjectType(this, UseCounter::WebkitBeforeTextInsertedOnInput, | |
115 UseCounter::WebkitBeforeTextInsertedOnTextArea, | |
116 UseCounter::WebkitBeforeTextInsertedOnContentEditable, | |
117 UseCounter::WebkitBeforeTextInsertedOnNotNode); | |
118 } else if (eventType == EventTypeNames::webkitEditableContentChanged) { | |
119 countByObjectType(this, UseCounter::WebkitEditableContentChangedOnInput, | |
120 UseCounter::WebkitEditableContentChangedOnTextArea, | |
121 UseCounter::WebkitEditableContentChangedOnContentEditable, | |
122 UseCounter::WebkitEditableContentChangedOnNotNode); | |
123 } | |
124 | |
89 return ensureEventTargetData().eventListenerMap.add(eventType, listener, use Capture); | 125 return ensureEventTargetData().eventListenerMap.add(eventType, listener, use Capture); |
90 } | 126 } |
91 | 127 |
92 bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen er* listener, bool useCapture) | 128 bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen er* listener, bool useCapture) |
93 { | 129 { |
94 EventTargetData* d = eventTargetData(); | 130 EventTargetData* d = eventTargetData(); |
95 if (!d) | 131 if (!d) |
96 return false; | 132 return false; |
97 | 133 |
98 size_t indexOfRemovedListener; | 134 size_t indexOfRemovedListener; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 // they have one less listener to invoke. | 406 // they have one less listener to invoke. |
371 if (d->firingEventIterators) { | 407 if (d->firingEventIterators) { |
372 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 408 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
373 d->firingEventIterators->at(i).iterator = 0; | 409 d->firingEventIterators->at(i).iterator = 0; |
374 d->firingEventIterators->at(i).end = 0; | 410 d->firingEventIterators->at(i).end = 0; |
375 } | 411 } |
376 } | 412 } |
377 } | 413 } |
378 | 414 |
379 } // namespace WebCore | 415 } // namespace WebCore |
OLD | NEW |