void addAccessibilityNotificationHandler(AccessibilityNotificationHandler* notificationHandler) { if (!notificationHandler) return; #if PLATFORM(GTK) JSGlobalContextRef jsContext = webkit_web_frame_get_global_context(mainFrame); #else JSContextRef jsContext = 0; #endif if (!jsContext) return; JSValueProtect(jsContext, notificationHandler->notificationFunctionCallback()); // Check if this notification handler is related to a specific element. if (notificationHandler->platformElement()) { if (notificationHandlers.contains(notificationHandler->platformElement())) { JSValueUnprotect(jsContext, notificationHandlers.find(notificationHandler->platformElement())->value->notificationFunctionCallback()); notificationHandlers.remove(notificationHandler->platformElement()); } notificationHandlers.add(notificationHandler->platformElement(), notificationHandler); } else { if (notificationHandlers.contains(GlobalNotificationKey)) { JSValueUnprotect(jsContext, notificationHandlers.find(GlobalNotificationKey)->value->notificationFunctionCallback()); notificationHandlers.remove(GlobalNotificationKey); } notificationHandlers.add(GlobalNotificationKey, notificationHandler); } connectAccessibilityCallbacks(); }
void addAccessibilityNotificationHandler(AccessibilityNotificationHandler* notificationHandler) { if (!notificationHandler) return; #if PLATFORM(GTK) JSGlobalContextRef jsContext = webkit_web_frame_get_global_context(mainFrame); #elif PLATFORM(EFL) JSGlobalContextRef jsContext = DumpRenderTreeSupportEfl::globalContextRefForFrame(browser->mainFrame()); #else JSContextRef jsContext = 0; #endif if (!jsContext) return; JSValueProtect(jsContext, notificationHandler->notificationFunctionCallback()); // Check if this notification handler is related to a specific element. if (notificationHandler->platformElement()) { NotificationHandlersMap::iterator currentNotificationHandler = notificationHandlers.find(notificationHandler->platformElement()); if (currentNotificationHandler != notificationHandlers.end()) { ASSERT(currentNotificationHandler->value->platformElement()); JSValueUnprotect(jsContext, currentNotificationHandler->value->notificationFunctionCallback()); notificationHandlers.remove(currentNotificationHandler->value->platformElement()); } notificationHandlers.add(notificationHandler->platformElement(), notificationHandler); } else { if (globalNotificationHandler) JSValueUnprotect(jsContext, globalNotificationHandler->notificationFunctionCallback()); globalNotificationHandler = notificationHandler; } connectAccessibilityCallbacks(); }
void AccessibilityController::setLogAccessibilityEvents(bool logAccessibilityEvents) { if (logAccessibilityEvents == loggingAccessibilityEvents) return; if (!logAccessibilityEvents) { disconnectAccessibilityCallbacks(); loggingAccessibilityEvents = false; return; } connectAccessibilityCallbacks(); loggingAccessibilityEvents = true; }
void AccessibilityNotificationHandler::setNotificationFunctionCallback(JSValueRef notificationFunctionCallback) { if (!notificationFunctionCallback) { removeAccessibilityNotificationHandler(); disconnectAccessibilityCallbacks(); return; } m_notificationFunctionCallback = notificationFunctionCallback; #if PLATFORM(GTK) || PLATFORM(EFL) WKBundlePageRef page = InjectedBundle::singleton().page()->page(); WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(page); JSContextRef jsContext = WKBundleFrameGetJavaScriptContext(mainFrame); #else JSContextRef jsContext = nullptr; #endif if (!jsContext) return; connectAccessibilityCallbacks(); JSValueProtect(jsContext, m_notificationFunctionCallback); // Check if this notification handler is related to a specific element. if (m_platformElement) { NotificationHandlersMap::iterator currentNotificationHandler = notificationHandlers.find(m_platformElement.get()); if (currentNotificationHandler != notificationHandlers.end()) { ASSERT(currentNotificationHandler->value->platformElement()); JSValueUnprotect(jsContext, currentNotificationHandler->value->notificationFunctionCallback()); notificationHandlers.remove(currentNotificationHandler->value->platformElement().get()); } notificationHandlers.add(m_platformElement.get(), this); } else { if (globalNotificationHandler) JSValueUnprotect(jsContext, globalNotificationHandler->notificationFunctionCallback()); globalNotificationHandler = this; } }
void AccessibilityNotificationHandler::logAccessibilityEvents() { connectAccessibilityCallbacks(); loggingAccessibilityEvents = true; }