}
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)
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);
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)
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)) {
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<EwkViewImpl*>(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)
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:
return true;
}
-void ScreenReaderProxy::didSettingsChanged(keynode_t* keynode, void* data)
-{
- ScreenReaderProxy* screenReader = static_cast<ScreenReaderProxy*>(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())
void WebPageProxy::openLink(const IntPoint& position)
{
#if ENABLE(GESTURE_EVENTS)
- IntPoint globalPosition(EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position));
+ IntPoint globalPosition(static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position));
WebGestureEvent gesture(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
handleGestureEvent(gesture);
#endif
bool WebPageProxy::raiseTapEvent(const IntPoint& position)
{
- IntPoint globalPosition = EwkViewImpl::fromEvasObject(viewWidget())->transformToScreen().mapPoint(position);
+ IntPoint globalPosition = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->transformToScreen().mapPoint(position);
bool result;
process()->sendSync(Messages::WebPage::RaiseTapEvent(position, globalPosition), Messages::WebPage::RaiseTapEvent::Reply(result), m_pageID);
void WebPageProxy::recalcScreenReaderFocusRect()
{
- if (!ScreenReaderProxy::screenReader().isEnabled())
+ if (!ScreenReaderProxy::screenReader().isActive(static_cast<PageClientImpl*>(m_pageClient)->viewImpl()))
return;
process()->send(Messages::WebPage::RecalcScreenReaderFocusRect(), m_pageID);