Remove js_overlay_addEventListener
authorTaejeong Lee <taejeong.lee@samsung.com>
Wed, 22 May 2013 07:37:17 +0000 (16:37 +0900)
committerTaejeong Lee <taejeong.lee@samsung.com>
Thu, 23 May 2013 08:19:45 +0000 (17:19 +0900)
[Issue#] N/A
[Problem] Stability.
[Cause] Before custom event dispatch implementation was very complicated and instability,
        because it works by overlay type. It had very heavy operation on webkit with JSC.
[Solution] So we have replaced that to very simple operation which is using dom dispatchEvent() api.

Change-Id: Iecbc105d2aced7f8649e8504b62014e0cdb0c1b9

23 files changed:
CMakeLists.txt
pkgconfigs/wrt-dispatch-event.pc.in [new file with mode: 0644]
src/CMakeLists.txt
src/dispatch-event/CMakeLists.txt [new file with mode: 0644]
src/dispatch-event/dispatch_event_support.cpp [new file with mode: 0644]
src/dispatch-event/dispatch_event_support.h [new file with mode: 0644]
src/js-overlay/CMakeLists.txt
src/js-overlay/deprecated/JSClass/JSSoftKeyboardChangeEvent.cpp [moved from src/js-overlay/JSClass/JSSoftKeyboardChangeEvent.cpp with 100% similarity]
src/js-overlay/deprecated/JSClass/JSSoftKeyboardChangeEvent.h [moved from src/js-overlay/JSClass/JSSoftKeyboardChangeEvent.h with 100% similarity]
src/js-overlay/deprecated/JSClass/JSStorageEvent.cpp [moved from src/js-overlay/JSClass/JSStorageEvent.cpp with 100% similarity]
src/js-overlay/deprecated/JSClass/JSStorageEvent.h [moved from src/js-overlay/JSClass/JSStorageEvent.h with 100% similarity]
src/js-overlay/deprecated/JSClass/JSTizenServiceEvent.cpp [moved from src/js-overlay/JSClass/JSTizenServiceEvent.cpp with 100% similarity]
src/js-overlay/deprecated/JSClass/JSTizenServiceEvent.h [moved from src/js-overlay/JSClass/JSTizenServiceEvent.h with 100% similarity]
src/js-overlay/deprecated/js_iframe_support.cpp [moved from src/js-overlay/js_iframe_support.cpp with 100% similarity, mode: 0755]
src/js-overlay/deprecated/js_iframe_support.h [moved from src/js-overlay/js_iframe_support.h with 100% similarity, mode: 0755]
src/js-overlay/deprecated/js_overlay_addEventListener.cpp [moved from src/js-overlay/js_overlay_addEventListener.cpp with 100% similarity, mode: 0755]
src/js-overlay/deprecated/js_overlay_addEventListener.h [moved from src/js-overlay/js_overlay_addEventListener.h with 100% similarity, mode: 0755]
src/js-overlay/js_function_manager.cpp
src/plugin-loading/explorer.cpp
src/standards/W3C/Widget/CMakeLists.txt [changed mode: 0755->0644]
src/standards/W3C/Widget/JSPreferences.cpp
src/standards/W3C/Widget/JSWidget.cpp
src/standards/W3C/Widget/plugin_initializer.cpp

index 3536d7a..8777310 100644 (file)
@@ -35,7 +35,8 @@ include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-loading
   ${CMAKE_CURRENT_SOURCE_DIR}/src/js-overlay
   ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner
-  ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins_ipc_message)
+  ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins_ipc_message
+  ${CMAKE_CURRENT_SOURCE_DIR}/src/dispatch-event)
 
 ##############################################################################
 # Build type
@@ -153,6 +154,7 @@ configure_and_install_pkg(wrt-popup-ace-runner.pc)
 configure_and_install_pkg(wrt-popup-wrt-runner.pc)
 configure_and_install_pkg(wrt-plugins-api-support.pc)
 configure_and_install_pkg(wrt-plugins-ipc-message.pc)
+configure_and_install_pkg(wrt-dispatch-event.pc)
 
 ################################################################################
 # Cache
diff --git a/pkgconfigs/wrt-dispatch-event.pc.in b/pkgconfigs/wrt-dispatch-event.pc.in
new file mode 100644 (file)
index 0000000..937bcaf
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/wrt-dispatch-event
+
+Name: wrt dispatch event support
+Description: Support to dispatch DOM event
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl ewebkit2
+Libs: -L${libdir} -lwrt-dispatch-event
+Cflags: -I${includedir}
index 259b2da..5152f7e 100644 (file)
@@ -56,6 +56,7 @@ add_subdirectory(plugin-loading)
 add_subdirectory(js-overlay)
 add_subdirectory(Commons)
 add_subdirectory(CommonsJavaScript)
+add_subdirectory(dispatch-event)
 add_subdirectory(modules)
 add_subdirectory(standards)
 add_subdirectory(wrt-popup)
diff --git a/src/dispatch-event/CMakeLists.txt b/src/dispatch-event/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3ba4072
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+# @file     CMakeLists.txt
+# @author   Tae-Jeong Lee (taejeong.lee@samsung.com)
+# @version  1.0
+#
+
+pkg_search_module(webkit2 REQUIRED ewebkit2)
+pkg_search_module(dpl REQUIRED dpl-efl)
+
+SET(TARGET_NAME wrt-dispatch-event)
+
+SET(SRCS
+    ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_event_support.cpp
+)
+
+INCLUDE_DIRECTORIES(
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${webkit2_INCLUDE_DIRS}
+    ${dpl_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_NAME}
+    ${webkit2_LIBRARIES}
+    ${dpl_LIBRARIES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+    COMPILE_FLAGS -fPIC
+    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
+)
+
+SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+    SOVERSION ${CMAKE_PROJECT_API_VERSION}
+    VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+INSTALL(TARGETS ${TARGET_NAME}
+    DESTINATION ${DESTINATION_LIB_PREFIX}
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+    GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+)
+
+INSTALL(FILES dispatch_event_support.h DESTINATION include/wrt-dispatch-event)
\ No newline at end of file
diff --git a/src/dispatch-event/dispatch_event_support.cpp b/src/dispatch-event/dispatch_event_support.cpp
new file mode 100644 (file)
index 0000000..14aa01a
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ *
+ * @file       dispatch_event_support.cpp
+ * @author     Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#ifndef _DISPATCH_EVENT_SUPPORT_CPP_
+#define _DISPATCH_EVENT_SUPPORT_CPP_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/log/log.h>
+
+#include "dispatch_event_support.h"
+
+namespace DispatchEventSupport {
+
+static std::string getExceptionString(JSContextRef context, JSValueRef exception)
+{
+    if (exception)
+    {
+        JSStringRef jsString = JSValueToStringCopy(context, exception, NULL);
+        size_t bufSize = JSStringGetMaximumUTF8CStringSize(jsString);
+
+        char* buf = new char[bufSize];
+        JSStringGetUTF8CString(jsString, buf, bufSize);
+        JSStringRelease(jsString);
+
+        std::string ret = buf;
+        delete[] buf;
+
+        return ret;
+    }
+    else
+    {
+        return "NULL";
+    }
+}
+
+void dispatchAppServiceEvent(JSContextRef context, const float scale, const std::string bundle)
+{
+    LogDebug("DispatchTizenServiceEvent(" << context << ", " << scale << ", " << bundle << ")");
+
+    if (context != NULL)
+    {
+        std::stringstream script;
+
+        script << "{\n"
+               << "    var event = document.createEvent(\"CustomEvent\");\n"
+               << "    event.initCustomEvent(\"appservice\", true, true);\n"
+               << "    event.scale = " << scale << ";\n"
+               << "    event.__bundle = \"" << bundle << "\";\n"
+               << "    document.dispatchEvent(event);\n"
+               << "    \n"
+               << "    for (var i=0; i < window.frames.length; i++)\n"
+               << "    { window.frames[i].document.dispatchEvent(event); }\n"
+               << "}";
+
+        // just for debugging
+        // LogDebug("script :\n" << script.str());
+
+        JSValueRef exception = NULL, ret = NULL;
+        JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+        ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+        JSStringRelease(jsScript);
+
+        LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+    }
+}
+
+void dispatchSoftKeyboardChangeEvent(JSContextRef context, const std::string state, const int width, const int height)
+{
+    LogDebug("dispatchSoftKeyboardChangeEvent(" << context << ", " << state << ", " << width << ", " << height << ")");
+
+    if (context != NULL)
+    {
+        std::stringstream script;
+
+        script << "{\n"
+               << "    var event = document.createEvent(\"CustomEvent\");\n"
+               << "    event.initCustomEvent(\"softkeyboardchange\", true, true);\n"
+               << "    event.state = \"" << state << "\";\n"
+               << "    event.width = " << width << ";\n"
+               << "    event.height = " << height << ";\n"
+               << "    document.dispatchEvent(event);\n"
+               << "    \n"
+               << "    for (var i=0; i < window.frames.length; i++)\n"
+               << "    { window.frames[i].document.dispatchEvent(event); }\n"
+               << "}";
+
+        // just for debugging
+        // LogDebug("script :\n" << script.str());
+
+        JSValueRef exception = NULL, ret = NULL;
+        JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+        ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+        JSStringRelease(jsScript);
+
+        LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+    }
+}
+
+void dispatchStorageEvent(JSContextRef context, const std::string key, const std::string oldValue, const std::string newValue, const std::string url)
+{
+    LogDebug("dispatchStorageEvent(" << context << ", " << key << ", " << oldValue << ", " << newValue << ", " << url << ")");
+
+    if (context != NULL)
+    {
+        std::stringstream script;
+
+        script << "{\n"
+               << "    var event = document.createEvent(\"CustomEvent\");\n"
+               << "    event.initCustomEvent(\"storage\", true, true);\n"
+               << "    event.key = \"" << key << "\";\n"
+               << "    event.oldValue = \"" << oldValue << "\";\n"
+               << "    event.newValue = \"" << newValue << "\";\n"
+               << "    event.url = \"" << url << "\";\n"
+               << "    event.storageArea = widget.preferences;\n"
+               << "    document.dispatchEvent(event);\n"
+               << "    \n"
+               << "    for (var i=0; i < window.frames.length; i++)\n"
+               << "    { window.frames[i].document.dispatchEvent(event); }\n"
+               << "}";
+
+        // just for debugging
+        // LogDebug("script :\n" << script.str());
+
+        JSValueRef exception = NULL, ret = NULL;
+        JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+        ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+        JSStringRelease(jsScript);
+
+        LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+    }
+}
+
+}
+#endif //_DISPATCH_EVENT_SUPPORT_CPP_
diff --git a/src/dispatch-event/dispatch_event_support.h b/src/dispatch-event/dispatch_event_support.h
new file mode 100644 (file)
index 0000000..a267e2c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ *
+ * @file       dispatch_event_support.h
+ * @author     Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#ifndef _DISPATCH_EVENT_SUPPORT_H_
+#define _DISPATCH_EVENT_SUPPORT_H_
+
+namespace DispatchEventSupport {
+
+void dispatchAppServiceEvent(JSContextRef context, const float scale, const std::string bundle);
+void dispatchSoftKeyboardChangeEvent(JSContextRef context, const std::string state, const int width, const int height);
+void dispatchStorageEvent(JSContextRef context, const std::string key, const std::string oldValue, const std::string newValue, const std::string url);
+
+}
+#endif //_DISPATCH_EVENT_SUPPORT_H_
index dd68584..5cbb0d8 100644 (file)
@@ -30,12 +30,7 @@ SET(TARGET_NAME ${TARGET_JS_OVERLAY})
 SET(SRCS
     ${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_support.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/js_function_manager.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_addEventListener.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_functions.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/js_iframe_support.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSStorageEvent.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSTizenServiceEvent.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSSoftKeyboardChangeEvent.cpp
 )
 
 INCLUDE_DIRECTORIES(
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from src/js-overlay/js_iframe_support.h
rename to src/js-overlay/deprecated/js_iframe_support.h
index dfa55b2..388a3f0 100644 (file)
 
 #include <dpl/singleton_safe_impl.h>
 #include <js_function_manager.h>
-#include <js_iframe_support.h>
 #include <js_overlay_functions.h>
-#include <js_overlay_addEventListener.h>
 #include <wrt_plugin_export.h>
 
-using namespace WrtPlugins::W3C;
-
 IMPLEMENT_SAFE_SINGLETON(JsFunctionManager)
 
 namespace {
 const char* JSPRINT_NAME = "jsPrint";
 const char* JSGLOBAL_OBJECT = "GLOBAL_OBJECT";
 const char* JSHOOK_NAME = "jsHook";
-const char* ADD_EVENT_LISTENER_NAME = "addEventListener";
 }
 
 namespace JavaScriptFunctions {
@@ -61,17 +56,6 @@ class_definition_options_t jsPrintfunctionsOptions = {
     reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptPrintProc)
 };
 
-class_definition_options_t addEventListenerOptions = {
-    JS_FUNCTION,
-    CREATE_INSTANCE,
-    ALWAYS_NOTICE,
-    OVERLAYED_BEFORE_ORIGINAL,
-    IFrameSupport::RegisterAddEventListener,
-    NULL,
-    reinterpret_cast<js_function_impl>(AddEventListenerSupport::
-                                           AddEventListener)
-};
-
 js_entity_definition_t jsPrint = {
     JSGLOBAL_OBJECT,
     JSPRINT_NAME,
@@ -90,17 +74,8 @@ js_entity_definition_t jsHook = {
     &jsHookfunctionsOptions
 };
 
-js_entity_definition_t addEventListener = {
-    JSGLOBAL_OBJECT,
-    ADD_EVENT_LISTENER_NAME,
-    "",
-    NULL,
-    NULL,
-    &addEventListenerOptions
-};
 const js_entity_definition_ptr_t jsPrintPtr = &jsPrint;
 const js_entity_definition_ptr_t jsHookPtr = &jsHook;
-const js_entity_definition_ptr_t addEventListenerPtr = &addEventListener;
 }
 
 bool JsFunctionManager::initialize()
@@ -112,12 +87,8 @@ bool JsFunctionManager::initialize()
     JSObjectDeclarationPtr jsHookObj(
         new JSObjectDeclaration(JavaScriptFunctions::jsHookPtr));
 
-    JSObjectDeclarationPtr addEventListenerObj(
-        new JSObjectDeclaration(JavaScriptFunctions::addEventListenerPtr));
-
     m_functions.push_back(jsPrintObj);
     m_functions.push_back(jsHookObj);
-    m_functions.push_back(addEventListenerObj);
 
     return true;
 }
index 3a76b3a..1ecad15 100644 (file)
 // JS overlay
 #include <js_overlay_support.h>
 #include <js_overlay_types.h>
-#include <js_overlay_addEventListener.h>
-#include <TizenServiceEvent/ITizenServiceEvent.h>
-#include <TizenServiceEvent/TizenServiceEvent.h>
-#include <SoftKeyboardChangeEvent/ISoftKeyboardChangeEvent.h>
-#include <SoftKeyboardChangeEvent/SoftKeyboardChangeEvent.h>
-#include <JSClass/JSTizenServiceEvent.h>
-#include <JSClass/JSSoftKeyboardChangeEvent.h>
 
 namespace {
 //const char* SEPARATOR = ".";
@@ -342,7 +335,6 @@ void Explorer::unloadFrame(JSGlobalContextRef context)
     JSObjectPtr frameObject =
         JavaScriptInterfaceSingleton::Instance().getGlobalObject(context);
 
-    AddEventListenerSupport::RemoveIFrame(frameObject);
     m_iframeSupport.unregisterIframe(frameObject);
 }
 
@@ -379,6 +371,7 @@ void Explorer::cleanIframesData()
 
 void Explorer::callEventListeners(CustomEventType eventType, void* data)
 {
+#if 0 // deprecated
     using namespace WrtPlugins::Tizen;
     // get iframe objects from javascript global context
     JavaScriptInterface::ObjectsListPtr frameLists =
@@ -450,6 +443,7 @@ void Explorer::callEventListeners(CustomEventType eventType, void* data)
         LogInfo("Not supported custom event type");
         return;
     }
+#endif
 }
 
 WindowPropertySupport* Explorer::getWindowPropertySupport()
old mode 100755 (executable)
new mode 100644 (file)
index 70ef116..fe0174f
@@ -29,8 +29,6 @@ include_directories(
   ${API_WIDGET_PATH}
   ${webkit2_INCLUDE_DIRS}
   ${plugin-types_INCLUDE_DIRS}
-#  ${API_STORAGE_EVENT_PATH}
-#  ${API_LOCALSTORAGE_PATH}
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
@@ -42,6 +40,7 @@ target_link_libraries(${TARGET_NAME}
   wrt-plugins-widget
   wrt-plugins-localstorage
   wrt-plugins-storageevent
+  wrt-dispatch-event
 )
 
 INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION /usr/lib/wrt-plugins/w3c-widget-interface)
index 2f962f0..1f6326f 100644 (file)
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <StorageEvent/StorageEventMgr.h>
 #include <StorageEvent/IStorageEvent.h>
-#include <js-overlay/js_iframe_support.h>
-#include <js-overlay/js_overlay_addEventListener.h>
+#include <dispatch-event/dispatch_event_support.h>
+
+// import temporarily from JSContextRefPrivate.h
+extern "C" JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
 
 using namespace std;
 using namespace WrtDeviceApis;
@@ -256,17 +258,18 @@ JSValueRef JSPreferences::removeItem(JSContextRef context,
 
         std::string key = converter.toString(arguments[0]);
 
-        auto event = modifyItemAndCreateEvent(ModificationType::RemoveItem,
-                                              thisObject,
-                                              key);
-
-        auto iframe = IFrameSupport::
-                getIFrameObjectForWidget(getWidgetObject(thisObject));
+        DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+        getIStorage(thisObject)->removeItem(key);
+        DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
 
-        Assert(iframe && "Iframe is NULL");
+        JSContextRef g_context  = JSContextGetGlobalContext(context);
+        std::string oldValueStr = "";
+        std::string newValueStr = "";
 
-        AddEventListenerSupport::
-            CallStorageListenersFromDifferentIFrames(iframe, event);
+        if (!!oldValue) { oldValueStr = *oldValue; }
+        if (!!newValue) { newValueStr = *newValue; }
+        
+        DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");
         return JSValueMakeNull(context);
@@ -295,17 +298,18 @@ JSValueRef JSPreferences::setItem(JSContextRef context,
         std::string key = converter.toString(arguments[0]);
         std::string value = converter.tryString(arguments[1]);
 
-        auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
-                                              thisObject,
-                                              key,
-                                              value);
+        DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+        getIStorage(thisObject)->setItem(key, value, false);
+        DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
 
-        auto iframe = IFrameSupport::
-                getIFrameObjectForWidget(getWidgetObject(thisObject));
-        Assert(iframe && "Iframe is NULL");
+        JSContextRef g_context  = JSContextGetGlobalContext(context);
+        std::string oldValueStr = "";
+        std::string newValueStr = "";
 
-        AddEventListenerSupport::
-            CallStorageListenersFromDifferentIFrames(iframe, event);
+        if (!!oldValue) { oldValueStr = *oldValue; }
+        if (!!newValue) { newValueStr = *newValue; }
+        
+        DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");
 
@@ -331,16 +335,9 @@ JSValueRef JSPreferences::clear(JSContextRef context,
     Try {
         getIStorage(thisObject)->clear(false);
 
-        auto iframe = IFrameSupport::
-                getIFrameObjectForWidget(getWidgetObject(thisObject));
-
-        Assert(iframe && "Iframe is NULL");
-
-        //create event object
-        IStorageEventPtr storageEvent = getStorageEvent();
+        JSContextRef g_context  = JSContextGetGlobalContext(context);
 
-        AddEventListenerSupport::
-            CallStorageListenersFromDifferentIFrames(iframe, storageEvent);
+        DispatchEventSupport::dispatchStorageEvent(g_context, "", "", "", "");
 
         LogDebug("end");
 
@@ -516,17 +513,18 @@ bool JSPreferences::setProperty(JSContextRef context,
         std::string key = converter.toString(propertyName);
         std::string value = converter.toString(jvalue);
 
-        auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
-                                              object,
-                                              key,
-                                              value);
+        DPL::Optional<std::string> oldValue = getIStorage(object)->getValue(key);
+        getIStorage(object)->setItem(key, value, false);
+        DPL::Optional<std::string> newValue = getIStorage(object)->getValue(key);
 
-        auto iframe = IFrameSupport::
-                getIFrameObjectForWidget(getWidgetObject(object));
-        Assert(iframe && "Iframe is NULL");
+        JSContextRef g_context  = JSContextGetGlobalContext(context);
+        std::string oldValueStr = "";
+        std::string newValueStr = "";
 
-        AddEventListenerSupport::
-            CallStorageListenersFromDifferentIFrames(iframe, event);
+        if (!!oldValue) { oldValueStr = *oldValue; }
+        if (!!newValue) { newValueStr = *newValue; }
+        
+        DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");
 
index 6dd18ba..162820f 100644 (file)
@@ -31,7 +31,6 @@
 #include <Widget/IWidget.h>
 #include <LocalStorage/LocalStorageMgr.h>
 #include <Commons/WrtAccess/WrtAccess.h>
-#include <js-overlay/js_iframe_support.h>
 
 #define CATCH_EXCEPTION_NO_MODIFABLE \
     Catch(Commons::LocalStorageValueNoModifableException) { \
@@ -302,7 +301,6 @@ void JSWidget::acquireGlobalContext(java_script_context_t global_context,
                                     js_object_instance_t iframe,
                                     js_object_instance_t object)
 {
-    IFrameSupport::RegisterWidget(global_context, iframe, object);
     if (!m_globalContext) {
         m_globalContext = static_cast<JSContextRef>(global_context);
         LogInfo("Global context acquired.");
index 6b64770..d296869 100644 (file)
@@ -25,8 +25,6 @@
 
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtAccess/WrtAccess.h>
-#include <js-overlay/js_overlay_addEventListener.h>
-#include <js-overlay/js_iframe_support.h>
 
 #include "JSWidget.h"
 #include "JSPreferences.h"
@@ -45,9 +43,9 @@ namespace Options {
 class_definition_options_t WidgetOptions = {
     JS_CLASS,
     CREATE_INSTANCE,
-    ALWAYS_NOTICE,
+    NONE_NOTICE,
     USE_OVERLAYED, //ignored
-    IFrameSupport::RegisterWidget,
+    NULL,
     NULL,
     NULL
 };