From 481e714b507718ddfd48a85cca8483ec2e210f78 Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Tue, 9 Nov 2010 18:21:56 +0800 Subject: [PATCH] Bug 608201 File chooser and some other dialogs are not added to Firefox a11y tree r=surkov.alexander,roc a=blocking-2.0 --- accessible/src/base/nsAccessible.cpp | 33 +++++++++++++++++++--------- widget/src/gtk2/nsFilePicker.cpp | 2 +- widget/src/gtk2/nsPrintDialogGTK.cpp | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index d9b3a72551e..c0e82f7bc56 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2730,6 +2730,9 @@ nsAccessible::InvalidateChildren() PRBool nsAccessible::AppendChild(nsAccessible* aChild) { + if (!aChild) + return PR_FLASE; + if (!mChildren.AppendElement(aChild)) return PR_FALSE; @@ -2743,11 +2746,16 @@ nsAccessible::AppendChild(nsAccessible* aChild) PRBool nsAccessible::InsertChildAt(PRUint32 aIndex, nsAccessible* aChild) { + if (!aChild) + return PR_FLASE; + if (!mChildren.InsertElementAt(aIndex, aChild)) return PR_FALSE; - for (PRUint32 idx = aIndex + 1; idx < mChildren.Length(); idx++) - mChildren[idx]->mIndexInParent++; + for (PRUint32 idx = aIndex + 1; idx < mChildren.Length(); idx++) { + NS_ASSERTION(mChildren[idx]->mIndexInParent == idx - 1, "Accessible child index doesn't match"); + mChildren[idx]->mIndexInParent = idx; + } if (nsAccUtils::IsText(aChild)) mChildrenFlags = eMixedChildren; @@ -2761,23 +2769,28 @@ nsAccessible::InsertChildAt(PRUint32 aIndex, nsAccessible* aChild) PRBool nsAccessible::RemoveChild(nsAccessible* aChild) { - if (aChild->mParent != this || aChild->mIndexInParent == -1) + if (!aChild) + return PR_FLASE; + + PRInt32 index = aChild->mIndexInParent; + if (aChild->mParent != this || index == -1) return PR_FALSE; - if (aChild->mIndexInParent >= mChildren.Length() || - mChildren[aChild->mIndexInParent] != aChild) { + if (index >= mChildren.Length() || mChildren[index] != aChild) { NS_ERROR("Child is bound to parent but parent hasn't this child at its index!"); aChild->UnbindFromParent(); return PR_FALSE; } - for (PRUint32 idx = aChild->mIndexInParent + 1; idx < mChildren.Length(); idx++) - mChildren[idx]->mIndexInParent--; - - mChildren.RemoveElementAt(aChild->mIndexInParent); - mEmbeddedObjCollector = nsnull; + for (PRUint32 idx = index + 1; idx < mChildren.Length(); idx++) { + NS_ASSERTION(mChildren[idx]->mIndexInParent == idx, "Accessible child index doesn't match"); + mChildren[idx]->mIndexInParent = idx - 1; + } aChild->UnbindFromParent(); + mChildren.RemoveElementAt(index); + mEmbeddedObjCollector = nsnull; + return PR_TRUE; } diff --git a/widget/src/gtk2/nsFilePicker.cpp b/widget/src/gtk2/nsFilePicker.cpp index 73e27724415..897eeeb7715 100644 --- a/widget/src/gtk2/nsFilePicker.cpp +++ b/widget/src/gtk2/nsFilePicker.cpp @@ -538,7 +538,7 @@ nsFilePicker::Show(PRInt16 *aReturn) } gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(file_chooser), PR_TRUE); - gint response = gtk_dialog_run(GTK_DIALOG(file_chooser)); + gint response = RunDialog(GTK_DIALOG(file_chooser)); switch (response) { case GTK_RESPONSE_OK: diff --git a/widget/src/gtk2/nsPrintDialogGTK.cpp b/widget/src/gtk2/nsPrintDialogGTK.cpp index 1843cc1625f..c2983b243a0 100644 --- a/widget/src/gtk2/nsPrintDialogGTK.cpp +++ b/widget/src/gtk2/nsPrintDialogGTK.cpp @@ -142,7 +142,7 @@ ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data) gtk_widget_show_all(custom_hbox); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(prompt_dialog)->vbox), custom_hbox, FALSE, FALSE, 0); - gint diag_response = gtk_dialog_run(GTK_DIALOG(prompt_dialog)); + gint diag_response = RunDialog(GTK_DIALOG(prompt_dialog)); if (diag_response == GTK_RESPONSE_ACCEPT) { const gchar* response_text = gtk_entry_get_text(GTK_ENTRY(custom_entry));