| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 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 "core/editing/InputMethodController.h" | 27 #include "core/editing/InputMethodController.h" |
| 28 | 28 |
| 29 #include "core/InputModeNames.h" |
| 29 #include "core/InputTypeNames.h" | 30 #include "core/InputTypeNames.h" |
| 30 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 31 #include "core/dom/Element.h" | 32 #include "core/dom/Element.h" |
| 32 #include "core/dom/Text.h" | 33 #include "core/dom/Text.h" |
| 33 #include "core/editing/EditingUtilities.h" | 34 #include "core/editing/EditingUtilities.h" |
| 34 #include "core/editing/Editor.h" | 35 #include "core/editing/Editor.h" |
| 35 #include "core/editing/commands/TypingCommand.h" | 36 #include "core/editing/commands/TypingCommand.h" |
| 36 #include "core/editing/markers/DocumentMarkerController.h" | 37 #include "core/editing/markers/DocumentMarkerController.h" |
| 37 #include "core/events/CompositionEvent.h" | 38 #include "core/events/CompositionEvent.h" |
| 38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 else if (autocapitalize == sentences) | 1039 else if (autocapitalize == sentences) |
| 1039 flags |= WebTextInputFlagAutocapitalizeSentences; | 1040 flags |= WebTextInputFlagAutocapitalizeSentences; |
| 1040 else | 1041 else |
| 1041 NOTREACHED(); | 1042 NOTREACHED(); |
| 1042 } | 1043 } |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 return flags; | 1046 return flags; |
| 1046 } | 1047 } |
| 1047 | 1048 |
| 1048 String InputMethodController::inputModeOfFocusedElement() const { | 1049 WebTextInputMode InputMethodController::inputModeOfFocusedElement() const { |
| 1049 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 1050 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 1050 return String(); | 1051 return kWebTextInputModeDefault; |
| 1051 | 1052 |
| 1052 Element* element = frame().document()->focusedElement(); | 1053 Element* element = frame().document()->focusedElement(); |
| 1053 if (!element) | 1054 if (!element) |
| 1054 return String(); | 1055 return kWebTextInputModeDefault; |
| 1055 | 1056 |
| 1057 AtomicString mode; |
| 1056 if (isHTMLInputElement(*element)) { | 1058 if (isHTMLInputElement(*element)) { |
| 1057 const HTMLInputElement& input = toHTMLInputElement(*element); | 1059 const HTMLInputElement& input = toHTMLInputElement(*element); |
| 1058 if (input.supportsInputModeAttribute()) | 1060 if (input.supportsInputModeAttribute()) |
| 1059 return input.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 1061 mode = input.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 1060 return String(); | |
| 1061 } | 1062 } |
| 1062 if (isHTMLTextAreaElement(*element)) { | 1063 if (isHTMLTextAreaElement(*element)) { |
| 1063 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); | 1064 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); |
| 1064 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 1065 mode = textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 return String(); | 1068 if (mode.isEmpty()) |
| 1069 return kWebTextInputModeDefault; |
| 1070 if (mode == InputModeNames::verbatim) |
| 1071 return kWebTextInputModeVerbatim; |
| 1072 if (mode == InputModeNames::latin) |
| 1073 return kWebTextInputModeLatin; |
| 1074 if (mode == InputModeNames::latin_name) |
| 1075 return kWebTextInputModeLatinName; |
| 1076 if (mode == InputModeNames::latin_prose) |
| 1077 return kWebTextInputModeLatinProse; |
| 1078 if (mode == InputModeNames::full_width_latin) |
| 1079 return kWebTextInputModeFullWidthLatin; |
| 1080 if (mode == InputModeNames::kana) |
| 1081 return kWebTextInputModeKana; |
| 1082 if (mode == InputModeNames::kana_name) |
| 1083 return kWebTextInputModeKanaName; |
| 1084 if (mode == InputModeNames::katakana) |
| 1085 return kWebTextInputModeKataKana; |
| 1086 if (mode == InputModeNames::numeric) |
| 1087 return kWebTextInputModeNumeric; |
| 1088 if (mode == InputModeNames::tel) |
| 1089 return kWebTextInputModeTel; |
| 1090 if (mode == InputModeNames::email) |
| 1091 return kWebTextInputModeEmail; |
| 1092 if (mode == InputModeNames::url) |
| 1093 return kWebTextInputModeUrl; |
| 1094 return kWebTextInputModeDefault; |
| 1068 } | 1095 } |
| 1069 | 1096 |
| 1070 WebTextInputType InputMethodController::textInputType() const { | 1097 WebTextInputType InputMethodController::textInputType() const { |
| 1071 if (!frame().selection().isAvailable()) { | 1098 if (!frame().selection().isAvailable()) { |
| 1072 // "mouse-capture-inside-shadow.html" reaches here. | 1099 // "mouse-capture-inside-shadow.html" reaches here. |
| 1073 return WebTextInputTypeNone; | 1100 return WebTextInputTypeNone; |
| 1074 } | 1101 } |
| 1075 | 1102 |
| 1076 // It's important to preserve the equivalence of textInputInfo().type and | 1103 // It's important to preserve the equivalence of textInputInfo().type and |
| 1077 // textInputType(), so perform the same rootEditableElement() existence check | 1104 // textInputType(), so perform the same rootEditableElement() existence check |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 | 1156 |
| 1130 return WebTextInputTypeNone; | 1157 return WebTextInputTypeNone; |
| 1131 } | 1158 } |
| 1132 | 1159 |
| 1133 DEFINE_TRACE(InputMethodController) { | 1160 DEFINE_TRACE(InputMethodController) { |
| 1134 visitor->trace(m_frame); | 1161 visitor->trace(m_frame); |
| 1135 visitor->trace(m_compositionRange); | 1162 visitor->trace(m_compositionRange); |
| 1136 } | 1163 } |
| 1137 | 1164 |
| 1138 } // namespace blink | 1165 } // namespace blink |
| OLD | NEW |