mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
m-c to e10 merge
This commit is contained in:
commit
93984b6736
@ -894,10 +894,6 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// XXX Fix this so it is not O(n^2) to walk through the children!
|
||||
// Either we can cache the last accessed child so that we can just GetNextSibling()
|
||||
// or we should cache an array of children in each nsAccessible
|
||||
// (instead of mNextSibling on the children)
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (!accWrap || nsAccUtils::MustPrune(accWrap)) {
|
||||
return nsnull;
|
||||
@ -907,7 +903,9 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
||||
nsCOMPtr<nsIAccessibleHyperText> hyperText;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(hyperText));
|
||||
if (hyperText) {
|
||||
// If HyperText, then number of links matches number of children
|
||||
// If HyperText, then number of links matches number of children.
|
||||
// XXX Fix this so it is not O(n^2) to walk through the children
|
||||
// (bug 566328).
|
||||
nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
|
||||
hyperText->GetLink(aChildIndex, getter_AddRefs(hyperLink));
|
||||
accChild = do_QueryInterface(hyperLink);
|
||||
@ -945,36 +943,26 @@ getIndexInParentCB(AtkObject *aAtkObj)
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
accWrap->GetParent(getter_AddRefs(parent));
|
||||
nsAccessible *parent = accWrap->GetParent();
|
||||
if (!parent) {
|
||||
return -1; // No parent
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> sibling;
|
||||
parent->GetFirstChild(getter_AddRefs(sibling));
|
||||
if (!sibling) {
|
||||
return -1; // Error, parent has no children
|
||||
}
|
||||
|
||||
PRInt32 currentIndex = 0;
|
||||
|
||||
while (sibling != static_cast<nsIAccessible*>(accWrap)) {
|
||||
NS_ASSERTION(sibling, "Never ran into the same child that we started from");
|
||||
|
||||
if (!sibling) {
|
||||
return -1;
|
||||
PRInt32 childCount = parent->GetChildCount();
|
||||
for (PRInt32 idx = 0; idx < childCount; idx++) {
|
||||
nsAccessible *sibling = parent->GetChildAt(idx);
|
||||
if (sibling == accWrap) {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
if (nsAccUtils::IsEmbeddedObject(sibling)) {
|
||||
++ currentIndex;
|
||||
++ currentIndex;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> tempAccessible;
|
||||
sibling->GetNextSibling(getter_AddRefs(tempAccessible));
|
||||
sibling.swap(tempAccessible);
|
||||
}
|
||||
|
||||
return currentIndex;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void TranslateStates(PRUint32 aState, const AtkStateMap *aStateMap,
|
||||
|
@ -50,6 +50,7 @@ LIBXUL_LIBRARY = 1
|
||||
CPPSRCS = \
|
||||
nsAccessNode.cpp \
|
||||
nsAccEvent.cpp \
|
||||
nsAccIterator.cpp \
|
||||
nsARIAGridAccessible.cpp \
|
||||
nsARIAMap.cpp \
|
||||
nsDocAccessible.cpp \
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "nsARIAGridAccessible.h"
|
||||
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsAccIterator.h"
|
||||
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -101,9 +101,13 @@ nsARIAGridAccessible::GetColumnCount(PRInt32 *acolumnCount)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetNextRow();
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while ((cell = GetNextCellInRow(row, cell)))
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
nsAccessible *row = rowIter.GetNext();
|
||||
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
|
||||
while ((cell = cellIter.GetNext()))
|
||||
(*acolumnCount)++;
|
||||
|
||||
return NS_OK;
|
||||
@ -118,8 +122,8 @@ nsARIAGridAccessible::GetRowCount(PRInt32 *arowCount)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while ((row = GetNextRow(row)))
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
while (rowIter.GetNext())
|
||||
(*arowCount)++;
|
||||
|
||||
return NS_OK;
|
||||
@ -135,10 +139,10 @@ nsARIAGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetRowAt(aRowIndex);
|
||||
nsAccessible *row = GetRowAt(aRowIndex);
|
||||
NS_ENSURE_ARG(row);
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumnIndex);
|
||||
nsAccessible *cell = GetCellInRowAt(row, aColumnIndex);
|
||||
NS_ENSURE_ARG(cell);
|
||||
|
||||
NS_ADDREF(*aAccessible = cell);
|
||||
@ -288,20 +292,21 @@ nsARIAGridAccessible::IsColumnSelected(PRInt32 aColumn, PRBool *aIsSelected)
|
||||
|
||||
NS_ENSURE_ARG(IsValidColumn(aColumn));
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetNextRow();
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
nsAccessible *row = rowIter.GetNext();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
do {
|
||||
if (!nsAccUtils::IsARIASelected(row)) {
|
||||
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumn);
|
||||
nsAccessible *cell = GetCellInRowAt(row, aColumn);
|
||||
if (!cell) // Do not fail due to wrong markup
|
||||
return NS_OK;
|
||||
|
||||
if (!nsAccUtils::IsARIASelected(cell))
|
||||
return NS_OK;
|
||||
}
|
||||
} while ((row = GetNextRow(row)));
|
||||
} while ((row = rowIter.GetNext()));
|
||||
|
||||
*aIsSelected = PR_TRUE;
|
||||
return NS_OK;
|
||||
@ -316,12 +321,13 @@ nsARIAGridAccessible::IsRowSelected(PRInt32 aRow, PRBool *aIsSelected)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetRowAt(aRow);
|
||||
nsAccessible *row = GetRowAt(aRow);
|
||||
NS_ENSURE_ARG(row);
|
||||
|
||||
if (!nsAccUtils::IsARIASelected(row)) {
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while ((cell = GetNextCellInRow(row, cell))) {
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
while ((cell = cellIter.GetNext())) {
|
||||
if (!nsAccUtils::IsARIASelected(cell))
|
||||
return NS_OK;
|
||||
}
|
||||
@ -341,11 +347,11 @@ nsARIAGridAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row(GetRowAt(aRow));
|
||||
nsAccessible *row = GetRowAt(aRow);
|
||||
NS_ENSURE_ARG(row);
|
||||
|
||||
if (!nsAccUtils::IsARIASelected(row)) {
|
||||
nsCOMPtr<nsIAccessible> cell(GetCellInRowAt(row, aColumn));
|
||||
nsAccessible *cell = GetCellInRowAt(row, aColumn);
|
||||
NS_ENSURE_ARG(cell);
|
||||
|
||||
if (!nsAccUtils::IsARIASelected(cell))
|
||||
@ -367,16 +373,20 @@ nsARIAGridAccessible::GetSelectedCellCount(PRUint32* aCount)
|
||||
|
||||
PRInt32 colCount = 0;
|
||||
GetColumnCount(&colCount);
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while ((row = GetNextRow(row))) {
|
||||
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
while ((row = rowIter.GetNext())) {
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
(*aCount) += colCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while ((cell = GetNextCellInRow(row, cell))) {
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
|
||||
while ((cell = cellIter.GetNext())) {
|
||||
if (nsAccUtils::IsARIASelected(cell))
|
||||
(*aCount)++;
|
||||
}
|
||||
@ -400,14 +410,17 @@ nsARIAGridAccessible::GetSelectedRowCount(PRUint32* aCount)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while ((row = GetNextRow(row))) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
while ((row = rowIter.GetNext())) {
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
(*aCount)++;
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell = GetNextCellInRow(row);
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = cellIter.GetNext();
|
||||
if (!cell)
|
||||
continue;
|
||||
|
||||
@ -417,7 +430,7 @@ nsARIAGridAccessible::GetSelectedRowCount(PRUint32* aCount)
|
||||
isRowSelected = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
} while ((cell = GetNextCellInRow(row, cell)));
|
||||
} while ((cell = cellIter.GetNext()));
|
||||
|
||||
if (isRowSelected)
|
||||
(*aCount)++;
|
||||
@ -440,18 +453,21 @@ nsARIAGridAccessible::GetSelectedCells(nsIArray **aCells)
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while (row = GetNextRow(row)) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
while (row = rowIter.GetNext()) {
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsIAccessible *cell = nsnull;
|
||||
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while (cell = GetNextCellInRow(row, cell))
|
||||
while (cell = cellIter.GetNext())
|
||||
selCells->AppendElement(cell, PR_FALSE);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while (cell = GetNextCellInRow(row, cell)) {
|
||||
while (cell = cellIter.GetNext()) {
|
||||
if (nsAccUtils::IsARIASelected(cell))
|
||||
selCells->AppendElement(cell, PR_FALSE);
|
||||
}
|
||||
@ -481,8 +497,10 @@ nsARIAGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
|
||||
|
||||
nsTArray<PRInt32> selCells(rowCount * colCount);
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
for (PRInt32 rowIdx = 0; row = GetNextRow(row); rowIdx++) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
for (PRInt32 rowIdx = 0; row = rowIter.GetNext(); rowIdx++) {
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
for (PRInt32 colIdx = 0; colIdx < colCount; colIdx++)
|
||||
selCells.AppendElement(rowIdx * colCount + colIdx);
|
||||
@ -490,8 +508,10 @@ nsARIAGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
for (PRInt32 colIdx = 0; cell = GetNextCellInRow(row, cell); colIdx++) {
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
|
||||
for (PRInt32 colIdx = 0; cell = cellIter.GetNext(); colIdx++) {
|
||||
if (nsAccUtils::IsARIASelected(cell))
|
||||
selCells.AppendElement(rowIdx * colCount + colIdx);
|
||||
}
|
||||
@ -537,14 +557,17 @@ nsARIAGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount,
|
||||
|
||||
nsTArray<PRInt32> selRows(rowCount);
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
for (PRInt32 rowIdx = 0; row = GetNextRow(row); rowIdx++) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
for (PRInt32 rowIdx = 0; row = rowIter.GetNext(); rowIdx++) {
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
selRows.AppendElement(rowIdx);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell = GetNextCellInRow(row);
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = cellIter.GetNext();
|
||||
if (!cell)
|
||||
continue;
|
||||
|
||||
@ -554,7 +577,7 @@ nsARIAGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount,
|
||||
isRowSelected = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
} while ((cell = GetNextCellInRow(row, cell)));
|
||||
} while ((cell = cellIter.GetNext()));
|
||||
|
||||
if (isRowSelected)
|
||||
selRows.AppendElement(rowIdx);
|
||||
@ -580,8 +603,10 @@ nsARIAGridAccessible::SelectRow(PRInt32 aRow)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
for (PRInt32 rowIdx = 0; row = GetNextRow(row); rowIdx++) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
for (PRInt32 rowIdx = 0; row = rowIter.GetNext(); rowIdx++) {
|
||||
nsresult rv = SetARIASelected(row, rowIdx == aRow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -597,14 +622,16 @@ nsARIAGridAccessible::SelectColumn(PRInt32 aColumn)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while ((row = GetNextRow(row))) {
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
while ((row = rowIter.GetNext())) {
|
||||
// Unselect all cells in the row.
|
||||
nsresult rv = SetARIASelected(row, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Select cell at the column index.
|
||||
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumn);
|
||||
nsAccessible *cell = GetCellInRowAt(row, aColumn);
|
||||
if (cell) {
|
||||
rv = SetARIASelected(cell, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -620,7 +647,7 @@ nsARIAGridAccessible::UnselectRow(PRInt32 aRow)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetRowAt(aRow);
|
||||
nsAccessible *row = GetRowAt(aRow);
|
||||
NS_ENSURE_ARG(row);
|
||||
|
||||
return SetARIASelected(row, PR_FALSE);
|
||||
@ -634,9 +661,11 @@ nsARIAGridAccessible::UnselectColumn(PRInt32 aColumn)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
while ((row = GetNextRow(row))) {
|
||||
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumn);
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = nsnull;
|
||||
while ((row = rowIter.GetNext())) {
|
||||
nsAccessible *cell = GetCellInRowAt(row, aColumn);
|
||||
if (cell) {
|
||||
nsresult rv = SetARIASelected(cell, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -696,84 +725,39 @@ nsARIAGridAccessible::IsValidRowNColumn(PRInt32 aRow, PRInt32 aColumn)
|
||||
return aColumn < colCount;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsAccessible*
|
||||
nsARIAGridAccessible::GetRowAt(PRInt32 aRow)
|
||||
{
|
||||
PRInt32 rowIdx = aRow;
|
||||
nsCOMPtr<nsIAccessible> row(GetNextRow());
|
||||
while (rowIdx != 0 && (row = GetNextRow(row)))
|
||||
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
|
||||
nsAccessible *row = rowIter.GetNext();
|
||||
while (rowIdx != 0 && (row = rowIter.GetNext()))
|
||||
rowIdx--;
|
||||
|
||||
return row.forget();
|
||||
return row;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsARIAGridAccessible::GetCellInRowAt(nsIAccessible *aRow, PRInt32 aColumn)
|
||||
nsAccessible*
|
||||
nsARIAGridAccessible::GetCellInRowAt(nsAccessible *aRow, PRInt32 aColumn)
|
||||
{
|
||||
PRInt32 colIdx = aColumn;
|
||||
nsCOMPtr<nsIAccessible> cell(GetNextCellInRow(aRow));
|
||||
while (colIdx != 0 && (cell = GetNextCellInRow(aRow, cell)))
|
||||
|
||||
nsAccIterator cellIter(aRow, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = cellIter.GetNext();
|
||||
while (colIdx != 0 && (cell = cellIter.GetNext()))
|
||||
colIdx--;
|
||||
|
||||
return cell.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsARIAGridAccessible::GetNextRow(nsIAccessible *aRow)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> nextRow, tmpAcc;
|
||||
if (!aRow)
|
||||
GetFirstChild(getter_AddRefs(nextRow));
|
||||
else
|
||||
aRow->GetNextSibling(getter_AddRefs(nextRow));
|
||||
|
||||
while (nextRow) {
|
||||
if (nsAccUtils::Role(nextRow) == nsIAccessibleRole::ROLE_ROW)
|
||||
return nextRow.forget();
|
||||
|
||||
nextRow->GetNextSibling(getter_AddRefs(tmpAcc));
|
||||
tmpAcc.swap(nextRow);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsARIAGridAccessible::GetNextCellInRow(nsIAccessible *aRow, nsIAccessible *aCell)
|
||||
{
|
||||
if (!aRow)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> nextCell, tmpAcc;
|
||||
if (!aCell)
|
||||
aRow->GetFirstChild(getter_AddRefs(nextCell));
|
||||
else
|
||||
aCell->GetNextSibling(getter_AddRefs(nextCell));
|
||||
|
||||
while (nextCell) {
|
||||
PRUint32 role = nsAccUtils::Role(nextCell);
|
||||
if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
return nextCell.forget();
|
||||
|
||||
nextCell->GetNextSibling(getter_AddRefs(tmpAcc));
|
||||
tmpAcc.swap(nextCell);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
return cell;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
|
||||
nsARIAGridAccessible::SetARIASelected(nsAccessible *aAccessible,
|
||||
PRBool aIsSelected, PRBool aNotify)
|
||||
{
|
||||
nsRefPtr<nsAccessible> acc = do_QueryObject(aAccessible);
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
acc->GetDOMNode(getter_AddRefs(node));
|
||||
NS_ENSURE_STATE(node);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aAccessible->GetDOMNode()));
|
||||
NS_ENSURE_STATE(content);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (aIsSelected)
|
||||
@ -800,8 +784,10 @@ nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
|
||||
// If the given accessible is row that was unselected then remove
|
||||
// aria-selected from cell accessible.
|
||||
if (role == nsIAccessibleRole::ROLE_ROW) {
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while ((cell = GetNextCellInRow(aAccessible, cell))) {
|
||||
nsAccIterator cellIter(aAccessible, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
|
||||
while ((cell = cellIter.GetNext())) {
|
||||
rv = SetARIASelected(cell, PR_FALSE, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -814,16 +800,16 @@ nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
|
||||
if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER) {
|
||||
nsCOMPtr<nsIAccessible> row;
|
||||
aAccessible->GetParent(getter_AddRefs(row));
|
||||
nsAccessible *row = aAccessible->GetParent();
|
||||
|
||||
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW &&
|
||||
nsAccUtils::IsARIASelected(row)) {
|
||||
rv = SetARIASelected(row, PR_FALSE, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
while ((cell = GetNextCellInRow(row, cell))) {
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
while ((cell = cellIter.GetNext())) {
|
||||
if (cell != aAccessible) {
|
||||
rv = SetARIASelected(cell, PR_TRUE, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -847,7 +833,8 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *acolumnCount,
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row = GetNextRow();
|
||||
nsAccIterator rowIter(this, nsAccIterator::GetRow);
|
||||
nsAccessible *row = rowIter.GetNext();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
@ -868,15 +855,17 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *acolumnCount,
|
||||
continue;
|
||||
|
||||
PRInt32 colIdx = 0;
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
for (colIdx = 0; cell = GetNextCellInRow(row, cell); colIdx++) {
|
||||
|
||||
nsAccIterator cellIter(row, nsAccIterator::GetCell);
|
||||
nsAccessible *cell = nsnull;
|
||||
for (colIdx = 0; cell = cellIter.GetNext(); colIdx++) {
|
||||
if (isColSelArray.SafeElementAt(colIdx, PR_FALSE) &&
|
||||
!nsAccUtils::IsARIASelected(cell)) {
|
||||
isColSelArray[colIdx] = PR_FALSE;
|
||||
selColCount--;
|
||||
}
|
||||
}
|
||||
} while ((row = GetNextRow(row)));
|
||||
} while ((row = rowIter.GetNext()));
|
||||
|
||||
if (!selColCount)
|
||||
return NS_OK;
|
||||
@ -1130,15 +1119,14 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
||||
|
||||
// Expose "table-cell-index" attribute.
|
||||
|
||||
nsCOMPtr<nsIAccessible> thisRow;
|
||||
GetParent(getter_AddRefs(thisRow));
|
||||
nsAccessible *thisRow = GetParent();
|
||||
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 colIdx = 0, colCount = 0;
|
||||
nsCOMPtr<nsIAccessible> child, nextChild;
|
||||
thisRow->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
PRInt32 childCount = thisRow->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = thisRow->GetChildAt(childIdx);
|
||||
if (child == this)
|
||||
colIdx = colCount;
|
||||
|
||||
@ -1147,25 +1135,22 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
colCount++;
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> table;
|
||||
thisRow->GetParent(getter_AddRefs(table));
|
||||
nsAccessible *table = thisRow->GetParent();
|
||||
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE &&
|
||||
nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 rowIdx = 0;
|
||||
table->GetFirstChild(getter_AddRefs(child));
|
||||
while (child && child != thisRow) {
|
||||
childCount = table->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = table->GetChildAt(childIdx);
|
||||
if (child == thisRow)
|
||||
break;
|
||||
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_ROW)
|
||||
rowIdx++;
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
|
||||
PRInt32 idx = rowIdx * colCount + colIdx;
|
||||
|
@ -77,31 +77,12 @@ protected:
|
||||
/**
|
||||
* Return row accessible at the given row index.
|
||||
*/
|
||||
already_AddRefed<nsIAccessible> GetRowAt(PRInt32 aRow);
|
||||
nsAccessible *GetRowAt(PRInt32 aRow);
|
||||
|
||||
/**
|
||||
* Return cell accessible at the given column index in the row.
|
||||
*/
|
||||
already_AddRefed<nsIAccessible> GetCellInRowAt(nsIAccessible *aRow,
|
||||
PRInt32 aColumn);
|
||||
|
||||
/**
|
||||
* Return next row accessible relative given row accessible or first row
|
||||
* accessible if it is null.
|
||||
*
|
||||
* @param aRow [in, optional] row accessible
|
||||
*/
|
||||
already_AddRefed<nsIAccessible> GetNextRow(nsIAccessible *aRow = nsnull);
|
||||
|
||||
/**
|
||||
* Return next cell accessible relative given cell accessible or first cell
|
||||
* in the given row accessible if given cell accessible is null.
|
||||
*
|
||||
* @param aRow [in] row accessible
|
||||
* @param aCell [in, optional] cell accessible
|
||||
*/
|
||||
already_AddRefed<nsIAccessible> GetNextCellInRow(nsIAccessible *aRow,
|
||||
nsIAccessible *aCell = nsnull);
|
||||
nsAccessible *GetCellInRowAt(nsAccessible *aRow, PRInt32 aColumn);
|
||||
|
||||
/**
|
||||
* Set aria-selected attribute value on DOM node of the given accessible.
|
||||
@ -111,7 +92,7 @@ protected:
|
||||
* @param aNotify [in, optional] specifies if DOM should be notified
|
||||
* about attribute change (used internally).
|
||||
*/
|
||||
nsresult SetARIASelected(nsIAccessible *aAccessible, PRBool aIsSelected,
|
||||
nsresult SetARIASelected(nsAccessible *aAccessible, PRBool aIsSelected,
|
||||
PRBool aNotify = PR_TRUE);
|
||||
|
||||
/**
|
||||
|
93
accessible/src/base/nsAccIterator.cpp
Normal file
93
accessible/src/base/nsAccIterator.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAccIterator.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsAccIterator
|
||||
|
||||
nsAccIterator::nsAccIterator(nsAccessible *aAccessible,
|
||||
AccIteratorFilterFuncPtr aFilterFunc,
|
||||
IterationType aIterationType) :
|
||||
mFilterFunc(aFilterFunc), mIsDeep(aIterationType != eFlatNav)
|
||||
{
|
||||
mState = new IteratorState(aAccessible);
|
||||
}
|
||||
|
||||
nsAccIterator::~nsAccIterator()
|
||||
{
|
||||
while (mState) {
|
||||
IteratorState *tmp = mState;
|
||||
mState = tmp->mParentState;
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
||||
nsAccessible*
|
||||
nsAccIterator::GetNext()
|
||||
{
|
||||
while (mState) {
|
||||
nsAccessible *child = mState->mParent->GetChildAt(mState->mIndex++);
|
||||
if (!child) {
|
||||
IteratorState *tmp = mState;
|
||||
mState = mState->mParentState;
|
||||
delete tmp;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
PRBool isComplying = mFilterFunc(child);
|
||||
if (isComplying)
|
||||
return child;
|
||||
|
||||
if (mIsDeep) {
|
||||
IteratorState *childState = new IteratorState(child, mState);
|
||||
mState = childState;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsAccIterator::IteratorState
|
||||
|
||||
nsAccIterator::IteratorState::IteratorState(nsAccessible *aParent,
|
||||
IteratorState *mParentState) :
|
||||
mParent(aParent), mIndex(0), mParentState(mParentState)
|
||||
{
|
||||
}
|
124
accessible/src/base/nsAccIterator.h
Normal file
124
accessible/src/base/nsAccIterator.h
Normal file
@ -0,0 +1,124 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsAccIterator_h_
|
||||
#define nsAccIterator_h_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsAccUtils.h"
|
||||
|
||||
/**
|
||||
* Return true if the traversed accessible complies with filter.
|
||||
*/
|
||||
typedef PRBool (*AccIteratorFilterFuncPtr) (nsAccessible *);
|
||||
|
||||
/**
|
||||
* Allows to iterate through accessible children or subtree complying with
|
||||
* filter function.
|
||||
*/
|
||||
class nsAccIterator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Used to define iteration type.
|
||||
*/
|
||||
enum IterationType {
|
||||
/**
|
||||
* Navigation happens through direct children.
|
||||
*/
|
||||
eFlatNav,
|
||||
|
||||
/**
|
||||
* Navigation through subtree excluding iterator root; if the accessible
|
||||
* complies with filter, iterator ignores its children.
|
||||
*/
|
||||
eTreeNav
|
||||
};
|
||||
|
||||
nsAccIterator(nsAccessible *aRoot, AccIteratorFilterFuncPtr aFilterFunc,
|
||||
IterationType aIterationType = eFlatNav);
|
||||
~nsAccIterator();
|
||||
|
||||
/**
|
||||
* Return next accessible complying with filter function. Return the first
|
||||
* accessible for the first time.
|
||||
*/
|
||||
nsAccessible *GetNext();
|
||||
|
||||
/**
|
||||
* Predefined filters.
|
||||
*/
|
||||
static PRBool GetSelected(nsAccessible *aAccessible)
|
||||
{
|
||||
return nsAccUtils::State(aAccessible) & nsIAccessibleStates::STATE_SELECTED;
|
||||
}
|
||||
static PRBool GetSelectable(nsAccessible *aAccessible)
|
||||
{
|
||||
return nsAccUtils::State(aAccessible) & nsIAccessibleStates::STATE_SELECTABLE;
|
||||
}
|
||||
static PRBool GetRow(nsAccessible *aAccessible)
|
||||
{
|
||||
return nsAccUtils::Role(aAccessible) == nsIAccessibleRole::ROLE_ROW;
|
||||
}
|
||||
static PRBool GetCell(nsAccessible *aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
return role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER;
|
||||
}
|
||||
|
||||
private:
|
||||
nsAccIterator();
|
||||
nsAccIterator(const nsAccIterator&);
|
||||
nsAccIterator& operator =(const nsAccIterator&);
|
||||
|
||||
struct IteratorState
|
||||
{
|
||||
IteratorState(nsAccessible *aParent, IteratorState *mParentState = nsnull);
|
||||
|
||||
nsAccessible *mParent;
|
||||
PRInt32 mIndex;
|
||||
IteratorState *mParentState;
|
||||
};
|
||||
|
||||
AccIteratorFilterFuncPtr mFilterFunc;
|
||||
PRBool mIsDeep;
|
||||
IteratorState *mState;
|
||||
};
|
||||
|
||||
#endif
|
@ -789,31 +789,29 @@ nsAccUtils::GetLiveAttrValue(PRUint32 aRule, nsAString& aValue)
|
||||
#ifdef DEBUG_A11Y
|
||||
|
||||
PRBool
|
||||
nsAccUtils::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible)
|
||||
nsAccUtils::IsTextInterfaceSupportCorrect(nsAccessible *aAccessible)
|
||||
{
|
||||
PRBool foundText = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryInterface(aAccessible);
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryObject(aAccessible);
|
||||
if (accDoc) {
|
||||
// Don't test for accessible docs, it makes us create accessibles too
|
||||
// early and fire mutation events before we need to
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> child, nextSibling;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
PRInt32 childCount = aAccessible->GetChildCount();
|
||||
for (PRint32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = GetChildAt(childIdx);
|
||||
if (IsText(child)) {
|
||||
foundText = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(nextSibling));
|
||||
child.swap(nextSibling);
|
||||
}
|
||||
|
||||
if (foundText) {
|
||||
// found text child node
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryInterface(aAccessible);
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryObject(aAccessible);
|
||||
if (!text)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public:
|
||||
* Detect whether the given accessible object implements nsIAccessibleText,
|
||||
* when it is text or has text child node.
|
||||
*/
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible);
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsAccessible *aAccessible);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -110,6 +110,8 @@
|
||||
#include "nsXFormsWidgetsAccessible.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsAccessibilityService
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -119,6 +121,8 @@ PRBool nsAccessibilityService::gIsShutdown = PR_TRUE;
|
||||
|
||||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
NS_TIME_FUNCTION;
|
||||
|
||||
// Add observers.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "nsIXBLAccessible.h"
|
||||
|
||||
#include "nsAccIterator.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "nsDocAccessible.h"
|
||||
@ -175,9 +176,10 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) {
|
||||
// Every embedded accessible within hypertext accessible implements
|
||||
// hyperlink interface.
|
||||
nsCOMPtr<nsIAccessibleHyperText> hyperTextParent = do_QueryObject(GetParent());
|
||||
|
||||
if (hyperTextParent) {
|
||||
if (hyperTextParent && nsAccUtils::IsEmbeddedObject(this)) {
|
||||
*aInstancePtr = static_cast<nsIAccessibleHyperLink*>(this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
@ -2465,39 +2467,6 @@ nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
|
||||
nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_UP, presShell, aContent);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsAccessible::GetNextWithState(nsIAccessible *aStart, PRUint32 matchState)
|
||||
{
|
||||
// Return the next descendant that matches one of the states in matchState
|
||||
// Uses depth first search
|
||||
NS_ASSERTION(matchState, "GetNextWithState() not called with a state to match");
|
||||
NS_ASSERTION(aStart, "GetNextWithState() not called with an accessible to start with");
|
||||
nsCOMPtr<nsIAccessible> look, current = aStart;
|
||||
PRUint32 state = 0;
|
||||
while (0 == (state & matchState)) {
|
||||
current->GetFirstChild(getter_AddRefs(look));
|
||||
while (!look) {
|
||||
if (current == this) {
|
||||
return nsnull; // At top of subtree
|
||||
}
|
||||
current->GetNextSibling(getter_AddRefs(look));
|
||||
if (!look) {
|
||||
current->GetParent(getter_AddRefs(look));
|
||||
current = look;
|
||||
look = nsnull;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
current.swap(look);
|
||||
state = nsAccUtils::State(current);
|
||||
}
|
||||
|
||||
nsIAccessible *returnAccessible = nsnull;
|
||||
current.swap(returnAccessible);
|
||||
|
||||
return returnAccessible;
|
||||
}
|
||||
|
||||
// nsIAccessibleSelectable
|
||||
NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
|
||||
{
|
||||
@ -2507,10 +2476,10 @@ NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
NS_ENSURE_STATE(selectedAccessibles);
|
||||
|
||||
nsCOMPtr<nsIAccessible> selected = this;
|
||||
while ((selected = GetNextWithState(selected, nsIAccessibleStates::STATE_SELECTED)) != nsnull) {
|
||||
nsAccIterator iter(this, nsAccIterator::GetSelected, nsAccIterator::eTreeNav);
|
||||
nsIAccessible *selected = nsnull;
|
||||
while ((selected = iter.GetNext()))
|
||||
selectedAccessibles->AppendElement(selected, PR_FALSE);
|
||||
}
|
||||
|
||||
PRUint32 length = 0;
|
||||
selectedAccessibles->GetLength(&length);
|
||||
@ -2525,16 +2494,22 @@ NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
|
||||
// return the nth selected descendant nsIAccessible object
|
||||
NS_IMETHODIMP nsAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aSelected)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelected);
|
||||
*aSelected = nsnull;
|
||||
|
||||
if (aIndex < 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> selected = this;
|
||||
|
||||
nsAccIterator iter(this, nsAccIterator::GetSelected, nsAccIterator::eTreeNav);
|
||||
nsAccessible *selected = nsnull;
|
||||
|
||||
PRInt32 count = 0;
|
||||
while (count ++ <= aIndex) {
|
||||
selected = GetNextWithState(selected, nsIAccessibleStates::STATE_SELECTED);
|
||||
selected = iter.GetNext();
|
||||
if (!selected) {
|
||||
return NS_ERROR_FAILURE; // aIndex out of range
|
||||
// The index is out of range.
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
NS_IF_ADDREF(*aSelected = selected);
|
||||
@ -2543,11 +2518,13 @@ NS_IMETHODIMP nsAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aSelect
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetSelectionCount(PRInt32 *aSelectionCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelectionCount);
|
||||
*aSelectionCount = 0;
|
||||
nsCOMPtr<nsIAccessible> selected = this;
|
||||
while ((selected = GetNextWithState(selected, nsIAccessibleStates::STATE_SELECTED)) != nsnull) {
|
||||
++ *aSelectionCount;
|
||||
}
|
||||
|
||||
nsAccIterator iter(this, nsAccIterator::GetSelected, nsAccIterator::eTreeNav);
|
||||
nsAccessible *selected = nsnull;
|
||||
while ((selected = iter.GetNext()))
|
||||
++(*aSelectionCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2603,21 +2580,24 @@ NS_IMETHODIMP nsAccessible::IsChildSelected(PRInt32 aIndex, PRBool *aIsSelected)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::ClearSelection()
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::ClearSelection()
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> selected = this;
|
||||
while ((selected = GetNextWithState(selected, nsIAccessibleStates::STATE_SELECTED)) != nsnull) {
|
||||
nsAccIterator iter(this, nsAccIterator::GetSelected, nsAccIterator::eTreeNav);
|
||||
nsAccessible *selected = nsnull;
|
||||
while ((selected = iter.GetNext()))
|
||||
selected->SetSelected(PR_FALSE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::SelectAllSelection(PRBool *_retval)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> selectable = this;
|
||||
while ((selectable = GetNextWithState(selectable, nsIAccessibleStates::STATE_SELECTED)) != nsnull) {
|
||||
nsAccIterator iter(this, nsAccIterator::GetSelectable, nsAccIterator::eTreeNav);
|
||||
nsAccessible *selectable = nsnull;
|
||||
while((selectable = iter.GetNext()))
|
||||
selectable->SetSelected(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2641,6 +2621,10 @@ nsAccessible::GetStartIndex(PRInt32 *aStartIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStartIndex);
|
||||
*aStartIndex = 0;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 endIndex;
|
||||
return GetLinkOffset(aStartIndex, &endIndex);
|
||||
}
|
||||
@ -2651,6 +2635,10 @@ nsAccessible::GetEndIndex(PRInt32 *aEndIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEndIndex);
|
||||
*aEndIndex = 0;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 startIndex;
|
||||
return GetLinkOffset(&startIndex, aEndIndex);
|
||||
}
|
||||
@ -2719,32 +2707,28 @@ nsAccessible::GetSelected(PRBool *aSelected)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
|
||||
nsresult
|
||||
nsAccessible::GetLinkOffset(PRInt32 *aStartOffset, PRInt32 *aEndOffset)
|
||||
{
|
||||
*aStartOffset = *aEndOffset = 0;
|
||||
nsAccessible* parent = GetParent();
|
||||
if (!parent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAccessible *parent = GetParent();
|
||||
NS_ENSURE_STATE(parent);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible, nextSibling;
|
||||
PRInt32 characterCount = 0;
|
||||
parent->GetFirstChild(getter_AddRefs(accessible));
|
||||
|
||||
while (accessible) {
|
||||
if (nsAccUtils::IsText(accessible))
|
||||
characterCount += nsAccUtils::TextLength(accessible);
|
||||
PRInt32 childCount = parent->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *sibling = parent->GetChildAt(childIdx);
|
||||
|
||||
else if (accessible == this) {
|
||||
if (sibling == this) {
|
||||
*aStartOffset = characterCount;
|
||||
*aEndOffset = characterCount + 1;
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
|
||||
if (nsAccUtils::IsText(sibling))
|
||||
characterCount += nsAccUtils::TextLength(sibling);
|
||||
else
|
||||
++ characterCount;
|
||||
}
|
||||
accessible->GetNextSibling(getter_AddRefs(nextSibling));
|
||||
accessible.swap(nextSibling);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -245,6 +245,11 @@ public:
|
||||
*/
|
||||
PRInt32 GetIndexInParent();
|
||||
|
||||
/**
|
||||
* Return true if accessible has children;
|
||||
*/
|
||||
PRBool HasChildren() { return !!GetChildAt(0); }
|
||||
|
||||
/**
|
||||
* Return parent accessible only if cached.
|
||||
*/
|
||||
@ -325,8 +330,6 @@ protected:
|
||||
// helper method to verify frames
|
||||
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
|
||||
static nsresult GetTranslatedString(const nsAString& aKey, nsAString& aStringOut);
|
||||
|
||||
already_AddRefed<nsIAccessible> GetNextWithState(nsIAccessible *aStart, PRUint32 matchState);
|
||||
|
||||
/**
|
||||
* Return an accessible for the given DOM node, or if that node isn't
|
||||
|
@ -1460,18 +1460,14 @@ nsDocAccessible::FireTextChangeEventForText(nsIContent *aContent,
|
||||
if (NS_FAILED(rv) || !accessible)
|
||||
return;
|
||||
|
||||
nsRefPtr<nsHyperTextAccessible> textAccessible;
|
||||
rv = accessible->QueryInterface(NS_GET_IID(nsHyperTextAccessible),
|
||||
getter_AddRefs(textAccessible));
|
||||
if (NS_FAILED(rv) || !textAccessible)
|
||||
nsRefPtr<nsHyperTextAccessible> textAccessible(do_QueryObject(accessible));
|
||||
if (!textAccessible)
|
||||
return;
|
||||
|
||||
PRInt32 start = aInfo->mChangeStart;
|
||||
|
||||
PRInt32 offset = 0;
|
||||
rv = textAccessible->DOMPointToHypertextOffset(node, start, &offset);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
textAccessible->DOMPointToHypertextOffset(node, start, &offset);
|
||||
|
||||
PRInt32 length = aIsInserted ?
|
||||
aInfo->mReplaceLength: // text has been added
|
||||
@ -1511,19 +1507,16 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
||||
PRBool aIsAsynch,
|
||||
EIsFromUserInput aIsFromUserInput)
|
||||
{
|
||||
nsRefPtr<nsHyperTextAccessible> textAccessible;
|
||||
aContainerAccessible->QueryInterface(NS_GET_IID(nsHyperTextAccessible),
|
||||
getter_AddRefs(textAccessible));
|
||||
nsRefPtr<nsHyperTextAccessible> textAccessible =
|
||||
do_QueryObject(aContainerAccessible);
|
||||
if (!textAccessible) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRInt32 offset;
|
||||
PRInt32 length = 0;
|
||||
nsCOMPtr<nsIAccessible> changeAccessible;
|
||||
nsresult rv = textAccessible->DOMPointToHypertextOffset(aChangeNode, -1, &offset,
|
||||
getter_AddRefs(changeAccessible));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
nsAccessible *changeAcc =
|
||||
textAccessible->DOMPointToHypertextOffset(aChangeNode, -1, &offset);
|
||||
|
||||
if (!aAccessibleForChangeNode) {
|
||||
// A span-level object or something else without an accessible is being removed, where
|
||||
@ -1531,33 +1524,29 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
||||
// into the parent hypertext.
|
||||
// In this case, accessibleToBeRemoved may just be the first
|
||||
// accessible that is removed, which affects the text in the hypertext container
|
||||
if (!changeAccessible) {
|
||||
if (!changeAcc)
|
||||
return nsnull; // No descendant content that represents any text in the hypertext parent
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> changeNode(do_QueryInterface(aChangeNode));
|
||||
nsCOMPtr<nsIAccessible> child = changeAccessible;
|
||||
while (PR_TRUE) {
|
||||
nsCOMPtr<nsIAccessNode> childAccessNode =
|
||||
do_QueryInterface(changeAccessible);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> childDOMNode;
|
||||
childAccessNode->GetDOMNode(getter_AddRefs(childDOMNode));
|
||||
nsAccessible *parent = changeAcc->GetParent();
|
||||
PRInt32 childCount = parent->GetChildCount();
|
||||
PRInt32 changeAccIdx = parent->GetIndexOf(changeAcc);
|
||||
|
||||
for (PRInt32 idx = changeAccIdx; idx < childCount; idx++) {
|
||||
nsAccessible *child = parent->GetChildAt(idx);
|
||||
nsCOMPtr<nsINode> childNode(do_QueryInterface(child->GetDOMNode()));
|
||||
|
||||
nsCOMPtr<nsINode> childNode(do_QueryInterface(childDOMNode));
|
||||
if (!nsCoreUtils::IsAncestorOf(changeNode, childNode)) {
|
||||
break; // We only want accessibles with DOM nodes as children of this node
|
||||
}
|
||||
length += nsAccUtils::TextLength(child);
|
||||
child->GetNextSibling(getter_AddRefs(changeAccessible));
|
||||
if (!changeAccessible) {
|
||||
// We only want accessibles with DOM nodes as children of this node
|
||||
break;
|
||||
}
|
||||
child.swap(changeAccessible);
|
||||
|
||||
length += nsAccUtils::TextLength(child);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(!changeAccessible || changeAccessible == aAccessibleForChangeNode,
|
||||
NS_ASSERTION(!changeAcc || changeAcc == aAccessibleForChangeNode,
|
||||
"Hypertext is reporting a different accessible for this node");
|
||||
|
||||
length = nsAccUtils::TextLength(aAccessibleForChangeNode);
|
||||
@ -1814,9 +1803,8 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
|
||||
// created.
|
||||
if (accessible->GetCachedFirstChild()) {
|
||||
nsCOMPtr<nsIArray> children;
|
||||
// use GetChildren() to fetch children at one time, instead of using
|
||||
// GetNextSibling(), because after we shutdown the first child,
|
||||
// mNextSibling will be set null.
|
||||
// use GetChildren() to fetch all children at once, because after shutdown
|
||||
// the child references are cleared.
|
||||
accessible->GetChildren(getter_AddRefs(children));
|
||||
PRUint32 childCount =0;
|
||||
if (children)
|
||||
|
@ -208,22 +208,17 @@ nsRootAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
if (!aExtraState)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWin;
|
||||
GetWindow(getter_AddRefs(domWin));
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_GetInterface(domWin);
|
||||
if (dsti) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
dsti->GetRootTreeItem(getter_AddRefs(root));
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow = do_GetInterface(root);
|
||||
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow;
|
||||
GetWindow(getter_AddRefs(rootWindow));
|
||||
|
||||
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
||||
if (fm && rootWindow) {
|
||||
nsCOMPtr<nsIDOMWindow> activeWindow;
|
||||
fm->GetActiveWindow(getter_AddRefs(activeWindow));
|
||||
if (activeWindow == rootWindow)
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_ACTIVE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> activeWindow;
|
||||
fm->GetActiveWindow(getter_AddRefs(activeWindow));
|
||||
if (activeWindow == rootWindow)
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_ACTIVE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
if (GetChromeFlags() & nsIWebBrowserChrome::CHROME_MODAL) {
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_MODAL;
|
||||
|
@ -214,11 +214,8 @@ nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray,
|
||||
if (!textAttr->Equal(currElm)) {
|
||||
|
||||
PRInt32 startHTOffset = 0;
|
||||
nsCOMPtr<nsIAccessible> startAcc;
|
||||
nsresult rv = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(tmpNode, -1, &startHTOffset,
|
||||
getter_AddRefs(startAcc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAccessible *startAcc = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(tmpNode, -1, &startHTOffset);
|
||||
|
||||
if (!startAcc)
|
||||
startHTOffset = 0;
|
||||
@ -262,9 +259,7 @@ nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray,
|
||||
if (!textAttr->Equal(currElm)) {
|
||||
|
||||
PRInt32 endHTOffset = 0;
|
||||
nsresult rv = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(currNode, -1, &endHTOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mHyperTextAcc->DOMPointToHypertextOffset(currNode, -1, &endHTOffset);
|
||||
|
||||
if (endHTOffset < *aEndHTOffset)
|
||||
*aEndHTOffset = endHTOffset;
|
||||
@ -317,10 +312,7 @@ nsTextAttrsMgr::FindEndOffsetInSubtree(const nsTPtrArray<nsITextAttr>& aTextAttr
|
||||
nsITextAttr *textAttr = aTextAttrArray[idx];
|
||||
if (!textAttr->Equal(currElm)) {
|
||||
PRInt32 endHTOffset = 0;
|
||||
nsresult rv = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(aCurrNode, -1, &endHTOffset);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
mHyperTextAcc->DOMPointToHypertextOffset(aCurrNode, -1, &endHTOffset);
|
||||
if (endHTOffset < *aHTOffset)
|
||||
*aHTOffset = endHTOffset;
|
||||
|
||||
@ -375,11 +367,8 @@ nsTextAttrsMgr::FindStartOffsetInSubtree(const nsTPtrArray<nsITextAttr>& aTextAt
|
||||
if (!textAttr->Equal(currElm)) {
|
||||
|
||||
PRInt32 startHTOffset = 0;
|
||||
nsCOMPtr<nsIAccessible> startAcc;
|
||||
nsresult rv = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(aPrevNode, -1, &startHTOffset,
|
||||
getter_AddRefs(startAcc));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
nsAccessible *startAcc = mHyperTextAcc->
|
||||
DOMPointToHypertextOffset(aPrevNode, -1, &startHTOffset);
|
||||
|
||||
if (!startAcc)
|
||||
startHTOffset = 0;
|
||||
|
@ -236,16 +236,14 @@ nsresult
|
||||
nsTextEquivUtils::AppendFromAccessibleChildren(nsIAccessible *aAccessible,
|
||||
nsAString *aString)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accChild, accNextChild;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(accChild));
|
||||
|
||||
nsresult rv = NS_OK_NO_NAME_CLAUSE_HANDLED;
|
||||
while (accChild) {
|
||||
rv = AppendFromAccessible(accChild, aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
accChild->GetNextSibling(getter_AddRefs(accNextChild));
|
||||
accChild.swap(accNextChild);
|
||||
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
|
||||
PRInt32 childCount = accessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = accessible->GetChildAt(childIdx);
|
||||
rv = AppendFromAccessible(child, aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -185,7 +185,7 @@ nsHTMLImageAccessible::DoAction(PRUint8 aIndex)
|
||||
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(piWindow));
|
||||
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMWindow> tmp;
|
||||
return win->Open(longDesc, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""),
|
||||
return win->Open(longDesc, EmptyString(), EmptyString(),
|
||||
getter_AddRefs(tmp));
|
||||
}
|
||||
return nsLinkableAccessible::DoAction(aIndex);
|
||||
|
@ -523,22 +523,18 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterAtOffset(PRInt32 aOffset, PRUni
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRInt32 aNodeOffset,
|
||||
PRInt32* aHyperTextOffset,
|
||||
nsIAccessible **aFinalAccessible,
|
||||
PRBool aIsEndOffset)
|
||||
nsAccessible*
|
||||
nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode *aNode,
|
||||
PRInt32 aNodeOffset,
|
||||
PRInt32 *aHyperTextOffset,
|
||||
PRBool aIsEndOffset)
|
||||
{
|
||||
// Turn a DOM Node and offset into an offset into this hypertext.
|
||||
// On failure, return null. On success, return the DOM node which contains the offset.
|
||||
NS_ENSURE_ARG_POINTER(aHyperTextOffset);
|
||||
if (!aHyperTextOffset)
|
||||
return nsnull;
|
||||
*aHyperTextOffset = 0;
|
||||
|
||||
if (!aNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (aFinalAccessible) {
|
||||
*aFinalAccessible = nsnull;
|
||||
}
|
||||
if (!aNode)
|
||||
return nsnull;
|
||||
|
||||
PRUint32 addTextOffset = 0;
|
||||
nsCOMPtr<nsIDOMNode> findNode;
|
||||
@ -555,9 +551,9 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
NS_ASSERTION(content, "No nsIContent for dom node");
|
||||
nsIFrame *frame = content->GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(frame, nsnull);
|
||||
nsresult rv = ContentToRenderedOffset(frame, aNodeOffset, &addTextOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
// Get the child node and
|
||||
findNode = aNode;
|
||||
}
|
||||
@ -565,7 +561,7 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
// For non-text nodes, aNodeOffset comes in as a child node index
|
||||
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(aNode));
|
||||
// Should not happen, but better to protect against crash if doc node is somehow passed in
|
||||
NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(parentContent, nsnull);
|
||||
// findNode could be null if aNodeOffset == # of child nodes, which means one of two things:
|
||||
// 1) we're at the end of the children, keep findNode = null, so that we get the last possible offset
|
||||
// 2) there are no children and the passed-in node is mDOMNode, which means we're an aempty nsIAccessibleText
|
||||
@ -577,7 +573,7 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
// There are no children, which means this is an empty nsIAccessibleText, in which
|
||||
// case we can only be at hypertext offset 0
|
||||
*aHyperTextOffset = 0;
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
findNode = do_QueryInterface(parentContent); // Case #2: there are no children
|
||||
}
|
||||
@ -596,7 +592,7 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
eIgnoreCase)) {
|
||||
// This <br> is the hacky "bogus node" used when there is no text in a control
|
||||
*aHyperTextOffset = 0;
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
descendantAcc = GetFirstAvailableAccessible(findNode);
|
||||
}
|
||||
@ -656,15 +652,14 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
NS_ASSERTION(childAcc == childAccAtOffset,
|
||||
"These should be equal whenever we exit loop and childAcc != nsnull");
|
||||
|
||||
if (aFinalAccessible &&
|
||||
(childIdx < childCount - 1 ||
|
||||
static_cast<PRInt32>(addTextOffset) < nsAccUtils::TextLength(childAccAtOffset))) {
|
||||
if (childIdx < childCount - 1 ||
|
||||
static_cast<PRInt32>(addTextOffset) < nsAccUtils::TextLength(childAccAtOffset)) {
|
||||
// If not at end of last text node, we will return the accessible we were in
|
||||
NS_ADDREF(*aFinalAccessible = childAccAtOffset);
|
||||
return childAccAtOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -816,13 +811,11 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
nsCOMPtr<nsIDOMNode> resultNode = do_QueryInterface(pos.mResultContent);
|
||||
NS_ENSURE_TRUE(resultNode, -1);
|
||||
|
||||
nsCOMPtr<nsIAccessible> finalAccessible;
|
||||
rv = DOMPointToHypertextOffset(resultNode, pos.mContentOffset, &hyperTextOffset,
|
||||
getter_AddRefs(finalAccessible),
|
||||
aDirection == eDirNext);
|
||||
// If finalAccessible == nsnull, then DOMPointToHypertextOffset() searched through the hypertext
|
||||
// children without finding the node/offset position
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
// If finalAccessible is nsnull, then DOMPointToHypertextOffset() searched
|
||||
// through the hypertext children without finding the node/offset position.
|
||||
nsAccessible *finalAccessible =
|
||||
DOMPointToHypertextOffset(resultNode, pos.mContentOffset, &hyperTextOffset,
|
||||
aDirection == eDirNext);
|
||||
|
||||
if (!finalAccessible && aDirection == eDirPrevious) {
|
||||
// If we reached the end during search, this means we didn't find the DOM point
|
||||
@ -1109,6 +1102,9 @@ nsHyperTextAccessible::GetTextAttributes(PRBool aIncludeDefAttrs,
|
||||
nsresult rv = GetCharacterCount(aEndOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aAttributes) {
|
||||
*aAttributes = nsnull;
|
||||
|
||||
@ -1119,12 +1115,46 @@ nsHyperTextAccessible::GetTextAttributes(PRBool aIncludeDefAttrs,
|
||||
NS_ADDREF(*aAttributes = attributes);
|
||||
}
|
||||
|
||||
if (!mDOMNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
// Offset 0 is correct offset when accessible has empty text. Include
|
||||
// default attributes if they were requested, otherwise return empty set.
|
||||
if (aOffset == 0) {
|
||||
// XXX: bug 567321. We handle here the cases when there are no children
|
||||
// or when existing children have zero length.
|
||||
PRBool isEmpty = PR_TRUE;
|
||||
PRInt32 childCount = GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = mChildren[childIdx];
|
||||
if (!nsAccUtils::IsText(child) || nsAccUtils::TextLength(child) > 0) {
|
||||
isEmpty = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmpty) {
|
||||
if (aIncludeDefAttrs) {
|
||||
nsTextAttrsMgr textAttrsMgr(this, mDOMNode, PR_TRUE, nsnull);
|
||||
return textAttrsMgr.GetAttributes(*aAttributes);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the frame and accessible at the given offset.
|
||||
PRInt32 startOffset = aOffset, endOffset = aOffset;
|
||||
nsCOMPtr<nsIAccessible> startAcc;
|
||||
nsIFrame *startFrame = GetPosAndText(startOffset, endOffset,
|
||||
nsnull, nsnull, nsnull,
|
||||
getter_AddRefs(startAcc), nsnull);
|
||||
|
||||
// No start frame or accessible means wrong given offset.
|
||||
if (!startFrame || !startAcc)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
PRInt32 nodeOffset = 0;
|
||||
rv = HypertextOffsetToDOMPoint(aOffset, getter_AddRefs(node), &nodeOffset);
|
||||
rv = GetDOMPointByFrameOffset(startFrame, startOffset, startAcc,
|
||||
getter_AddRefs(node), &nodeOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set 'misspelled' text attribute.
|
||||
@ -1630,7 +1660,8 @@ nsHyperTextAccessible::GetCaretOffset(PRInt32 *aCaretOffset)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return DOMPointToHypertextOffset(focusNode, focusOffset, aCaretOffset);
|
||||
DOMPointToHypertextOffset(focusNode, focusOffset, aCaretOffset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 nsHyperTextAccessible::GetCaretLineNumber()
|
||||
@ -1853,14 +1884,14 @@ NS_IMETHODIMP nsHyperTextAccessible::GetSelectionBounds(PRInt32 aSelectionNum, P
|
||||
endOffset = tempOffset;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> startAccessible;
|
||||
rv = DOMPointToHypertextOffset(startNode, startOffset, aStartOffset, getter_AddRefs(startAccessible));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAccessible *startAccessible =
|
||||
DOMPointToHypertextOffset(startNode, startOffset, aStartOffset);
|
||||
if (!startAccessible) {
|
||||
*aStartOffset = 0; // Could not find start point within this hypertext, so starts before
|
||||
}
|
||||
|
||||
return DOMPointToHypertextOffset(endNode, endOffset, aEndOffset, nsnull, PR_TRUE);
|
||||
DOMPointToHypertextOffset(endNode, endOffset, aEndOffset, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2176,10 +2207,8 @@ nsHyperTextAccessible::DOMRangeBoundToHypertextOffset(nsIDOMRange *aRange,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> startAcc;
|
||||
rv = DOMPointToHypertextOffset(node, nodeOffset, aHTOffset,
|
||||
getter_AddRefs(startAcc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAccessible *startAcc =
|
||||
DOMPointToHypertextOffset(node, nodeOffset, aHTOffset);
|
||||
|
||||
if (aIsStartHTOffset && !startAcc)
|
||||
*aHTOffset = 0;
|
||||
|
@ -108,10 +108,6 @@ public:
|
||||
* if >=0 and aNode is not text, this represents a child node offset
|
||||
* @param aResultOffset - the character offset into the current
|
||||
* nsHyperTextAccessible
|
||||
* @param aFinalAccessible [optional] - returns the accessible child which
|
||||
* contained the offset, if it is within
|
||||
* the current nsHyperTextAccessible,
|
||||
* otherwise it is set to nsnull.
|
||||
* @param aIsEndOffset - if PR_TRUE, then then this offset is not inclusive. The character
|
||||
* indicated by the offset returned is at [offset - 1]. This means
|
||||
* if the passed-in offset is really in a descendant, then the offset returned
|
||||
@ -119,11 +115,15 @@ public:
|
||||
* If PR_FALSE, then the offset is inclusive. The character indicated
|
||||
* by the offset returned is at [offset]. If the passed-in offset in inside a
|
||||
* descendant, then the returned offset will be on the relevant embedded object char.
|
||||
*
|
||||
* @return the accessible child which contained the offset, if
|
||||
* it is within the current nsHyperTextAccessible,
|
||||
* otherwise nsnull
|
||||
*/
|
||||
nsresult DOMPointToHypertextOffset(nsIDOMNode* aNode, PRInt32 aNodeOffset,
|
||||
PRInt32 *aHypertextOffset,
|
||||
nsIAccessible **aFinalAccessible = nsnull,
|
||||
PRBool aIsEndOffset = PR_FALSE);
|
||||
nsAccessible *DOMPointToHypertextOffset(nsIDOMNode *aNode,
|
||||
PRInt32 aNodeOffset,
|
||||
PRInt32 *aHypertextOffset,
|
||||
PRBool aIsEndOffset = PR_FALSE);
|
||||
|
||||
/**
|
||||
* Turn a hypertext offsets into DOM point.
|
||||
|
@ -390,26 +390,21 @@ __try {
|
||||
|
||||
PRUint32 currentRole = nsAccUtils::Role(xpAccessible);
|
||||
if (currentRole == nsIAccessibleRole::ROLE_OUTLINEITEM) {
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
xpAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
PRInt32 childCount = xpAccessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = xpAccessible->GetChildAt(childIdx);
|
||||
currentRole = nsAccUtils::Role(child);
|
||||
if (currentRole == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
nsCOMPtr<nsIAccessible> groupChild;
|
||||
child->GetFirstChild(getter_AddRefs(groupChild));
|
||||
while (groupChild) {
|
||||
PRInt32 groupChildCount = child->GetChildCount();
|
||||
for (PRInt32 groupChildIdx = 0; groupChildIdx < groupChildCount;
|
||||
groupChildIdx++) {
|
||||
nsAccessible *groupChild = child->GetChildAt(groupChildIdx);
|
||||
currentRole = nsAccUtils::Role(groupChild);
|
||||
numChildren +=
|
||||
(currentRole == nsIAccessibleRole::ROLE_OUTLINEITEM);
|
||||
nsCOMPtr<nsIAccessible> nextGroupChild;
|
||||
groupChild->GetNextSibling(getter_AddRefs(nextGroupChild));
|
||||
groupChild.swap(nextGroupChild);
|
||||
}
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> nextChild;
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,39 +553,32 @@ already_AddRefed<nsIDOMNode>
|
||||
nsXFormsSelectableAccessible::GetItemByIndex(PRInt32 *aIndex,
|
||||
nsIAccessible *aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible(aAccessible ? aAccessible : this);
|
||||
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
|
||||
if (!accessible)
|
||||
accessible = this;
|
||||
|
||||
nsCOMPtr<nsIAccessible> curAccChild;
|
||||
accessible->GetFirstChild(getter_AddRefs(curAccChild));
|
||||
PRInt32 childCount = accessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = accessible->GetChildAt(childIdx);
|
||||
|
||||
while (curAccChild) {
|
||||
nsCOMPtr<nsIAccessNode> curAccNodeChild(do_QueryInterface(curAccChild));
|
||||
if (curAccNodeChild) {
|
||||
nsCOMPtr<nsIDOMNode> curChildNode;
|
||||
curAccNodeChild->GetDOMNode(getter_AddRefs(curChildNode));
|
||||
nsCOMPtr<nsIContent> curChildContent(do_QueryInterface(curChildNode));
|
||||
if (curChildContent) {
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo = curChildContent->NodeInfo();
|
||||
if (nodeInfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
|
||||
if (nodeInfo->Equals(nsAccessibilityAtoms::item)) {
|
||||
if (!*aIndex) {
|
||||
nsIDOMNode *itemNode = nsnull;
|
||||
curChildNode.swap(itemNode);
|
||||
return itemNode;
|
||||
}
|
||||
--*aIndex;
|
||||
} else if (nodeInfo->Equals(nsAccessibilityAtoms::choices)) {
|
||||
nsIDOMNode *itemNode = GetItemByIndex(aIndex, curAccChild).get();
|
||||
if (itemNode)
|
||||
return itemNode;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> childNode(child->GetDOMNode());
|
||||
nsCOMPtr<nsIContent> childContent(do_QueryInterface(childNode));
|
||||
if (!childContent)
|
||||
continue;
|
||||
|
||||
nsINodeInfo *nodeInfo = childContent->NodeInfo();
|
||||
if (nodeInfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
|
||||
if (nodeInfo->Equals(nsAccessibilityAtoms::item)) {
|
||||
if (!*aIndex)
|
||||
return childNode.forget();
|
||||
|
||||
--*aIndex;
|
||||
} else if (nodeInfo->Equals(nsAccessibilityAtoms::choices)) {
|
||||
nsIDOMNode *itemNode = GetItemByIndex(aIndex, child).get();
|
||||
if (itemNode)
|
||||
return itemNode;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> nextAccChild;
|
||||
curAccChild->GetNextSibling(getter_AddRefs(nextAccChild));
|
||||
curAccChild.swap(nextAccChild);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
|
@ -1149,25 +1149,23 @@ nsXULListCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
|
||||
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
||||
|
||||
// Get column header cell from XUL listhead.
|
||||
nsCOMPtr<nsIAccessible> tableAcc(do_QueryInterface(table));
|
||||
nsAccessible *list = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> list, nextChild;
|
||||
tableAcc->GetFirstChild(getter_AddRefs(list));
|
||||
while (list) {
|
||||
if (nsAccUtils::Role(list) == nsIAccessibleRole::ROLE_LIST)
|
||||
nsRefPtr<nsAccessible> tableAcc(do_QueryObject(table));
|
||||
PRInt32 tableChildCount = tableAcc->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < tableChildCount; childIdx++) {
|
||||
nsAccessible *child = tableAcc->GetChildAt(childIdx);
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_LIST) {
|
||||
list = child;
|
||||
break;
|
||||
|
||||
list->GetNextSibling(getter_AddRefs(nextChild));
|
||||
nextChild.swap(list);
|
||||
}
|
||||
}
|
||||
|
||||
if (list) {
|
||||
PRInt32 colIdx = -1;
|
||||
GetColumnIndex(&colIdx);
|
||||
|
||||
nsCOMPtr<nsIAccessible> headerCell;
|
||||
list->GetChildAt(colIdx, getter_AddRefs(headerCell));
|
||||
|
||||
nsIAccessible *headerCell = list->GetChildAt(colIdx);
|
||||
if (headerCell) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> headerCells =
|
||||
|
@ -42,7 +42,7 @@ srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = accessible
|
||||
|
||||
DIRS = actions attributes events relations selectable states tree
|
||||
DIRS = actions attributes events relations selectable states table tree
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@ -68,6 +68,7 @@ _TEST_FILES =\
|
||||
nsIAccessible_selects.js \
|
||||
relations.js \
|
||||
role.js \
|
||||
selectable.js \
|
||||
states.js \
|
||||
table.js \
|
||||
value.js \
|
||||
@ -105,26 +106,6 @@ _TEST_FILES =\
|
||||
test_nsIAccessNode_utils.html \
|
||||
test_nsOuterDocAccessible.html \
|
||||
test_role_nsHyperTextAcc.html \
|
||||
test_table_1.html \
|
||||
test_table_4.html \
|
||||
test_table_headers.html \
|
||||
test_table_headers_ariagrid.html \
|
||||
test_table_headers_listbox.xul \
|
||||
test_table_headers_tree.xul \
|
||||
test_table_indexes.html \
|
||||
test_table_indexes_ariagrid.html \
|
||||
test_table_indexes_listbox.xul \
|
||||
test_table_indexes_tree.xul \
|
||||
test_table_layoutguess.html \
|
||||
test_table_sels.html \
|
||||
test_table_sels_ariagrid.html \
|
||||
test_table_sels_listbox.xul \
|
||||
test_table_sels_tree.xul \
|
||||
test_table_struct.html \
|
||||
test_table_struct_ariagrid.html \
|
||||
test_table_struct_ariatreegrid.html \
|
||||
test_table_struct_listbox.xul \
|
||||
test_table_struct_tree.xul \
|
||||
test_text_caret.html \
|
||||
test_textboxes.html \
|
||||
test_textboxes.xul \
|
||||
|
@ -160,6 +160,62 @@ function testDefaultTextAttrs(aID, aDefAttrs, aSkipUnexpectedAttrs)
|
||||
compareAttrs(errorMsg, defAttrs, aDefAttrs, aSkipUnexpectedAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test text attributes for wrong offset.
|
||||
*/
|
||||
function testTextAttrsWrongOffset(aID, aOffset)
|
||||
{
|
||||
var res = false;
|
||||
try {
|
||||
var s = {}, e = {};
|
||||
var acc = getAccessible(ID, [nsIAccessibleText]);
|
||||
acc.getTextAttributes(false, 157, s, e);
|
||||
} catch (e) {
|
||||
res = true;
|
||||
}
|
||||
|
||||
ok(res,
|
||||
"text attributes are calculated successfully at wrong offset " + aOffset + " for " + prettyName(aID));
|
||||
}
|
||||
|
||||
const kNormalFontWeight =
|
||||
function equalsToNormal(aWeight) { return aWeight <= 400 ; }
|
||||
|
||||
const kBoldFontWeight =
|
||||
function equalsToBold(aWeight) { return aWeight > 400; }
|
||||
|
||||
// The pt font size of the input element can vary by Linux distro.
|
||||
const kInputFontSize = WIN ?
|
||||
"10pt" : (MAC ? "8pt" : function() { return true; });
|
||||
|
||||
/**
|
||||
* Build an object of default text attributes expected for the given accessible.
|
||||
*
|
||||
* @param aID [in] identifier of accessible
|
||||
* @param aFontSize [in] font size
|
||||
* @param aFontWeight [in, optional] kBoldFontWeight or kNormalFontWeight,
|
||||
* default value is kNormalFontWeight
|
||||
*/
|
||||
function buildDefaultTextAttrs(aID, aFontSize, aFontWeight)
|
||||
{
|
||||
var elm = getNode(aID);
|
||||
var computedStyle = document.defaultView.getComputedStyle(elm, "");
|
||||
var bgColor = computedStyle.backgroundColor == "transparent" ?
|
||||
"rgb(255, 255, 255)" : computedStyle.backgroundColor;
|
||||
|
||||
var defAttrs = {
|
||||
"font-style": computedStyle.fontStyle,
|
||||
"font-size": aFontSize,
|
||||
"background-color": bgColor,
|
||||
"font-weight": aFontWeight ? aFontWeight : kNormalFontWeight,
|
||||
"color": computedStyle.color,
|
||||
"font-family": computedStyle.fontFamily,
|
||||
"text-position": computedStyle.verticalAlign
|
||||
};
|
||||
|
||||
return defAttrs;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private.
|
||||
|
||||
|
@ -23,16 +23,6 @@
|
||||
|
||||
var gComputedStyle = null;
|
||||
|
||||
function equalsToNormal(aWeight)
|
||||
{
|
||||
return aWeight <= 400;
|
||||
}
|
||||
|
||||
function equalsToBold(aWeight)
|
||||
{
|
||||
return aWeight > 400;
|
||||
}
|
||||
|
||||
var gTextAttrChangedEventHandler = {
|
||||
handleEvent: function gTextAttrChangedEventHandler_handleEvent(aEvent)
|
||||
{
|
||||
@ -59,17 +49,7 @@
|
||||
|
||||
window.setTimeout(function()
|
||||
{
|
||||
gComputedStyle = document.defaultView.getComputedStyle(node, "");
|
||||
var defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
// The pt font size of the input element can vary by Linux distro.
|
||||
"font-size": (WIN ? "10pt" : (MAC ? "8pt" : function() { return true; })),
|
||||
"background-color": gComputedStyle.backgroundColor,
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
var defAttrs = buildDefaultTextAttrs(node, kInputFontSize);
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
var attrs = { };
|
||||
@ -97,26 +77,13 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area1
|
||||
var ID = "area1";
|
||||
var tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
var defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "10pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
var defAttrs = buildDefaultTextAttrs(ID, "10pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
var attrs = {};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 7);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "font-weight": equalsToBold };
|
||||
attrs = { "font-weight": kBoldFontWeight };
|
||||
testTextAttrs(ID, 7, attrs, defAttrs, 7, 11);
|
||||
|
||||
attrs = {};
|
||||
@ -125,37 +92,22 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area2
|
||||
ID = "area2";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "14pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "14pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 7);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "font-weight": equalsToBold };
|
||||
attrs = { "font-weight": kBoldFontWeight };
|
||||
testTextAttrs(ID, 7, attrs, defAttrs, 7, 12);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
var tempElem = getNode(ID).firstChild.nextSibling.firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"font-style": gComputedStyle.fontStyle,
|
||||
"font-weight": equalsToBold };
|
||||
"font-weight": kBoldFontWeight };
|
||||
testTextAttrs(ID, 13, attrs, defAttrs, 12, 19);
|
||||
|
||||
tempElem = tempElem.parentNode;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "font-weight": equalsToBold };
|
||||
attrs = { "font-weight": kBoldFontWeight };
|
||||
testTextAttrs(ID, 20, attrs, defAttrs, 19, 23);
|
||||
|
||||
attrs = {};
|
||||
@ -164,21 +116,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area3
|
||||
ID = "area3";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": gComputedStyle.backgroundColor,
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"color": gComputedStyle.color};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 6);
|
||||
@ -202,21 +143,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area4
|
||||
ID = "area4";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"color": gComputedStyle.color};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 16);
|
||||
@ -234,21 +164,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area5
|
||||
ID = "area5";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"color": gComputedStyle.color};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 5);
|
||||
@ -267,24 +186,13 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area6 (CSS vertical-align property, bug 445938)
|
||||
ID = "area6";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 5);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"text-position": gComputedStyle.verticalAlign,
|
||||
"font-size": "10pt"};
|
||||
@ -318,19 +226,8 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area7
|
||||
ID = "area7";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"language": "en",
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
defAttrs["language"] = "en";
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {"language": "ru"};
|
||||
@ -339,7 +236,7 @@
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 12, attrs, defAttrs, 12, 13);
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling.nextSibling.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "background-color": gComputedStyle.backgroundColor};
|
||||
testTextAttrs(ID, 13, attrs, defAttrs, 13, 26);
|
||||
@ -363,7 +260,7 @@
|
||||
|
||||
tempElem = tempElem.firstChild.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = {"font-weight": equalsToBold,
|
||||
attrs = {"font-weight": kBoldFontWeight,
|
||||
"color": gComputedStyle.color};
|
||||
testTextAttrs(ID, 57, attrs, defAttrs, 57, 61);
|
||||
|
||||
@ -375,18 +272,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area9, different single style spans in styled paragraph
|
||||
ID = "area9";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "10pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "10pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {};
|
||||
@ -399,7 +285,7 @@
|
||||
testTextAttrs(ID, 13, attrs, defAttrs, 12, 21);
|
||||
|
||||
// Walk to the span with the different background color
|
||||
tempElem = tempElem.firstChild.nextSibling.nextSibling.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "background-color": gComputedStyle.backgroundColor };
|
||||
testTextAttrs(ID, 22, attrs, defAttrs, 21, 36);
|
||||
@ -439,18 +325,7 @@
|
||||
|
||||
// area10, different single style spans in non-styled paragraph
|
||||
ID = "area10";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToNormal,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {};
|
||||
@ -463,7 +338,7 @@
|
||||
testTextAttrs(ID, 13, attrs, defAttrs, 13, 22);
|
||||
|
||||
// Walk to the span with the different background color
|
||||
tempElem = tempElem.firstChild.nextSibling.nextSibling.nextSibling;
|
||||
tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
attrs = { "background-color": gComputedStyle.backgroundColor };
|
||||
testTextAttrs(ID, 23, attrs, defAttrs, 22, 37);
|
||||
@ -503,42 +378,47 @@
|
||||
|
||||
// area11, "font-weight" tests
|
||||
ID = "area11";
|
||||
tempElem = document.getElementById(ID);
|
||||
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
||||
|
||||
defAttrs = {
|
||||
"font-style": gComputedStyle.fontStyle,
|
||||
"font-size": "12pt",
|
||||
"background-color": "rgb(255, 255, 255)",
|
||||
"font-weight": equalsToBold,
|
||||
"color": gComputedStyle.color,
|
||||
"font-family": gComputedStyle.fontFamily,
|
||||
"text-position": gComputedStyle.verticalAlign
|
||||
};
|
||||
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt", kBoldFontWeight);
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 13);
|
||||
|
||||
attrs = { "font-weight": equalsToNormal };
|
||||
attrs = { "font-weight": kNormalFontWeight };
|
||||
testTextAttrs(ID, 13, attrs, defAttrs, 13, 20);
|
||||
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 20, attrs, defAttrs, 20, 27);
|
||||
|
||||
attrs = { "font-weight": equalsToNormal };
|
||||
attrs = { "font-weight": kNormalFontWeight };
|
||||
testTextAttrs(ID, 27, attrs, defAttrs, 27, 33);
|
||||
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 33, attrs, defAttrs, 33, 51);
|
||||
|
||||
attrs = { "font-weight": equalsToNormal };
|
||||
attrs = { "font-weight": kNormalFontWeight };
|
||||
testTextAttrs(ID, 51, attrs, defAttrs, 51, 57);
|
||||
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 57, attrs, defAttrs, 57, 97);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test out of range offset
|
||||
testTextAttrsWrongOffset("area12", -1);
|
||||
testTextAttrsWrongOffset("area12", 500);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test zero offset on empty hypertext accessibles
|
||||
ID = "area13";
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 0);
|
||||
|
||||
ID = "area14";
|
||||
defAttrs = buildDefaultTextAttrs(ID, kInputFontSize);
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test spelling text attributes
|
||||
testSpellTextAttrs(); // Will call SimpleTest.finish();
|
||||
@ -631,5 +511,9 @@
|
||||
<span style="font-weight: bold;">bold</span>bolder
|
||||
<span style="font-weight: 900;">bold</span>bolder
|
||||
</p>
|
||||
|
||||
<p id="area12">hello</p>
|
||||
<p id="area13"></p>
|
||||
<input id="area14">
|
||||
</body>
|
||||
</html>
|
||||
|
@ -8,6 +8,8 @@ const nsIAccessibleStateChangeEvent =
|
||||
Components.interfaces.nsIAccessibleStateChangeEvent;
|
||||
const nsIAccessibleCaretMoveEvent =
|
||||
Components.interfaces.nsIAccessibleCaretMoveEvent;
|
||||
const nsIAccessibleTextChangeEvent =
|
||||
Components.interfaces.nsIAccessibleTextChangeEvent;
|
||||
|
||||
const nsIAccessibleStates = Components.interfaces.nsIAccessibleStates;
|
||||
const nsIAccessibleRole = Components.interfaces.nsIAccessibleRole;
|
||||
@ -73,6 +75,7 @@ const STATE_SELECTED = nsIAccessibleStates.STATE_SELECTED;
|
||||
const STATE_TRAVERSED = nsIAccessibleStates.STATE_TRAVERSED;
|
||||
const STATE_UNAVAILABLE = nsIAccessibleStates.STATE_UNAVAILABLE;
|
||||
|
||||
const EXT_STATE_ACTIVE = nsIAccessibleStates.EXT_STATE_ACTIVE;
|
||||
const EXT_STATE_EDITABLE = nsIAccessibleStates.EXT_STATE_EDITABLE;
|
||||
const EXT_STATE_EXPANDABLE = nsIAccessibleStates.EXT_STATE_EXPANDABLE;
|
||||
const EXT_STATE_HORIZONTAL = nsIAccessibleStates.EXT_STATE_HORIZONTAL;
|
||||
@ -261,7 +264,8 @@ function isAccessible(aAccOrElmOrID, aInterfaces)
|
||||
*/
|
||||
function getRootAccessible(aAccOrElmOrID)
|
||||
{
|
||||
var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document);
|
||||
var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document,
|
||||
[nsIAccessNode]);
|
||||
return acc ? acc.rootDocument.QueryInterface(nsIAccessible) : null;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START;
|
||||
const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
|
||||
const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
|
||||
const EVENT_TEXT_CARET_MOVED = nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED;
|
||||
const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// General
|
||||
|
@ -61,6 +61,7 @@ _TEST_FILES =\
|
||||
test_focusdoc.html \
|
||||
test_mutation.html \
|
||||
test_scroll.xul \
|
||||
test_text.html \
|
||||
test_tree.xul \
|
||||
test_valuechange.html \
|
||||
$(NULL)
|
||||
|
89
accessible/tests/mochitest/events/test_text.html
Normal file
89
accessible/tests/mochitest/events/test_text.html
Normal file
@ -0,0 +1,89 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Accessible mutation events testing</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
/**
|
||||
* Invokers.
|
||||
*/
|
||||
function removeChildSpan(aID)
|
||||
{
|
||||
this.DOMNode = getNode(aID);
|
||||
|
||||
this.invoke = function removeChildSpan_invoke()
|
||||
{
|
||||
// remove HTML span, a first child of the node
|
||||
this.DOMNode.removeChild(this.DOMNode.firstChild);
|
||||
}
|
||||
|
||||
this.eventSeq = [
|
||||
new invokerChecker(EVENT_TEXT_REMOVED, this.DOMNode)
|
||||
];
|
||||
|
||||
this.check = function removeChildSpan_check(aEvent)
|
||||
{
|
||||
aEvent.QueryInterface(nsIAccessibleTextChangeEvent);
|
||||
is(aEvent.length, 5, "Wrong length of removed text");
|
||||
}
|
||||
|
||||
this.getID = function focusElmWhileSubdocIsFocused_getID()
|
||||
{
|
||||
return "Remove inaccessible span containing accessible nodes" + prettyName(aID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do tests.
|
||||
*/
|
||||
var gQueue = null;
|
||||
// gA11yEventDumpID = "eventdump"; // debug stuff
|
||||
|
||||
function doTests()
|
||||
{
|
||||
gQueue = new eventQueue();
|
||||
|
||||
// Text remove event on inaccessible child HTML span removal containing
|
||||
// accessible text nodes.
|
||||
gQueue.push(new removeChildSpan("p"));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566293"
|
||||
title=" wrong length of text remove event when inaccessible node containing accessible nodes is removed">
|
||||
Mozilla Bug 566293
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<div id="eventdump"></div>
|
||||
|
||||
<p id="p"><span><span>333</span><span>22</span></span>1111</p>
|
||||
</body>
|
||||
</html>
|
@ -31,9 +31,8 @@
|
||||
setOverLink: function (link, b) {
|
||||
}
|
||||
};
|
||||
var gFindBar = {
|
||||
hidden: true
|
||||
};
|
||||
|
||||
gFindBarInitialized = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Invoker implementation.
|
||||
|
36
accessible/tests/mochitest/selectable.js
Normal file
36
accessible/tests/mochitest/selectable.js
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Test selection getter methods of nsIAccessibleSelectable.
|
||||
*
|
||||
* @param aIdentifier [in] selectable container accessible
|
||||
* @param aSelectedChildren [in] array of selected children
|
||||
*/
|
||||
function testSelectableSelection(aIdentifier, aSelectedChildren)
|
||||
{
|
||||
var acc = getAccessible(aIdentifier, [nsIAccessibleSelectable]);
|
||||
if (!acc)
|
||||
return;
|
||||
|
||||
var len = aSelectedChildren.length;
|
||||
|
||||
// getSelectedChildren
|
||||
var selectedChildren = acc.GetSelectedChildren();
|
||||
is(selectedChildren ? selectedChildren.length : 0, aSelectedChildren.length,
|
||||
"getSelectedChildren: wrong selected children count for " + prettyName(aIdentifier));
|
||||
|
||||
for (var idx = 0; idx < len; idx++) {
|
||||
var expectedAcc = getAccessible(aSelectedChildren[idx]);
|
||||
is(selectedChildren.queryElementAt(idx, nsIAccessible), expectedAcc,
|
||||
"getSelectedChildren: wrong selected child at index " + idx + " for " + prettyName(aIdentifier));
|
||||
}
|
||||
|
||||
// selectionCount
|
||||
is(acc.selectionCount, aSelectedChildren.length,
|
||||
"selectionCount: wrong selected children count for " + prettyName(aIdentifier));
|
||||
|
||||
// refSelection
|
||||
for (var idx = 0; idx < len; idx++) {
|
||||
var expectedAcc = getAccessible(aSelectedChildren[idx]);
|
||||
is(acc.refSelection(idx), expectedAcc,
|
||||
"refSelection: wrong selected child at index " + idx + " for " + prettyName(aIdentifier));
|
||||
}
|
||||
}
|
@ -17,8 +17,23 @@
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/selectable.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function testSelectable(aID, aSelectableChildren)
|
||||
{
|
||||
var acc = getAccessible(aID, [nsIAccessibleSelectable]);
|
||||
|
||||
testSelectableSelection(acc, []);
|
||||
|
||||
acc.selectAllSelection();
|
||||
testSelectableSelection(acc, aSelectableChildren);
|
||||
|
||||
acc.clearSelection();
|
||||
testSelectableSelection(acc, []);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var id = "list1";
|
||||
@ -45,6 +60,11 @@
|
||||
ok(isAccessible(id, [nsIAccessibleSelectable]),
|
||||
"No selectable accessible for " + id);
|
||||
|
||||
// Test selection methods for selectable children in subtree.
|
||||
testSelectable("grid2",
|
||||
["grid2_colhead1", "grid2_colhead2", "grid2_colhead3",
|
||||
"grid2_rowhead", "grid2_cell1", "grid2_cell2"]);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -61,6 +81,11 @@
|
||||
title="ARIA single selectable widget should implement nsIAccessibleSelectable">
|
||||
Mozilla Bug 530014
|
||||
</a><br>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566551"
|
||||
title="ARIA grid and accessible selectable methods shouldn't use GetNextSibling">
|
||||
Mozilla Bug 566551
|
||||
</a><br>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
@ -116,5 +141,29 @@
|
||||
<span role="gridcell">cell</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table tabindex="0" border="2" cellspacing="0" id="grid2" role="grid"
|
||||
aria-multiselectable="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th tabindex="-1" role="columnheader" id="grid2_colhead1"
|
||||
style="width:6em">Entry #</th>
|
||||
<th tabindex="-1" role="columnheader" id="grid2_colhead2"
|
||||
style="width:10em">Date</th>
|
||||
<th tabindex="-1" role="columnheader" id="grid2_colhead3"
|
||||
style="width:20em">Expense</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td tabindex="-1" role="rowheader" id="grid2_rowhead"
|
||||
aria-readonly="true">1</td>
|
||||
<td tabindex="-1" role="gridcell" id="grid2_cell1"
|
||||
aria-selected="false">03/14/05</td>
|
||||
<td tabindex="-1" role="gridcell" id="grid2_cell2"
|
||||
aria-selected="false">Conference Fee</td>
|
||||
</tr>
|
||||
</tobdy>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -22,6 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=509696
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
// Bug 566542: root accesible should expose active state when focused.
|
||||
testStates(getRootAccessible(), 0, EXT_STATE_ACTIVE);
|
||||
|
||||
// Bug 509696
|
||||
testStates(document, STATE_READONLY); // role=""
|
||||
todo(false, "enable commented tests when we support body role changes");
|
||||
@ -71,6 +74,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=509696
|
||||
<a target="_blank"
|
||||
title="Role attribute on body with empty string causes DocAccessible not to have read-only state."
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=509696">Mozilla Bug 509696</a>
|
||||
<a target="_blank"
|
||||
title="Frame for firefox does not implement the state "active" when firefox is the active frame"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566542">Mozilla Bug 566542</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
|
72
accessible/tests/mochitest/table/Makefile.in
Normal file
72
accessible/tests/mochitest/table/Makefile.in
Normal file
@ -0,0 +1,72 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2010
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = accessible/table
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_headers_ariagrid.html \
|
||||
test_headers_listbox.xul \
|
||||
test_headers_table.html \
|
||||
test_headers_tree.xul \
|
||||
test_indexes_ariagrid.html \
|
||||
test_indexes_listbox.xul \
|
||||
test_indexes_table.html \
|
||||
test_indexes_tree.xul \
|
||||
test_layoutguess.html \
|
||||
test_sels_ariagrid.html \
|
||||
test_sels_listbox.xul \
|
||||
test_sels_table.html \
|
||||
test_sels_tree.xul \
|
||||
test_struct_ariagrid.html \
|
||||
test_struct_ariatreegrid.html \
|
||||
test_struct_listbox.xul \
|
||||
test_struct_table.html \
|
||||
test_struct_tree.xul \
|
||||
test_table_1.html \
|
||||
test_table_2.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)
|
@ -73,7 +73,8 @@
|
||||
// Note: if input have label elements then the name isn't calculated
|
||||
// from them.
|
||||
testName("btn_labelledby_mixed_input",
|
||||
"input button Submit Query Reset Submit Query");
|
||||
"Submit Query Reset Submit Query");
|
||||
// XXX Bug 567203 "input button Submit Query Reset Submit Query");
|
||||
|
||||
// Gets the name from the title of object element.
|
||||
testName("btn_labelledby_mixed_object", "object");
|
||||
|
@ -242,7 +242,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
|
||||
testAction(id, linkAcc, "jump");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Text accessible shouldn't implement nsIAccessibleHyperLink
|
||||
var res = isAccessible(getNode("namedAnchor").firstChild,
|
||||
[nsIAccessibleHyperLink]);
|
||||
ok(!res, "Text accessible shouldn't implement nsIAccessibleHyperLink");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -36,24 +36,18 @@
|
||||
testAccessibleTree("radio", accTree);
|
||||
|
||||
// input@type="button" and input@type="submit"
|
||||
accTree = {
|
||||
role: ROLE_PUSHBUTTON,
|
||||
children: [ ]
|
||||
};
|
||||
|
||||
testAccessibleTree("btn1", accTree);
|
||||
testAccessibleTree("submit", accTree);
|
||||
|
||||
// button
|
||||
accTree = {
|
||||
role: ROLE_PUSHBUTTON,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
role: ROLE_TEXT_LEAF // XXX Bug 567203
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
testAccessibleTree("btn1", accTree);
|
||||
testAccessibleTree("submit", accTree);
|
||||
testAccessibleTree("btn2", accTree);
|
||||
|
||||
// input@type="image"
|
||||
|
@ -603,7 +603,7 @@
|
||||
type="checkbox"
|
||||
label="&inspectMenu.label;"
|
||||
accesskey="&inspectMenu.accesskey;"
|
||||
key="&inspectMenu.commandkey;"
|
||||
key="key_inspect"
|
||||
command="Tools:Inspect"/>
|
||||
<menuitem id="javascriptConsole"
|
||||
label="&errorConsoleCmd.label;"
|
||||
|
@ -91,8 +91,7 @@ var gEditUIVisible = true;
|
||||
["gBrowser", "content"],
|
||||
["gNavToolbox", "navigator-toolbox"],
|
||||
["gURLBar", "urlbar"],
|
||||
["gNavigatorBundle", "bundle_browser"],
|
||||
["gFindBar", "FindToolbar"]
|
||||
["gNavigatorBundle", "bundle_browser"]
|
||||
].forEach(function (elementGlobal) {
|
||||
var [name, id] = elementGlobal;
|
||||
window.__defineGetter__(name, function () {
|
||||
@ -108,6 +107,24 @@ var gEditUIVisible = true;
|
||||
});
|
||||
});
|
||||
|
||||
// Smart getter for the findbar. If you don't wish to force the creation of
|
||||
// the findbar, check gFindBarInitialized first.
|
||||
var gFindBarInitialized = false;
|
||||
XPCOMUtils.defineLazyGetter(window, "gFindBar", function() {
|
||||
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
let findbar = document.createElementNS(XULNS, "findbar");
|
||||
findbar.setAttribute("browserid", "content");
|
||||
findbar.id = "FindToolbar";
|
||||
|
||||
let browserBottomBox = document.getElementById("browser-bottombox");
|
||||
browserBottomBox.insertBefore(findbar, browserBottomBox.firstChild);
|
||||
|
||||
// Force a style flush to ensure that our binding is attached.
|
||||
findbar.clientTop;
|
||||
window.gFindBarInitialized = true;
|
||||
return findbar;
|
||||
});
|
||||
|
||||
__defineGetter__("gPrefService", function() {
|
||||
delete this.gPrefService;
|
||||
return this.gPrefService = Services.prefs;
|
||||
@ -971,10 +988,13 @@ function BrowserStartup() {
|
||||
}
|
||||
|
||||
if (window.opener && !window.opener.closed) {
|
||||
let openerFindBar = window.opener.gFindBar;
|
||||
if (openerFindBar && !openerFindBar.hidden &&
|
||||
openerFindBar.findMode == gFindBar.FIND_NORMAL)
|
||||
let openerFindBar = window.opener.gFindBarInitialized ?
|
||||
window.opener.gFindBar : null;
|
||||
if (openerFindBar &&
|
||||
!openerFindBar.hidden &&
|
||||
openerFindBar.findMode == openerFindBar.FIND_NORMAL) {
|
||||
gFindBar.open();
|
||||
}
|
||||
|
||||
let openerSidebarBox = window.opener.document.getElementById("sidebar-box");
|
||||
// If the opener had a sidebar, open the same sidebar in our window.
|
||||
@ -2598,8 +2618,9 @@ var PrintPreviewListener = {
|
||||
this._chromeState.statusbarOpen = !statusbar.hidden;
|
||||
statusbar.hidden = true;
|
||||
|
||||
this._chromeState.findOpen = !gFindBar.hidden;
|
||||
gFindBar.close();
|
||||
this._chromeState.findOpen = gFindBarInitialized && !gFindBar.hidden;
|
||||
if (gFindBarInitialized)
|
||||
gFindBar.close();
|
||||
},
|
||||
_showChrome: function () {
|
||||
if (this._chromeState.notificationsOpen)
|
||||
@ -4112,17 +4133,19 @@ var XULBrowserWindow = {
|
||||
}
|
||||
UpdateBackForwardCommands(gBrowser.webNavigation);
|
||||
|
||||
if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
|
||||
// Close the Find toolbar if we're in old-style TAF mode
|
||||
gFindBar.close();
|
||||
if (gFindBarInitialized) {
|
||||
if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
|
||||
// Close the Find toolbar if we're in old-style TAF mode
|
||||
gFindBar.close();
|
||||
}
|
||||
|
||||
// XXXmano new-findbar, do something useful once it lands.
|
||||
// Of course, this is especially wrong with bfcache on...
|
||||
|
||||
// fix bug 253793 - turn off highlight when page changes
|
||||
gFindBar.getElement("highlight").checked = false;
|
||||
}
|
||||
|
||||
// XXXmano new-findbar, do something useful once it lands.
|
||||
// Of course, this is especially wrong with bfcache on...
|
||||
|
||||
// fix bug 253793 - turn off highlight when page changes
|
||||
gFindBar.getElement("highlight").checked = false;
|
||||
|
||||
// See bug 358202, when tabs are switched during a drag operation,
|
||||
// timers don't fire on windows (bug 203573)
|
||||
if (aRequest)
|
||||
@ -7255,7 +7278,7 @@ let gPrivateBrowsingUI = {
|
||||
if (BrowserSearch.searchBar)
|
||||
this._searchBarValue = BrowserSearch.searchBar.textbox.value;
|
||||
|
||||
if (gFindBar)
|
||||
if (gFindBarInitialized)
|
||||
this._findBarValue = gFindBar.getElement("findbar-textbox").value;
|
||||
|
||||
this._setPBMenuTitle("stop");
|
||||
@ -7313,7 +7336,7 @@ let gPrivateBrowsingUI = {
|
||||
// temporary fix until bug 463607 is fixed
|
||||
document.getElementById("Tools:Sanitize").removeAttribute("disabled");
|
||||
|
||||
if (gFindBar) {
|
||||
if (gFindBarInitialized) {
|
||||
let findbox = gFindBar.getElement("findbar-textbox");
|
||||
findbox.reset();
|
||||
if (this._findBarValue) {
|
||||
@ -7610,4 +7633,4 @@ var TabContextMenu = {
|
||||
getService(Ci.nsISessionStore).
|
||||
getClosedTabCount(window) == 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -753,8 +753,6 @@
|
||||
</hbox>
|
||||
|
||||
<vbox id="browser-bottombox">
|
||||
<findbar browserid="content" id="FindToolbar"/>
|
||||
|
||||
<statusbar class="chromeclass-status" id="status-bar"
|
||||
#ifdef WINCE
|
||||
hidden="true"
|
||||
|
@ -508,13 +508,10 @@ var InspectorUI = {
|
||||
*/
|
||||
toggleInspectorUI: function InspectorUI_toggleInspectorUI()
|
||||
{
|
||||
let toolsInspectCmd = document.getElementById("Tools:Inspect");
|
||||
if (this.isPanelOpen) {
|
||||
this.closeInspectorUI();
|
||||
toolsInspectCmd.setAttribute("checked", "false");
|
||||
} else {
|
||||
this.openInspectorUI();
|
||||
toolsInspectCmd.setAttribute("checked", "true");
|
||||
}
|
||||
},
|
||||
|
||||
@ -583,6 +580,7 @@ var InspectorUI = {
|
||||
this.startInspecting();
|
||||
this.win.document.addEventListener("scroll", this, false);
|
||||
gBrowser.tabContainer.addEventListener("TabSelect", this, false);
|
||||
this.inspectCmd.setAttribute("checked", true);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -611,6 +609,7 @@ var InspectorUI = {
|
||||
this.treePanel.hidePopup();
|
||||
this.treeView.destroy();
|
||||
}
|
||||
this.inspectCmd.setAttribute("checked", false);
|
||||
this.browser = this.win = null; // null out references to browser and window
|
||||
},
|
||||
|
||||
@ -756,3 +755,7 @@ var InspectorUI = {
|
||||
},
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI, "inspectCmd", function () {
|
||||
return document.getElementById("Tools:Inspect");
|
||||
});
|
||||
|
||||
|
@ -175,8 +175,7 @@
|
||||
accesskey="&detailsProgressiveDisclosure.accesskey;"
|
||||
control="detailsExpander"/>
|
||||
</hbox>
|
||||
<listbox id="itemList" rows="6" collapsed="true" persist="collapsed"
|
||||
flex="1">
|
||||
<listbox id="itemList" rows="6" collapsed="true" persist="collapsed">
|
||||
<listitem label="&itemHistoryAndDownloads.label;"
|
||||
type="checkbox"
|
||||
accesskey="&itemHistoryAndDownloads.accesskey;"
|
||||
|
@ -904,7 +904,8 @@
|
||||
this._tabAttrModified(this.mCurrentTab);
|
||||
|
||||
// Change focus to the new browser unless the findbar is focused.
|
||||
if (gFindBar.hidden ||
|
||||
if (!gFindBarInitialized ||
|
||||
gFindBar.hidden ||
|
||||
gFindBar.getElement("findbar-textbox").getAttribute("focused") != "true") {
|
||||
|
||||
var fm = Components.classes["@mozilla.org/focus-manager;1"].
|
||||
|
@ -86,7 +86,7 @@ function test() {
|
||||
let tab_A2 = window_A.gBrowser.addTab("http://example.com");
|
||||
let tab_A3 = window_A.gBrowser.addTab("about:config");
|
||||
tab_A3.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
tab_A3.removeEventListener("load", arguments.callee, true);
|
||||
tab_A3.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// tab_A2 isn't focused yet
|
||||
isWindowState(window_A, [-10, 0, 0]);
|
||||
@ -129,7 +129,6 @@ function test() {
|
||||
}, window_B);
|
||||
}, window_A);
|
||||
}, window_B);
|
||||
|
||||
}, true);
|
||||
}, false);
|
||||
}, true);
|
||||
|
@ -450,8 +450,10 @@ WindowHelper.prototype = {
|
||||
"Details button should be " + dir + " because item list is " +
|
||||
(hidden ? "" : "not ") + "hidden");
|
||||
let height = 0;
|
||||
if (!hidden)
|
||||
if (!hidden) {
|
||||
ok(list.boxObject.height > 30, "listbox has sufficient size")
|
||||
height += list.boxObject.height;
|
||||
}
|
||||
if (this.isWarningPanelVisible())
|
||||
height += this.getWarningPanel().boxObject.height;
|
||||
ok(height < this.win.innerHeight,
|
||||
|
@ -1246,7 +1246,8 @@ BrowserGlue.prototype = {
|
||||
// get this contractID registered for certain categories via XPCOMUtils
|
||||
_xpcom_categories: [
|
||||
// make BrowserGlue a startup observer
|
||||
{ category: "app-startup", service: true }
|
||||
{ category: "app-startup", service: true,
|
||||
apps: [ /* Firefox */ "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" ] }
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# browser_506482.js is disabled because of frequent failures (bug 538672)
|
||||
# browser_524745.js is disabled because of frequent failures (bug 539002)
|
||||
# browser_526613.js is disabled because of frequent failures (bug 534489)
|
||||
|
||||
_BROWSER_TEST_FILES = \
|
||||
@ -113,6 +112,7 @@ _BROWSER_TEST_FILES = \
|
||||
browser_500328.js \
|
||||
browser_514751.js \
|
||||
browser_522545.js \
|
||||
browser_524745.js \
|
||||
browser_528776.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
@BINPATH@/searchplugins/*
|
||||
@BINPATH@/defaults/profile/bookmarks.html
|
||||
@BINPATH@/defaults/profile/localstore.rdf
|
||||
@BINPATH@/defaults/profile/prefs.js
|
||||
@BINPATH@/defaults/profile/mimeTypes.rdf
|
||||
@BINPATH@/defaults/profile/chrome/*
|
||||
@BINPATH@/update.locale
|
||||
@ -373,6 +372,7 @@
|
||||
@BINPATH@/greprefs.js
|
||||
@BINPATH@/defaults/autoconfig/platform.js
|
||||
@BINPATH@/defaults/autoconfig/prefcalls.js
|
||||
@BINPATH@/defaults/profile/prefs.js
|
||||
|
||||
; [Layout Engine Resources]
|
||||
; Style Sheets, Graphics and other Resources used by the layout engine.
|
||||
|
@ -160,7 +160,7 @@
|
||||
<!ENTITY errorConsoleCmd.commandkey "j">
|
||||
|
||||
<!ENTITY inspectMenu.label "Inspect">
|
||||
<!ENTITY inspectMenu.accesskey "I">
|
||||
<!ENTITY inspectMenu.accesskey "T">
|
||||
<!ENTITY inspectMenu.commandkey "I">
|
||||
|
||||
<!ENTITY fileMenu.label "File">
|
||||
|
@ -484,7 +484,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
||||
for (PRInt32 l = 0; l < agentSheets.Count(); ++l) {
|
||||
nsIStyleSheet *sheet = agentSheets[l];
|
||||
|
||||
nsCOMPtr<nsIURI> uri = sheet->GetSheetURI();
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
|
@ -80,6 +80,7 @@ SYSTEM_LIBXUL = @SYSTEM_LIBXUL@
|
||||
XULRUNNER_STUB_NAME = @XULRUNNER_STUB_NAME@
|
||||
|
||||
MOZ_CHROME_FILE_FORMAT = @MOZ_CHROME_FILE_FORMAT@
|
||||
MOZ_OMNIJAR = @MOZ_OMNIJAR@
|
||||
|
||||
MOZ_WIDGET_TOOLKIT = @MOZ_WIDGET_TOOLKIT@
|
||||
MOZ_GFX_OPTIMIZE_MOBILE = @MOZ_GFX_OPTIMIZE_MOBILE@
|
||||
@ -651,3 +652,9 @@ MOZ_OFFICIAL_BRANDING = @MOZ_OFFICIAL_BRANDING@
|
||||
|
||||
HAVE_CLOCK_MONOTONIC = @HAVE_CLOCK_MONOTONIC@
|
||||
REALTIME_LIBS = @REALTIME_LIBS@
|
||||
|
||||
ANDROID_NDK = @ANDROID_NDK@
|
||||
ANDROID_TOOLCHAIN = @ANDROID_TOOLCHAIN@
|
||||
ANDROID_PLATFORM = @ANDROID_PLATFORM@
|
||||
ANDROID_SDK = @ANDROID_SDK@
|
||||
ANDROID_TOOLS = @ANDROID_TOOLS@
|
||||
|
219
configure.in
219
configure.in
@ -239,6 +239,108 @@ if test -z "$PERL" || test "$PERL" = ":"; then
|
||||
AC_MSG_ERROR([perl not found in \$PATH])
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Android uses a very custom (hacky) toolchain; we need to do this
|
||||
dnl = here, so that the compiler checks can succeed
|
||||
dnl ========================================================
|
||||
|
||||
MOZ_ARG_WITH_STRING(android-ndk,
|
||||
[ --with-android-ndk=DIR
|
||||
location where the Android NDK can be found],
|
||||
android_ndk=$withval)
|
||||
|
||||
MOZ_ARG_WITH_STRING(android-toolchain,
|
||||
[ --with-android-toolchain=DIR
|
||||
location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
|
||||
android_toolchain=$withval)
|
||||
|
||||
MOZ_ARG_WITH_STRING(android-platform,
|
||||
[ --with-android-platform=DIR
|
||||
location of NDK platform dir, default NDK/build/platforms/android-5/arch-arm],
|
||||
android_platform=$withval)
|
||||
|
||||
MOZ_ARG_WITH_STRING(android-sdk,
|
||||
[ --with-android-sdk=DIR
|
||||
location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
|
||||
android_sdk=$withval)
|
||||
|
||||
MOZ_ARG_WITH_STRING(android-tools,
|
||||
[ --with-android-tools=DIR
|
||||
location where the Android Tools can be found (base directory, e.g. .../android/tools)],
|
||||
android_tools=$withval)
|
||||
|
||||
if test "$target" = "arm-android-eabi" ; then
|
||||
if test -z "$android_ndk" ; then
|
||||
AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
|
||||
fi
|
||||
|
||||
if test -z "$android_sdk" ; then
|
||||
AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
|
||||
fi
|
||||
|
||||
if test -z "$android_tools" ; then
|
||||
AC_MSG_ERROR([You must specify --with-android-tools=/path/to/sdk/tools when targeting Android.])
|
||||
fi
|
||||
|
||||
if test -z "$android_toolchain" ; then
|
||||
android_toolchain="$android_ndk"/build/prebuilt/`uname -s | tr "[[:upper:]]" "[[:lower:]]"`-x86/arm-eabi-4.4.0
|
||||
fi
|
||||
|
||||
if test -z "$android_platform" ; then
|
||||
android_platform="$android_ndk"/build/platforms/android-5/arch-arm
|
||||
fi
|
||||
|
||||
dnl set up compilers
|
||||
AS="$android_toolchain"/bin/arm-eabi-as
|
||||
CC="$android_toolchain"/bin/arm-eabi-gcc
|
||||
CXX="$android_toolchain"/bin/arm-eabi-g++
|
||||
CPP="$android_toolchain"/bin/arm-eabi-cpp
|
||||
LD="$android_toolchain"/bin/arm-eabi-ld
|
||||
AR="$android_toolchain"/bin/arm-eabi-ar
|
||||
RANLIB="$android_toolchain"/bin/arm-eabi-ranlib
|
||||
STRIP="$android_toolchain"/bin/arm-eabi-strip
|
||||
|
||||
CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
|
||||
CFLAGS="-mandroid -I$android_platform/usr/include -msoft-float -fno-short-enums -fno-exceptions -march=armv5te -mthumb-interwork $CFLAGS"
|
||||
CXXFLAGS="-mandroid -I$android_platform/usr/include -msoft-float -fno-short-enums -fno-exceptions -march=armv5te -mthumb-interwork $CXXFLAGS"
|
||||
|
||||
dnl Add -llog by default, since we use it all over the place.
|
||||
dnl Add --allow-shlib-undefined, because libGLESv2 links to an
|
||||
dnl undefined symbol (present on the hardware, just not in the
|
||||
dnl NDK.)
|
||||
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
|
||||
|
||||
dnl prevent cross compile section from using these flags as host flags
|
||||
if test -z "$HOST_CPPFLAGS" ; then
|
||||
HOST_CPPFLAGS=" "
|
||||
fi
|
||||
if test -z "$HOST_CFLAGS" ; then
|
||||
HOST_CFLAGS=" "
|
||||
fi
|
||||
if test -z "$HOST_CXXFLAGS" ; then
|
||||
HOST_CXXFLAGS=" "
|
||||
fi
|
||||
if test -z "$HOST_LDFLAGS" ; then
|
||||
HOST_LDFLAGS=" "
|
||||
fi
|
||||
|
||||
ANDROID_NDK="${android_ndk}"
|
||||
ANDROID_TOOLCHAIN="{android_toolchain}"
|
||||
ANDROID_PLATFORM="{android_platform}"
|
||||
ANDROID_SDK="${android_sdk}"
|
||||
ANDROID_TOOLS="${android_tools}"
|
||||
|
||||
AC_DEFINE(ANDROID)
|
||||
CROSS_COMPILE=1
|
||||
MOZ_CHROME_FILE_FORMAT=omni
|
||||
fi
|
||||
|
||||
AC_SUBST(ANDROID_NDK)
|
||||
AC_SUBST(ANDROID_TOOLCHAIN)
|
||||
AC_SUBST(ANDROID_PLATFORM)
|
||||
AC_SUBST(ANDROID_SDK)
|
||||
AC_SUBST(ANDROID_TOOLS)
|
||||
|
||||
dnl ========================================================
|
||||
dnl Checks for compilers.
|
||||
dnl ========================================================
|
||||
@ -1149,6 +1251,9 @@ if test -n "$CROSS_COMPILE"; then
|
||||
winmo*) OS_ARCH=WINCE ;;
|
||||
darwin*) OS_ARCH=Darwin OS_TARGET=Darwin ;;
|
||||
esac
|
||||
case "${target}" in
|
||||
arm-android-eabi) OS_ARCH=Linux OS_TARGET=Android ;;
|
||||
esac
|
||||
else
|
||||
OS_TARGET=`uname -s`
|
||||
OS_ARCH=`uname -s | sed -e 's|/|_|g'`
|
||||
@ -1460,6 +1565,9 @@ if test "$GNU_CC"; then
|
||||
if test "$GCC_USE_GNU_LD"; then
|
||||
# Don't allow undefined symbols in libraries
|
||||
DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
|
||||
LDFLAGS="$LDFLAGS -Wl,--gc-sections"
|
||||
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
|
||||
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
|
||||
fi
|
||||
WARNINGS_AS_ERRORS='-Werror'
|
||||
DSO_CFLAGS=''
|
||||
@ -1494,13 +1602,9 @@ if test "$GNU_CC"; then
|
||||
_PEDANTIC=1
|
||||
|
||||
if test -z "$INTEL_CC"; then
|
||||
_IGNORE_LONG_LONG_WARNINGS=1
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
|
||||
else
|
||||
_IGNORE_LONG_LONG_WARNINGS=
|
||||
fi
|
||||
|
||||
|
||||
_DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
|
||||
_USE_CPP_INCLUDE_FLAG=1
|
||||
elif test "$SOLARIS_SUNPRO_CC"; then
|
||||
@ -1914,7 +2018,6 @@ case "$target" in
|
||||
*-bsdi*)
|
||||
dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
|
||||
_PEDANTIC=
|
||||
_IGNORE_LONG_LONG_WARNINGS=
|
||||
case $OS_RELEASE in
|
||||
4.*|5.*)
|
||||
STRIP="$STRIP -d"
|
||||
@ -2793,6 +2896,18 @@ alpha*-*-osf*)
|
||||
HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
|
||||
;;
|
||||
|
||||
*-android*)
|
||||
AC_DEFINE(NO_PW_GECOS)
|
||||
no_x=yes
|
||||
_PLATFORM_DEFAULT_TOOLKIT=cairo-android
|
||||
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
|
||||
|
||||
MOZ_GFX_OPTIMIZE_MOBILE=1
|
||||
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer"
|
||||
|
||||
dnl MOZ_MEMORY=1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
dnl Only one oddball right now (QNX), but this gives us flexibility
|
||||
@ -4371,8 +4486,11 @@ LDFLAGS=$_SAVE_LDFLAGS
|
||||
if test "$ac_cv_thread_keyword" = yes; then
|
||||
# mips builds fail with TLS variables because of a binutils bug.
|
||||
# See bug 528687
|
||||
case "${target_cpu}" in
|
||||
mips*)
|
||||
case "${target}" in
|
||||
mips*-*)
|
||||
:
|
||||
;;
|
||||
*-android*)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
@ -4555,12 +4673,12 @@ fi
|
||||
if test -n "$MOZ_NATIVE_NSPR"; then
|
||||
_SAVE_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS $NSPR_CFLAGS"
|
||||
AC_TRY_COMPILE([#include "prlog.h"],
|
||||
AC_TRY_COMPILE([#include "prtypes.h"],
|
||||
[#ifndef PR_STATIC_ASSERT
|
||||
#error PR_STATIC_ASSERT not defined
|
||||
#error PR_STATIC_ASSERT not defined or requires including prlog.h
|
||||
#endif],
|
||||
[MOZ_NATIVE_NSPR=1],
|
||||
AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
|
||||
AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
|
||||
CFLAGS=$_SAVE_CFLAGS
|
||||
else
|
||||
if test "$OS_ARCH" = "WINCE"; then
|
||||
@ -5063,7 +5181,8 @@ MOZ_ARG_HEADER(Toolkit Options)
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-beos" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-cocoa"
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
|
||||
-o "$_DEFAULT_TOOLKIT" = "cairo-android"
|
||||
then
|
||||
dnl nglayout only supports building with one toolkit,
|
||||
dnl so ignore everything after the first comma (",").
|
||||
@ -5171,6 +5290,13 @@ cairo-cocoa)
|
||||
MOZ_FS_LAYOUT=bundle
|
||||
MOZ_WEBGL=1
|
||||
;;
|
||||
|
||||
cairo-android)
|
||||
AC_DEFINE(MOZ_WIDGET_ANDROID)
|
||||
MOZ_WIDGET_TOOLKIT=android
|
||||
MOZ_WEBGL=
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
if test "$MOZ_ENABLE_XREMOTE"; then
|
||||
@ -5629,7 +5755,7 @@ dnl ========================================================
|
||||
dnl = Disable IPC support for tabs and plugins
|
||||
dnl ========================================================
|
||||
case "${target}" in
|
||||
*-wince*)
|
||||
*-wince*|*-android*)
|
||||
MOZ_IPC=
|
||||
;;
|
||||
esac
|
||||
@ -6811,19 +6937,7 @@ MOZ_ARG_ENABLE_STRING(debug,
|
||||
fi ],
|
||||
MOZ_DEBUG=)
|
||||
|
||||
MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG"
|
||||
case "${target_os}" in
|
||||
beos*)
|
||||
MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${USER}"
|
||||
;;
|
||||
msvc*|mks*|cygwin*|mingw*|os2*|wince*|winmo*)
|
||||
MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
|
||||
;;
|
||||
*)
|
||||
MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`"
|
||||
;;
|
||||
esac
|
||||
MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DTRACING"
|
||||
MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
|
||||
|
||||
MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
|
||||
|
||||
@ -7372,7 +7486,7 @@ dnl =========================================================
|
||||
dnl = Chrome format
|
||||
dnl =========================================================
|
||||
MOZ_ARG_ENABLE_STRING([chrome-format],
|
||||
[ --enable-chrome-format=jar|flat|both|symlink
|
||||
[ --enable-chrome-format=jar|flat|both|symlink|omni
|
||||
Select FORMAT of chrome files (default=jar)],
|
||||
MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
|
||||
|
||||
@ -7383,13 +7497,30 @@ fi
|
||||
if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
|
||||
test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
|
||||
test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
|
||||
test "$MOZ_CHROME_FILE_FORMAT" != "both"; then
|
||||
AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, or symlink])
|
||||
test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
|
||||
test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
|
||||
AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
|
||||
fi
|
||||
|
||||
if test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
|
||||
AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
|
||||
dnl =========================================================
|
||||
dnl Omnijar packaging (bug 552121)
|
||||
dnl =========================================================
|
||||
dnl Omnijar packaging is compatible with flat packaging.
|
||||
dnl In unpackaged builds, omnijar looks for files as if
|
||||
dnl things were flat packaged. After packaging, all files
|
||||
dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
|
||||
dnl is set to flat since putting files into jars is only
|
||||
dnl done during packaging with omnijar.
|
||||
if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
|
||||
MOZ_OMNIJAR=1
|
||||
AC_DEFINE(MOZ_OMNIJAR)
|
||||
MOZ_CHROME_FILE_FORMAT=flat
|
||||
elif test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
|
||||
AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_OMNIJAR)
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Define default location for MOZILLA_FIVE_HOME
|
||||
dnl ========================================================
|
||||
@ -7483,28 +7614,6 @@ else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl Pass -Wno-long-long to the compiler
|
||||
dnl ========================================================
|
||||
MOZ_ARG_DISABLE_BOOL(long-long-warning,
|
||||
[ --disable-long-long-warning
|
||||
Do not warn about use of non-ANSI long long type (if supported)],
|
||||
_IGNORE_LONG_LONG_WARNINGS=1,
|
||||
_IGNORE_LONG_LONG_WARNINGS=)
|
||||
|
||||
if test -n "$_IGNORE_LONG_LONG_WARNINGS"; then
|
||||
_SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
AC_MSG_CHECKING([whether compiler supports -Wno-long-long])
|
||||
AC_TRY_COMPILE([], [return(0);],
|
||||
[ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
result="yes" ],
|
||||
result="no")
|
||||
AC_MSG_RESULT([$result])
|
||||
CFLAGS="$_SAVE_CFLAGS"
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl Profile guided optimization
|
||||
dnl ========================================================
|
||||
@ -7581,7 +7690,7 @@ MOZ_ARG_DISABLE_BOOL(pedantic,
|
||||
_PEDANTIC= )
|
||||
if test "$_PEDANTIC"; then
|
||||
_SAVE_CXXFLAGS=$CXXFLAGS
|
||||
CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic"
|
||||
CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
|
||||
AC_TRY_COMPILE([$configure_static_assert_macros],
|
||||
[CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
|
||||
@ -7591,8 +7700,8 @@ if test "$_PEDANTIC"; then
|
||||
|
||||
case "$result" in
|
||||
no)
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-pedantic"
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic"
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-pedantic ${_COMPILER_PREFIX}-Wno-long-long"
|
||||
;;
|
||||
yes)
|
||||
AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic. Reconfigure using --disable-pedantic. ])
|
||||
|
@ -19,7 +19,7 @@ load 338391-1.xhtml
|
||||
load 340733-1.html
|
||||
load 343730-1.xhtml
|
||||
load 343850-1.xhtml
|
||||
asserts(3) load 343889-1.html # bug 563536
|
||||
load 343889-1.html
|
||||
load 344434-1.xhtml
|
||||
load 348049-1.xhtml
|
||||
load 344882-1.html
|
||||
@ -41,7 +41,7 @@ skip load 399712-1.html # sporadically times out (bug 473680)
|
||||
load 398088-1.xul
|
||||
load 400763-1.html
|
||||
load 401993-1.html
|
||||
asserts(1) load 407818.html # bug 336104
|
||||
load 407818.html
|
||||
load 410860-1.xml
|
||||
load 416734-1.html
|
||||
load 418928-1.html
|
||||
@ -60,7 +60,7 @@ load 493281-2.html
|
||||
load 490760-1.xhtml
|
||||
load 494810-1.html
|
||||
load 529670.html
|
||||
asserts(1) load 554230-1.xhtml # bug 336104
|
||||
load 554230-1.xhtml
|
||||
load 552651.html
|
||||
load 558973.html
|
||||
load 564079-1.html
|
||||
|
@ -40,6 +40,9 @@
|
||||
/**
|
||||
* This is the enum used by nsIDocument::FlushPendingNotifications to
|
||||
* decide what to flush.
|
||||
*
|
||||
* Please note that if you change these values, you should sync it with the
|
||||
* flushTypeNames array inside PresShell::FlushPendingNotifications.
|
||||
*/
|
||||
enum mozFlushType {
|
||||
Flush_Content = 1, /* flush the content model construction */
|
||||
|
@ -138,9 +138,14 @@ typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
|
||||
namespace mozilla {
|
||||
class IHistory;
|
||||
|
||||
namespace layers {
|
||||
class LayerManager;
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
extern const char kLoadAsData[];
|
||||
@ -1603,6 +1608,19 @@ public:
|
||||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
/**
|
||||
* Returns a layer manager to use for the given document. Basically we
|
||||
* look up the document hierarchy for the first document which has
|
||||
* a presentation with an associated widget, and use that widget's
|
||||
* layer manager.
|
||||
*
|
||||
* If one can't be found, a BasicLayerManager is created and returned.
|
||||
*
|
||||
* @param aDoc the document for which to return a layer manager.
|
||||
*/
|
||||
static already_AddRefed<mozilla::layers::LayerManager>
|
||||
LayerManagerForDocument(nsIDocument *aDoc);
|
||||
|
||||
private:
|
||||
|
||||
static PRBool InitializeEventTable();
|
||||
|
@ -1358,6 +1358,15 @@ public:
|
||||
virtual void ResetScrolledToRefAlready() = 0;
|
||||
virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue) = 0;
|
||||
|
||||
/**
|
||||
* This method is similar to GetElementById() from nsIDOMDocument but it
|
||||
* returns a mozilla::dom::Element instead of a nsIDOMElement.
|
||||
* It prevents converting nsIDOMElement to mozill:dom::Element which is
|
||||
* already converted from mozilla::dom::Element.
|
||||
*/
|
||||
virtual mozilla::dom::Element* GetElementById(const nsAString& aElementId,
|
||||
nsresult* aResult) = 0;
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ interface nsIFrame;
|
||||
interface nsIChromeFrameMessageManager;
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, uuid(85a7f80b-4a3f-4606-8513-a1c4cced874f)]
|
||||
[scriptable, uuid(bd69ff3d-d2cb-4dee-94e4-c6948df7603a)]
|
||||
interface nsIFrameLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -113,6 +113,7 @@ interface nsIFrameLoader : nsISupports
|
||||
*/
|
||||
void activateFrameEvent(in AString aType, in boolean capture);
|
||||
|
||||
// Note, when frameloaders are swapped, also messageManagers are swapped.
|
||||
readonly attribute nsIChromeFrameMessageManager messageManager;
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDocShell;
|
||||
interface nsIContent;
|
||||
|
||||
[scriptable, function, uuid(938fcb95-3d63-46be-aa72-94d08fd3b418)]
|
||||
interface nsIFrameMessageListener : nsISupports
|
||||
@ -97,6 +98,12 @@ interface nsIContentFrameMessageManager : nsIFrameMessageManager
|
||||
void dump(in DOMString aStr);
|
||||
};
|
||||
|
||||
[uuid(9c48d557-92fe-4edb-95fc-bfe97e77bdc3)]
|
||||
interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
|
||||
{
|
||||
[notxpcom] nsIContent getOwnerContent();
|
||||
};
|
||||
|
||||
[scriptable, uuid(ed6522fd-ffb6-4920-b50d-cf629309616b)]
|
||||
interface nsIChromeFrameMessageManager : nsIFrameMessageManager
|
||||
{
|
||||
|
@ -143,8 +143,9 @@ CPPSRCS = \
|
||||
nsXMLHttpRequest.cpp \
|
||||
nsXMLNameSpaceMap.cpp \
|
||||
Link.cpp \
|
||||
nsFrameMessageManager.cpp \
|
||||
nsFileDataProtocolHandler.cpp \
|
||||
nsFrameMessageManager.cpp \
|
||||
nsInProcessTabChildGlobal.cpp \
|
||||
$(NULL)
|
||||
|
||||
GQI_SRCS = contentbase.gqi
|
||||
|
@ -175,6 +175,9 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "nsHtml5Module.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsFrameManager.h"
|
||||
#include "BasicLayers.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
@ -195,6 +198,9 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "jstypedarray.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsChannelPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -2324,12 +2330,23 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
|
||||
nsIURI *documentURI = aLoadingDocument->GetDocumentURI();
|
||||
|
||||
// check for a Content Security Policy to pass down to the channel that
|
||||
// will get created to load the image
|
||||
nsCOMPtr<nsIChannelPolicy> channelPolicy;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
if (aLoadingPrincipal) {
|
||||
nsresult rv = aLoadingPrincipal->GetCsp(getter_AddRefs(csp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (csp) {
|
||||
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
|
||||
channelPolicy->SetContentSecurityPolicy(csp);
|
||||
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_IMAGE);
|
||||
}
|
||||
}
|
||||
|
||||
// Make the URI immutable so people won't change it under us
|
||||
NS_TryToSetImmutable(aURI);
|
||||
|
||||
// We don't use aLoadingPrincipal for anything here yet... but we
|
||||
// will. See bug 377092.
|
||||
|
||||
// XXXbz using "documentURI" for the initialDocumentURI is not quite
|
||||
// right, but the best we can do here...
|
||||
return sImgLoader->LoadImage(aURI, /* uri to load */
|
||||
@ -2341,6 +2358,7 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
aLoadFlags, /* load flags */
|
||||
nsnull, /* cache key */
|
||||
nsnull, /* existing request*/
|
||||
channelPolicy, /* CSP info */
|
||||
aRequest);
|
||||
}
|
||||
|
||||
@ -3191,14 +3209,22 @@ nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
|
||||
NS_ASSERTION(aDoc, "GetEventAndTarget lied?");
|
||||
if (!aDoc->GetWindow())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (!aDoc->GetWindow()->GetChromeEventHandler())
|
||||
|
||||
nsPIDOMEventTarget* piTarget = aDoc->GetWindow()->GetChromeEventHandler();
|
||||
if (!piTarget)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIFrameLoaderOwner> flo = do_QueryInterface(piTarget);
|
||||
if (flo) {
|
||||
nsRefPtr<nsFrameLoader> fl = flo->GetFrameLoader();
|
||||
if (fl) {
|
||||
nsPIDOMEventTarget* t = fl->GetTabChildGlobalAsEventTarget();
|
||||
piTarget = t ? t : piTarget;
|
||||
}
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
rv = aDoc->GetWindow()->GetChromeEventHandler()->DispatchDOMEvent(nsnull,
|
||||
event,
|
||||
nsnull,
|
||||
&status);
|
||||
rv = piTarget->DispatchDOMEvent(nsnull, event, nsnull, &status);
|
||||
if (aDefaultAction) {
|
||||
*aDefaultAction = (status != nsEventStatus_eConsumeNoDefault);
|
||||
}
|
||||
@ -5494,7 +5520,7 @@ CloneSimpleValues(JSContext* cx,
|
||||
return SetPropertyOnValueOrObject(cx, val, rval, robj, rid);
|
||||
}
|
||||
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(val), "Not an object!");
|
||||
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(val), "Not an object!");
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
|
||||
// Dense arrays of primitives can be cloned quickly.
|
||||
@ -5963,7 +5989,8 @@ void nsContentUtils::RemoveNewlines(nsString &aString)
|
||||
aString.StripChars(badChars);
|
||||
}
|
||||
|
||||
void nsContentUtils::PlatformToDOMLineBreaks(nsString &aString)
|
||||
void
|
||||
nsContentUtils::PlatformToDOMLineBreaks(nsString &aString)
|
||||
{
|
||||
if (aString.FindChar(PRUnichar('\r')) != -1) {
|
||||
// Windows linebreaks: Map CRLF to LF:
|
||||
@ -5976,6 +6003,53 @@ void nsContentUtils::PlatformToDOMLineBreaks(nsString &aString)
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::layers::LayerManager>
|
||||
nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
|
||||
{
|
||||
nsIDocument* doc = aDoc;
|
||||
nsIDocument* displayDoc = doc->GetDisplayDocument();
|
||||
if (displayDoc) {
|
||||
doc = displayDoc;
|
||||
}
|
||||
|
||||
nsIPresShell* shell = doc->GetPrimaryShell();
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = do_QueryInterface(container);
|
||||
while (!shell && docShellTreeItem) {
|
||||
// We may be in a display:none subdocument, or we may not have a presshell
|
||||
// created yet.
|
||||
// Walk the docshell tree to find the nearest container that has a presshell,
|
||||
// and find the root widget from that.
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(docShellTreeItem);
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
shell = presShell;
|
||||
} else {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
docShellTreeItem->GetParent(getter_AddRefs(parent));
|
||||
docShellTreeItem = parent;
|
||||
}
|
||||
}
|
||||
|
||||
if (shell) {
|
||||
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
nsIWidget* widget =
|
||||
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetWindow();
|
||||
if (widget) {
|
||||
nsRefPtr<mozilla::layers::LayerManager> manager = widget->GetLayerManager();
|
||||
return manager.forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<mozilla::layers::LayerManager> manager =
|
||||
new mozilla::layers::BasicLayerManager(nsnull);
|
||||
return manager.forget();
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsIContentUtils, nsIContentUtils)
|
||||
|
||||
PRBool
|
||||
@ -5983,3 +6057,4 @@ nsIContentUtils::IsSafeToRunScript()
|
||||
{
|
||||
return nsContentUtils::IsSafeToRunScript();
|
||||
}
|
||||
|
||||
|
@ -2014,7 +2014,7 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
||||
// is probably the right thing to do.
|
||||
|
||||
// Now reset our inline style and attribute sheets.
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
nsStyleSet::sheetType attrSheetType = GetAttrSheetType();
|
||||
if (mAttrStyleSheet) {
|
||||
// Remove this sheet from all style sets
|
||||
@ -2022,11 +2022,11 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
||||
if (shell) {
|
||||
shell->StyleSet()->RemoveStyleSheet(attrSheetType, mAttrStyleSheet);
|
||||
}
|
||||
rv = mAttrStyleSheet->Reset(aURI);
|
||||
mAttrStyleSheet->Reset(aURI);
|
||||
} else {
|
||||
rv = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), aURI, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Don't use AddStyleSheet, since it'll put the sheet into style
|
||||
// sets in the document level, which is not desirable here.
|
||||
@ -2039,13 +2039,13 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
||||
shell->StyleSet()->
|
||||
RemoveStyleSheet(nsStyleSet::eStyleAttrSheet, mStyleAttrStyleSheet);
|
||||
}
|
||||
rv = mStyleAttrStyleSheet->Reset(aURI);
|
||||
mStyleAttrStyleSheet->Reset(aURI);
|
||||
} else {
|
||||
mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet();
|
||||
NS_ENSURE_TRUE(mStyleAttrStyleSheet, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = mStyleAttrStyleSheet->Init(aURI, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// The loop over style sets below will handle putting this sheet
|
||||
// into style sets as needed.
|
||||
@ -3524,9 +3524,8 @@ nsDocument::EnsureCatalogStyleSheet(const char *aStyleSheetURI)
|
||||
nsIStyleSheet* sheet = GetCatalogStyleSheetAt(i);
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri = sheet->GetSheetURI();
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
sheet->GetSheetURI()->GetSpec(uriStr);
|
||||
if (uriStr.Equals(aStyleSheetURI))
|
||||
return;
|
||||
}
|
||||
@ -3893,26 +3892,47 @@ nsDocument::GetElementByIdInternal(nsIAtom* aID)
|
||||
return entry;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementById(const nsAString& aElementId,
|
||||
nsIDOMElement** aReturn)
|
||||
Element*
|
||||
nsDocument::GetElementById(const nsAString& aElementId, nsresult *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAtom> idAtom(do_GetAtom(aElementId));
|
||||
NS_ENSURE_TRUE(idAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!CheckGetElementByIdArg(idAtom))
|
||||
return NS_OK;
|
||||
if (!idAtom) {
|
||||
*aResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!CheckGetElementByIdArg(idAtom)) {
|
||||
*aResult = NS_OK;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIdentifierMapEntry *entry = GetElementByIdInternal(idAtom);
|
||||
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!entry) {
|
||||
*aResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
Element *e = entry->GetIdElement();
|
||||
if (!e)
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return CallQueryInterface(e, aReturn);
|
||||
*aResult = NS_OK;
|
||||
|
||||
return entry->GetIdElement();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementById(const nsAString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
nsresult rv;
|
||||
Element *content = GetElementById(aId, &rv);
|
||||
if (content) {
|
||||
rv = CallQueryInterface(content, aReturn);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
Element*
|
||||
@ -4364,25 +4384,38 @@ nsDocument::CreateEntityReference(const nsAString& aName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsContentList>
|
||||
nsDocument::GetElementsByTagName(const nsAString& aTagname)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
|
||||
if (IsHTML()) {
|
||||
nsAutoString tmp(aTagname);
|
||||
ToLowerCase(tmp); // HTML elements are lower case internally.
|
||||
nameAtom = do_GetAtom(tmp);
|
||||
}
|
||||
else {
|
||||
nameAtom = do_GetAtom(aTagname);
|
||||
}
|
||||
NS_ENSURE_TRUE(nameAtom, nsnull);
|
||||
|
||||
return NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementsByTagName(const nsAString& aTagname,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsContentList *list = NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown).get();
|
||||
nsRefPtr<nsContentList> list = GetElementsByTagName(aTagname);
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// transfer ref to aReturn
|
||||
*aReturn = list;
|
||||
*aReturn = list.forget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
already_AddRefed<nsContentList>
|
||||
nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNodeList** aReturn)
|
||||
const nsAString& aLocalName)
|
||||
{
|
||||
PRInt32 nameSpaceId = kNameSpaceID_Wildcard;
|
||||
|
||||
@ -4390,17 +4423,26 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||
nsresult rv =
|
||||
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
|
||||
nameSpaceId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(nameAtom, nsnull);
|
||||
|
||||
nsContentList *list = NS_GetContentList(this, nameAtom, nameSpaceId).get();
|
||||
return NS_GetContentList(this, nameAtom, nameSpaceId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
nsRefPtr<nsContentList> list = GetElementsByTagNameNS(aNamespaceURI,
|
||||
aLocalName);
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// transfer ref to aReturn
|
||||
*aReturn = list;
|
||||
*aReturn = list.forget().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -936,6 +936,15 @@ public:
|
||||
virtual void ResetScrolledToRefAlready();
|
||||
virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue);
|
||||
|
||||
already_AddRefed<nsContentList>
|
||||
GetElementsByTagName(const nsAString& aTagName);
|
||||
already_AddRefed<nsContentList>
|
||||
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName);
|
||||
|
||||
virtual mozilla::dom::Element *GetElementById(const nsAString& aElementId,
|
||||
nsresult *aResult);
|
||||
|
||||
protected:
|
||||
friend class nsNodeUtils;
|
||||
void RegisterNamedItems(nsIContent *aContent);
|
||||
|
@ -108,6 +108,7 @@
|
||||
#include "nsIView.h"
|
||||
|
||||
#include "nsIDOMChromeWindow.h"
|
||||
#include "nsInProcessTabChildGlobal.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "mozcontainer.h"
|
||||
@ -162,7 +163,20 @@ public:
|
||||
// we'd need to re-institute a fixed version of bug 98158.
|
||||
#define MAX_DEPTH_CONTENT_FRAMES 10
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(nsFrameLoader, mDocShell)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsFrameLoader)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameLoader)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocShell)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChildMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFrameLoader)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocShell)
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "nsFrameLoader::mMessageManager");
|
||||
cb.NoteXPCOMChild(static_cast<nsIContentFrameMessageManager*>(tmp->mMessageManager.get()));
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChildMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameLoader)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameLoader)
|
||||
@ -1037,6 +1051,38 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
mOwnerContent = otherContent;
|
||||
aOther->mOwnerContent = ourContent;
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
|
||||
nsRefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
|
||||
// Swap pointers in child message managers.
|
||||
if (mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
tabChild->SetOwner(otherContent);
|
||||
tabChild->SetChromeMessageManager(otherMessageManager);
|
||||
}
|
||||
if (aOther->mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* otherTabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aOther->mChildMessageManager.get());
|
||||
otherTabChild->SetOwner(ourContent);
|
||||
otherTabChild->SetChromeMessageManager(ourMessageManager);
|
||||
}
|
||||
// Swap and setup things in parent message managers.
|
||||
nsFrameMessageManager* ourParentManager = mMessageManager ?
|
||||
mMessageManager->GetParentManager() : nsnull;
|
||||
nsFrameMessageManager* otherParentManager = aOther->mMessageManager ?
|
||||
aOther->mMessageManager->GetParentManager() : nsnull;
|
||||
if (mMessageManager) {
|
||||
mMessageManager->Disconnect();
|
||||
mMessageManager->SetParentManager(otherParentManager);
|
||||
mMessageManager->SetCallbackData(aOther, PR_FALSE);
|
||||
}
|
||||
if (aOther->mMessageManager) {
|
||||
aOther->mMessageManager->Disconnect();
|
||||
aOther->mMessageManager->SetParentManager(ourParentManager);
|
||||
aOther->mMessageManager->SetCallbackData(this, PR_FALSE);
|
||||
}
|
||||
mMessageManager.swap(aOther->mMessageManager);
|
||||
|
||||
aFirstToSwap.swap(aSecondToSwap);
|
||||
|
||||
// Drop any cached content viewers in the two session histories.
|
||||
@ -1087,6 +1133,13 @@ nsFrameLoader::Destroy()
|
||||
}
|
||||
mDestroyCalled = PR_TRUE;
|
||||
|
||||
if (mMessageManager) {
|
||||
mMessageManager->Disconnect();
|
||||
}
|
||||
if (mChildMessageManager) {
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->Disconnect();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mOwnerContent) {
|
||||
doc = mOwnerContent->GetOwnerDoc();
|
||||
@ -1111,7 +1164,7 @@ nsFrameLoader::Destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Let our window know that we are gone
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
|
||||
if (win_private) {
|
||||
@ -1224,7 +1277,6 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
// Get the frame name and tell the docshell about it.
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString frameName;
|
||||
|
||||
PRInt32 namespaceID = mOwnerContent->GetNameSpaceID();
|
||||
@ -1289,6 +1341,8 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
mDocShell->SetChromeEventHandler(chromeEventHandler);
|
||||
}
|
||||
|
||||
EnsureMessageManager();
|
||||
|
||||
// This is nasty, this code (the do_GetInterface(mDocShell) below)
|
||||
// *must* come *after* the above call to
|
||||
// mDocShell->SetChromeEventHandler() for the global window to get
|
||||
@ -1708,50 +1762,104 @@ nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
bool LoadScript(void* aCallbackData, const nsAString& aURL)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
mozilla::dom::PIFrameEmbeddingParent* tabParent =
|
||||
static_cast<nsFrameLoader*>(aCallbackData)->GetChildProcess();
|
||||
if (tabParent) {
|
||||
return tabParent->SendloadRemoteScript(nsString(aURL));
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
nsFrameLoader* fl = static_cast<nsFrameLoader*>(aCallbackData);
|
||||
nsRefPtr<nsInProcessTabChildGlobal> tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(fl->GetTabChildGlobalAsEventTarget());
|
||||
if (tabChild) {
|
||||
tabChild->LoadFrameScript(aURL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class nsAsyncMessageToChild : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsAsyncMessageToChild(nsFrameLoader* aFrameLoader,
|
||||
const nsAString& aMessage, const nsAString& aJSON)
|
||||
: mFrameLoader(aFrameLoader), mMessage(aMessage), mJSON(aJSON) {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
if (tabChild && tabChild->GetInnerManager()) {
|
||||
tabChild->GetInnerManager()->
|
||||
ReceiveMessage(static_cast<nsPIDOMEventTarget*>(tabChild), mMessage,
|
||||
PR_FALSE, mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<nsFrameLoader> mFrameLoader;
|
||||
nsString mMessage;
|
||||
nsString mJSON;
|
||||
};
|
||||
|
||||
bool SendAsyncMessageToChild(void* aCallbackData,
|
||||
const nsAString& aMessage,
|
||||
const nsAString& aJSON)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
mozilla::dom::PIFrameEmbeddingParent* tabParent =
|
||||
static_cast<nsFrameLoader*>(aCallbackData)->GetChildProcess();
|
||||
if (tabParent) {
|
||||
return tabParent->SendsendAsyncMessageToChild(nsString(aMessage),
|
||||
nsString(aJSON));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
nsRefPtr<nsIRunnable> ev =
|
||||
new nsAsyncMessageToChild(static_cast<nsFrameLoader*>(aCallbackData),
|
||||
aMessage, aJSON);
|
||||
NS_DispatchToCurrentThread(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetMessageManager(nsIChromeFrameMessageManager** aManager)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
EnsureMessageManager();
|
||||
NS_IF_ADDREF(*aManager = mMessageManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::EnsureMessageManager()
|
||||
{
|
||||
NS_ENSURE_STATE(mOwnerContent);
|
||||
if (!mMessageManager) {
|
||||
nsresult rv;
|
||||
nsIScriptContext* sctx = mOwnerContent->GetContextForEventHandlers(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(sctx);
|
||||
JSContext* cx = static_cast<JSContext*>(sctx->GetNativeContext());
|
||||
NS_ENSURE_STATE(cx);
|
||||
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
|
||||
do_QueryInterface(mOwnerContent->GetOwnerDoc()->GetWindow());
|
||||
NS_ENSURE_STATE(chromeWindow);
|
||||
nsCOMPtr<nsIChromeFrameMessageManager> parentManager;
|
||||
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (mMessageManager) {
|
||||
if (ShouldUseRemoteProcess()) {
|
||||
mMessageManager->SetCallbackData(mRemoteWidgetCreated ? this : nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIScriptContext* sctx = mOwnerContent->GetContextForEventHandlers(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(sctx);
|
||||
JSContext* cx = static_cast<JSContext*>(sctx->GetNativeContext());
|
||||
NS_ENSURE_STATE(cx);
|
||||
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
|
||||
do_QueryInterface(mOwnerContent->GetOwnerDoc()->GetWindow());
|
||||
NS_ENSURE_STATE(chromeWindow);
|
||||
nsCOMPtr<nsIChromeFrameMessageManager> parentManager;
|
||||
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
if (ShouldUseRemoteProcess()) {
|
||||
mMessageManager = new nsFrameMessageManager(PR_TRUE,
|
||||
nsnull,
|
||||
SendAsyncMessageToChild,
|
||||
@ -1760,12 +1868,26 @@ nsFrameLoader::GetMessageManager(nsIChromeFrameMessageManager** aManager)
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
cx);
|
||||
NS_ENSURE_TRUE(mMessageManager, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else {
|
||||
mMessageManager->SetCallbackData(mRemoteWidgetCreated ? this : nsnull);
|
||||
}
|
||||
return CallQueryInterface(mMessageManager.get(), aManager);
|
||||
#else
|
||||
*aManager = nsnull;
|
||||
return NS_OK;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
||||
mMessageManager = new nsFrameMessageManager(PR_TRUE,
|
||||
nsnull,
|
||||
SendAsyncMessageToChild,
|
||||
LoadScript,
|
||||
this,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
cx);
|
||||
NS_ENSURE_TRUE(mMessageManager, NS_ERROR_OUT_OF_MEMORY);
|
||||
mChildMessageManager =
|
||||
new nsInProcessTabChildGlobal(mDocShell, mOwnerContent, mMessageManager);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPIDOMEventTarget*
|
||||
nsFrameLoader::GetTabChildGlobalAsEventTarget()
|
||||
{
|
||||
return static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class nsIContent;
|
||||
class nsIURI;
|
||||
class nsIFrameFrame;
|
||||
class nsIView;
|
||||
class nsIInProcessContentFrameMessageManager;
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
namespace mozilla {
|
||||
@ -112,7 +113,7 @@ public:
|
||||
nsresult ReallyStartLoading();
|
||||
void Finalize();
|
||||
nsIDocShell* GetExistingDocShell() { return mDocShell; }
|
||||
|
||||
nsPIDOMEventTarget* GetTabChildGlobalAsEventTarget();
|
||||
nsresult CreateStaticClone(nsIFrameLoader* aDest);
|
||||
|
||||
/**
|
||||
@ -160,7 +161,8 @@ private:
|
||||
* initialize mDocShell.
|
||||
*/
|
||||
nsresult MaybeCreateDocShell();
|
||||
void GetURL(nsString& aURL);
|
||||
nsresult EnsureMessageManager();
|
||||
NS_HIDDEN_(void) GetURL(nsString& aURL);
|
||||
|
||||
// Properly retrieves documentSize of any subdocument type.
|
||||
NS_HIDDEN_(nsIntSize) GetSubDocumentSize(const nsIFrame *aIFrame);
|
||||
@ -184,6 +186,11 @@ private:
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsCOMPtr<nsIURI> mURIToLoad;
|
||||
nsIContent *mOwnerContent; // WEAK
|
||||
public:
|
||||
// public because a callback needs these.
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
private:
|
||||
PRPackedBool mDepthTooGreat : 1;
|
||||
PRPackedBool mIsTopLevelContent : 1;
|
||||
PRPackedBool mDestroyCalled : 1;
|
||||
@ -204,7 +211,6 @@ private:
|
||||
QX11EmbedContainer* mRemoteSocket;
|
||||
#endif
|
||||
#endif
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -129,8 +129,10 @@ nsFrameMessageManager::LoadFrameScript(const nsAString& aURL,
|
||||
|
||||
PRInt32 len = mChildManagers.Count();
|
||||
for (PRInt32 i = 0; i < len; ++i) {
|
||||
static_cast<nsFrameMessageManager*>(mChildManagers[i])->LoadFrameScript(aURL,
|
||||
PR_FALSE);
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm = mChildManagers[i];
|
||||
if (mm) {
|
||||
static_cast<nsFrameMessageManager*>(mm.get())->LoadFrameScript(aURL, PR_FALSE);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -322,6 +324,20 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
JS_GetGlobalObject(mContext),
|
||||
aTarget, &targetv);
|
||||
|
||||
// To keep compatibility with e10s message manager,
|
||||
// define empty objects array.
|
||||
if (!aObjectsArray) {
|
||||
jsval* dest = nsnull;
|
||||
// Because we want JS messages to have always the same properties,
|
||||
// create array even if len == 0.
|
||||
aObjectsArray = js_NewArrayObjectWithCapacity(mContext, 0, &dest);
|
||||
if (!aObjectsArray) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
nsAutoGCRoot arrayGCRoot(&aObjectsArray, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
jsval json = JSVAL_NULL;
|
||||
nsAutoGCRoot root(&json, &rv);
|
||||
if (NS_SUCCEEDED(rv) && !aJSON.IsEmpty()) {
|
||||
@ -404,25 +420,30 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager)
|
||||
nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager,
|
||||
PRBool aLoadScripts)
|
||||
{
|
||||
mChildManagers.AppendObject(aManager);
|
||||
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
aManager->LoadFrameScript(mPendingScripts[i], PR_FALSE);
|
||||
if (aLoadScripts) {
|
||||
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
aManager->LoadFrameScript(mPendingScripts[i], PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameMessageManager::SetCallbackData(void* aData)
|
||||
nsFrameMessageManager::SetCallbackData(void* aData, PRBool aLoadScripts)
|
||||
{
|
||||
if (aData && mCallbackData != aData) {
|
||||
mCallbackData = aData;
|
||||
// First load global scripts by adding this to parent manager.
|
||||
if (mParentManager) {
|
||||
mParentManager->AddChildManager(this);
|
||||
mParentManager->AddChildManager(this, aLoadScripts);
|
||||
}
|
||||
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
LoadFrameScript(mPendingScripts[i], PR_FALSE);
|
||||
if (aLoadScripts) {
|
||||
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
LoadFrameScript(mPendingScripts[i], PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
mContext(aContext)
|
||||
{
|
||||
NS_ASSERTION(mContext, "Should have mContext!");
|
||||
NS_ASSERTION(aChrome || !aParentManager, "Should not set parent manager!");
|
||||
if (mParentManager && mCallbackData) {
|
||||
mParentManager->AddChildManager(this);
|
||||
}
|
||||
@ -106,18 +107,26 @@ public:
|
||||
PRBool aSync, const nsAString& aJSON,
|
||||
JSObject* aObjectsArray,
|
||||
nsTArray<nsString>* aJSONRetVal);
|
||||
void AddChildManager(nsFrameMessageManager* aManager);
|
||||
void AddChildManager(nsFrameMessageManager* aManager,
|
||||
PRBool aLoadScripts = PR_TRUE);
|
||||
void RemoveChildManager(nsFrameMessageManager* aManager)
|
||||
{
|
||||
mChildManagers.RemoveObject(aManager);
|
||||
}
|
||||
|
||||
void Disconnect(PRBool aRemoveFromParent = PR_TRUE);
|
||||
void SetCallbackData(void* aData);
|
||||
void SetCallbackData(void* aData, PRBool aLoadScripts = PR_TRUE);
|
||||
nsresult GetParamsForMessage(nsAString& aMessageName, nsAString& aJSON);
|
||||
nsresult SendAsyncMessageInternal(const nsAString& aMessage,
|
||||
const nsAString& aJSON);
|
||||
JSContext* GetJSContext() { return mContext; }
|
||||
nsFrameMessageManager* GetParentManager() { return mParentManager; }
|
||||
void SetParentManager(nsFrameMessageManager* aParent)
|
||||
{
|
||||
NS_ASSERTION(!mParentManager, "We have parent manager already!");
|
||||
NS_ASSERTION(mChrome, "Should not set parent manager!");
|
||||
mParentManager = aParent;
|
||||
}
|
||||
protected:
|
||||
nsTArray<nsMessageListenerInfo> mListeners;
|
||||
nsCOMArray<nsIContentFrameMessageManager> mChildManagers;
|
||||
|
@ -123,6 +123,7 @@ GK_ATOM(autobuffer, "autobuffer")
|
||||
#endif
|
||||
GK_ATOM(autocheck, "autocheck")
|
||||
GK_ATOM(autocomplete, "autocomplete")
|
||||
GK_ATOM(autofocus, "autofocus")
|
||||
#ifdef MOZ_MEDIA
|
||||
GK_ATOM(autoplay, "autoplay")
|
||||
#endif
|
||||
|
366
content/base/src/nsInProcessTabChildGlobal.cpp
Normal file
366
content/base/src/nsInProcessTabChildGlobal.cpp
Normal file
@ -0,0 +1,366 @@
|
||||
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsInProcessTabChildGlobal.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsFrameLoader.h"
|
||||
|
||||
bool SendSyncMessageToParent(void* aCallbackData,
|
||||
const nsAString& aMessage,
|
||||
const nsAString& aJSON,
|
||||
nsTArray<nsString>* aJSONRetVal)
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aCallbackData);
|
||||
PRInt32 count = tabChild->mASyncMessages.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIRunnable> async = tabChild->mASyncMessages.SafeObjectAt(i);
|
||||
async->Run();
|
||||
}
|
||||
if (tabChild->mChromeMessageManager) {
|
||||
tabChild->mChromeMessageManager->ReceiveMessage(tabChild->mOwner, aMessage, PR_TRUE,
|
||||
aJSON, nsnull, aJSONRetVal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class nsAsyncMessageToParent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsAsyncMessageToParent(nsInProcessTabChildGlobal* aTabChild,
|
||||
const nsAString& aMessage, const nsAString& aJSON)
|
||||
: mTabChild(aTabChild), mMessage(aMessage), mJSON(aJSON) {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
mTabChild->mASyncMessages.RemoveObject(this);
|
||||
if (mTabChild->mChromeMessageManager) {
|
||||
mTabChild->mChromeMessageManager->ReceiveMessage(mTabChild->mOwner, mMessage,
|
||||
PR_FALSE,
|
||||
mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<nsInProcessTabChildGlobal> mTabChild;
|
||||
nsString mMessage;
|
||||
nsString mJSON;
|
||||
};
|
||||
|
||||
bool SendAsyncMessageToParent(void* aCallbackData,
|
||||
const nsAString& aMessage,
|
||||
const nsAString& aJSON)
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aCallbackData);
|
||||
nsRefPtr<nsIRunnable> ev = new nsAsyncMessageToParent(tabChild, aMessage, aJSON);
|
||||
tabChild->mASyncMessages.AppendObject(ev);
|
||||
NS_DispatchToCurrentThread(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int tabChildC = 0;
|
||||
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
||||
nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome)
|
||||
: mCx(nsnull), mDocShell(aShell), mInitialized(PR_FALSE), mLoadingScript(PR_FALSE),
|
||||
mDelayedDisconnect(PR_FALSE), mOwner(aOwner), mChromeMessageManager(aChrome)
|
||||
{
|
||||
}
|
||||
|
||||
nsInProcessTabChildGlobal::~nsInProcessTabChildGlobal()
|
||||
{
|
||||
Disconnect();
|
||||
NS_ASSERTION(!mCx, "Couldn't release JSContext?!?");
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInProcessTabChildGlobal::Init()
|
||||
{
|
||||
nsresult rv = InitTabChildGlobal();
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
||||
"Couldn't initialize nsInProcessTabChildGlobal");
|
||||
mMessageManager = new nsFrameMessageManager(PR_FALSE,
|
||||
SendSyncMessageToParent,
|
||||
SendAsyncMessageToParent,
|
||||
nsnull,
|
||||
this,
|
||||
nsnull,
|
||||
mCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsInProcessTabChildGlobal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobal)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mGlobal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsInProcessTabChildGlobal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFrameMessageManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptContextPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetContent(nsIDOMWindow** aContent)
|
||||
{
|
||||
*aContent = nsnull;
|
||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
|
||||
window.swap(*aContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
NS_IF_ADDREF(*aDocShell = mDocShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsInProcessTabChildGlobal::Disconnect()
|
||||
{
|
||||
mDocShell = nsnull;
|
||||
mOwner = nsnull;
|
||||
mChromeMessageManager = nsnull;
|
||||
if (mMessageManager) {
|
||||
static_cast<nsFrameMessageManager*>(mMessageManager.get())->Disconnect();
|
||||
mMessageManager = nsnull;
|
||||
}
|
||||
if (!mLoadingScript) {
|
||||
if (mCx) {
|
||||
JS_DestroyContext(mCx);
|
||||
mCx = nsnull;
|
||||
}
|
||||
} else {
|
||||
mDelayedDisconnect = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIContent *)
|
||||
nsInProcessTabChildGlobal::GetOwnerContent()
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
aVisitor.mCanHandle = PR_TRUE;
|
||||
aVisitor.mParentTarget = mOwner;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mOwner) {
|
||||
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
|
||||
nsRefPtr<nsFrameLoader> fl = owner->GetFrameLoader();
|
||||
if (fl) {
|
||||
NS_ASSERTION(this == fl->GetTabChildGlobalAsEventTarget(),
|
||||
"Wrong event target!");
|
||||
NS_ASSERTION(fl->mMessageManager == mChromeMessageManager,
|
||||
"Wrong message manager!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInProcessTabChildGlobal::InitTabChildGlobal()
|
||||
{
|
||||
nsCOMPtr<nsIJSRuntimeService> runtimeSvc =
|
||||
do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
||||
NS_ENSURE_STATE(runtimeSvc);
|
||||
|
||||
JSRuntime* rt = nsnull;
|
||||
runtimeSvc->GetRuntime(&rt);
|
||||
NS_ENSURE_STATE(rt);
|
||||
|
||||
JSContext* cx = JS_NewContext(rt, 8192);
|
||||
NS_ENSURE_STATE(cx);
|
||||
|
||||
mCx = cx;
|
||||
|
||||
nsContentUtils::XPConnect()->SetSecurityManagerForJSContext(cx, nsContentUtils::GetSecurityManager(), 0);
|
||||
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
||||
|
||||
PRUint32 stackDummy;
|
||||
jsuword stackLimit, currentStackAddr = (jsuword)&stackDummy;
|
||||
|
||||
// 256k stack space.
|
||||
const jsuword kStackSize = 0x40000;
|
||||
|
||||
#if JS_STACK_GROWTH_DIRECTION < 0
|
||||
stackLimit = (currentStackAddr > kStackSize) ?
|
||||
currentStackAddr - kStackSize :
|
||||
0;
|
||||
#else
|
||||
stackLimit = (currentStackAddr + kStackSize > currentStackAddr) ?
|
||||
currentStackAddr + kStackSize :
|
||||
(jsuword) -1;
|
||||
#endif
|
||||
|
||||
JS_SetThreadStackLimit(cx, stackLimit);
|
||||
JS_SetScriptStackQuota(cx, 100*1024*1024);
|
||||
|
||||
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_JIT | JSOPTION_ANONFUNFIX | JSOPTION_PRIVATE_IS_NSISUPPORTS);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 1 * 1024 * 1024);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
const PRUint32 flags = nsIXPConnect::INIT_JS_STANDARD_CLASSES |
|
||||
/*nsIXPConnect::OMIT_COMPONENTS_OBJECT ? |*/
|
||||
nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT;
|
||||
|
||||
nsISupports* scopeSupports =
|
||||
NS_ISUPPORTS_CAST(nsPIDOMEventTarget*, this);
|
||||
JS_SetContextPrivate(cx, scopeSupports);
|
||||
|
||||
nsresult rv =
|
||||
xpc->InitClassesWithNewWrappedGlobal(cx, scopeSupports,
|
||||
NS_GET_IID(nsISupports), flags,
|
||||
getter_AddRefs(mGlobal));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
JSObject* global = nsnull;
|
||||
rv = mGlobal->GetJSObject(&global);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
JS_SetGlobalObject(cx, global);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
mInitialized = PR_TRUE;
|
||||
Init();
|
||||
}
|
||||
if (!mGlobal || !mCx) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString url = NS_ConvertUTF16toUTF8(aURL);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), url);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
NS_NewChannel(getter_AddRefs(channel), uri);
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> input;
|
||||
channel->Open(getter_AddRefs(input));
|
||||
nsString dataString;
|
||||
if (input) {
|
||||
const PRUint32 bufferSize = 256;
|
||||
char buffer[bufferSize];
|
||||
nsCString data;
|
||||
PRUint32 avail = 0;
|
||||
input->Available(&avail);
|
||||
PRUint32 read = 0;
|
||||
if (avail) {
|
||||
while (NS_SUCCEEDED(input->Read(buffer, bufferSize, &read)) && read) {
|
||||
data.Append(buffer, read);
|
||||
read = 0;
|
||||
}
|
||||
}
|
||||
nsScriptLoader::ConvertToUTF16(channel, (PRUint8*)data.get(), data.Length(),
|
||||
EmptyString(), nsnull, dataString);
|
||||
}
|
||||
|
||||
if (!dataString.IsEmpty()) {
|
||||
JSAutoRequest ar(mCx);
|
||||
jsval retval;
|
||||
JSObject* global = nsnull;
|
||||
mGlobal->GetJSObject(&global);
|
||||
if (!global) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSPrincipals* jsprin = nsnull;
|
||||
mPrincipal->GetJSPrincipals(mCx, &jsprin);
|
||||
nsContentUtils::XPConnect()->FlagSystemFilenamePrefix(url.get(), PR_TRUE);
|
||||
nsContentUtils::ThreadJSContextStack()->Push(mCx);
|
||||
PRBool tmp = mLoadingScript;
|
||||
mLoadingScript = PR_TRUE;
|
||||
JS_EvaluateUCScriptForPrincipals(mCx, global, jsprin,
|
||||
(jschar*)dataString.get(),
|
||||
dataString.Length(),
|
||||
url.get(), 1, &retval);
|
||||
//XXX Argh, JSPrincipals are manually refcounted!
|
||||
JSPRINCIPALS_DROP(mCx, jsprin);
|
||||
mLoadingScript = tmp;
|
||||
JSContext* unused;
|
||||
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
||||
}
|
||||
if (!mLoadingScript && mDelayedDisconnect) {
|
||||
mDelayedDisconnect = PR_FALSE;
|
||||
Disconnect();
|
||||
}
|
||||
}
|
142
content/base/src/nsInProcessTabChildGlobal.h
Normal file
142
content/base/src/nsInProcessTabChildGlobal.h
Normal file
@ -0,0 +1,142 @@
|
||||
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsInProcessTabChildGlobal_h
|
||||
#define nsInProcessTabChildGlobal_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
|
||||
public nsIInProcessContentFrameMessageManager,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsIScriptContextPrincipal
|
||||
{
|
||||
public:
|
||||
nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome);
|
||||
virtual ~nsInProcessTabChildGlobal();
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsInProcessTabChildGlobal,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
|
||||
NS_IMETHOD SendSyncMessage()
|
||||
{
|
||||
return mMessageManager ? mMessageManager->SendSyncMessage()
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(nsIDOMWindow** aContent);
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
|
||||
NS_IMETHOD Dump(const nsAString& aStr)
|
||||
{
|
||||
return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
|
||||
}
|
||||
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, PR_FALSE, 1);
|
||||
}
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture, PRBool aWantsUntrusted,
|
||||
PRUint8 optional_argc)
|
||||
{
|
||||
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
|
||||
virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; }
|
||||
virtual JSContext* GetJSContextForEventHandlers() { return mCx; }
|
||||
virtual nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
||||
void LoadFrameScript(const nsAString& aURL);
|
||||
void Disconnect();
|
||||
void SendMessageToParent(const nsString& aMessage, PRBool aSync,
|
||||
const nsString& aJSON,
|
||||
nsTArray<nsString>* aJSONRetVal);
|
||||
nsFrameMessageManager* GetInnerManager()
|
||||
{
|
||||
return static_cast<nsFrameMessageManager*>(mMessageManager.get());
|
||||
}
|
||||
|
||||
void SetOwner(nsIContent* aOwner) { mOwner = aOwner; }
|
||||
nsFrameMessageManager* GetChromeMessageManager()
|
||||
{
|
||||
return mChromeMessageManager;
|
||||
}
|
||||
void SetChromeMessageManager(nsFrameMessageManager* aParent)
|
||||
{
|
||||
mChromeMessageManager = aParent;
|
||||
}
|
||||
protected:
|
||||
nsresult Init();
|
||||
nsresult InitTabChildGlobal();
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
JSContext* mCx;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobal;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
PRPackedBool mInitialized;
|
||||
PRPackedBool mLoadingScript;
|
||||
PRPackedBool mDelayedDisconnect;
|
||||
public:
|
||||
nsIContent* mOwner;
|
||||
nsFrameMessageManager* mChromeMessageManager;
|
||||
nsCOMArray<nsIRunnable> mASyncMessages;
|
||||
};
|
||||
|
||||
#endif
|
@ -500,9 +500,6 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
// We're done with the classifier
|
||||
mClassifier = nsnull;
|
||||
|
||||
AutoNotifier notifier(this, PR_TRUE);
|
||||
|
||||
if (!IsSuccessfulRequest(aRequest)) {
|
||||
@ -1039,10 +1036,6 @@ nsObjectLoadingContent::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
if (mClassifier) {
|
||||
mClassifier->OnRedirect(aOldChannel, aNewChannel);
|
||||
}
|
||||
|
||||
mChannel = aNewChannel;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1210,11 +1203,6 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
||||
if (mChannel) {
|
||||
LOG(("OBJLC [%p]: Cancelling existing load\n", this));
|
||||
|
||||
if (mClassifier) {
|
||||
mClassifier->Cancel();
|
||||
mClassifier = nsnull;
|
||||
}
|
||||
|
||||
// These three statements are carefully ordered:
|
||||
// - onStopRequest should get a channel whose status is the same as the
|
||||
// status argument
|
||||
@ -1442,7 +1430,8 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
||||
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_OBJECT);
|
||||
}
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), aURI, nsnull, group, this,
|
||||
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS,
|
||||
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
|
||||
nsIChannel::LOAD_CLASSIFY_URI,
|
||||
channelPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1483,12 +1472,6 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG(("OBJLC [%p]: Channel opened.\n", this));
|
||||
|
||||
rv = CheckClassifier(chan);
|
||||
if (NS_FAILED(rv)) {
|
||||
chan->Cancel(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mChannel = chan;
|
||||
mType = eType_Loading;
|
||||
}
|
||||
@ -1930,22 +1913,6 @@ nsObjectLoadingContent::Instantiate(nsIObjectFrame* aFrame,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsObjectLoadingContent::CheckClassifier(nsIChannel *aChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannelClassifier> classifier =
|
||||
do_CreateInstance(NS_CHANNELCLASSIFIER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = classifier->Start(aChannel, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mClassifier = classifier;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ PluginSupportState
|
||||
nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
|
||||
const nsCString& aContentType)
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIChannelClassifier.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsAsyncInstantiateEvent;
|
||||
@ -328,13 +327,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
*/
|
||||
nsresult Instantiate(nsIObjectFrame* aFrame, const nsACString& aMIMEType, nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Check the channel load against the URI classifier service (if it
|
||||
* exists). The channel will be suspended until the classification is
|
||||
* complete.
|
||||
*/
|
||||
nsresult CheckClassifier(nsIChannel *aChannel);
|
||||
|
||||
/**
|
||||
* Get the plugin support state for the given content node and MIME type.
|
||||
* This is used for purposes of determining whether to fire PluginNotFound
|
||||
@ -394,11 +386,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
// The data we were last asked to load
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
|
||||
/**
|
||||
* Suspends/resumes channels based on the URI classifier.
|
||||
*/
|
||||
nsCOMPtr<nsIChannelClassifier> mClassifier;
|
||||
|
||||
/**
|
||||
* Type of the currently-loaded content.
|
||||
*/
|
||||
|
@ -69,13 +69,14 @@
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIChannelClassifier.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "prlog.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsChannelPolicy.h"
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gCspPRLog;
|
||||
#endif
|
||||
@ -303,8 +304,8 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType)
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
aRequest->mURI, nsnull, loadGroup,
|
||||
prompter, nsIRequest::LOAD_NORMAL,
|
||||
aRequest->mURI, nsnull, loadGroup, prompter,
|
||||
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI,
|
||||
channelPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -323,17 +324,6 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType)
|
||||
rv = channel->AsyncOpen(loader, aRequest);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Check the load against the URI classifier
|
||||
nsCOMPtr<nsIChannelClassifier> classifier =
|
||||
do_CreateInstance(NS_CHANNELCLASSIFIER_CONTRACTID);
|
||||
if (classifier) {
|
||||
rv = classifier->Start(channel, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
channel->Cancel(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -656,6 +646,8 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
|
||||
nsAFlatString* script;
|
||||
nsAutoString textData;
|
||||
|
||||
NS_TIME_FUNCTION;
|
||||
|
||||
// If there's no script text, we try to get it from the element
|
||||
if (aRequest->mIsInline) {
|
||||
// XXX This is inefficient - GetText makes multiple
|
||||
|
@ -248,7 +248,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
nsCOMPtr<nsIURI> uri = GetStyleSheetURL(&isInline);
|
||||
|
||||
if (!aForceUpdate && mStyleSheet && !isInline && uri) {
|
||||
nsCOMPtr<nsIURI> oldURI = mStyleSheet->GetSheetURI();
|
||||
nsIURI* oldURI = mStyleSheet->GetSheetURI();
|
||||
if (oldURI) {
|
||||
PRBool equal;
|
||||
nsresult rv = oldURI->Equals(uri, &equal);
|
||||
|
@ -58,6 +58,8 @@ _CHROME_FILES = \
|
||||
bug514705_helper.xul \
|
||||
test_title.xul \
|
||||
title_window.xul \
|
||||
test_bug549682.xul \
|
||||
file_bug549682.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
45
content/base/test/chrome/file_bug549682.xul
Normal file
45
content/base/test/chrome/file_bug549682.xul
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
||||
-->
|
||||
<window title="Mozilla Bug 549682"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="run()">
|
||||
<label value="Mozilla Bug 549682"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
var didRunAsync = false;
|
||||
|
||||
function asyncL(m) {
|
||||
didRunAsync = true;
|
||||
opener.wrappedJSObject.is(m.name, "async", "Wrong message!");
|
||||
opener.wrappedJSObject.is(m.json.data, 1234, "Wrong data!");
|
||||
}
|
||||
|
||||
function syncL(m) {
|
||||
opener.wrappedJSObject.is(m.name, "sync", "Wrong message!");
|
||||
opener.wrappedJSObject.is(m.json.data, 1234, "Wrong data!");
|
||||
opener.wrappedJSObject.ok(didRunAsync, "Should have run async!");
|
||||
opener.setTimeout("done()", 0);
|
||||
var i = document.getElementById("ifr");
|
||||
i.parentNode.removeChild(i); // This is a crash test!
|
||||
window.close();
|
||||
}
|
||||
|
||||
function loadScript() {
|
||||
// Async should be prosessed first!
|
||||
messageManager.loadFrameScript("data:,sendAsyncMessage('async', { data: 1234 }); sendSyncMessage('sync', { data: 1234 });", true);
|
||||
}
|
||||
|
||||
function run() {
|
||||
messageManager.addMessageListener("async", asyncL);
|
||||
messageManager.addMessageListener("sync", syncL);
|
||||
setTimeout(loadScript, 0);
|
||||
}
|
||||
|
||||
]]></script>
|
||||
<browser type="content" src="about:blank" id="ifr"/>
|
||||
</window>
|
35
content/base/test/chrome/test_bug549682.xul
Normal file
35
content/base/test/chrome/test_bug549682.xul
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
||||
-->
|
||||
<window title="Mozilla Bug 549682"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=549682"
|
||||
target="_blank">Mozilla Bug 549682</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
/** Test for Bug 549682 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
window.open("file_bug549682.xul", "", "chrome");
|
||||
});
|
||||
]]></script>
|
||||
</window>
|
@ -13,7 +13,7 @@ var page = "/tests/content/base/test/file_csp_redirects_page.sjs";
|
||||
|
||||
var tests = { "font-src": thisSite+page+"?testid=font-src&csp=1",
|
||||
"frame-src": thisSite+page+"?testid=frame-src&csp=1",
|
||||
// "img-src": thisSite+page+"?testid=img-src&csp=1",
|
||||
"img-src": thisSite+page+"?testid=img-src&csp=1",
|
||||
"media-src": thisSite+page+"?testid=media-src&csp=1",
|
||||
"object-src": thisSite+page+"?testid=object-src&csp=1",
|
||||
"script-src": thisSite+page+"?testid=script-src&csp=1",
|
||||
|
@ -83,8 +83,8 @@ var testExpectedResults = { "font-src": true,
|
||||
"font-src-redir": false,
|
||||
"frame-src": true,
|
||||
"frame-src-redir": false,
|
||||
// "img-src": true,
|
||||
// "img-src-redir": false,
|
||||
"img-src": true,
|
||||
"img-src-redir": false,
|
||||
"media-src": true,
|
||||
"media-src-redir": false,
|
||||
"object-src": true,
|
||||
|
@ -49,8 +49,7 @@ EXPORTS_NAMESPACES = mozilla/ipc
|
||||
|
||||
EXPORTS = \
|
||||
nsICanvasRenderingContextInternal.h \
|
||||
nsICanvasElement.h \
|
||||
WebGLArray.h \
|
||||
nsICanvasElementExternal.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_mozilla/ipc = \
|
||||
|
@ -35,8 +35,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsICanvasElement_h___
|
||||
#define nsICanvasElement_h___
|
||||
#ifndef nsICanvasElementExternal_h___
|
||||
#define nsICanvasElementExternal_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "gfxPattern.h"
|
||||
@ -45,68 +45,41 @@ class gfxContext;
|
||||
class nsIFrame;
|
||||
struct gfxRect;
|
||||
|
||||
// {D31B3CCF-DDA3-49a8-AEF6-B95AF8E09159}
|
||||
#define NS_ICANVASELEMENT_IID \
|
||||
{ 0xd31b3ccf, 0xdda3, 0x49a8, { 0xae, 0xf6, 0xb9, 0x5a, 0xf8, 0xe0, 0x91, 0x59 } }
|
||||
#define NS_ICANVASELEMENTEXTERNAL_IID \
|
||||
{ 0x51870f54, 0x6c4c, 0x469a, {0xad, 0x46, 0xf0, 0xa9, 0x8e, 0x32, 0xa7, 0xe2 } }
|
||||
|
||||
class nsIRenderingContext;
|
||||
|
||||
class nsICanvasRenderingContextInternal;
|
||||
|
||||
struct _cairo_surface;
|
||||
|
||||
class nsICanvasElement : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASELEMENT_IID)
|
||||
/*
|
||||
* This interface contains methods that are needed outside of the content/layout
|
||||
* modules, specifically widget. It should eventually go away when we support
|
||||
* libxul builds, and nsHTMLCanvasElement be used directly.
|
||||
*
|
||||
* Code internal to content/layout should /never/ use this interface; if the
|
||||
* same functionality is needed in both places, two separate methods should be
|
||||
* used.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ask the canvas Element to return the primary frame, if any
|
||||
*/
|
||||
NS_IMETHOD GetPrimaryCanvasFrame (nsIFrame **aFrame) = 0;
|
||||
class nsICanvasElementExternal : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASELEMENTEXTERNAL_IID)
|
||||
|
||||
/**
|
||||
* Get the size in pixels of this canvas element
|
||||
*/
|
||||
NS_IMETHOD GetSize (PRUint32 *width, PRUint32 *height) = 0;
|
||||
NS_IMETHOD_(nsIntSize) GetSizeExternal() = 0;
|
||||
|
||||
/*
|
||||
* Ask the canvas element to tell the contexts to render themselves
|
||||
* to the given gfxContext at the origin of its coordinate space.
|
||||
*/
|
||||
NS_IMETHOD RenderContexts (gfxContext *ctx, gfxPattern::GraphicsFilter aFilter) = 0;
|
||||
|
||||
/**
|
||||
* Determine whether the canvas is write-only.
|
||||
*/
|
||||
virtual PRBool IsWriteOnly() = 0;
|
||||
|
||||
/**
|
||||
* Force the canvas to be write-only.
|
||||
*/
|
||||
virtual void SetWriteOnly() = 0;
|
||||
|
||||
/*
|
||||
* Ask the canvas frame to invalidate itself
|
||||
*/
|
||||
NS_IMETHOD InvalidateFrame () = 0;
|
||||
|
||||
/*
|
||||
* Ask the canvas frame to invalidate a portion of the frame; damageRect
|
||||
* is relative to the origin of the canvas frame in CSS pixels.
|
||||
*/
|
||||
NS_IMETHOD InvalidateFrameSubrect (const gfxRect& damageRect) = 0;
|
||||
|
||||
/*
|
||||
* Get the number of contexts in this canvas, and request a context at
|
||||
* an index.
|
||||
*/
|
||||
virtual PRInt32 CountContexts () = 0;
|
||||
virtual nsICanvasRenderingContextInternal *GetContextAtIndex (PRInt32 index) = 0;
|
||||
|
||||
virtual PRBool GetIsOpaque() = 0;
|
||||
|
||||
NS_IMETHOD RenderContextsExternal(gfxContext *ctx,
|
||||
gfxPattern::GraphicsFilter aFilter) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasElement, NS_ICANVASELEMENT_IID)
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasElementExternal, NS_ICANVASELEMENTEXTERNAL_IID)
|
||||
|
||||
#endif /* nsICanvasElement_h___ */
|
||||
#endif /* nsICanvasElementExternal_h___ */
|
@ -39,19 +39,24 @@
|
||||
#define nsICanvasRenderingContextInternal_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsICanvasElement.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "gfxPattern.h"
|
||||
|
||||
// {3c4632ab-8443-4082-a8a310e7cfba4c74}
|
||||
// {b96168fd-6f13-4ca7-b820-e96f22e71fe5}
|
||||
#define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
|
||||
{ 0x3c4632ab, 0x8443, 0x4082, { 0xa8, 0xa3, 0x10, 0xe7, 0xcf, 0xba, 0x4c, 0x74 } }
|
||||
{ 0xb96168fd, 0x6f13, 0x4ca7, \
|
||||
{ 0xb8, 0x20, 0xe9, 0x6f, 0x22, 0xe7, 0x1f, 0xe5 } }
|
||||
|
||||
class nsHTMLCanvasElement;
|
||||
class gfxContext;
|
||||
class gfxASurface;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
class CanvasLayer;
|
||||
class LayerManager;
|
||||
}
|
||||
namespace ipc {
|
||||
class Shmem;
|
||||
}
|
||||
@ -59,11 +64,14 @@ class Shmem;
|
||||
|
||||
class nsICanvasRenderingContextInternal : public nsISupports {
|
||||
public:
|
||||
typedef mozilla::layers::CanvasLayer CanvasLayer;
|
||||
typedef mozilla::layers::LayerManager LayerManager;
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
|
||||
|
||||
// This method should NOT hold a ref to aParentCanvas; it will be called
|
||||
// with nsnull when the element is going away.
|
||||
NS_IMETHOD SetCanvasElement(nsICanvasElement* aParentCanvas) = 0;
|
||||
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas) = 0;
|
||||
|
||||
// Sets the dimensions of the canvas, in pixels. Called
|
||||
// whenever the size of the element changes.
|
||||
@ -94,6 +102,12 @@ public:
|
||||
// defaults to false (not opaque).
|
||||
NS_IMETHOD SetIsOpaque(PRBool isOpaque) = 0;
|
||||
|
||||
// Return the CanvasLayer for this context, creating
|
||||
// one for the given layer manager if not available.
|
||||
virtual already_AddRefed<CanvasLayer> GetCanvasLayer(LayerManager *mgr) = 0;
|
||||
|
||||
virtual void MarkContextClean() = 0;
|
||||
|
||||
// Redraw the dirty rectangle of this canvas.
|
||||
NS_IMETHOD Redraw(const gfxRect &dirty) = 0;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user