Merge mozilla-central to tracemonkey.

This commit is contained in:
Robert Sayre 2010-05-24 09:05:39 -07:00
commit 2a3fb0fb81
679 changed files with 19535 additions and 16168 deletions

View File

@ -943,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,

View File

@ -50,6 +50,7 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
nsAccessNode.cpp \
nsAccEvent.cpp \
nsAccIterator.cpp \
nsARIAGridAccessible.cpp \
nsARIAMap.cpp \
nsDocAccessible.cpp \

View File

@ -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;

View File

@ -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);
/**

View 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)
{
}

View 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

View File

@ -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;
}

View File

@ -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
/**

View File

@ -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();

View File

@ -41,6 +41,7 @@
#include "nsIXBLAccessible.h"
#include "nsAccIterator.h"
#include "nsAccUtils.h"
#include "nsARIAMap.h"
#include "nsDocAccessible.h"
@ -2466,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)
{
@ -2508,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);
@ -2526,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);
@ -2544,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;
}
@ -2604,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;
}

View File

@ -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

View File

@ -1803,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)

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -1102,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;
@ -1112,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.

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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 =

View File

@ -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 \

View File

@ -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.

View File

@ -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>

View File

@ -75,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;
@ -263,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;
}

View File

@ -31,9 +31,8 @@
setOverLink: function (link, b) {
}
};
var gFindBar = {
hidden: true
};
gFindBarInitialized = false;
////////////////////////////////////////////////////////////////////////////
// Invoker implementation.

View 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));
}
}

View File

@ -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>

View File

@ -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">

View File

@ -12,15 +12,15 @@
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Communicator client code, released
# March 31, 1998.
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# 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"),
@ -40,10 +40,33 @@ DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/table
include $(DEPTH)/config/autoconf.mk
DIRS = idl src
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)

View File

@ -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");

View File

@ -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"

View File

@ -181,7 +181,7 @@ pref("browser.shell.checkDefaultBrowser", true);
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last visited page, 3 = resume previous browser session
// The behavior of option 3 is detailed at: http://wiki.mozilla.org/Session_Restore
pref("browser.startup.page", 1);
pref("browser.startup.homepage", "resource:/browserconfig.properties");
pref("browser.startup.homepage", "chrome://branding/locale/browserconfig.properties");
pref("browser.enable_automatic_image_resizing", true);
pref("browser.chrome.site_icons", true);

View File

@ -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;"

View File

@ -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)
@ -4241,7 +4264,7 @@ var XULBrowserWindow = {
FullZoom.onLocationChange(gBrowser.currentURI, true);
var nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
var loadingDone = aStateFlags & nsIWebProgressListener.STATE_STOP;
// use a pseudo-object instead of a (potentially non-existing) channel for getting
// use a pseudo-object instead of a (potentially nonexistent) channel for getting
// a correct error message - and make sure that the UI is always either in
// loading (STATE_START) or done (STATE_STOP) mode
this.onStateChange(
@ -4752,7 +4775,7 @@ var gHomeButton = {
// use this if we can't find the pref
if (!url) {
var SBS = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
var configBundle = SBS.createBundle("resource:/browserconfig.properties");
var configBundle = SBS.createBundle("chrome://branding/locale/browserconfig.properties");
url = configBundle.GetStringFromName(this.prefDomain);
}
@ -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;
}
}
};

View File

@ -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"

View File

@ -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");
});

View File

@ -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;"

View File

@ -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"].

View File

@ -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);

View File

@ -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,

View File

@ -45,11 +45,3 @@ include $(DEPTH)/config/autoconf.mk
DEFINES += -DAB_CD=$(AB_CD) -DMOZ_DISTRIBUTION_ID_UNQUOTED=$(MOZ_DISTRIBUTION_ID)
include $(topsrcdir)/config/rules.mk
libs::
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
$(srcdir)/browserconfig.properties > $(FINAL_TARGET)/browserconfig.properties
install::
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
$(srcdir)/browserconfig.properties > $(DESTDIR)$(mozappdir)/browserconfig.properties

View File

@ -5,3 +5,4 @@
# Nightly branding only exists in en-US
locale/branding/brand.dtd (en-US/brand.dtd)
* locale/branding/brand.properties (en-US/brand.properties)
* locale/branding/browserconfig.properties (browserconfig.properties)

View File

@ -45,11 +45,3 @@ include $(DEPTH)/config/autoconf.mk
DEFINES += -DAB_CD=$(AB_CD) -DMOZ_DISTRIBUTION_ID_UNQUOTED=$(MOZ_DISTRIBUTION_ID)
include $(topsrcdir)/config/rules.mk
libs::
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
$(srcdir)/browserconfig.properties > $(FINAL_TARGET)/browserconfig.properties
install::
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
$(srcdir)/browserconfig.properties > $(DESTDIR)$(mozappdir)/browserconfig.properties

View File

@ -5,3 +5,4 @@
# Unofficial branding only exists in en-US
locale/branding/brand.dtd (en-US/brand.dtd)
* locale/branding/brand.properties (en-US/brand.properties)
* locale/branding/browserconfig.properties (browserconfig.properties)

View File

@ -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}" ] }
]
}

View File

@ -109,7 +109,7 @@ var tests = [
},
{
desc: "JSON restore: nonexisting file should fail",
desc: "JSON restore: nonexistent file should fail",
currTopic: NSIOBSERVER_TOPIC_BEGIN,
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_JSON,
@ -163,7 +163,7 @@ var tests = [
},
{
desc: "HTML restore: nonexisting file should fail",
desc: "HTML restore: nonexistent file should fail",
currTopic: NSIOBSERVER_TOPIC_BEGIN,
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_HTML,
@ -217,7 +217,7 @@ var tests = [
},
{
desc: "HTML initial restore: nonexisting file should fail",
desc: "HTML initial restore: nonexistent file should fail",
currTopic: NSIOBSERVER_TOPIC_BEGIN,
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_HTML_INIT,
@ -279,7 +279,7 @@ var tests = [
},
{
desc: "HTML restore into folder: nonexisting file should fail",
desc: "HTML restore into folder: nonexistent file should fail",
currTopic: NSIOBSERVER_TOPIC_BEGIN,
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_HTML,

View File

@ -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)

View File

@ -8,11 +8,11 @@ var testdata = {
};
function test() {
// test getting non-existing values
// test getting nonexistent values
var itemValue = Application.prefs.getValue(testdata.missing, "default");
is(itemValue, "default", "Check 'Application.prefs.getValue' for non-existing item");
is(itemValue, "default", "Check 'Application.prefs.getValue' for nonexistent item");
is(Application.prefs.get(testdata.missing), null, "Check 'Application.prefs.get' for non-existing item");
is(Application.prefs.get(testdata.missing), null, "Check 'Application.prefs.get' for nonexistent item");
// test setting and getting a value
Application.prefs.setValue(testdata.dummy, "dummy");

View File

@ -1,14 +1,14 @@
function test() {
// test for existence of values
var hasItem = Application.storage.has("fuel-test-missing");
is(hasItem, false, "Check 'Application.storage.has' for non-existing item");
is(hasItem, false, "Check 'Application.storage.has' for nonexistent item");
Application.storage.set("fuel-test", "dummy");
hasItem = Application.storage.has("fuel-test");
is(hasItem, true, "Check 'Application.storage.has' for existing item");
// test getting non-existing and existing values
// test getting nonexistent and existing values
var itemValue = Application.storage.get("fuel-test-missing", "default");
is(itemValue, "default", "Check 'Application.storage.get' for non-existing item");
is(itemValue, "default", "Check 'Application.storage.get' for nonexistent item");
itemValue = Application.storage.get("fuel-test", "default");
is(itemValue, "dummy", "Check 'Application.storage.get' for existing item");

View File

@ -22,11 +22,9 @@
@BINPATH@/chrome/@AB_CD@.jar
@BINPATH@/chrome/@AB_CD@.manifest
@BINPATH@/@PREF_DIR@/firefox-l10n.js
@BINPATH@/browserconfig.properties
@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 +371,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.

View File

@ -10,6 +10,7 @@
@DLL_PREFIX@xpistub@DLL_SUFFIX@
@DLL_PREFIX@zlib@DLL_SUFFIX@
LICENSE
browserconfig.properties
chrome.manifest
chrome/US.jar
chrome/app-chrome.manifest

View File

@ -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">

View File

@ -2,7 +2,6 @@
%include browser.css
%undef WINSTRIPE_AERO
%if 0
@media all and (-moz-windows-compositor) {
#main-window:not(:-moz-lwtheme) {
-moz-appearance: -moz-win-glass;
@ -73,7 +72,6 @@
text-shadow: white -1px -1px .5em, white -1px 1px .5em, white 1px 1px .5em, white 1px -1px .5em;
}
}
%endif
@media not all and (-moz-windows-compositor) {
#print-preview-toolbar:not(:-moz-lwtheme) {

View File

@ -2135,15 +2135,15 @@ nsScriptSecurityManager::GetPrincipalFromContext(JSContext *cx,
{
*result = nsnull;
nsIScriptContext *scriptContext = GetScriptContext(cx);
nsIScriptContextPrincipal* scp =
GetScriptContextPrincipalFromJSContext(cx);
if (!scriptContext)
if (!scp)
{
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIScriptObjectPrincipal> globalData =
do_QueryInterface(scriptContext->GetGlobalObject());
nsIScriptObjectPrincipal* globalData = scp->GetObjectPrincipal();
if (globalData)
NS_IF_ADDREF(*result = globalData->GetPrincipal());
@ -2328,11 +2328,11 @@ nsScriptSecurityManager::GetPrincipalAndFrame(JSContext *cx,
return targetPrincipal;
}
nsIScriptContext *scriptContext = GetScriptContext(cx);
if (scriptContext)
nsIScriptContextPrincipal* scp =
GetScriptContextPrincipalFromJSContext(cx);
if (scp)
{
nsCOMPtr<nsIScriptObjectPrincipal> globalData =
do_QueryInterface(scriptContext->GetGlobalObject());
nsIScriptObjectPrincipal* globalData = scp->GetObjectPrincipal();
if (!globalData)
{
*rv = NS_ERROR_FAILURE;

View File

@ -959,7 +959,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.

View File

@ -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@
@ -112,7 +113,6 @@ MOZ_VTUNE = @MOZ_VTUNE@
MOZ_TRACEVIS = @MOZ_TRACEVIS@
DEHYDRA_PATH = @DEHYDRA_PATH@
MOZ_XPCTOOLS = @MOZ_XPCTOOLS@
NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
USE_ELF_DYNSTR_GC = @USE_ELF_DYNSTR_GC@
INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
@ -651,3 +651,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@

View File

@ -41,7 +41,7 @@
#Compares with: foo1.class foo2.class (if -d specified, checks in 'dir',
# otherwise assumes .class files in same directory as .java files)
#Returns: list of input arguments which are newer than corresponding class
#files (non-existent class files are considered to be real old :-)
#files (nonexistent class files are considered to be real old :-)
#
$found = 1;

View File

@ -1518,7 +1518,7 @@ normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
else
# assume MSYS
# We use 'pwd -W' to get DOS form of the path. However, since the given path
# could be a file or a non-existent path, we cannot call 'pwd -W' directly
# could be a file or a nonexistent path, we cannot call 'pwd -W' directly
# on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
# on it, then merge with the rest of the path.
root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")

View File

@ -212,6 +212,7 @@ dbus/dbus-glib.h
dbus/dbus-glib-lowlevel.h
ddeml.h
Debug.h
deque
dem.h
descrip.h
Devices.h
@ -274,6 +275,7 @@ freetype/tttables.h
freetype/t1tables.h
fribidi/fribidi.h
FSp_fopen.h
fstream
fstream.h
ft2build.h
fts.h
@ -329,6 +331,7 @@ IOKit/pwr_mgt/IOPMLib.h
iomanip
iostream
iostream.h
iterator
jar.h
JavaControl.h
JavaEmbedding/JavaControl.h
@ -607,6 +610,7 @@ pthread.h
pwd.h
Python.h
QDOffscreen.h
queue
Quickdraw.h
QuickDraw.h
QuickTimeComponents.h
@ -641,6 +645,7 @@ security.h
secutil.h
semaphore.h
servprov.h
set
setjmp.h
SFNTLayoutTypes.h
SFNTTypes.h
@ -834,6 +839,7 @@ UReanimator.h
URegions.h
URegistrar.h
UResourceMgr.h
utility
urlhist.h
urlmon.h
UScrap.h

View File

@ -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
@ -6150,7 +6276,7 @@ dnl Remove dupes
MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
dnl when trying to build a non-existent extension.
dnl when trying to build a nonexistent extension.
for extension in $MOZ_EXTENSIONS; do
if test ! -d "${srcdir}/extensions/${extension}"; then
AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
@ -6404,15 +6530,6 @@ MOZ_ARG_ENABLE_BOOL(leaky,
MOZ_LEAKY=)
dnl ========================================================
dnl xpctools
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(xpctools,
[ --enable-xpctools Build JS profiling tool],
MOZ_XPCTOOLS=1,
MOZ_XPCTOOLS= )
dnl ========================================================
dnl build the tests by default
dnl ========================================================
@ -7372,7 +7489,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 +7500,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 +7617,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 +7693,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 +7703,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. ])
@ -8370,7 +8482,6 @@ AC_SUBST(MOZ_JPROF)
AC_SUBST(MOZ_SHARK)
AC_SUBST(MOZ_CALLGRIND)
AC_SUBST(MOZ_VTUNE)
AC_SUBST(MOZ_XPCTOOLS)
AC_SUBST(MOZ_JSLOADER)
AC_SUBST(MOZ_USE_NATIVE_UCONV)
AC_SUBST(MOZ_QUANTIFY)

View File

@ -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

View File

@ -122,6 +122,7 @@ XPIDLSRCS = \
nsIFrameLoader.idl \
nsIXMLHttpRequest.idl \
nsIContentSecurityPolicy.idl \
nsIFrameMessageManager.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -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 */

View File

@ -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();
@ -1703,7 +1721,7 @@ public:
PRBool RePush(nsPIDOMEventTarget *aCurrentTarget);
// If a null JSContext is passed to Push(), that will cause no
// push to happen and false to be returned.
PRBool Push(JSContext *cx);
PRBool Push(JSContext *cx, PRBool aRequiresScriptContext = PR_TRUE);
// Explicitly push a null JSContext on the the stack
PRBool PushNull();

View File

@ -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()
{

View File

@ -41,8 +41,9 @@
interface nsIDocShell;
interface nsIURI;
interface nsIChromeFrameMessageManager;
[scriptable, uuid(d675c531-6bdc-417c-b176-635060105f07)]
[scriptable, uuid(3b256c12-20e1-4fd3-8edb-b9c793919f15)]
interface nsIFrameLoader : nsISupports
{
/**
@ -74,6 +75,9 @@ interface nsIFrameLoader : nsISupports
* or may not be allowed on the loader's docshell.
*/
readonly attribute boolean depthTooGreat;
// Note, when frameloaders are swapped, also messageManagers are swapped.
readonly attribute nsIChromeFrameMessageManager messageManager;
};
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);

View File

@ -0,0 +1,119 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Corporation
* 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 "nsISupports.idl"
interface nsIDOMWindow;
interface nsIDocShell;
interface nsIContent;
[scriptable, function, uuid(938fcb95-3d63-46be-aa72-94d08fd3b418)]
interface nsIFrameMessageListener : nsISupports
{
/**
* This is for JS only.
* receiveMessage is called with one parameter, which has the following
* properties:
* {
* name: %message name%,
* sync: %true or false%.
* json: %json object or null%,
* objects: %array of cpow or null, always null if sync is false%
* }
* @note objects property isn't implemented yet.
*
* if the message is synchronous, possible return value is sent back
* as JSON.
*
* When the listener is called, 'this' value is the target of the message.
*/
void receiveMessage();
};
[scriptable, uuid(6b736edb-863d-40bd-bca2-62f44da803c0)]
interface nsIFrameMessageManager : nsISupports
{
void addMessageListener(in AString aMessage, in nsIFrameMessageListener aListener);
void removeMessageListener(in AString aMessage, in nsIFrameMessageListener aListener);
void sendAsyncMessage(/*in messageName, in JSON*/);
};
[scriptable, uuid(c56e85b8-6736-4ae2-ae90-66bcef952a82)]
interface nsIContentFrameMessageManager : nsIFrameMessageManager
{
/**
* @note sending JS objects isn't implemented yet.
*
* Returns an array of JSON objects.
*/
void sendSyncMessage(/*in messageName, in JSON, in an array of JS objects,*/);
/**
* The current top level window in the frame or null.
*/
readonly attribute nsIDOMWindow content;
/**
* The top level docshell or null.
*/
readonly attribute nsIDocShell docShell;
/**
* Print a string to stdout.
*/
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
{
/*
* Load a script in the (remote) frame. aURL must be the absolute URL.
* data: URLs are also supported. For example data:,dump("foo\n");
* If aAllowDelayedLoad is true, script will be loaded when the
* remote frame becomes available. Otherwise the script will be loaded
* only if the frame is already available.
*/
void loadFrameScript(in AString aURL, in boolean aAllowDelayedLoad);
};

View File

@ -144,6 +144,8 @@ CPPSRCS = \
nsXMLNameSpaceMap.cpp \
Link.cpp \
nsFileDataProtocolHandler.cpp \
nsFrameMessageManager.cpp \
nsInProcessTabChildGlobal.cpp \
$(NULL)
GQI_SRCS = contentbase.gqi

View File

@ -1099,6 +1099,23 @@ nsAttrValue::ParseNonNegativeIntValue(const nsAString& aString)
return PR_TRUE;
}
PRBool
nsAttrValue::ParsePositiveIntValue(const nsAString& aString)
{
ResetIfSet();
PRInt32 ec;
PRBool strict;
PRInt32 originalVal = StringToInteger(aString, &strict, &ec);
if (NS_FAILED(ec) || originalVal <= 0) {
return PR_FALSE;
}
SetIntValueAndType(originalVal, eInteger, nsnull);
return PR_TRUE;
}
void
nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
{

View File

@ -258,6 +258,21 @@ public:
*/
PRBool ParseNonNegativeIntValue(const nsAString& aString);
/**
* Parse a string value into a positive integer.
* This method follows the rules for parsing non-negative integer from:
* http://dev.w3.org/html5/spec/infrastructure.html#rules-for-parsing-non-negative-integers
* In addition of these rules, the value has to be greater than zero.
*
* This is generally used for parsing content attributes which reflecting IDL
* attributes are limited to only non-negative numbers greater than zero, see:
* http://dev.w3.org/html5/spec/common-dom-interfaces.html#limited-to-only-non-negative-numbers-greater-than-zero
*
* @param aString the string to parse
* @return whether the value was valid
*/
PRBool ParsePositiveIntValue(const nsAString& aString);
/**
* Parse a string into a color.
*

View File

@ -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);
}
@ -2696,6 +2714,12 @@ nsCxPusher::Push(nsPIDOMEventTarget *aCurrentTarget)
NS_ENSURE_SUCCESS(rv, PR_FALSE);
if (!scx) {
// The target may have a special JS context for event handlers.
JSContext* cx = aCurrentTarget->GetJSContextForEventHandlers();
if (cx) {
DoPush(cx);
}
// Nothing to do here, I guess. Have to return true so that event firing
// will still work correctly even if there is no associated JSContext
return PR_TRUE;
@ -2745,7 +2769,7 @@ nsCxPusher::RePush(nsPIDOMEventTarget *aCurrentTarget)
}
PRBool
nsCxPusher::Push(JSContext *cx)
nsCxPusher::Push(JSContext *cx, PRBool aRequiresScriptContext)
{
if (mPushedSomething) {
NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!");
@ -2761,7 +2785,7 @@ nsCxPusher::Push(JSContext *cx)
// XXXbz do we really need to? If we don't get one of these in Pop(), is
// that really a problem? Or do we need to do this to effectively root |cx|?
mScx = GetScriptContextFromJSContext(cx);
if (!mScx) {
if (!mScx && aRequiresScriptContext) {
// Should probably return PR_FALSE. See bug 416916.
return PR_TRUE;
}
@ -3185,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);
}
@ -5488,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.
@ -5957,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:
@ -5970,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
@ -5977,3 +6057,4 @@ nsIContentUtils::IsSafeToRunScript()
{
return nsContentUtils::IsSafeToRunScript();
}

View File

@ -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;
}

View File

@ -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);

View File

@ -87,6 +87,8 @@
#include "nsThreadUtils.h"
#include "nsIContentViewer.h"
#include "nsIDOMChromeWindow.h"
#include "nsInProcessTabChildGlobal.h"
class nsAsyncDocShellDestroyer : public nsRunnable
{
@ -124,7 +126,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)
@ -831,6 +846,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.
@ -869,6 +916,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();
@ -1019,6 +1073,8 @@ nsFrameLoader::EnsureDocShell()
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
@ -1173,3 +1229,101 @@ nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
viewer->SetDOMDocument(clonedDOMDoc);
return NS_OK;
}
bool LoadScript(void* aCallbackData, const nsAString& aURL)
{
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)
{
nsRefPtr<nsIRunnable> ev =
new nsAsyncMessageToChild(static_cast<nsFrameLoader*>(aCallbackData),
aMessage, aJSON);
NS_DispatchToCurrentThread(ev);
return true;
}
NS_IMETHODIMP
nsFrameLoader::GetMessageManager(nsIChromeFrameMessageManager** aManager)
{
NS_IF_ADDREF(*aManager = mMessageManager);
return NS_OK;
}
nsresult
nsFrameLoader::EnsureMessageManager()
{
NS_ENSURE_STATE(mOwnerContent);
//XXX Should we create message manager also for chrome iframes?
if (!mIsTopLevelContent) {
return NS_OK;
}
EnsureDocShell();
if (mMessageManager) {
return NS_OK;
}
nsresult rv = 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));
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());
}

View File

@ -48,10 +48,12 @@
#include "nsStringFwd.h"
#include "nsIFrameLoader.h"
#include "nsIURI.h"
#include "nsFrameMessageManager.h"
class nsIContent;
class nsIURI;
class nsIFrameFrame;
class nsIInProcessContentFrameMessageManager;
class nsFrameLoader : public nsIFrameLoader
{
@ -80,7 +82,7 @@ public:
nsresult ReallyStartLoading();
void Finalize();
nsIDocShell* GetExistingDocShell() { return mDocShell; }
nsPIDOMEventTarget* GetTabChildGlobalAsEventTarget();
nsresult CreateStaticClone(nsIFrameLoader* aDest);
/**
@ -109,6 +111,7 @@ public:
private:
NS_HIDDEN_(nsresult) EnsureDocShell();
nsresult EnsureMessageManager();
NS_HIDDEN_(void) GetURL(nsString& aURL);
nsresult CheckURILoad(nsIURI* aURI);
void FireErrorEvent();
@ -117,6 +120,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;

View File

@ -0,0 +1,459 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Corporation
* 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 "nsFrameMessageManager.h"
#include "nsContentUtils.h"
#include "nsIXPConnect.h"
#include "jsapi.h"
#include "jsarray.h"
#include "jsinterp.h"
#include "nsJSUtils.h"
NS_IMPL_CYCLE_COLLECTION_CLASS(nsFrameMessageManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFrameMessageManager)
PRUint32 count = tmp->mListeners.Length();
for (PRUint32 i = 0; i < count; i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mListeners[i] mListener");
cb.NoteXPCOMChild(tmp->mListeners[i].mListener.get());
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mChildManagers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameMessageManager)
tmp->mListeners.Clear();
for (PRInt32 i = tmp->mChildManagers.Count(); i > 0; --i) {
static_cast<nsFrameMessageManager*>(tmp->mChildManagers[i - 1])->
Disconnect(PR_FALSE);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mChildManagers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIFrameMessageManager, nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIContentFrameMessageManager, !mChrome)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIChromeFrameMessageManager, mChrome)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
NS_IMETHODIMP
nsFrameMessageManager::AddMessageListener(const nsAString& aMessage,
nsIFrameMessageListener* aListener)
{
nsCOMPtr<nsIAtom> message = do_GetAtom(aMessage);
PRUint32 len = mListeners.Length();
for (PRUint32 i = 0; i < len; ++i) {
if (mListeners[i].mMessage == message &&
mListeners[i].mListener == aListener) {
return NS_OK;
}
}
nsMessageListenerInfo* entry = mListeners.AppendElement();
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
entry->mMessage = message;
entry->mListener = aListener;
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::RemoveMessageListener(const nsAString& aMessage,
nsIFrameMessageListener* aListener)
{
nsCOMPtr<nsIAtom> message = do_GetAtom(aMessage);
PRUint32 len = mListeners.Length();
for (PRUint32 i = 0; i < len; ++i) {
if (mListeners[i].mMessage == message &&
mListeners[i].mListener == aListener) {
mListeners.RemoveElementAt(i);
return NS_OK;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::LoadFrameScript(const nsAString& aURL,
PRBool aAllowDelayedLoad)
{
if (aAllowDelayedLoad && !mCallbackData && !mChildManagers.Count()) {
mPendingScripts.AppendElement(aURL);
return NS_OK;
}
if (mCallbackData) {
#ifdef DEBUG_smaug
printf("Will load %s \n", NS_ConvertUTF16toUTF8(aURL).get());
#endif
NS_ENSURE_TRUE(mLoadScriptCallback(mCallbackData, aURL), NS_ERROR_FAILURE);
}
PRInt32 len = mChildManagers.Count();
for (PRInt32 i = 0; i < len; ++i) {
nsCOMPtr<nsIContentFrameMessageManager> mm = mChildManagers[i];
if (mm) {
static_cast<nsFrameMessageManager*>(mm.get())->LoadFrameScript(aURL, PR_FALSE);
}
}
return NS_OK;
}
static JSBool
JSONCreator(const jschar* aBuf, uint32 aLen, void* aData)
{
nsAString* result = static_cast<nsAString*>(aData);
result->Append((PRUnichar*)aBuf, (PRUint32)aLen);
return JS_TRUE;
}
nsresult
nsFrameMessageManager::GetParamsForMessage(nsAString& aMessageName,
nsAString& aJSON)
{
aMessageName.Truncate();
aJSON.Truncate();
nsAXPCNativeCallContext* ncc = nsnull;
nsresult rv = nsContentUtils::XPConnect()->GetCurrentNativeCallContext(&ncc);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(ncc);
JSContext* ctx = nsnull;
rv = ncc->GetJSContext(&ctx);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 argc;
jsval* argv = nsnull;
ncc->GetArgc(&argc);
ncc->GetArgvPtr(&argv);
JSAutoRequest ar(ctx);
JSString* str;
if (argc && (str = JS_ValueToString(ctx, argv[0])) && str) {
aMessageName.Assign(nsDependentJSString(str));
}
if (argc >= 2) {
jsval v = argv[1];
nsAutoGCRoot root(&v, &rv);
NS_ENSURE_SUCCESS(rv, JS_FALSE);
if (JS_TryJSON(ctx, &v)) {
JS_Stringify(ctx, &v, nsnull, JSVAL_NULL, JSONCreator, &aJSON);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::SendSyncMessage()
{
if (mSyncCallback) {
NS_ENSURE_TRUE(mCallbackData, NS_ERROR_NOT_INITIALIZED);
nsString messageName;
nsString json;
nsresult rv = GetParamsForMessage(messageName, json);
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<nsString> retval;
if (mSyncCallback(mCallbackData, messageName, json, &retval)) {
nsAXPCNativeCallContext* ncc = nsnull;
rv = nsContentUtils::XPConnect()->GetCurrentNativeCallContext(&ncc);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(ncc);
JSContext* ctx = nsnull;
rv = ncc->GetJSContext(&ctx);
NS_ENSURE_SUCCESS(rv, rv);
JSAutoRequest ar(ctx);
PRUint32 len = retval.Length();
jsval* dest = nsnull;
JSObject* dataArray = js_NewArrayObjectWithCapacity(ctx, len, &dest);
NS_ENSURE_TRUE(dataArray, NS_ERROR_OUT_OF_MEMORY);
nsAutoGCRoot arrayGCRoot(&dataArray, &rv);
NS_ENSURE_SUCCESS(rv, rv);
for (PRUint32 i = 0; i < len; ++i) {
jsval ret = JSVAL_VOID;
nsAutoGCRoot root(&ret, &rv);
NS_ENSURE_SUCCESS(rv, rv);
JSONParser* parser = JS_BeginJSONParse(ctx, &ret);
JSBool ok = JS_ConsumeJSONText(ctx, parser, (jschar*)retval[i].get(),
(uint32)retval[i].Length());
ok = JS_FinishJSONParse(ctx, parser, JSVAL_NULL) && ok;
if (ok) {
dest[i] = ret;
}
}
jsval* retvalPtr;
ncc->GetRetValPtr(&retvalPtr);
*retvalPtr = OBJECT_TO_JSVAL(dataArray);
ncc->SetReturnValueWasSet(PR_TRUE);
}
}
NS_ASSERTION(!mParentManager, "Should not have parent manager in content!");
return NS_OK;
}
nsresult
nsFrameMessageManager::SendAsyncMessageInternal(const nsAString& aMessage,
const nsAString& aJSON)
{
if (mAsyncCallback) {
NS_ENSURE_TRUE(mCallbackData, NS_ERROR_NOT_INITIALIZED);
mAsyncCallback(mCallbackData, aMessage, aJSON);
}
PRInt32 len = mChildManagers.Count();
for (PRInt32 i = 0; i < len; ++i) {
static_cast<nsFrameMessageManager*>(mChildManagers[i])->
SendAsyncMessageInternal(aMessage, aJSON);
}
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::SendAsyncMessage()
{
nsString messageName;
nsString json;
nsresult rv = GetParamsForMessage(messageName, json);
NS_ENSURE_SUCCESS(rv, rv);
return SendAsyncMessageInternal(messageName, json);
}
NS_IMETHODIMP
nsFrameMessageManager::Dump(const nsAString& aStr)
{
fputs(NS_ConvertUTF16toUTF8(aStr).get(), stdout);
fflush(stdout);
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetContent(nsIDOMWindow** aContent)
{
*aContent = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetDocShell(nsIDocShell** aDocShell)
{
*aDocShell = nsnull;
return NS_OK;
}
nsresult
nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
const nsAString& aMessage,
PRBool aSync, const nsAString& aJSON,
JSObject* aObjectsArray,
nsTArray<nsString>* aJSONRetVal)
{
if (mListeners.Length()) {
nsCOMPtr<nsIAtom> name = do_GetAtom(aMessage);
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip(this);
for (PRUint32 i = 0; i < mListeners.Length(); ++i) {
if (mListeners[i].mMessage == name) {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS =
do_QueryInterface(mListeners[i].mListener);
if (!wrappedJS) {
continue;
}
JSObject* object = nsnull;
wrappedJS->GetJSObject(&object);
if (!object) {
continue;
}
nsCxPusher pusher;
NS_ENSURE_STATE(pusher.Push(mContext, PR_FALSE));
JSAutoRequest ar(mContext);
// The parameter for the listener function.
JSObject* param = JS_NewObject(mContext, NULL, NULL, NULL);
NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
nsresult rv;
nsAutoGCRoot resultGCRoot(&param, &rv);
NS_ENSURE_SUCCESS(rv, rv);
jsval targetv;
nsAutoGCRoot resultGCRoot2(&targetv, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::WrapNative(mContext,
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()) {
JSONParser* parser = JS_BeginJSONParse(mContext, &json);
if (parser) {
JSBool ok = JS_ConsumeJSONText(mContext, parser,
(jschar*)nsString(aJSON).get(),
(uint32)aJSON.Length());
ok = JS_FinishJSONParse(mContext, parser, JSVAL_NULL) && ok;
if (!ok) {
json = JSVAL_NULL;
}
}
}
JSString* jsMessage =
JS_NewUCStringCopyN(mContext,
reinterpret_cast<const jschar *>(nsString(aMessage).get()),
aMessage.Length());
NS_ENSURE_TRUE(jsMessage, NS_ERROR_OUT_OF_MEMORY);
JS_DefineProperty(mContext, param, "target", targetv, NULL, NULL, JSPROP_ENUMERATE);
JS_DefineProperty(mContext, param, "name",
STRING_TO_JSVAL(jsMessage), NULL, NULL, JSPROP_ENUMERATE);
JS_DefineProperty(mContext, param, "sync",
BOOLEAN_TO_JSVAL(aSync), NULL, NULL, JSPROP_ENUMERATE);
JS_DefineProperty(mContext, param, "json", json, NULL, NULL, JSPROP_ENUMERATE);
JS_DefineProperty(mContext, param, "objects", OBJECT_TO_JSVAL(aObjectsArray),
NULL, NULL, JSPROP_ENUMERATE);
jsval thisValue = JSVAL_VOID;
nsAutoGCRoot resultGCRoot3(&thisValue, &rv);
NS_ENSURE_SUCCESS(rv, rv);
jsval funval = JSVAL_VOID;
if (JS_ObjectIsFunction(mContext, object)) {
// If the listener is a JS function:
funval = OBJECT_TO_JSVAL(object);
nsCOMPtr<nsISupports> defaultThisValue =
do_QueryInterface(static_cast<nsIContentFrameMessageManager*>(this));
nsContentUtils::WrapNative(mContext,
JS_GetGlobalObject(mContext),
defaultThisValue, &thisValue);
} else {
// If the listener is a JS object which has receiveMessage function:
NS_ENSURE_STATE(JS_GetProperty(mContext, object, "receiveMessage",
&funval) &&
JSVAL_IS_OBJECT(funval) &&
!JSVAL_IS_NULL(funval));
JSObject* funobject = JSVAL_TO_OBJECT(funval);
NS_ENSURE_STATE(JS_ObjectIsFunction(mContext, funobject));
thisValue = OBJECT_TO_JSVAL(object);
}
jsval rval = JSVAL_VOID;
nsAutoGCRoot resultGCRoot4(&rval, &rv);
NS_ENSURE_SUCCESS(rv, rv);
void* mark = nsnull;
jsval* argv = js_AllocStack(mContext, 1, &mark);
NS_ENSURE_TRUE(argv, NS_ERROR_OUT_OF_MEMORY);
argv[0] = OBJECT_TO_JSVAL(param);
JSObject* thisObject = JSVAL_TO_OBJECT(thisValue);
JS_CallFunctionValue(mContext, thisObject,
funval, 1, argv, &rval);
if (aJSONRetVal) {
nsString json;
if (JS_TryJSON(mContext, &rval) &&
JS_Stringify(mContext, &rval, nsnull, JSVAL_NULL,
JSONCreator, &json)) {
aJSONRetVal->AppendElement(json);
}
}
js_FreeStack(mContext, mark);
}
}
}
return mParentManager ? mParentManager->ReceiveMessage(aTarget, aMessage,
aSync, aJSON, aObjectsArray,
aJSONRetVal) : NS_OK;
}
void
nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager,
PRBool aLoadScripts)
{
mChildManagers.AppendObject(aManager);
if (aLoadScripts) {
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
aManager->LoadFrameScript(mPendingScripts[i], PR_FALSE);
}
}
}
void
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, aLoadScripts);
}
if (aLoadScripts) {
for (PRUint32 i = 0; i < mPendingScripts.Length(); ++i) {
LoadFrameScript(mPendingScripts[i], PR_FALSE);
}
}
}
}
void
nsFrameMessageManager::Disconnect(PRBool aRemoveFromParent)
{
if (mParentManager && aRemoveFromParent) {
mParentManager->RemoveChildManager(this);
}
mParentManager = nsnull;
mCallbackData = nsnull;
}

View File

@ -0,0 +1,143 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Corporation
* 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 nsFrameMessageManager_h__
#define nsFrameMessageManager_h__
#include "nsIFrameMessageManager.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsCOMArray.h"
#include "nsTArray.h"
#include "nsIAtom.h"
#include "nsCycleCollectionParticipant.h"
#include "nsTArray.h"
class nsAXPCNativeCallContext;
struct JSContext;
struct JSObject;
struct nsMessageListenerInfo
{
nsCOMPtr<nsIFrameMessageListener> mListener;
nsCOMPtr<nsIAtom> mMessage;
};
typedef bool (*nsLoadScriptCallback)(void* aCallbackData, const nsAString& aURL);
typedef bool (*nsSyncMessageCallback)(void* aCallbackData,
const nsAString& aMessage,
const nsAString& aJSON,
nsTArray<nsString>* aJSONRetVal);
typedef bool (*nsAsyncMessageCallback)(void* aCallbackData,
const nsAString& aMessage,
const nsAString& aJSON);
class nsFrameMessageManager : public nsIContentFrameMessageManager,
public nsIChromeFrameMessageManager
{
public:
nsFrameMessageManager(PRBool aChrome,
nsSyncMessageCallback aSyncCallback,
nsAsyncMessageCallback aAsyncCallback,
nsLoadScriptCallback aLoadScriptCallback,
void* aCallbackData,
nsFrameMessageManager* aParentManager,
JSContext* aContext)
: mChrome(aChrome), mParentManager(aParentManager),
mSyncCallback(aSyncCallback), mAsyncCallback(aAsyncCallback),
mLoadScriptCallback(aLoadScriptCallback), mCallbackData(aCallbackData),
mContext(aContext)
{
NS_ASSERTION(mContext, "Should have mContext!");
NS_ASSERTION(aChrome || !aParentManager, "Should not set parent manager!");
if (mParentManager && mCallbackData) {
mParentManager->AddChildManager(this);
}
}
~nsFrameMessageManager()
{
for (PRInt32 i = mChildManagers.Count(); i > 0; --i) {
static_cast<nsFrameMessageManager*>(mChildManagers[i - 1])->
Disconnect(PR_FALSE);
}
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
NS_DECL_NSIFRAMEMESSAGEMANAGER
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
NS_DECL_NSICHROMEFRAMEMESSAGEMANAGER
nsresult ReceiveMessage(nsISupports* aTarget, const nsAString& aMessage,
PRBool aSync, const nsAString& aJSON,
JSObject* aObjectsArray,
nsTArray<nsString>* aJSONRetVal);
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, 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;
PRBool mChrome;
nsFrameMessageManager* mParentManager;
nsSyncMessageCallback mSyncCallback;
nsAsyncMessageCallback mAsyncCallback;
nsLoadScriptCallback mLoadScriptCallback;
void* mCallbackData;
JSContext* mContext;
nsTArray<nsString> mPendingScripts;
};
#endif

View File

@ -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

View File

@ -432,7 +432,7 @@ nsImageLoadingContent::RemoveObserver(imgIDecoderObserver* aObserver)
}
#ifdef DEBUG
else {
NS_WARNING("Asked to remove non-existent observer");
NS_WARNING("Asked to remove nonexistent observer");
}
#endif
return NS_OK;

View 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();
}
}

View 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

Some files were not shown because too many files have changed in this diff Show More