aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
diff options
context:
space:
mode:
authorFabrice Desré <fabrice@desre.org>2018-04-21 14:17:02 -0700
committerFabrice Desré <fabrice@desre.org>2018-04-21 19:46:42 -0700
commit42886613d32f2daff25f1f3ce7a7328bcc2306f7 (patch)
treef04f4b80566b6acea2323e9fceedbd2aab9a97b2 /components/script/dom/element.rs
parent05fe8fa08d507836ce5659ff56f83022a90b241a (diff)
downloadservo-42886613d32f2daff25f1f3ce7a7328bcc2306f7.tar.gz
servo-42886613d32f2daff25f1f3ce7a7328bcc2306f7.zip
Notify the embedder when it should display or hide an IME
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r--components/script/dom/element.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a53446fd4a3..11b9168eb41 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -83,6 +83,7 @@ use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use js::jsapi::Heap;
use js::jsval::JSVal;
+use msg::constellation_msg::InputMethodType;
use net_traits::request::CorsSettings;
use ref_filter_map::ref_filter_map;
use script_layout_interface::message::ReflowGoal;
@@ -1087,6 +1088,22 @@ impl Element {
None
}
+ // Returns the kind of IME control needed for a focusable element, if any.
+ pub fn input_method_type(&self) -> Option<InputMethodType> {
+ if !self.is_focusable_area() {
+ return None;
+ }
+
+ if let Some(input) = self.downcast::<HTMLInputElement>() {
+ input.input_type().as_ime_type()
+ } else if self.is::<HTMLTextAreaElement>() {
+ Some(InputMethodType::Text)
+ } else {
+ // Other focusable elements that are not input fields.
+ None
+ }
+ }
+
pub fn is_focusable_area(&self) -> bool {
if self.is_actually_disabled() {
return false;