tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsMaiInterfaceImage.cpp (1845B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "InterfaceInitFuncs.h"
      8 
      9 #include "AccessibleWrap.h"
     10 #include "mozilla/a11y/Accessible.h"
     11 #include "mozilla/Likely.h"
     12 #include "nsMai.h"
     13 #include "nsIAccessibleTypes.h"
     14 
     15 using namespace mozilla;
     16 using namespace mozilla::a11y;
     17 
     18 extern "C" {
     19 const gchar* getDescriptionCB(AtkObject* aAtkObj);
     20 
     21 static void getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
     22                               AtkCoordType aCoordType) {
     23  LayoutDeviceIntPoint pos(-1, -1);
     24  uint32_t geckoCoordType =
     25      (aCoordType == ATK_XY_WINDOW)
     26          ? nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE
     27          : nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
     28 
     29  if (Accessible* acc = GetInternalObj(ATK_OBJECT(aImage))) {
     30    pos = acc->Position(geckoCoordType);
     31  }
     32 
     33  *aAccX = pos.x;
     34  *aAccY = pos.y;
     35 }
     36 
     37 static const gchar* getImageDescriptionCB(AtkImage* aImage) {
     38  return getDescriptionCB(ATK_OBJECT(aImage));
     39 }
     40 
     41 static void getImageSizeCB(AtkImage* aImage, gint* aAccWidth,
     42                           gint* aAccHeight) {
     43  LayoutDeviceIntSize size(-1, -1);
     44  if (Accessible* acc = GetInternalObj(ATK_OBJECT(aImage))) {
     45    size = acc->Size();
     46  }
     47 
     48  *aAccWidth = size.width;
     49  *aAccHeight = size.height;
     50 }
     51 
     52 }  // extern "C"
     53 
     54 void imageInterfaceInitCB(AtkImageIface* aIface) {
     55  NS_ASSERTION(aIface, "no interface!");
     56  if (MOZ_UNLIKELY(!aIface)) return;
     57 
     58  aIface->get_image_position = getImagePositionCB;
     59  aIface->get_image_description = getImageDescriptionCB;
     60  aIface->get_image_size = getImageSizeCB;
     61 }