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

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 2440513002: Add inputmode support to content editable. (Closed)
Patch Set: Add TODO Created 4 years, 1 month 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: third_party/WebKit/Source/core/editing/InputMethodController.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodController.cpp b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
index b618db2bc3f70868830da25a3e96d76c5111bb31..7bbbbd378e7aaf301e3a53951c205de3fd34f813 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -138,6 +138,29 @@ void insertTextDuringCompositionWithEvents(
// TODO(chongz): Fire 'input' event.
}
+AtomicString getInputModeAttribute(Element* element) {
+ if (!element)
+ return AtomicString();
+
+ bool queryAttribute = false;
+ if (isHTMLInputElement(*element)) {
+ queryAttribute = toHTMLInputElement(*element).supportsInputModeAttribute();
+ } else if (isHTMLTextAreaElement(*element)) {
+ queryAttribute = true;
+ } else {
+ element->document().updateStyleAndLayoutTree();
+ if (hasEditableStyle(*element))
+ queryAttribute = true;
+ }
+
+ if (!queryAttribute)
+ return AtomicString();
+
+ // TODO(dtapuska): We may wish to restrict this to a yet to be proposed
+ // <contenteditable> or <richtext> element Mozilla discussed at TPAC 2016.
+ return element->fastGetAttribute(HTMLNames::inputmodeAttr).lower();
+}
+
} // anonymous namespace
InputMethodController* InputMethodController::create(LocalFrame& frame) {
@@ -1048,20 +1071,8 @@ WebTextInputMode InputMethodController::inputModeOfFocusedElement() const {
if (!RuntimeEnabledFeatures::inputModeAttributeEnabled())
return kWebTextInputModeDefault;
- Element* element = frame().document()->focusedElement();
- if (!element)
- return kWebTextInputModeDefault;
-
- AtomicString mode;
- if (isHTMLInputElement(*element)) {
- const HTMLInputElement& input = toHTMLInputElement(*element);
- if (input.supportsInputModeAttribute())
- mode = input.fastGetAttribute(HTMLNames::inputmodeAttr).lower();
- }
- if (isHTMLTextAreaElement(*element)) {
- const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element);
- mode = textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower();
- }
+ AtomicString mode =
+ getInputModeAttribute(frame().document()->focusedElement());
if (mode.isEmpty())
return kWebTextInputModeDefault;

Powered by Google App Engine
This is Rietveld 408576698