2012-12-01 16:58:25 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "Platform.h"
|
|
|
|
|
|
|
|
#include "AccEvent.h"
|
|
|
|
#include "Compatibility.h"
|
2013-01-08 16:41:58 -08:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2015-08-06 12:27:35 -07:00
|
|
|
#include "ia2AccessibleText.h"
|
2012-12-01 16:58:25 -08:00
|
|
|
#include "nsWinUtils.h"
|
2015-01-19 13:34:14 -08:00
|
|
|
#include "mozilla/a11y/ProxyAccessible.h"
|
2015-04-06 03:04:44 -07:00
|
|
|
#include "ProxyWrappers.h"
|
2012-12-01 16:58:25 -08:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
|
|
|
void
|
|
|
|
a11y::PlatformInit()
|
|
|
|
{
|
|
|
|
Compatibility::Init();
|
|
|
|
|
|
|
|
nsWinUtils::MaybeStartWindowEmulation();
|
2015-08-06 12:27:35 -07:00
|
|
|
ia2AccessibleText::InitTextChangeData();
|
2012-12-01 16:58:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
a11y::PlatformShutdown()
|
|
|
|
{
|
|
|
|
::DestroyCaret();
|
|
|
|
|
|
|
|
nsWinUtils::ShutdownWindowEmulation();
|
|
|
|
}
|
|
|
|
|
2014-03-07 13:35:19 -08:00
|
|
|
void
|
2015-08-07 13:27:34 -07:00
|
|
|
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
|
2014-03-07 13:35:19 -08:00
|
|
|
{
|
2015-08-07 13:27:34 -07:00
|
|
|
AccessibleWrap* wrapper = nullptr;
|
|
|
|
if (aInterfaces & Interfaces::DOCUMENT) {
|
|
|
|
wrapper = new DocProxyAccessibleWrap(aProxy);
|
|
|
|
} else if (aInterfaces & Interfaces::HYPERTEXT) {
|
|
|
|
wrapper = new HyperTextProxyAccessibleWrap(aProxy);
|
|
|
|
} else {
|
|
|
|
wrapper = new ProxyAccessibleWrap(aProxy);
|
|
|
|
}
|
|
|
|
|
2015-10-08 12:39:10 -07:00
|
|
|
wrapper->SetProxyInterfaces(aInterfaces);
|
2015-01-19 13:34:14 -08:00
|
|
|
wrapper->AddRef();
|
|
|
|
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(wrapper));
|
2014-03-07 13:35:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-19 13:34:14 -08:00
|
|
|
a11y::ProxyDestroyed(ProxyAccessible* aProxy)
|
2014-03-07 13:35:19 -08:00
|
|
|
{
|
2015-08-07 13:27:34 -07:00
|
|
|
AccessibleWrap* wrapper =
|
|
|
|
reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
|
2015-07-27 14:52:03 -07:00
|
|
|
MOZ_ASSERT(wrapper);
|
|
|
|
if (!wrapper)
|
|
|
|
return;
|
|
|
|
|
2015-08-27 14:24:13 -07:00
|
|
|
auto doc =
|
|
|
|
static_cast<DocProxyAccessibleWrap*>(WrapperFor(aProxy->Document()));
|
2015-10-14 07:58:35 -07:00
|
|
|
MOZ_ASSERT(doc);
|
|
|
|
if (doc) {
|
2015-08-27 14:24:13 -07:00
|
|
|
#ifdef _WIN64
|
2015-10-14 07:58:35 -07:00
|
|
|
uint32_t id = wrapper->GetExistingID();
|
|
|
|
if (id != AccessibleWrap::kNoID) {
|
|
|
|
doc->RemoveID(id);
|
|
|
|
}
|
2015-08-27 14:24:13 -07:00
|
|
|
#else
|
2015-10-14 07:58:35 -07:00
|
|
|
doc->RemoveID(-reinterpret_cast<int32_t>(wrapper));
|
2015-08-27 14:24:13 -07:00
|
|
|
#endif
|
2015-10-14 07:58:35 -07:00
|
|
|
}
|
2015-08-27 14:24:13 -07:00
|
|
|
|
2015-01-19 13:34:14 -08:00
|
|
|
wrapper->Shutdown();
|
|
|
|
aProxy->SetWrapper(0);
|
|
|
|
wrapper->Release();
|
2014-03-07 13:35:19 -08:00
|
|
|
}
|
2014-09-30 07:00:26 -07:00
|
|
|
|
|
|
|
void
|
2015-08-27 11:03:53 -07:00
|
|
|
a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
|
2014-09-30 07:00:26 -07:00
|
|
|
{
|
2015-08-27 11:03:53 -07:00
|
|
|
AccessibleWrap::FireWinEvent(WrapperFor(aTarget), aEventType);
|
2014-09-30 07:00:26 -07:00
|
|
|
}
|
2015-05-13 11:21:23 -07:00
|
|
|
|
|
|
|
void
|
2015-08-27 11:03:53 -07:00
|
|
|
a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget, uint64_t, bool)
|
2015-05-13 11:21:23 -07:00
|
|
|
{
|
2015-08-27 11:03:53 -07:00
|
|
|
AccessibleWrap::FireWinEvent(WrapperFor(aTarget),
|
|
|
|
nsIAccessibleEvent::EVENT_STATE_CHANGE);
|
2015-05-13 11:21:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
|
|
|
|
{
|
2015-08-27 11:03:53 -07:00
|
|
|
AccessibleWrap::FireWinEvent(WrapperFor(aTarget),
|
|
|
|
nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED);
|
2015-05-13 11:21:23 -07:00
|
|
|
}
|
2015-06-05 12:43:30 -07:00
|
|
|
|
|
|
|
void
|
2015-08-07 12:02:10 -07:00
|
|
|
a11y::ProxyTextChangeEvent(ProxyAccessible* aText, const nsString& aStr,
|
|
|
|
int32_t aStart, uint32_t aLen, bool aInsert, bool)
|
2015-06-05 12:43:30 -07:00
|
|
|
{
|
2015-08-07 12:02:10 -07:00
|
|
|
AccessibleWrap* wrapper = WrapperFor(aText);
|
2015-09-08 14:08:16 -07:00
|
|
|
MOZ_ASSERT(wrapper);
|
|
|
|
if (!wrapper) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-07 12:02:10 -07:00
|
|
|
auto text = static_cast<HyperTextAccessibleWrap*>(wrapper->AsHyperText());
|
|
|
|
if (text) {
|
|
|
|
ia2AccessibleText::UpdateTextChangeData(text, aInsert, aStr, aStart, aLen);
|
|
|
|
}
|
2015-08-27 11:03:53 -07:00
|
|
|
|
|
|
|
uint32_t eventType = aInsert ? nsIAccessibleEvent::EVENT_TEXT_INSERTED :
|
|
|
|
nsIAccessibleEvent::EVENT_TEXT_REMOVED;
|
|
|
|
AccessibleWrap::FireWinEvent(wrapper, eventType);
|
2015-06-05 12:43:30 -07:00
|
|
|
}
|