From c9621142bfbc318ed9c87b6262c0dc4ed64bac00 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Fri, 28 Jun 2013 15:47:50 +0900 Subject: [PATCH] Change screen reader mode setting without vconf [Title] Change screen reader mode setting without vconf [Issue#] N/A [Problem] Screen reader can behave in unwanted app. [Cause] Screen reader behavior can be different from settings. [Solution] Screen reader behave after receiving highlight action event. Change-Id: I0b9370430e5104b6134b6ee48ec5f3f8d15720b5 --- .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 2 +- Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | 2 +- .../UIProcess/API/efl/tizen/ScreenReaderProxy.cpp | 88 ++++++++++------------ .../UIProcess/API/efl/tizen/ScreenReaderProxy.h | 15 ++-- Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp | 6 +- .../WebProcess/WebPage/efl/tizen/ScreenReader.cpp | 6 +- .../WebProcess/WebPage/efl/tizen/ScreenReader.h | 1 - 7 files changed, 56 insertions(+), 64 deletions(-) mode change 100644 => 100755 Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.cpp mode change 100644 => 100755 Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.h diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index e10ae50..6ec2bfb 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -920,7 +920,7 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal displayViewport(); #if ENABLE(TIZEN_SCREEN_READER) - if (ScreenReaderProxy::screenReader().isEnabled() + if (ScreenReaderProxy::screenReader().isActive(m_viewImpl) && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale)) ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale); #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 13fd85b9..fe3a5b7 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -862,7 +862,7 @@ static void _ewk_view_smart_del(Evas_Object* ewkView) EwkViewImpl::removeFromPageViewMap(ewkView); EWK_VIEW_SD_GET(ewkView, smartData); #if ENABLE(TIZEN_SCREEN_READER) - ScreenReaderProxy::screenReader().remove(smartData->priv); + ScreenReaderProxy::screenReader().finalize(smartData->priv); #endif #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // Close color picker if it's opened. diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.cpp b/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.cpp index b8545b8..e9bea77 100755 --- a/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.cpp @@ -44,42 +44,41 @@ ScreenReaderProxy& ScreenReaderProxy::screenReader() } ScreenReaderProxy::ScreenReaderProxy() - : m_ttsHandle(0) + : m_activeViewImpl(0) + , m_ttsHandle(0) { - int enabled; - m_enabled = (!vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &enabled) && enabled); - vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, didSettingsChanged, this); } ScreenReaderProxy::~ScreenReaderProxy() { - vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, didSettingsChanged); + if (m_ttsHandle) + tts_destroy(m_ttsHandle); } -void ScreenReaderProxy::addViewImpl(EwkViewImpl* viewImpl) +void ScreenReaderProxy::setActiveViewImpl(EwkViewImpl* viewImpl) { - if (m_viewImplSet.contains(viewImpl)) + if (viewImpl == m_activeViewImpl) return; - m_viewImplSet.append(viewImpl); + if (m_activeViewImpl) + clearActiveViewImpl(m_activeViewImpl); + + m_activeViewImpl = viewImpl; viewImpl->focusRing->setImage(SCREEN_READER_FOCUS_RING_IMAGE_PATH, 4, 2); + + initializeTTS(); } -void ScreenReaderProxy::removeViewImpl(EwkViewImpl* viewImpl) +void ScreenReaderProxy::clearActiveViewImpl(EwkViewImpl* viewImpl) { - size_t remove = m_viewImplSet.find(viewImpl); - if (remove == notFound) + if (viewImpl != m_activeViewImpl) return; - m_viewImplSet.remove(remove); + m_activeViewImpl = 0; viewImpl->page()->clearScreenReader(); viewImpl->focusRing->setImage(String(), 0, 0); - if (!m_viewImplSet.isEmpty() || !m_ttsHandle) - return; - - tts_destroy(m_ttsHandle); - m_ttsHandle = 0; + tts_stop(m_ttsHandle); } void ScreenReaderProxy::initialize(EwkViewImpl* viewImpl) @@ -101,8 +100,10 @@ void ScreenReaderProxy::initialize(EwkViewImpl* viewImpl) elm_access_action_cb_set(accessObject, ELM_ACCESS_ACTION_READ, executeAction, viewImpl); } -void ScreenReaderProxy::remove(EwkViewImpl* viewImpl) +void ScreenReaderProxy::finalize(EwkViewImpl* viewImpl) { + clearActiveViewImpl(viewImpl); + Evas_Object* accessObject = elm_access_object_get(viewImpl->view()); if (accessObject) { elm_access_action_cb_set(accessObject, ELM_ACCESS_ACTION_HIGHLIGHT, 0, 0); @@ -117,8 +118,23 @@ void ScreenReaderProxy::remove(EwkViewImpl* viewImpl) elm_access_action_cb_set(accessObject, ELM_ACCESS_ACTION_BACK, 0, 0); elm_access_action_cb_set(accessObject, ELM_ACCESS_ACTION_READ, 0, 0); } +} - removeViewImpl(viewImpl); +bool ScreenReaderProxy::initializeTTS() +{ + if (m_ttsHandle) + return true; + + if (tts_create(&m_ttsHandle) + || tts_set_state_changed_cb(m_ttsHandle, didTTSStateChanged, 0) + || tts_set_mode(m_ttsHandle, TTS_MODE_SCREEN_READER) + || tts_prepare(m_ttsHandle)) { + tts_destroy(m_ttsHandle); + m_ttsHandle = 0; + return false; + } + + return true; } void ScreenReaderProxy::setText(const String& text) @@ -130,16 +146,8 @@ void ScreenReaderProxy::setText(const String& text) return; } - if (!m_ttsHandle) { - if (tts_create(&m_ttsHandle) - || tts_set_state_changed_cb(m_ttsHandle, didTTSStateChanged, 0) - || tts_set_mode(m_ttsHandle, TTS_MODE_SCREEN_READER) - || tts_prepare(m_ttsHandle)) { - tts_destroy(m_ttsHandle); - m_ttsHandle = 0; - return; - } - } + if (!initializeTTS()) + return; tts_state_e state; if (!tts_get_state(m_ttsHandle, &state)) { @@ -152,14 +160,15 @@ void ScreenReaderProxy::setText(const String& text) Eina_Bool ScreenReaderProxy::executeAction(void* data, Evas_Object*, Elm_Access_Action_Info* actionInfo) { - if (!screenReader().m_enabled || !actionInfo) + if (!actionInfo) return false; EwkViewImpl* viewImpl = static_cast(data); - screenReader().addViewImpl(viewImpl); switch (actionInfo->action_type) { case ELM_ACCESS_ACTION_HIGHLIGHT: + screenReader().setActiveViewImpl(viewImpl); + if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_NEXT) return viewImpl->page()->moveScreenReaderFocus(true); if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_PREV) @@ -167,9 +176,7 @@ Eina_Bool ScreenReaderProxy::executeAction(void* data, Evas_Object*, Elm_Access_ break; case ELM_ACCESS_ACTION_UNHIGHLIGHT: - viewImpl->page()->clearScreenReader(); - viewImpl->focusRing->hide(false); - tts_stop(screenReader().m_ttsHandle); + screenReader().clearActiveViewImpl(viewImpl); break; case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT: @@ -252,19 +259,6 @@ Eina_Bool ScreenReaderProxy::executeAction(void* data, Evas_Object*, Elm_Access_ return true; } -void ScreenReaderProxy::didSettingsChanged(keynode_t* keynode, void* data) -{ - ScreenReaderProxy* screenReader = static_cast(data); - - int enabled; - screenReader->m_enabled = (!vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &enabled) && enabled); - - if (!screenReader->m_enabled) { - while (!screenReader->m_viewImplSet.isEmpty()) - screenReader->removeViewImpl(screenReader->m_viewImplSet[0]); - } -} - void ScreenReaderProxy::didTTSStateChanged(tts_h, tts_state_e, tts_state_e currentState, void*) { if (currentState != TTS_STATE_READY || screenReader().m_ttsText.isEmpty()) diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.h b/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.h index 8eed23d..52b0b3c 100755 --- a/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.h +++ b/Source/WebKit2/UIProcess/API/efl/tizen/ScreenReaderProxy.h @@ -31,7 +31,6 @@ #include #include #include -#include #include class EwkViewImpl; @@ -44,10 +43,10 @@ public: virtual ~ScreenReaderProxy(); - bool isEnabled() { return m_enabled; } + bool isActive(EwkViewImpl* viewImpl) { return viewImpl == m_activeViewImpl; } void initialize(EwkViewImpl*); - void remove(EwkViewImpl*); + void finalize(EwkViewImpl*); void setText(const String&); @@ -56,14 +55,14 @@ public: private: ScreenReaderProxy(); - void addViewImpl(EwkViewImpl*); - void removeViewImpl(EwkViewImpl*); + void setActiveViewImpl(EwkViewImpl*); + void clearActiveViewImpl(EwkViewImpl*); + + bool initializeTTS(); - static void didSettingsChanged(keynode_t*, void*); static void didTTSStateChanged(tts_h, tts_state_e, tts_state_e, void*); - bool m_enabled; - Vector m_viewImplSet; + EwkViewImpl* m_activeViewImpl; tts_h m_ttsHandle; String m_ttsText; diff --git a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp index f4b5481..0507d75 100755 --- a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp @@ -976,7 +976,7 @@ void WebPageProxy::didGetLinkMagnifierRect(const IntPoint& position, const IntRe void WebPageProxy::openLink(const IntPoint& position) { #if ENABLE(GESTURE_EVENTS) - IntPoint globalPosition(EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position)); + IntPoint globalPosition(static_cast(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position)); WebGestureEvent gesture(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get()); handleGestureEvent(gesture); #endif @@ -1003,7 +1003,7 @@ void WebPageProxy::clearScreenReaderFocus() bool WebPageProxy::raiseTapEvent(const IntPoint& position) { - IntPoint globalPosition = EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position); + IntPoint globalPosition = static_cast(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position); bool result; process()->sendSync(Messages::WebPage::RaiseTapEvent(position, globalPosition), Messages::WebPage::RaiseTapEvent::Reply(result), m_pageID); @@ -1017,7 +1017,7 @@ void WebPageProxy::adjustScreenReaderFocusedObjectValue(bool up) void WebPageProxy::recalcScreenReaderFocusRect() { - if (!ScreenReaderProxy::screenReader().isEnabled()) + if (!ScreenReaderProxy::screenReader().isActive(static_cast(m_pageClient)->viewImpl())) return; process()->send(Messages::WebPage::RecalcScreenReaderFocusRect(), m_pageID); diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.cpp b/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.cpp old mode 100644 new mode 100755 index f712b60..ac1ba95 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.cpp @@ -53,7 +53,6 @@ using namespace WebCore; namespace WebKit { -int ScreenReader::s_readerCount = 0; IntSize ScreenReader::s_hitTestPadding = IntSize(); ScreenReader::ScreenReader(WebPage* page) @@ -62,17 +61,18 @@ ScreenReader::ScreenReader(WebPage* page) , m_hasFocus(false) , m_isForward(true) { - if (++s_readerCount) { + static bool initialized = false; + if (!initialized) { AXObjectCache::enableAccessibility(); int unit = static_cast(screenRect(0).width() / 10); s_hitTestPadding.setWidth(unit); s_hitTestPadding.setHeight(unit); + initialized = true; } } ScreenReader::~ScreenReader() { - --s_readerCount; } RenderObject* ScreenReader::traverse(RenderObject* object) diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.h b/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.h old mode 100644 new mode 100755 index b1f30cc..41bf628 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.h +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/ScreenReader.h @@ -73,7 +73,6 @@ private: bool m_hasFocus; bool m_isForward; - static int s_readerCount; static WebCore::IntSize s_hitTestPadding; }; -- 2.7.4