2007-05-16 10:04:20 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=2:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04: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-16 10:04:20 +04:00
|
|
|
|
2012-04-13 19:46:37 +04:00
|
|
|
#include "ia2AccessibleComponent.h"
|
2007-05-16 10:04:20 +04:00
|
|
|
|
|
|
|
#include "AccessibleComponent_i.c"
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
#include "AccessibleWrap.h"
|
2011-04-10 03:38:06 +04:00
|
|
|
#include "States.h"
|
2013-05-05 09:38:14 +04:00
|
|
|
#include "IUnknownImpl.h"
|
2007-05-16 10:04:20 +04:00
|
|
|
|
2012-04-13 19:46:37 +04:00
|
|
|
#include "nsIFrame.h"
|
2007-05-16 10:04:20 +04:00
|
|
|
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2007-05-16 10:04:20 +04:00
|
|
|
// IUnknown
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-04-13 19:46:37 +04:00
|
|
|
ia2AccessibleComponent::QueryInterface(REFIID iid, void** ppv)
|
2007-05-16 10:04:20 +04:00
|
|
|
{
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-04-03 04:33:43 +04:00
|
|
|
*ppv = nullptr;
|
2007-05-16 10:04:20 +04:00
|
|
|
|
|
|
|
if (IID_IAccessibleComponent == iid) {
|
2007-07-08 11:08:04 +04:00
|
|
|
*ppv = static_cast<IAccessibleComponent*>(this);
|
|
|
|
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
2007-05-16 10:04:20 +04:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IAccessibleComponent
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-04-13 19:46:37 +04:00
|
|
|
ia2AccessibleComponent::get_locationInParent(long* aX, long* aY)
|
2007-05-16 10:04:20 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aX || !aY)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2007-05-16 10:04:20 +04:00
|
|
|
*aX = 0;
|
|
|
|
*aY = 0;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
|
2012-04-09 18:45:47 +04:00
|
|
|
if (acc->IsDefunct())
|
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2007-05-16 10:04:20 +04:00
|
|
|
|
|
|
|
// If the object is not on any screen the returned position is (0,0).
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = acc->State();
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::INVISIBLE)
|
2007-05-16 10:04:20 +04:00
|
|
|
return S_OK;
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
nsIntRect rect = acc->Bounds();
|
2007-05-16 10:04:20 +04:00
|
|
|
|
|
|
|
// The coordinates of the returned position are relative to this object's
|
|
|
|
// parent or relative to the screen on which this object is rendered if it
|
|
|
|
// has no parent.
|
2014-09-16 21:30:23 +04:00
|
|
|
if (!acc->Parent()) {
|
|
|
|
*aX = rect.x;
|
|
|
|
*aY = rect.y;
|
2008-03-30 07:24:02 +04:00
|
|
|
return S_OK;
|
2007-05-16 10:04:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// The coordinates of the bounding box are given relative to the parent's
|
|
|
|
// coordinate system.
|
2014-09-16 21:30:23 +04:00
|
|
|
nsIntRect parentRect = acc->Parent()->Bounds();
|
|
|
|
*aX = rect.x - parentRect.x;
|
|
|
|
*aY = rect.y - parentRect.y;
|
2007-05-16 10:04:20 +04:00
|
|
|
return S_OK;
|
2008-03-30 07:24:02 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-16 10:04:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-04-13 19:46:37 +04:00
|
|
|
ia2AccessibleComponent::get_foreground(IA2Color* aForeground)
|
2007-05-16 10:04:20 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aForeground)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*aForeground = 0;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
|
2012-03-13 21:35:26 +04:00
|
|
|
if (acc->IsDefunct())
|
2012-04-09 18:45:47 +04:00
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2008-02-12 18:48:51 +03:00
|
|
|
|
2012-03-13 21:35:26 +04:00
|
|
|
nsIFrame* frame = acc->GetFrame();
|
|
|
|
if (frame)
|
2013-02-17 01:51:02 +04:00
|
|
|
*aForeground = frame->StyleColor()->mColor;
|
2012-03-13 21:35:26 +04:00
|
|
|
|
|
|
|
return S_OK;
|
2007-05-16 10:04:20 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-16 10:04:20 +04:00
|
|
|
}
|
|
|
|
|
2012-03-13 21:35:26 +04:00
|
|
|
STDMETHODIMP
|
2012-04-13 19:46:37 +04:00
|
|
|
ia2AccessibleComponent::get_background(IA2Color* aBackground)
|
2007-05-16 10:04:20 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aBackground)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*aBackground = 0;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
|
2012-03-13 05:00:29 +04:00
|
|
|
if (acc->IsDefunct())
|
2012-04-09 18:45:47 +04:00
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2007-05-16 10:04:20 +04:00
|
|
|
|
2012-03-13 21:35:26 +04:00
|
|
|
nsIFrame* frame = acc->GetFrame();
|
|
|
|
if (frame)
|
2013-02-17 01:51:02 +04:00
|
|
|
*aBackground = frame->StyleBackground()->mBackgroundColor;
|
2007-05-16 10:04:20 +04:00
|
|
|
|
|
|
|
return S_OK;
|
2008-03-30 07:24:02 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-16 10:04:20 +04:00
|
|
|
}
|
|
|
|
|