mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Notify the embedder when it should display or hide an IME
This commit is contained in:
parent
05fe8fa08d
commit
42886613d3
8 changed files with 93 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue