michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "InterfaceInitFuncs.h" michael@0: michael@0: #include "AccessibleWrap.h" michael@0: #include "ImageAccessible.h" michael@0: #include "mozilla/Likely.h" michael@0: #include "nsMai.h" michael@0: #include "nsIAccessibleTypes.h" michael@0: #include "nsIURI.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::a11y; michael@0: michael@0: extern "C" { michael@0: const gchar* getDescriptionCB(AtkObject* aAtkObj); michael@0: michael@0: static void michael@0: getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY, michael@0: AtkCoordType aCoordType) michael@0: { michael@0: AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage)); michael@0: if (!accWrap || !accWrap->IsImage()) michael@0: return; michael@0: michael@0: ImageAccessible* image = accWrap->AsImage(); michael@0: uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ? michael@0: nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE : michael@0: nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE; michael@0: // Returned in screen coordinates michael@0: image->GetImagePosition(geckoCoordType, aAccX, aAccY); michael@0: } michael@0: michael@0: static const gchar* michael@0: getImageDescriptionCB(AtkImage* aImage) michael@0: { michael@0: return getDescriptionCB(ATK_OBJECT(aImage)); michael@0: } michael@0: michael@0: static void michael@0: getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight) michael@0: { michael@0: AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage)); michael@0: if (!accWrap || !accWrap->IsImage()) michael@0: return; michael@0: michael@0: accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight); michael@0: } michael@0: } michael@0: michael@0: void michael@0: imageInterfaceInitCB(AtkImageIface* aIface) michael@0: { michael@0: NS_ASSERTION(aIface, "no interface!"); michael@0: if (MOZ_UNLIKELY(!aIface)) michael@0: return; michael@0: michael@0: aIface->get_image_position = getImagePositionCB; michael@0: aIface->get_image_description = getImageDescriptionCB; michael@0: aIface->get_image_size = getImageSizeCB; michael@0: }