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

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-10T06:41:10 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
Index: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index f1044e816a0bd4b4274aaabdc61bc328b00aa359..809a7b0eb98daa9e74f2995b9da642b1f0f9a031 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 (node->hasTagName(HTMLNames::inputTag)) {
tkent 2014/06/11 01:05:48 You can omit HTMLNames::. Or, use isHTMLElement(no
tkent 2014/06/11 01:06:36 oops, isHTMLElement -> isHTMLInputElement
yosin_UTC9 2014/06/11 02:23:20 Done.
+ UseCounter::count(executionContext, featureOnInput);
+ return;
+ }
+
+ if (node->hasTagName(HTMLNames::textareaTag)) {
tkent 2014/06/11 01:05:48 Ditto.
yosin_UTC9 2014/06/11 02:23:19 Done.
+ UseCounter::count(executionContext, featureOnTextArea);
+ return;
+ }
+
+ HTMLTextFormControlElement* control = enclosingTextFormControl(node);
+ if (control && control->hasTagName(HTMLNames::inputTag)) {
tkent 2014/06/11 01:05:48 You can write |if (isHTMLInputElement(control))|.
yosin_UTC9 2014/06/11 02:23:19 Done.
+ UseCounter::count(executionContext, featureOnInput);
+ return;
+ }
+
+ if (control && control->hasTagName(HTMLNames::textareaTag)) {
tkent 2014/06/11 01:05:48 Ditto.
yosin_UTC9 2014/06/11 02:23:19 Done.
+ 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());

Powered by Google App Engine
This is Rietveld 408576698