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

Unified Diff: Source/core/events/EventTarget.cpp

Issue 328513004: Introduce use counters for Blink specific editing event usage (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/EventTarget.cpp
diff --git a/Source/core/events/EventTarget.cpp b/Source/core/events/EventTarget.cpp
index 3f1b07283c7ce7667810b795c23d42d9ec96b560..fa2becc13517105c0a18a8b43e955d7d451b6cdc 100644
--- a/Source/core/events/EventTarget.cpp
+++ b/Source/core/events/EventTarget.cpp
@@ -32,6 +32,8 @@
#include "config.h"
#include "core/events/EventTarget.h"
+#include "EventTypeNames.h"
+#include "HTMLNames.h"
#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
@@ -39,6 +41,7 @@
#include "core/events/Event.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/frame/DOMWindow.h"
+#include "core/frame/UseCounter.h"
#include "wtf/StdLibExtras.h"
#include "wtf/Vector.h"
@@ -80,12 +83,45 @@ inline DOMWindow* EventTarget::executingWindow()
return 0;
}
+static void countByObjectType(const EventTarget* eventTarget, UseCounter::Feature featureOnInput, UseCounter::Feature featureOnTextArea, UseCounter::Feature featureOnContentEditable, UseCounter::Feature featureOnNonNode)
+{
+ UseCounter::Feature feature = featureOnNonNode;
+ if (const Node* node = const_cast<EventTarget*>(eventTarget)->toNode()) {
+ if (node->hasTagName(HTMLNames::inputTag))
+ feature = featureOnInput;
+ else if (node->hasTagName(HTMLNames::textareaTag))
+ feature = featureOnTextArea;
+ else
+ feature = featureOnContentEditable;
+ }
+ if (ExecutionContext* context = eventTarget->executionContext())
+ UseCounter::count(context, feature);
+}
+
bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
{
// FIXME: listener null check should throw TypeError (and be done in
// generated bindings), but breaks legacy content. http://crbug.com/249598
if (!listener)
return false;
+
+ 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.
+ countByObjectType(this, UseCounter::TextInputEventOnInput,
+ UseCounter::TextInputEventOnTextArea,
+ UseCounter::TextInputEventOnContentEditable,
+ UseCounter::TextInputEventOnNotNode);
+ } else if (eventType == EventTypeNames::webkitBeforeTextInserted) {
+ countByObjectType(this, UseCounter::WebkitBeforeTextInsertedOnInput,
+ UseCounter::WebkitBeforeTextInsertedOnTextArea,
+ UseCounter::WebkitBeforeTextInsertedOnContentEditable,
+ UseCounter::WebkitBeforeTextInsertedOnNotNode);
+ } else if (eventType == EventTypeNames::webkitEditableContentChanged) {
+ countByObjectType(this, UseCounter::WebkitEditableContentChangedOnInput,
+ UseCounter::WebkitEditableContentChangedOnTextArea,
+ UseCounter::WebkitEditableContentChangedOnContentEditable,
+ UseCounter::WebkitEditableContentChangedOnNotNode);
+ }
+
return ensureEventTargetData().eventListenerMap.add(eventType, listener, useCapture);
}
« no previous file with comments | « no previous file | Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698