bug 809871 - patch 3/3 - xul tree accessible creation flushes layout r=surkov

This commit is contained in:
Trevor Saunders 2012-11-19 15:36:05 -05:00
parent 473669735c
commit 18d59087ea
10 changed files with 42 additions and 42 deletions

View File

@ -85,6 +85,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../../layout/style \
-I$(srcdir)/../../../layout/svg \
-I$(srcdir)/../../../layout/xul/base/src \
-I$(srcdir)/../../../layout/xul/tree/ \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)

View File

@ -57,6 +57,9 @@
#include "nsNPAPIPluginInstance.h"
#include "nsObjectFrame.h"
#include "nsSVGPathGeometryFrame.h"
#include "nsTreeBodyFrame.h"
#include "nsTreeColumns.h"
#include "nsTreeUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
@ -1572,27 +1575,28 @@ already_AddRefed<Accessible>
nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent,
DocAccessible* aDoc)
{
nsCOMPtr<nsITreeBoxObject> treeBoxObj = nsCoreUtils::GetTreeBoxObject(aContent);
if (!treeBoxObj)
nsIContent* child = nsTreeUtils::GetDescendantChild(aContent,
nsGkAtoms::treechildren);
if (!child)
return nullptr;
nsCOMPtr<nsITreeColumns> treeColumns;
treeBoxObj->GetColumns(getter_AddRefs(treeColumns));
if (!treeColumns)
nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame());
if (!treeFrame)
return nullptr;
nsRefPtr<nsTreeColumns> treeCols = treeFrame->Columns();
int32_t count = 0;
treeColumns->GetCount(&count);
treeCols->GetCount(&count);
// Outline of list accessible.
if (count == 1) {
Accessible* accessible = new XULTreeAccessible(aContent, aDoc);
Accessible* accessible = new XULTreeAccessible(aContent, aDoc, treeFrame);
NS_ADDREF(accessible);
return accessible;
}
// Table or tree table accessible.
Accessible* accessible = new XULTreeGridAccessibleWrap(aContent, aDoc);
Accessible* accessible = new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame);
NS_ADDREF(accessible);
return accessible;
}

View File

@ -22,8 +22,9 @@ class XULTreeGridAccessibleWrap : public XULTreeGridAccessible,
public ia2AccessibleTable
{
public:
XULTreeGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
XULTreeGridAccessible(aContent, aDoc), ia2AccessibleTable(this) {}
XULTreeGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTree) :
XULTreeGridAccessible(aContent, aDoc, aTree), ia2AccessibleTable(this) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

View File

@ -43,6 +43,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../xpcom \
-I$(srcdir)/../../../layout/generic \
-I$(srcdir)/../../../layout/xul/base/src \
-I$(srcdir)/../../../layout/xul/tree// \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)

View File

@ -27,6 +27,9 @@
#include "nsIDOMXULTreeElement.h"
#include "nsITreeSelection.h"
#include "nsIMutableArray.h"
#include "nsTreeBodyFrame.h"
#include "nsTreeColumns.h"
#include "nsTreeUtils.h"
using namespace mozilla::a11y;
@ -35,21 +38,19 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
XULTreeAccessible::
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc) :
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeFrame) :
AccessibleWrap(aContent, aDoc)
{
mType = eXULTreeType;
mGenericTypes |= eSelect;
nsCOMPtr<nsITreeView> view = aTreeFrame->GetExistingView();
mTreeView = view;
mTree = nsCoreUtils::GetTreeBoxObject(aContent);
NS_ASSERTION(mTree, "Can't get mTree!\n");
if (mTree) {
nsCOMPtr<nsITreeView> treeView;
mTree->GetView(getter_AddRefs(treeView));
mTreeView = treeView;
}
nsIContent* parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
@ -159,11 +160,16 @@ XULTreeAccessible::NativeRole()
// No primary column means we're in a list. In fact, history and mail turn off
// the primary flag when switching to a flat view.
nsCOMPtr<nsITreeColumns> cols;
mTree->GetColumns(getter_AddRefs(cols));
nsIContent* child = nsTreeUtils::GetDescendantChild(mContent, nsGkAtoms::treechildren);
NS_ASSERTION(child, "tree without treechildren!");
nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame());
NS_ASSERTION(treeFrame, "xul tree accessible for tree without a frame!");
if (!treeFrame)
return roles::LIST;
nsRefPtr<nsTreeColumns> cols = treeFrame->Columns();
nsCOMPtr<nsITreeColumn> primaryCol;
if (cols)
cols->GetPrimaryColumn(getter_AddRefs(primaryCol));
cols->GetPrimaryColumn(getter_AddRefs(primaryCol));
return primaryCol ? roles::OUTLINE : roles::LIST;
}

View File

@ -11,6 +11,8 @@
#include "nsITreeColumns.h"
#include "XULListboxAccessible.h"
class nsTreeBodyFrame;
namespace mozilla {
namespace a11y {
@ -29,7 +31,8 @@ class XULTreeAccessible : public AccessibleWrap
public:
using Accessible::GetChildAt;
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc);
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeframe);
// nsISupports and cycle collection
NS_DECL_ISUPPORTS_INHERITED

View File

@ -20,17 +20,6 @@
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridAccessible
////////////////////////////////////////////////////////////////////////////////
XULTreeGridAccessible::
XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc) :
XULTreeAccessible(aContent, aDoc), xpcAccessibleTable(this)
{
mGenericTypes |= eTable;
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridAccessible: nsISupports implementation

View File

@ -24,7 +24,10 @@ class XULTreeGridAccessible : public XULTreeAccessible,
public TableAccessible
{
public:
XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc);
XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeFrame) :
XULTreeAccessible(aContent, aDoc, aTreeFrame), xpcAccessibleTable(this)
{ mGenericTypes |= eTable; }
// nsISupports
NS_DECL_ISUPPORTS_INHERITED

View File

@ -32,9 +32,6 @@
<script type="application/javascript">
<![CDATA[
if (!navigator.platform.startsWith("Mac")) {
SimpleTest.expectAssertions(2);
}
////////////////////////////////////////////////////////////////////////////
// Hacky stuffs

View File

@ -18,11 +18,6 @@
<script type="application/javascript">
<![CDATA[
if (navigator.platform.startsWith("Mac")) {
SimpleTest.expectAssertions(0, 1);
} else {
SimpleTest.expectAssertions(1);
}
////////////////////////////////////////////////////////////////////////////
// Test