2007-05-01 10:08:26 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=2:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-05-01 10:08:26 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2013-01-18 03:16:01 -08:00
|
|
|
#include "Accessible-inl.h"
|
2007-05-01 10:08:26 -07:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsEventShell.h"
|
|
|
|
|
2013-01-08 16:41:58 -08:00
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessibleWrap,
|
|
|
|
HyperTextAccessible)
|
2007-05-01 10:08:26 -07:00
|
|
|
|
2012-07-01 20:42:45 -07:00
|
|
|
STDMETHODIMP
|
|
|
|
HyperTextAccessibleWrap::QueryInterface(REFIID aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (!aInstancePtr)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2013-04-02 17:33:43 -07:00
|
|
|
*aInstancePtr = nullptr;
|
2012-07-01 20:42:45 -07:00
|
|
|
|
|
|
|
if (IsTextRole()) {
|
|
|
|
if (aIID == IID_IAccessibleText)
|
|
|
|
*aInstancePtr =
|
|
|
|
static_cast<IAccessibleText*>(static_cast<ia2AccessibleText*>(this));
|
|
|
|
else if (aIID == IID_IAccessibleHypertext)
|
|
|
|
*aInstancePtr = static_cast<IAccessibleHypertext*>(this);
|
|
|
|
else if (aIID == IID_IAccessibleEditableText)
|
|
|
|
*aInstancePtr = static_cast<IAccessibleEditableText*>(this);
|
|
|
|
|
|
|
|
if (*aInstancePtr) {
|
|
|
|
AddRef();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return AccessibleWrap::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
2007-05-01 10:08:26 -07:00
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
nsresult
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
2007-05-01 10:08:26 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t eventType = aEvent->GetEventType();
|
2007-05-01 10:08:26 -07:00
|
|
|
|
2007-08-10 18:44:44 -07:00
|
|
|
if (eventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
|
|
|
|
eventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* accessible = aEvent->GetAccessible();
|
2013-01-08 16:41:58 -08:00
|
|
|
if (accessible && accessible->IsHyperText()) {
|
|
|
|
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
2015-08-06 13:57:31 -07:00
|
|
|
HyperTextAccessibleWrap* text =
|
|
|
|
static_cast<HyperTextAccessibleWrap*>(accessible->AsHyperText());
|
|
|
|
ia2AccessibleText::UpdateTextChangeData(text, event->IsTextInserted(),
|
|
|
|
event->ModifiedText(),
|
|
|
|
event->GetStartOffset(),
|
|
|
|
event->GetLength());
|
2007-05-12 09:22:08 -07:00
|
|
|
}
|
2007-05-01 10:08:26 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
return HyperTextAccessible::HandleAccEvent(aEvent);
|
2007-05-01 10:08:26 -07:00
|
|
|
}
|