accessible/src/atk/nsMaiInterfaceImage.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/atk/nsMaiInterfaceImage.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "InterfaceInitFuncs.h"
    1.11 +
    1.12 +#include "AccessibleWrap.h"
    1.13 +#include "ImageAccessible.h"
    1.14 +#include "mozilla/Likely.h"
    1.15 +#include "nsMai.h"
    1.16 +#include "nsIAccessibleTypes.h"
    1.17 +#include "nsIURI.h"
    1.18 +
    1.19 +using namespace mozilla;
    1.20 +using namespace mozilla::a11y;
    1.21 +
    1.22 +extern "C" {
    1.23 +const gchar* getDescriptionCB(AtkObject* aAtkObj);
    1.24 +
    1.25 +static void
    1.26 +getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
    1.27 +                   AtkCoordType aCoordType)
    1.28 +{
    1.29 +  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
    1.30 +  if (!accWrap || !accWrap->IsImage())
    1.31 +    return;
    1.32 +
    1.33 +  ImageAccessible* image = accWrap->AsImage();
    1.34 +  uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
    1.35 +    nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
    1.36 +    nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
    1.37 +  // Returned in screen coordinates
    1.38 +  image->GetImagePosition(geckoCoordType, aAccX, aAccY);
    1.39 +}
    1.40 +
    1.41 +static const gchar*
    1.42 +getImageDescriptionCB(AtkImage* aImage)
    1.43 +{
    1.44 +  return getDescriptionCB(ATK_OBJECT(aImage));
    1.45 +}
    1.46 +
    1.47 +static void
    1.48 +getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
    1.49 +{
    1.50 +  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
    1.51 +  if (!accWrap || !accWrap->IsImage())
    1.52 +    return;
    1.53 +
    1.54 +  accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
    1.55 +}
    1.56 +}
    1.57 +
    1.58 +void
    1.59 +imageInterfaceInitCB(AtkImageIface* aIface)
    1.60 +{
    1.61 +  NS_ASSERTION(aIface, "no interface!");
    1.62 +  if (MOZ_UNLIKELY(!aIface))
    1.63 +    return;
    1.64 +
    1.65 +  aIface->get_image_position = getImagePositionCB;
    1.66 +  aIface->get_image_description = getImageDescriptionCB;
    1.67 +  aIface->get_image_size = getImageSizeCB;
    1.68 +}

mercurial