Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/editing/Editor.h" | 28 #include "core/editing/Editor.h" |
| 29 | 29 |
| 30 #include "CSSPropertyNames.h" | 30 #include "CSSPropertyNames.h" |
| 31 #include "EventNames.h" | |
| 31 #include "HTMLNames.h" | 32 #include "HTMLNames.h" |
| 32 #include "SVGNames.h" | 33 #include "SVGNames.h" |
| 33 #include "XLinkNames.h" | 34 #include "XLinkNames.h" |
| 34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 35 #include "core/accessibility/AXObjectCache.h" | 36 #include "core/accessibility/AXObjectCache.h" |
| 36 #include "core/clipboard/Clipboard.h" | 37 #include "core/clipboard/Clipboard.h" |
| 37 #include "core/clipboard/DataObject.h" | 38 #include "core/clipboard/DataObject.h" |
| 38 #include "core/clipboard/Pasteboard.h" | 39 #include "core/clipboard/Pasteboard.h" |
| 39 #include "core/css/CSSComputedStyleDeclaration.h" | 40 #include "core/css/CSSComputedStyleDeclaration.h" |
| 40 #include "core/css/StylePropertySet.h" | 41 #include "core/css/StylePropertySet.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 61 #include "core/editing/markup.h" | 62 #include "core/editing/markup.h" |
| 62 #include "core/events/ClipboardEvent.h" | 63 #include "core/events/ClipboardEvent.h" |
| 63 #include "core/events/KeyboardEvent.h" | 64 #include "core/events/KeyboardEvent.h" |
| 64 #include "core/events/ScopedEventQueue.h" | 65 #include "core/events/ScopedEventQueue.h" |
| 65 #include "core/events/TextEvent.h" | 66 #include "core/events/TextEvent.h" |
| 66 #include "core/fetch/ImageResource.h" | 67 #include "core/fetch/ImageResource.h" |
| 67 #include "core/fetch/ResourceFetcher.h" | 68 #include "core/fetch/ResourceFetcher.h" |
| 68 #include "core/frame/FrameView.h" | 69 #include "core/frame/FrameView.h" |
| 69 #include "core/frame/LocalFrame.h" | 70 #include "core/frame/LocalFrame.h" |
| 70 #include "core/frame/Settings.h" | 71 #include "core/frame/Settings.h" |
| 72 #include "core/frame/UseCounter.h" | |
| 71 #include "core/html/HTMLImageElement.h" | 73 #include "core/html/HTMLImageElement.h" |
| 72 #include "core/html/HTMLInputElement.h" | 74 #include "core/html/HTMLInputElement.h" |
| 73 #include "core/html/HTMLTextAreaElement.h" | 75 #include "core/html/HTMLTextAreaElement.h" |
| 74 #include "core/html/parser/HTMLParserIdioms.h" | 76 #include "core/html/parser/HTMLParserIdioms.h" |
| 75 #include "core/loader/EmptyClients.h" | 77 #include "core/loader/EmptyClients.h" |
| 76 #include "core/page/EditorClient.h" | 78 #include "core/page/EditorClient.h" |
| 77 #include "core/page/EventHandler.h" | 79 #include "core/page/EventHandler.h" |
| 78 #include "core/page/FocusController.h" | 80 #include "core/page/FocusController.h" |
| 79 #include "core/page/Page.h" | 81 #include "core/page/Page.h" |
| 80 #include "core/rendering/HitTestResult.h" | 82 #include "core/rendering/HitTestResult.h" |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 if (!canDelete()) | 915 if (!canDelete()) |
| 914 return; | 916 return; |
| 915 addToKillRing(selectedRange().get(), false); | 917 addToKillRing(selectedRange().get(), false); |
| 916 deleteSelectionWithSmartDelete(canSmartCopyOrDelete()); | 918 deleteSelectionWithSmartDelete(canSmartCopyOrDelete()); |
| 917 | 919 |
| 918 // clear the "start new kill ring sequence" setting, because it was set to t rue | 920 // clear the "start new kill ring sequence" setting, because it was set to t rue |
| 919 // when the selection was updated by deleting the range | 921 // when the selection was updated by deleting the range |
| 920 setStartNewKillRingSequence(false); | 922 setStartNewKillRingSequence(false); |
| 921 } | 923 } |
| 922 | 924 |
| 925 static void countEditingEvent(ExecutionContext* executionContext, const Event* e vent, UseCounter::Feature featureOnInput, UseCounter::Feature featureOnTextArea, UseCounter::Feature featureOnContentEditable, UseCounter::Feature featureOnNonN ode) | |
| 926 { | |
| 927 EventTarget* eventTarget = event->target(); | |
| 928 Node* node = eventTarget->toNode(); | |
| 929 if (!node) { | |
| 930 UseCounter::count(executionContext, featureOnNonNode); | |
| 931 return; | |
| 932 } | |
| 933 | |
| 934 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.
| |
| 935 UseCounter::count(executionContext, featureOnInput); | |
| 936 return; | |
| 937 } | |
| 938 | |
| 939 if (node->hasTagName(HTMLNames::textareaTag)) { | |
|
tkent
2014/06/11 01:05:48
Ditto.
yosin_UTC9
2014/06/11 02:23:19
Done.
| |
| 940 UseCounter::count(executionContext, featureOnTextArea); | |
| 941 return; | |
| 942 } | |
| 943 | |
| 944 HTMLTextFormControlElement* control = enclosingTextFormControl(node); | |
| 945 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.
| |
| 946 UseCounter::count(executionContext, featureOnInput); | |
| 947 return; | |
| 948 } | |
| 949 | |
| 950 if (control && control->hasTagName(HTMLNames::textareaTag)) { | |
|
tkent
2014/06/11 01:05:48
Ditto.
yosin_UTC9
2014/06/11 02:23:19
Done.
| |
| 951 UseCounter::count(executionContext, featureOnTextArea); | |
| 952 return; | |
| 953 } | |
| 954 | |
| 955 UseCounter::count(executionContext, featureOnContentEditable); | |
| 956 } | |
| 957 | |
| 958 void Editor::countEvent(ExecutionContext* executionContext, const Event* event) | |
| 959 { | |
| 960 if (!executionContext) | |
| 961 return; | |
| 962 | |
| 963 if (event->type() == EventTypeNames::textInput) { | |
| 964 countEditingEvent(executionContext, event, | |
| 965 UseCounter::TextInputEventOnInput, | |
| 966 UseCounter::TextInputEventOnTextArea, | |
| 967 UseCounter::TextInputEventOnContentEditable, | |
| 968 UseCounter::TextInputEventOnNotNode); | |
| 969 return; | |
| 970 } | |
| 971 | |
| 972 if (event->type() == EventTypeNames::webkitBeforeTextInserted) { | |
| 973 countEditingEvent(executionContext, event, | |
| 974 UseCounter::WebkitBeforeTextInsertedOnInput, | |
| 975 UseCounter::WebkitBeforeTextInsertedOnTextArea, | |
| 976 UseCounter::WebkitBeforeTextInsertedOnContentEditable, | |
| 977 UseCounter::WebkitBeforeTextInsertedOnNotNode); | |
| 978 return; | |
| 979 } | |
| 980 | |
| 981 if (event->type() == EventTypeNames::webkitEditableContentChanged) { | |
| 982 countEditingEvent(executionContext, event, | |
| 983 UseCounter::WebkitEditableContentChangedOnInput, | |
| 984 UseCounter::WebkitEditableContentChangedOnTextArea, | |
| 985 UseCounter::WebkitEditableContentChangedOnContentEditable, | |
| 986 UseCounter::WebkitEditableContentChangedOnNotNode); | |
| 987 } | |
| 988 } | |
| 989 | |
| 923 void Editor::copyImage(const HitTestResult& result) | 990 void Editor::copyImage(const HitTestResult& result) |
| 924 { | 991 { |
| 925 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), result.innerNonS haredNode(), result.altDisplayString()); | 992 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), result.innerNonS haredNode(), result.altDisplayString()); |
| 926 } | 993 } |
| 927 | 994 |
| 928 bool Editor::canUndo() | 995 bool Editor::canUndo() |
| 929 { | 996 { |
| 930 if (UndoStack* undoStack = this->undoStack()) | 997 if (UndoStack* undoStack = this->undoStack()) |
| 931 return undoStack->canUndo(); | 998 return undoStack->canUndo(); |
| 932 return false; | 999 return false; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1236 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 1303 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); |
| 1237 } | 1304 } |
| 1238 | 1305 |
| 1239 void Editor::trace(Visitor* visitor) | 1306 void Editor::trace(Visitor* visitor) |
| 1240 { | 1307 { |
| 1241 visitor->trace(m_lastEditCommand); | 1308 visitor->trace(m_lastEditCommand); |
| 1242 visitor->trace(m_mark); | 1309 visitor->trace(m_mark); |
| 1243 } | 1310 } |
| 1244 | 1311 |
| 1245 } // namespace WebCore | 1312 } // namespace WebCore |
| OLD | NEW |