Example #1
0
void BinaryTreeMethod::SerializeTree(TreeNode *p_Root, std::ostream &out)
{
	if(!p_Root)
	{
		out << "# ";
	}
	else
	{
		out << p_Root->i_val << " ";
		SerializeTree(p_Root->p_left, out);
		SerializeTree(p_Root->p_right, out);
	}
}
/* static */ void
DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
                                      nsTArray<AccessibleData>& aTree)
{
  uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
#if defined(XP_WIN)
  int32_t msaaId = AccessibleWrap::GetChildIDFor(aRoot);
#endif
  uint32_t role = aRoot->Role();
  uint32_t childCount = aRoot->ChildCount();
  uint32_t interfaces = InterfacesFor(aRoot);

  // OuterDocAccessibles are special because we don't want to serialize the
  // child doc here, we'll call PDocAccessibleConstructor in
  // NotificationController.
  MOZ_ASSERT(!aRoot->IsDoc(), "documents shouldn't be serialized");
  if (aRoot->IsOuterDoc()) {
    childCount = 0;
  }

#if defined(XP_WIN)
  aTree.AppendElement(AccessibleData(id, msaaId, role, childCount, interfaces));
#else
  aTree.AppendElement(AccessibleData(id, role, childCount, interfaces));
#endif

  for (uint32_t i = 0; i < childCount; i++) {
    SerializeTree(aRoot->GetChildAt(i), aTree);
  }
}
void DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) {
  Accessible* parent = aShowEvent->Parent();
  uint64_t parentID =
      parent->IsDoc() ? 0 : reinterpret_cast<uint64_t>(parent->UniqueID());
  uint32_t idxInParent = aShowEvent->GetAccessible()->IndexInParent();
  nsTArray<AccessibleData> shownTree;
  ShowEventData data(parentID, idxInParent, shownTree, false);
  SerializeTree(aShowEvent->GetAccessible(), data.NewTree());
  MaybeSendShowEvent(data, aShowEvent->IsFromUserInput());
}
void DocAccessibleChildBase::InsertIntoIpcTree(Accessible* aParent,
                                               Accessible* aChild,
                                               uint32_t aIdxInParent) {
  uint64_t parentID =
      aParent->IsDoc() ? 0 : reinterpret_cast<uint64_t>(aParent->UniqueID());
  nsTArray<AccessibleData> shownTree;
  ShowEventData data(parentID, aIdxInParent, shownTree, true);
  SerializeTree(aChild, data.NewTree());
  MaybeSendShowEvent(data, false);
}
static void
SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree)
{
  uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
  uint32_t role = aRoot->Role();
  uint32_t childCount = aRoot->ChildCount();
  uint32_t interfaces = InterfacesFor(aRoot);

  // OuterDocAccessibles are special because we don't want to serialize the
  // child doc here, we'll call PDocAccessibleConstructor in
  // NotificationController.
  if (childCount == 1 && aRoot->GetChildAt(0)->IsDoc())
    childCount = 0;

  aTree.AppendElement(AccessibleData(id, role, childCount, interfaces));
  for (uint32_t i = 0; i < childCount; i++)
    SerializeTree(aRoot->GetChildAt(i), aTree);
}
Example #6
0
// Serialize the binary tree
void BinaryTreeMethod::SerializeTree(TreeNode *p_Root)
{
	std::ofstream out(str_OutFilePath);

	SerializeTree(p_Root, out);
}