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

Unified Diff: Source/core/editing/Editor.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: 2014-06-11T11:21:22 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 | « Source/core/editing/Editor.h ('k') | Source/core/events/EventTarget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index f1044e816a0bd4b4274aaabdc61bc328b00aa359..c83d48d5e4fbd02617bd21b9970f1281ce8f04ee 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -28,6 +28,7 @@
#include "core/editing/Editor.h"
#include "CSSPropertyNames.h"
+#include "EventNames.h"
#include "HTMLNames.h"
#include "SVGNames.h"
#include "XLinkNames.h"
@@ -68,6 +69,7 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/frame/UseCounter.h"
#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLTextAreaElement.h"
@@ -920,6 +922,71 @@ void Editor::performDelete()
setStartNewKillRingSequence(false);
}
+static void countEditingEvent(ExecutionContext* executionContext, const Event* event, UseCounter::Feature featureOnInput, UseCounter::Feature featureOnTextArea, UseCounter::Feature featureOnContentEditable, UseCounter::Feature featureOnNonNode)
+{
+ EventTarget* eventTarget = event->target();
+ Node* node = eventTarget->toNode();
+ if (!node) {
+ UseCounter::count(executionContext, featureOnNonNode);
+ return;
+ }
+
+ if (isHTMLInputElement(node)) {
+ UseCounter::count(executionContext, featureOnInput);
+ return;
+ }
+
+ if (isHTMLTextAreaElement(node)) {
+ UseCounter::count(executionContext, featureOnTextArea);
+ return;
+ }
+
+ HTMLTextFormControlElement* control = enclosingTextFormControl(node);
+ if (isHTMLInputElement(control)) {
+ UseCounter::count(executionContext, featureOnInput);
+ return;
+ }
+
+ if (isHTMLTextAreaElement(control)) {
+ UseCounter::count(executionContext, featureOnTextArea);
+ return;
+ }
+
+ UseCounter::count(executionContext, featureOnContentEditable);
+}
+
+void Editor::countEvent(ExecutionContext* executionContext, const Event* event)
+{
+ if (!executionContext)
+ return;
+
+ if (event->type() == EventTypeNames::textInput) {
+ countEditingEvent(executionContext, event,
+ UseCounter::TextInputEventOnInput,
+ UseCounter::TextInputEventOnTextArea,
+ UseCounter::TextInputEventOnContentEditable,
+ UseCounter::TextInputEventOnNotNode);
+ return;
+ }
+
+ if (event->type() == EventTypeNames::webkitBeforeTextInserted) {
+ countEditingEvent(executionContext, event,
+ UseCounter::WebkitBeforeTextInsertedOnInput,
+ UseCounter::WebkitBeforeTextInsertedOnTextArea,
+ UseCounter::WebkitBeforeTextInsertedOnContentEditable,
+ UseCounter::WebkitBeforeTextInsertedOnNotNode);
+ return;
+ }
+
+ if (event->type() == EventTypeNames::webkitEditableContentChanged) {
+ countEditingEvent(executionContext, event,
+ UseCounter::WebkitEditableContentChangedOnInput,
+ UseCounter::WebkitEditableContentChangedOnTextArea,
+ UseCounter::WebkitEditableContentChangedOnContentEditable,
+ UseCounter::WebkitEditableContentChangedOnNotNode);
+ }
+}
+
void Editor::copyImage(const HitTestResult& result)
{
writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), result.innerNonSharedNode(), result.altDisplayString());
« no previous file with comments | « Source/core/editing/Editor.h ('k') | Source/core/events/EventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698