ewk_context_notify_low_memory(ewk_context_);
}
+void WebApplication::OnSoftKeyboardChangeEvent(WebView* /*view*/,
+ SoftKeyboardChangeEventValue softkeyboard_value) {
+ LOGGER(DEBUG) << "OnSoftKeyboardChangeEvent";
+ std::stringstream script;
+ script
+ << "(function(){"
+ << "var __event = document.createEvent(\"CustomEvent\");\n"
+ << "var __detail = {};\n"
+ << "__event.initCustomEvent(\"softkeyboardchange\",true,true,__detail);\n"
+ << "__event.state = \"" << softkeyboard_value.state << "\";\n"
+ << "__event.width = " << softkeyboard_value.width << ";\n"
+ << "__event.height = " << softkeyboard_value.height << ";\n"
+ << "document.dispatchEvent(__event);\n"
+ << "\n"
+ << "for (var i=0; i < window.frames.length; i++)\n"
+ << "{ window.frames[i].document.dispatchEvent(__event); }"
+ << "})()";
+ std::string kSoftKeyboardScript = script.str();
+ if (view_stack_.size() > 0 && view_stack_.front() != NULL)
+ view_stack_.front()->EvalJavascript(kSoftKeyboardScript.c_str());
+}
+
#ifdef PROFILE_WEARABLE
void WebApplication::OnRotaryEvent(WebView* /*view*/,
RotaryEventType type) {
virtual void OnUsermediaPermissionRequest(
WebView* view, const std::string& url,
std::function<void(bool)> result_handler);
+ virtual void OnSoftKeyboardChangeEvent(
+ WebView* view, SoftKeyboardChangeEventValue softkeyboard_value);
#ifdef PROFILE_WEARABLE
- virtual void OnRotaryEvent(WebView* view,
- RotaryEventType type);
+ virtual void OnRotaryEvent(
+ WebView* view, RotaryEventType type);
#endif // PROFILE_WEARABLE
private:
view_(view),
fullscreen_(false),
evas_smart_class_(NULL),
- internal_popup_opened_(false) {
+ internal_popup_opened_(false),
+ ime_width_(0),
+ ime_height_(0) {
Initialize();
}
InitCertificateAllowCallback();
InitPopupWaitCallback();
InitUsermediaCallback();
+ InitEditorClientImeCallback();
#ifdef PROFILE_WEARABLE
InitRotaryEventCallback();
#endif // PROFILE_WEARABLE
ewk_view_user_media_permission_callback_set(ewk_view_, callback, this);
}
+void WebViewImpl::InitEditorClientImeCallback() {
+ auto ime_changed_callback = [](void* user_data,
+ Evas_Object*,
+ void* event_info) {
+ WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+
+ Eina_Rectangle *rect = static_cast<Eina_Rectangle *>(event_info);
+ self->ime_width_ = rect->w;
+ self->ime_height_ = rect->h;
+ };
+
+ auto ime_opened_callback = [](void* user_data,
+ Evas_Object*,
+ void* event_info) {
+ WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+
+ SoftKeyboardChangeEventValue softkeyboard_value;
+ softkeyboard_value.state = "on";
+ softkeyboard_value.width = self->ime_width_;
+ softkeyboard_value.height = self->ime_height_;
+
+ self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+ };
+
+ auto ime_closed_callback = [](void* user_data,
+ Evas_Object*,
+ void* event_info) {
+ WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+
+ SoftKeyboardChangeEventValue softkeyboard_value;
+ softkeyboard_value.state = "off";
+
+ self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+ };
+ evas_object_smart_callback_add(ewk_view_,
+ "inputmethod,changed",
+ ime_changed_callback,
+ this);
+ evas_object_smart_callback_add(ewk_view_,
+ "editorclient,ime,opened",
+ ime_opened_callback,
+ this);
+ evas_object_smart_callback_add(ewk_view_,
+ "editorclient,ime,closed",
+ ime_closed_callback,
+ this);
+ smart_callbacks_["inputmethod,changed"] = ime_changed_callback;
+ smart_callbacks_["editorclient,ime,opened"] = ime_opened_callback;
+ smart_callbacks_["editorclient,ime,closed"] = ime_closed_callback;
+}
+
#ifdef PROFILE_WEARABLE
void WebViewImpl::InitRotaryEventCallback() {
auto rotary_callback = [](void* user_data,
void InitCertificateAllowCallback();
void InitPopupWaitCallback();
void InitUsermediaCallback();
+ void InitEditorClientImeCallback();
#ifdef PROFILE_WEARABLE
void InitRotaryEventCallback();
#endif // PROFILE_WEARABLE
Evas_Smart* evas_smart_class_;
Ewk_View_Smart_Class ewk_smart_class_;
bool internal_popup_opened_;
+ size_t ime_width_;
+ size_t ime_height_;
};
} // namespace runtime