author Andreas Farre <>
Sun, 05 May 2019 19:26:51 +0000
changeset 472634 f59b3336d254c80bf2b315a74fea0cb0fa8e0d47
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
child 489068 279533771340729b3112c25e889a91d2e5dd7f9d
permissions -rw-r--r--
Bug 1547911 - Don't assert that there are no children when restoring BC. r=nika This is essentially equal to restoring cached children and removing current children from a BrowsingContext, which is the correct behaviour. It would've been better if the current children were removed in a more transparent manner, but it is more important to remove an assert that too eagerly triggers. Differential Revision:

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 */

#include <atk/atk.h>
#include "AtkSocketAccessible.h"

#include "InterfaceInitFuncs.h"
#include "nsMai.h"
#include "mozilla/Likely.h"

using namespace mozilla::a11y;

AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
const char* AtkSocketAccessible::sATKSocketGetTypeSymbol =

bool AtkSocketAccessible::gCanEmbed = FALSE;

extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);

G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
                       AtkSocketAccessible::g_atk_socket_type, 0,

void mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) {}

void mai_atk_socket_init(MaiAtkSocket* aAcc) {}

static AtkObject* mai_atk_socket_new(AccessibleWrap* aAccWrap) {
  NS_ENSURE_TRUE(aAccWrap, nullptr);

  MaiAtkSocket* acc = nullptr;
  acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, nullptr));
  NS_ENSURE_TRUE(acc, nullptr);

  acc->accWrap = aAccWrap;
  return ATK_OBJECT(acc);

extern "C" {
static AtkObject* RefAccessibleAtPoint(AtkComponent* aComponent, gint aX,
                                       gint aY, AtkCoordType aCoordType) {
  NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);

  return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX,
                                    aY, aCoordType);

static void GetExtents(AtkComponent* aComponent, gint* aX, gint* aY,
                       gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
  *aX = *aY = *aWidth = *aHeight = 0;

  if (!MAI_IS_ATK_SOCKET(aComponent)) return;

  getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX, aY, aWidth,
                   aHeight, aCoordType);

void mai_atk_component_iface_init(AtkComponentIface* aIface) {
  NS_ASSERTION(aIface, "Invalid Interface");
  if (MOZ_UNLIKELY(!aIface)) return;

  aIface->ref_accessible_at_point = RefAccessibleAtPoint;
  aIface->get_extents = GetExtents;

AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
                                         DocAccessible* aDoc,
                                         const nsCString& aPlugId)
    : AccessibleWrap(aContent, aDoc) {
  mAtkObject = mai_atk_socket_new(this);
  if (!mAtkObject) return;

  // Embeds the children of an AtkPlug, specified by plugId, as the children of
  // this socket.
  // Using G_TYPE macros instead of ATK_SOCKET macros to avoid undefined
  // symbols.
  if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
      !aPlugId.IsVoid()) {
    AtkSocket* accSocket =
        G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
    g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());

void AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) {
  *aOutAccessible = mAtkObject;

void AtkSocketAccessible::Shutdown() {
  if (mAtkObject) {
    if (MAI_IS_ATK_SOCKET(mAtkObject))
      MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
    mAtkObject = nullptr;