Chromium Code Reviews| 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()); |