This commit is contained in:
Gregory Szorc 2012-05-11 11:31:42 -07:00
Родитель c967517f14 25e5317a3b
Коммит 1fb7e46ec6
704 изменённых файлов: 3849 добавлений и 30215 удалений

Просмотреть файл

@ -67,7 +67,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

Просмотреть файл

@ -75,22 +75,16 @@ refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
}
static gint
getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
getIndexAtCB(AtkTable* aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (!accWrap)
return -1;
nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, -1);
TableAccessible* table = accWrap->AsTable();
NS_ENSURE_TRUE(table, -1);
PRInt32 index;
nsresult rv = accTable->GetCellIndexAt(aRow, aColumn, &index);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(index);
return static_cast<gint>(table->CellIndexAt(aRow, aColumn));
}
static gint

Просмотреть файл

@ -51,7 +51,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsFocusManager.h"
#include "nsPresContext.h"
#include "mozilla/Services.h"
@ -62,8 +61,6 @@ using namespace mozilla::a11y;
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
nsIStringBundle *nsAccessNode::gStringBundle = 0;
ApplicationAccessible* nsAccessNode::gApplicationAccessible = nsnull;
/*
@ -149,25 +146,12 @@ nsAccessNode::GetApplicationAccessible()
return gApplicationAccessible;
}
void nsAccessNode::InitXPAccessibility()
{
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
if (stringBundleService) {
// Static variables are released in ShutdownAllXPAccessibility();
stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL,
&gStringBundle);
}
}
void nsAccessNode::ShutdownXPAccessibility()
{
// Called by nsAccessibilityService::Shutdown()
// which happens when xpcom is shutting down
// at exit of program
NS_IF_RELEASE(gStringBundle);
// Release gApplicationAccessible after everything else is shutdown
// so we don't accidently create it again while tearing down root accessibles
ApplicationAccessibleWrap::Unload();

Просмотреть файл

@ -69,9 +69,6 @@ class nsPresContext;
class nsIFrame;
class nsIDocShellTreeItem;
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
class nsAccessNode: public nsISupports
{
public:
@ -79,11 +76,10 @@ public:
nsAccessNode(nsIContent* aContent, nsDocAccessible* aDoc);
virtual ~nsAccessNode();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
static void InitXPAccessibility();
static void ShutdownXPAccessibility();
static void ShutdownXPAccessibility();
/**
* Return an application accessible.
@ -164,9 +160,6 @@ protected:
nsCOMPtr<nsIContent> mContent;
nsDocAccessible* mDoc;
// Static data, we do our own refcounting for our static data.
static nsIStringBundle* gStringBundle;
private:
nsAccessNode() MOZ_DELETE;
nsAccessNode(const nsAccessNode&) MOZ_DELETE;

Просмотреть файл

@ -82,6 +82,7 @@
#include "nsLayoutUtils.h"
#include "nsIPresShell.h"
#include "nsIStringBundle.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIView.h"
@ -626,12 +627,24 @@ nsAccessible::GetIndexInParent(PRInt32 *aIndexInParent)
}
void
nsAccessible::TranslateString(const nsAString& aKey, nsAString& aStringOut)
nsAccessible::TranslateString(const nsString& aKey, nsAString& aStringOut)
{
nsXPIDLString xsValue;
nsCOMPtr<nsIStringBundleService> stringBundleService =
services::GetStringBundleService();
if (!stringBundleService)
return;
gStringBundle->GetStringFromName(PromiseFlatString(aKey).get(), getter_Copies(xsValue));
aStringOut.Assign(xsValue);
nsCOMPtr<nsIStringBundle> stringBundle;
stringBundleService->CreateBundle(
"chrome://global-platform/locale/accessible.properties",
getter_AddRefs(stringBundle));
if (!stringBundle)
return;
nsXPIDLString xsValue;
nsresult rv = stringBundle->GetStringFromName(aKey.get(), getter_Copies(xsValue));
if (NS_SUCCEEDED(rv))
aStringOut.Assign(xsValue);
}
PRUint64
@ -3293,8 +3306,9 @@ KeyBinding::ToPlatformFormat(nsAString& aValue) const
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
if (stringBundleService)
stringBundleService->CreateBundle(PLATFORM_KEYS_BUNDLE_URL,
getter_AddRefs(keyStringBundle));
stringBundleService->CreateBundle(
"chrome://global-platform/locale/platformKeys.properties",
getter_AddRefs(keyStringBundle));
if (!keyStringBundle)
return;

Просмотреть файл

@ -662,7 +662,7 @@ public:
/**
* Return the localized string for the given key.
*/
static void TranslateString(const nsAString& aKey, nsAString& aStringOut);
static void TranslateString(const nsString& aKey, nsAString& aStringOut);
/**
* Return true if the accessible is defunct.

Просмотреть файл

@ -133,30 +133,6 @@ ARIAGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
return NS_OK;
}
NS_IMETHODIMP
ARIAGridAccessible::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32* aCellIndex)
{
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(aRowIndex >= 0 && aColumnIndex >= 0);
PRInt32 rowCount = 0;
GetRowCount(&rowCount);
NS_ENSURE_ARG(aRowIndex < rowCount);
PRInt32 colsCount = 0;
GetColumnCount(&colsCount);
NS_ENSURE_ARG(aColumnIndex < colsCount);
*aCellIndex = colsCount * aRowIndex + aColumnIndex;
return NS_OK;
}
NS_IMETHODIMP
ARIAGridAccessible::GetColumnIndexAt(PRInt32 aCellIndex,
PRInt32* aColumnIndex)

Просмотреть файл

@ -51,7 +51,8 @@ public:
/**
* Return the index of the cell at the given row and column.
*/
virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx) { return -1; }
virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx)
{ return ColCount() * aRowIdx + aColIdx; }
/**
* Return the column index of the cell with the given index.

Просмотреть файл

@ -900,20 +900,14 @@ nsHTMLTableAccessible::GetCellAt(PRInt32 aRow, PRInt32 aColumn,
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTableAccessible::GetCellIndexAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aIndex)
PRInt32
nsHTMLTableAccessible::CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx)
{
NS_ENSURE_ARG_POINTER(aIndex);
nsITableLayout* tableLayout = GetTableLayout();
nsITableLayout *tableLayout = GetTableLayout();
NS_ENSURE_STATE(tableLayout);
nsresult rv = tableLayout->GetIndexByRowAndColumn(aRow, aColumn, aIndex);
if (rv == NS_TABLELAYOUT_CELL_NOT_FOUND)
return NS_ERROR_INVALID_ARG;
return NS_OK;
PRInt32 index = -1;
tableLayout->GetIndexByRowAndColumn(aRowIdx, aColIdx, &index);
return index;
}
NS_IMETHODIMP

Просмотреть файл

@ -132,6 +132,7 @@ public:
virtual void Summary(nsString& aSummary);
virtual PRUint32 ColCount();
virtual PRUint32 RowCount();
virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx);
virtual void UnselectCol(PRUint32 aColIdx);
virtual void UnselectRow(PRUint32 aRowIdx);
virtual bool IsProbablyLayoutTable();

Просмотреть файл

@ -48,8 +48,7 @@ var AccessFu = {
} catch (x) {
}
if (this.amINeeded(accessPref))
this.enable();
this.processPreferences(accessPref);
},
/**
@ -57,6 +56,10 @@ var AccessFu = {
* with arrow keys.
*/
enable: function enable() {
if (this._enabled)
return;
this._enabled = true;
dump('AccessFu enable');
this.addPresenter(new VisualPresenter());
@ -77,6 +80,10 @@ var AccessFu = {
* Disable AccessFu and return to default interaction mode.
*/
disable: function disable() {
if (!this._enabled)
return;
this._enabled = false;
dump('AccessFu disable');
this.presenters.forEach(function(p) { p.detach(); });
@ -91,26 +98,29 @@ var AccessFu = {
this.chromeWin.removeEventListener('TabOpen', this, true);
},
amINeeded: function(aPref) {
switch (aPref) {
case ACCESSFU_ENABLE:
return true;
case ACCESSFU_AUTO:
if (Services.appinfo.OS == 'Android') {
let msg = Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify(
{ gecko: {
type: 'Accessibility:IsEnabled',
eventType: 1,
text: []
}
}));
return JSON.parse(msg).enabled;
processPreferences: function processPreferences(aPref) {
if (Services.appinfo.OS == 'Android') {
if (aPref == ACCESSFU_AUTO) {
if (!this._observingSystemSettings) {
Services.obs.addObserver(this, 'Accessibility:Settings', false);
this._observingSystemSettings = true;
}
default:
return false;
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ gecko: { type: 'Accessibility:Ready' } }));
return;
}
if (this._observingSystemSettings) {
Services.obs.removeObserver(this, 'Accessibility:Settings');
this._observingSystemSettings = false;
}
}
if (aPref == ACCESSFU_ENABLE)
this.enable();
else
this.disable();
},
addPresenter: function addPresenter(presenter) {
@ -159,13 +169,15 @@ var AccessFu = {
observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) {
case 'Accessibility:Settings':
if (JSON.parse(aData).enabled)
this.enable();
else
this.disable();
break;
case 'nsPref:changed':
if (aData == 'accessfu') {
if (this.amINeeded(this.prefsBranch.getIntPref('accessfu')))
this.enable();
else
this.disable();
}
if (aData == 'accessfu')
this.processPreferences(this.prefsBranch.getIntPref('accessfu'));
break;
case 'accessible-event':
let event;
@ -392,7 +404,13 @@ var AccessFu = {
},
// A hash of documents that don't yet have an accessible tree.
_pendingDocuments: {}
_pendingDocuments: {},
// So we don't enable/disable twice
_enabled: false,
// Observing accessibility settings
_observingSystemSettings: false
};
function getAccessible(aNode) {

Просмотреть файл

@ -476,10 +476,10 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
{
switch (mRole) {
case roles::LIST:
return NSAccessibilityContentListSubrole;
return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
case roles::DEFINITION_LIST:
return NSAccessibilityDefinitionListSubrole;
return @"AXDefinitionList"; // 10.6+ NSAccessibilityDefinitionListSubrole;
case roles::TERM:
return @"AXTerm";

Просмотреть файл

@ -67,7 +67,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

Просмотреть файл

@ -588,8 +588,6 @@ void nsAccessNodeWrap::InitAccessibility()
Compatibility::Init();
nsWinUtils::MaybeStartWindowEmulation();
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

Просмотреть файл

@ -66,7 +66,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

Просмотреть файл

@ -47,6 +47,24 @@ xpcAccessibleTable::GetRowCount(PRInt32* aRowCount)
return NS_OK;
}
nsresult
xpcAccessibleTable::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32* aCellIndex)
{
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
if (!mTable)
return NS_ERROR_FAILURE;
if (aRowIndex < 0 || aRowIndex >= mTable->RowCount() ||
aColumnIndex < 0 || aColumnIndex >= mTable->ColCount())
return NS_ERROR_INVALID_ARG;
*aCellIndex = mTable->CellIndexAt(aRowIndex, aColumnIndex);
return NS_OK;
}
nsresult
xpcAccessibleTable::GetSummary(nsAString& aSummary)
{

Просмотреть файл

@ -26,6 +26,8 @@ public:
nsresult GetSummary(nsAString& aSummary);
nsresult GetColumnCount(PRInt32* aColumnCount);
nsresult GetRowCount(PRInt32* aRowCount);
nsresult GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32* aCellIndex);
nsresult UnselectColumn(PRInt32 aColIdx);
nsresult UnselectRow(PRInt32 aRowIdx);
nsresult IsProbablyForLayout(bool* aIsForLayout);
@ -44,7 +46,8 @@ protected:
NS_SCRIPTABLE NS_IMETHOD GetRowCount(PRInt32* aRowCount) \
{ return xpcAccessibleTable::GetRowCount(aRowCount); } \
NS_SCRIPTABLE NS_IMETHOD GetCellAt(PRInt32 rowIndex, PRInt32 columnIndex, nsIAccessible * *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetCellIndexAt(PRInt32 rowIndex, PRInt32 columnIndex, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetCellIndexAt(PRInt32 rowIndex, PRInt32 columnIndex, PRInt32 *_retval NS_OUTPARAM) \
{ return xpcAccessibleTable::GetCellIndexAt(rowIndex, columnIndex, _retval); } \
NS_SCRIPTABLE NS_IMETHOD GetColumnIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowAndColumnIndicesAt(PRInt32 cellIndex, PRInt32 *rowIndex NS_OUTPARAM, PRInt32 *columnIndex NS_OUTPARAM); \

Просмотреть файл

@ -307,27 +307,6 @@ nsXULListboxAccessible::GetCellAt(PRInt32 aRow, PRInt32 aColumn,
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetCellIndexAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aIndex)
{
NS_ENSURE_ARG_POINTER(aIndex);
*aIndex = -1;
PRInt32 rowCount = 0;
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= aRow && aRow <= rowCount, NS_ERROR_INVALID_ARG);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= aColumn && aColumn <= columnCount, NS_ERROR_INVALID_ARG);
*aIndex = aRow * columnCount + aColumn;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumnIndexAt(PRInt32 aIndex, PRInt32 *aColumn)
{

Просмотреть файл

@ -356,24 +356,6 @@ nsXULTreeGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aCellIndex)
{
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 columnCount = 0;
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCellIndex = aRowIndex * columnCount + aColumnIndex;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnIndexAt(PRInt32 aCellIndex,
PRInt32 *aColumnIndex)

Просмотреть файл

@ -337,6 +337,118 @@ function testWords(aElement, aWords, aToDoFlag)
}
}
/**
* Remove all selections.
*
* @param aID [in] Id, DOM node, or acc obj
*/
function cleanTextSelections(aID)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
while (acc.selectionCount > 0)
acc.removeSelection(0);
}
/**
* Test addSelection method.
*
* @param aID [in] Id, DOM node, or acc obj
* @param aStartOffset [in] start offset for the new selection
* @param aEndOffset [in] end offset for the new selection
* @param aSelectionsCount [in] expected number of selections after addSelection
*/
function testTextAddSelection(aID, aStartOffset, aEndOffset, aSelectionsCount)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
var text = acc.getText(0, -1);
acc.addSelection(aStartOffset, aEndOffset);
ok(acc.selectionCount, aSelectionsCount,
text + ": failed to add selection from offset '" + aStartOffset +
"' to offset '" + aEndOffset + "': selectionCount after");
}
/**
* Test removeSelection method.
*
* @param aID [in] Id, DOM node, or acc obj
* @param aSelectionIndex [in] index of the selection to be removed
* @param aSelectionsCount [in] expected number of selections after
* removeSelection
*/
function testTextRemoveSelection(aID, aSelectionIndex, aSelectionsCount)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
var text = acc.getText(0, -1);
acc.removeSelection(aSelectionIndex);
ok(acc.selectionCount, aSelectionsCount,
text + ": failed to remove selection at index '" +
aSelectionIndex + "': selectionCount after");
}
/**
* Test setSelectionBounds method.
*
* @param aID [in] Id, DOM node, or acc obj
* @param aStartOffset [in] new start offset for the selection
* @param aEndOffset [in] new end offset for the selection
* @param aSelectionIndex [in] index of the selection to set
* @param aSelectionsCount [in] expected number of selections after
* setSelectionBounds
*/
function testTextSetSelection(aID, aStartOffset, aEndOffset,
aSelectionIndex, aSelectionsCount)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
var text = acc.getText(0, -1);
acc.setSelectionBounds(aSelectionIndex, aStartOffset, aEndOffset);
is(acc.selectionCount, aSelectionsCount,
text + ": failed to set selection at index '" +
aSelectionIndex + "': selectionCount after");
}
/**
* Test selectionCount method.
*
* @param aID [in] Id, DOM node, or acc obj
* @param aCount [in] expected selection count
*/
function testTextSelectionCount(aID, aCount)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
var text = acc.getText(0, -1);
is(acc.selectionCount, aCount, text + ": wrong selectionCount: ");
}
/**
* Test getSelectionBounds method.
*
* @param aID [in] Id, DOM node, or acc obj
* @param aStartOffset [in] expected start offset for the selection
* @param aEndOffset [in] expected end offset for the selection
* @param aSelectionIndex [in] index of the selection to get
*/
function testTextGetSelection(aID, aStartOffset, aEndOffset, aSelectionIndex)
{
var acc = getAccessible(aID, [nsIAccessibleText]);
var text = acc.getText(0, -1);
var startObj = {}, endObj = {};
acc.getSelectionBounds(aSelectionIndex, startObj, endObj);
is(startObj.value, aStartOffset, text + ": wrong start offset for index '" +
aSelectionIndex + "'");
is(endObj.value, aEndOffset, text + ": wrong end offset for index '" +
aSelectionIndex + "'");
}
////////////////////////////////////////////////////////////////////////////////
// Private

Просмотреть файл

@ -50,6 +50,7 @@ _TEST_FILES = \
test_doc.html \
test_hypertext.html \
test_passwords.html \
test_selection.html \
test_singleline.html \
test_whitespaces.html \
test_words.html \

Просмотреть файл

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html>
<head>
<title>Test text selection functions</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../text.js"></script>
<script type="application/javascript">
function doTest()
{
// Test selection count: clean selection / check count.
testTextAddSelection("div0", 0, 2, 1); // |Test selection...
cleanTextSelections("div0");
testTextSelectionCount("div0", 0);
// Test addition: adding two equal selections, the second one should
// not be added.
testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
testTextGetSelection("div1", 7, 9, 0);
// Test overlapping selections: adding three selections, one adjacent.
testTextAddSelection("div2", 0, 3, 1); // |Tes|t adding 3...
testTextAddSelection("div2", 7, 9, 2); // |Tes|t ad|di|ng 3...
testTextAddSelection("div2", 3, 4, 3); // |Tes||t| ad|di|ng 3...
testTextGetSelection("div2", 0, 3, 0);
testTextGetSelection("div2", 3, 4, 1);
testTextGetSelection("div2", 7, 9, 2);
// Test selection re-ordering: adding two selections.
// NOTE: removeSelections aSelectionIndex is from start of document.
testTextAddSelection("div3", 0, 3, 1); // |Tes|t adding 2...
testTextAddSelection("div3", 7, 9, 2); // |Tes|t ad|di|ng 2...
testTextRemoveSelection("div3", 4, 1); // Test ad|di|ng 2...
// Test extending existing selection.
// NOTE: setSelectionBounds aSelectionIndex is from start of document.
testTextAddSelection("div4", 4, 5, 1); // Test| |extending...
testTextSetSelection("div4", 4, 9, 6, 1); // Test| exte|nding...
// Test moving an existing selection.
// NOTE: setSelectionBounds aSelectionIndex is from start of document.
testTextAddSelection("div5", 1, 3, 1); // T|es|t moving...
testTextSetSelection("div5", 5, 9, 6, 1); // Test |movi|ng...
// Test adding selections to multiple inner elements.
testTextAddSelection("div71", 0, 3, 1); // |Tes|t adding...
testTextAddSelection("div71", 7, 8, 2); // |Tes|t ad|d|ing...
testTextAddSelection("div72", 4, 6, 1); // Test| a|dding...
testTextAddSelection("div72", 7, 8, 2); // Test| a|d|d|ing...
// Test adding selection to parent element.
// NOTE: If inner elements are represented as embedded chars
// we count their internal selections.
testTextAddSelection("div7", 7, 8, 5); // Test ad|d|ing...
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="div0">Test selection count</div>
</br>
<div id="div1">Test adding two equal selections </div>
<div id="div2">Test adding 3 selections one adjacent </div>
<div id="div3">Test adding 2 selections, remove first one </div>
<div id="div4">Test extending a selection </div>
<div id="div5">Test moving a selection </div>
</br>
<div id="div7">Test adding selections to parent element
<div id="div71">Test adding selections to inner element1 </div>
<div id="div72">Test adding selections to inner element2 </div>
</div>
</body>
</html>

Просмотреть файл

@ -459,7 +459,7 @@ class ShutdownLeakLogger(object):
DOM windows (that are still around after test suite shutdown, despite running
the GC) to the tests that created them and prints leak statistics.
"""
MAX_LEAK_COUNT = 11
MAX_LEAK_COUNT = 10
def __init__(self, logger):
self.logger = logger

Просмотреть файл

@ -1327,7 +1327,6 @@ private void CancelNotification()
{
String sRet = sErrorPrefix + sDir + " does not exist";
String tmpDir = fixFileName(sDir);
String [] theArgs = new String [3];
int nFiles = 0;
if (tmpDir.contains("org.mozilla.fennec") || tmpDir.contains("org.mozilla.firefox")) {
@ -1365,11 +1364,7 @@ private void CancelNotification()
}
else {
try {
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "ls -l " + sDir;
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("ls -l " + sDir));
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(5000);
@ -2335,35 +2330,30 @@ private void CancelNotification()
public String SetADB(String sWhat) {
String sRet = "";
String sTmp = "";
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
String sCmd;
if (sWhat.contains("ip")) {
theArgs[2] = "setprop service.adb.tcp.port 5555";
sCmd = "setprop service.adb.tcp.port 5555";
} else {
theArgs[2] = "setprop service.adb.tcp.port -1";
sCmd = "setprop service.adb.tcp.port -1";
}
try {
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs(sCmd));
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(5000);
sTmp = outThrd.strOutput;
Log.e("ADB", sTmp);
if (outThrd.nExitCode == 0) {
theArgs[2] = "stop adbd";
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("stop adbd"));
outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(5000);
sTmp = outThrd.strOutput;
Log.e("ADB", sTmp);
if (outThrd.nExitCode == 0) {
theArgs[2] = "start adbd";
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("start adbd"));
outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(5000);
@ -2397,11 +2387,7 @@ private void CancelNotification()
public String KillProcess(String sProcName, OutputStream out)
{
String sTmp = "";
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "kill";
String sCmd = "kill";
String sRet = sErrorPrefix + "Unable to kill " + sProcName + "\n";
ActivityManager aMgr = (ActivityManager) contextWrapper.getSystemService(Activity.ACTIVITY_SERVICE);
@ -2422,11 +2408,11 @@ private void CancelNotification()
nPID = lProcesses.get(lcv).pid;
sRet = sErrorPrefix + "Failed to kill " + nPID + " " + strProcName + "\n";
theArgs[2] += " " + nPID;
sCmd += " " + nPID;
try
{
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs(sCmd));
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(15000);
@ -2857,10 +2843,6 @@ private void CancelNotification()
String sRet = "";
String sM = "";
String sMillis = "";
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
if (((sDate != null) && (sTime != null)) &&
(sDate.contains("/") || sDate.contains(".")) &&
@ -2886,10 +2868,8 @@ private void CancelNotification()
// if we have an argument
if (sMillis.length() > 0) {
theArgs[2] = "date -u " + sMillis;
try {
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("date -u " + sMillis));
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
outThrd.start();
outThrd.join(10000);
@ -3123,11 +3103,7 @@ private void CancelNotification()
{
String sRet = "";
Context ctx = contextWrapper.getApplicationContext();
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "reboot";
try {
if ((sCallBackIP != null) && (sCallBackPort != null) &&
(sCallBackIP.length() > 0) && (sCallBackPort.length() > 0)) {
@ -3150,7 +3126,7 @@ private void CancelNotification()
// Tell all of the data channels we are rebooting
((ASMozStub)this.contextWrapper).SendToDataChannel("Rebooting ...");
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("reboot"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
outThrd.join(10000);
@ -3164,18 +3140,24 @@ private void CancelNotification()
return (sRet);
}
private String [] getSuArgs(String cmdString)
{
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
// as a security measure, ICS and later resets LD_LIBRARY_PATH. reset
// it here when executing the command
theArgs[2] = "LD_LIBRARY_PATH=/vendor/lib:/system/lib " + cmdString;
return theArgs;
}
public String UnInstallApp(String sApp, OutputStream out)
{
String sRet = "";
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "pm uninstall " + sApp + ";reboot;exit";
try
{
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm uninstall " + sApp + ";reboot;exit"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
@ -3205,13 +3187,8 @@ private void CancelNotification()
public String InstallApp(String sApp, OutputStream out)
{
String sRet = "";
String [] theArgs = new String [3];
File srcFile = new File(sApp);
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "mv " + GetTmpDir() + "/" + srcFile.getName() + " /data/local/tmp/" + srcFile.getName() + ";exit";
sRet = CopyFile(sApp, GetTmpDir() + "/" + srcFile.getName());
try {
out.write(sRet.getBytes());
@ -3224,7 +3201,10 @@ private void CancelNotification()
try
{
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("mv " + GetTmpDir() + "/" +
srcFile.getName() +
" /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
@ -3247,8 +3227,8 @@ private void CancelNotification()
e1.printStackTrace();
}
theArgs[2] = "chmod 666 /data/local/tmp/" + srcFile.getName() + ";exit";
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("chmod 666 /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd2 = new RedirOutputThread(pProc, out);
outThrd2.start();
try {
@ -3269,8 +3249,9 @@ private void CancelNotification()
e1.printStackTrace();
}
theArgs[2] = "pm install -r /data/local/tmp/" + srcFile.getName() + " Cleanup" + ";exit";
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r /data/local/tmp/" +
srcFile.getName() + " Cleanup" +
";exit"));
RedirOutputThread outThrd3 = new RedirOutputThread(pProc, out);
outThrd3.start();
try {
@ -3291,8 +3272,8 @@ private void CancelNotification()
e1.printStackTrace();
}
theArgs[2] = "rm /data/local/tmp/" + srcFile.getName() + ";exit";
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("rm /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd4 = new RedirOutputThread(pProc, out);
outThrd4.start();
try {

Просмотреть файл

@ -81,9 +81,11 @@ public class WatcherService extends Service
String sErrorPrefix = "##Installer Error## ";
String currentDir = "/";
String sPingTarget = "";
long lDelay = 60000;
long lPeriod = 300000;
int nMaxStrikes = 3;
long lDelay = 60000;
long lPeriod = 300000;
int nMaxStrikes = 3; // maximum number of tries before we consider network unreachable
boolean bStartSUTAgent = true;
Process pProc;
Context myContext = null;
Timer myTimer = null;
@ -143,6 +145,8 @@ public class WatcherService extends Service
this.lPeriod = Long.parseLong(sHold.trim());
sHold = GetIniData("watcher", "strikes", sIniFile,"3");
this.nMaxStrikes = Integer.parseInt(sHold.trim());
sHold = GetIniData("watcher", "StartSUTAgent", sIniFile, "true");
this.bStartSUTAgent = Boolean.parseBoolean(sHold.trim());
sHold = GetIniData("watcher", "stayon", sIniFile,"0");
int nStayOn = Integer.parseInt(sHold.trim());
@ -923,34 +927,33 @@ public class WatcherService extends Service
if (bInstalling)
return;
// See if the network is up, if not after three failures reboot
String sRet = SendPing(sPingTarget);
if (!sRet.contains("3 received"))
// See if the network is up, if not reboot after a configurable
// number of tries
if (nMaxStrikes > 0)
{
if (nMaxStrikes > 0)
{
if (++nStrikes >= nMaxStrikes)
RunReboot(null);
}
String sRet = SendPing(sPingTarget);
if (!sRet.contains("3 received") && ++nStrikes >= nMaxStrikes)
{
RunReboot(null);
}
else
{
nStrikes = 0;
}
}
else
{
nStrikes = 0;
}
sRet = null;
String sProgramName = "com.mozilla.SUTAgentAndroid";
PackageManager pm = myContext.getPackageManager();
// Debug.waitForDebugger();
if (!GetProcessInfo(sProgramName))
if (bStartSUTAgent && !GetProcessInfo(sProgramName))
{
Intent agentIntent = new Intent();
agentIntent.setPackage(sProgramName);
agentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
agentIntent.setAction(Intent.ACTION_MAIN);
try {
PackageManager pm = myContext.getPackageManager();
PackageInfo pi = pm.getPackageInfo(sProgramName, PackageManager.GET_ACTIVITIES | PackageManager.GET_INTENT_FILTERS);
ActivityInfo [] ai = pi.activities;
for (int i = 0; i < ai.length; i++)

Просмотреть файл

@ -117,6 +117,7 @@ xpcshell-tests:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--tests-root-dir=$(testxpcobjdir) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
--xunit-suite-name=xpcshell \
$(EXTRA_TEST_ARGS) \
@ -147,6 +148,7 @@ check-interactive:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--test-path=$(SOLO_FILE) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--profile-name=$(MOZ_APP_NAME) \
--interactive \
$(LIBXUL_DIST)/bin/xpcshell \
@ -160,6 +162,7 @@ check-one:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--test-path=$(SOLO_FILE) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--profile-name=$(MOZ_APP_NAME) \
--verbose \
$(EXTRA_TEST_ARGS) \
@ -1549,6 +1552,25 @@ endif
endif
################################################################################
# Copy testing-only JS modules to appropriate destination.
#
# For each file defined in TESTING_JS_MODULES, copy it to
# objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path
# wlll be appended to the output directory.
ifdef TESTING_JS_MODULES
testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
GENERATED_DIRS += $(testmodulesdir)
libs:: $(TESTING_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
endif
endif
################################################################################
# SDK

Просмотреть файл

@ -291,7 +291,16 @@ if test -n "$gonkdir" ; then
STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
STLPORT_LIBS="-lstlport"
CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/arch-arm/include -isystem $gonkdir/bionic/libc/kernel/arch-arm -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/frameworks/base/include -I$gonkdir/external/dbus $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice"
case "$target_cpu" in
arm)
ARCH_DIR=arch-arm
;;
i?86)
ARCH_DIR=arch-x86
;;
esac
CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/frameworks/base/include -I$gonkdir/external/dbus $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS $STLPORT_CPPFLAGS"
LIBS="$LIBS $STLPORT_LIBS"
@ -1748,11 +1757,15 @@ if test "$GNU_CC"; then
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
# -Werror=unused-result - enforces __attribute__((warn_unused_result));
# Seldom used in system headers, but frequently in Mozilla code to
# enforce checking of fallible methods.
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
MOZ_C_SUPPORTS_WARNING(-W, error=unused-result, ac_c_has_werror_unused_result)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-unused - lots of violations in third-party code
@ -1815,11 +1828,13 @@ if test "$GNU_CXX"; then
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
# -Werror=unused-result - see above
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
MOZ_CXX_SUPPORTS_WARNING(-W, error=unused-result, ac_cxx_has_werror_unused_result)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-ctor-dtor-privacy - ???

Просмотреть файл

@ -937,7 +937,10 @@ nsFrameLoader::ShowRemoteFrame(const nsIntSize& size)
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (OwnerIsBrowserFrame() && os) {
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
"remote-browser-frame-shown", NULL);
"remote-browser-frame-shown",
mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)
? NS_LITERAL_STRING("is-moz-app:true").get()
: NS_LITERAL_STRING("is-moz-app:false").get());
}
} else {
nsRect dimensions;
@ -1522,7 +1525,10 @@ nsFrameLoader::MaybeCreateDocShell()
if (OwnerIsBrowserFrame() && os) {
mDocShell->SetIsBrowserFrame(true);
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
"in-process-browser-frame-shown", NULL);
"in-process-browser-frame-shown",
mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)
? NS_LITERAL_STRING("is-moz-app:true").get()
: NS_LITERAL_STRING("is-moz-app:false").get());
}
// This is nasty, this code (the do_GetInterface(mDocShell) below)
@ -2165,19 +2171,6 @@ nsFrameLoader::GetRootContentView(nsIContentView** aContentView)
return NS_OK;
}
static already_AddRefed<nsIDocShell>
GetRootDocShell(nsIDocument *aDocument)
{
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aDocument->GetWindow());
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(webNav);
NS_ENSURE_TRUE(treeItem, NULL);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDocShell> rootDocShell = do_QueryInterface(rootItem);
return rootDocShell.forget();
}
nsresult
nsFrameLoader::EnsureMessageManager()
{
@ -2206,14 +2199,11 @@ nsFrameLoader::EnsureMessageManager()
NS_ENSURE_STATE(cx);
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
do_QueryInterface(OwnerDoc()->GetWindow());
if (!chromeWindow) {
nsCOMPtr<nsIDocShell> rootDocShell = GetRootDocShell(OwnerDoc());
nsCOMPtr<nsIDOMWindow> rootWindow = do_GetInterface(rootDocShell);
chromeWindow = do_GetInterface(rootWindow);
}
do_QueryInterface(GetOwnerDoc()->GetWindow());
nsCOMPtr<nsIChromeFrameMessageManager> parentManager;
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
if (chromeWindow) {
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
}
if (ShouldUseRemoteProcess()) {
mMessageManager = new nsFrameMessageManager(true,

Просмотреть файл

@ -249,7 +249,7 @@ public:
* Return the document that owns this, or null if we don't have
* an owner.
*/
nsIDocument* OwnerDoc() const
nsIDocument* GetOwnerDoc() const
{ return mOwnerContent ? mOwnerContent->OwnerDoc() : nsnull; }
PBrowserParent* GetRemoteBrowser();

Просмотреть файл

@ -108,6 +108,7 @@ GK_ATOM(ancestor, "ancestor")
GK_ATOM(ancestorOrSelf, "ancestor-or-self")
GK_ATOM(_and, "and")
GK_ATOM(any, "any")
GK_ATOM(mozapp, "mozapp")
GK_ATOM(applet, "applet")
GK_ATOM(applyImports, "apply-imports")
GK_ATOM(applyTemplates, "apply-templates")

Просмотреть файл

@ -881,7 +881,7 @@ nsXMLHttpRequest::AppendToResponseText(const char * aSrcBuffer,
&destBufferLen);
NS_ENSURE_SUCCESS(rv, rv);
if (!mResponseText.SetCapacity(mResponseText.Length() + destBufferLen)) {
if (!mResponseText.SetCapacity(mResponseText.Length() + destBufferLen, fallible_t())) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -284,6 +284,7 @@ nsGenericHTMLFrameElement::GetReallyIsBrowser(bool *aOut)
}
// Fail if the node principal isn't trusted.
// TODO: check properly for mozApps rights when mozApps will be less hacky.
nsIPrincipal *principal = NodePrincipal();
nsCOMPtr<nsIURI> principalURI;
principal->GetURI(getter_AddRefs(principalURI));

Просмотреть файл

@ -1,7 +1,7 @@
/**
* Import common SimpleTest methods so that they're usable in this window.
*/
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror", "todo",
var imports = [ "SimpleTest", "is", "isnot", "ise", "ok", "onerror", "todo",
"todo_is", "todo_isnot" ];
for each (var name in imports) {
window[name] = window.opener.wrappedJSObject[name];

Просмотреть файл

@ -7,6 +7,7 @@
let Cu = Components.utils;
let Ci = Components.interfaces;
let Cc = Components.classes;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function debug(msg) {
//dump("BrowserElementChild - " + msg + "\n");
@ -41,6 +42,17 @@ BrowserElementChild.prototype = {
Ci.nsIWebProgress.NOTIFY_LOCATION |
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
// A mozbrowser iframe contained inside a mozapp iframe should return false
// for nsWindowUtils::IsPartOfApp (unless the mozbrowser iframe is itself
// also mozapp). That is, mozapp is transitive down to its children, but
// mozbrowser serves as a barrier.
//
// This is because mozapp iframes have some privileges which we don't want
// to extend to untrusted mozbrowser content.
content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.setIsApp(false);
addEventListener('DOMTitleChanged',
this._titleChangedHandler.bind(this),
/* useCapture = */ true,

Просмотреть файл

@ -67,17 +67,17 @@ BrowserElementParent.prototype = {
}
},
_observeInProcessBrowserFrameShown: function(frameLoader) {
_observeInProcessBrowserFrameShown: function(frameLoader, isMozApp) {
debug("In-process browser frame shown " + frameLoader);
this._setUpMessageManagerListeners(frameLoader);
this._setUpMessageManagerListeners(frameLoader, isMozApp);
},
_observeRemoteBrowserFrameShown: function(frameLoader) {
_observeRemoteBrowserFrameShown: function(frameLoader, isMozApp) {
debug("Remote browser frame shown " + frameLoader);
this._setUpMessageManagerListeners(frameLoader);
this._setUpMessageManagerListeners(frameLoader, isMozApp);
},
_setUpMessageManagerListeners: function(frameLoader) {
_setUpMessageManagerListeners: function(frameLoader, isMozApp) {
let frameElement = frameLoader.QueryInterface(Ci.nsIFrameLoader).ownerElement;
if (!frameElement) {
debug("No frame element?");
@ -102,6 +102,12 @@ BrowserElementParent.prototype = {
mm.loadFrameScript("chrome://global/content/BrowserElementChild.js",
/* allowDelayedLoad = */ true);
if (isMozApp) {
mm.loadFrameScript("data:,content.QueryInterface(Ci.nsIInterfaceRequestor)" +
" .getInterface(Components.interfaces.nsIDOMWindowUtils)" +
" .setIsApp(true);",
/* allowDelayedLoad = */ true);
}
},
_recvHello: function(frameElement, data) {
@ -144,10 +150,10 @@ BrowserElementParent.prototype = {
}
break;
case 'remote-browser-frame-shown':
this._observeRemoteBrowserFrameShown(subject);
this._observeRemoteBrowserFrameShown(subject, data == "is-moz-app:true");
break;
case 'in-process-browser-frame-shown':
this._observeInProcessBrowserFrameShown(subject);
this._observeInProcessBrowserFrameShown(subject, data == "is-moz-app:true");
break;
case 'content-document-global-created':
this._observeContentGlobalCreated(subject);

Просмотреть файл

@ -2453,3 +2453,14 @@ nsDOMWindowUtils::SetScrollPositionClampingScrollPortSize(float aWidth, float aH
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetIsApp(bool aValue)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
static_cast<nsGlobalWindow*>(window.get())->SetIsApp(aValue);
return NS_OK;
}

Просмотреть файл

@ -692,6 +692,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mShowFocusRingForContent(false),
mFocusByKeyOccurred(false),
mNotifiedIDDestroyed(false),
mIsApp(TriState_Unknown),
mTimeoutInsertionPoint(nsnull),
mTimeoutPublicIdCounter(1),
mTimeoutFiringDepth(0),
@ -10015,6 +10016,33 @@ nsGlobalWindow::SizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
mNavigator->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf) : 0;
}
void
nsGlobalWindow::SetIsApp(bool aValue)
{
FORWARD_TO_OUTER_VOID(SetIsApp, (aValue));
mIsApp = aValue ? TriState_True : TriState_False;
}
bool
nsGlobalWindow::IsPartOfApp()
{
FORWARD_TO_OUTER(IsPartOfApp, (), TriState_False);
// We go trough all window parents until we find one with |mIsApp| set to
// something. If none is found, we are not part of an application.
for (nsGlobalWindow* w = this; w;
w = static_cast<nsGlobalWindow*>(w->GetParentInternal())) {
if (w->mIsApp == TriState_True) {
return true;
} else if (w->mIsApp == TriState_False) {
return false;
}
}
return false;
}
// nsGlobalChromeWindow implementation
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)

Просмотреть файл

@ -558,10 +558,23 @@ public:
void AddEventTargetObject(nsDOMEventTargetHelper* aObject);
void RemoveEventTargetObject(nsDOMEventTargetHelper* aObject);
/**
* Returns if the window is part of an application.
* It will check for the window app state and its parents until a window has
* an app state different from |TriState_Unknown|.
*/
bool IsPartOfApp();
protected:
friend class HashchangeCallback;
friend class nsBarProp;
enum TriState {
TriState_Unknown = -1,
TriState_False,
TriState_True
};
// Object Management
virtual ~nsGlobalWindow();
void CleanUp(bool aIgnoreModalDialog);
@ -811,6 +824,8 @@ protected:
nsresult CloneStorageEvent(const nsAString& aType,
nsCOMPtr<nsIDOMStorageEvent>& aEvent);
void SetIsApp(bool aValue);
// When adding new member variables, be careful not to create cycles
// through JavaScript. If there is any chance that a member variable
// could own objects that are implemented in JavaScript, then those
@ -878,6 +893,11 @@ protected:
// whether we've sent the destroy notification for our window id
bool mNotifiedIDDestroyed : 1;
// Whether the window is the window of an application frame.
// This is TriState_Unknown if the object is the content window of an
// iframe which is neither mozBrowser nor mozApp.
TriState mIsApp : 2;
nsCOMPtr<nsIScriptContext> mContext;
nsWeakPtr mOpener;
nsCOMPtr<nsIControllers> mControllers;

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIDocShellTreeItem.h"
#include "nsLayoutUtils.h"
#include "nsDOMEvent.h"
#include "nsGlobalWindow.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -381,11 +382,15 @@ nsScreen::MozLockOrientation(const nsAString& aOrientation, bool* aReturn)
return NS_OK;
}
bool fullscreen;
doc->GetMozFullScreen(&fullscreen);
if (!fullscreen) {
*aReturn = false;
return NS_OK;
// Apps and frames contained in apps can lock orientation.
// But non-apps can lock orientation only if they're fullscreen.
if (!static_cast<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
bool fullscreen;
doc->GetMozFullScreen(&fullscreen);
if (!fullscreen) {
*aReturn = false;
return NS_OK;
}
}
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());

Просмотреть файл

@ -418,6 +418,47 @@ GetWrapperCache(void* p)
return NULL;
}
struct ParentObject {
template<class T>
ParentObject(T* aObject) :
mObject(aObject),
mWrapperCache(GetWrapperCache(aObject))
{}
template<class T, template<class> class SmartPtr>
ParentObject(const SmartPtr<T>& aObject) :
mObject(aObject.get()),
mWrapperCache(GetWrapperCache(aObject.get()))
{}
ParentObject(nsISupports* aObject, nsWrapperCache* aCache) :
mObject(aObject),
mWrapperCache(aCache)
{}
nsISupports* const mObject;
nsWrapperCache* const mWrapperCache;
};
inline nsWrapperCache*
GetWrapperCache(const ParentObject& aParentObject)
{
return aParentObject.mWrapperCache;
}
template<class T>
inline nsISupports*
GetParentPointer(T* aObject)
{
return aObject;
}
inline nsISupports*
GetParentPointer(const ParentObject& aObject)
{
return aObject.mObject;
}
// Only set allowNativeWrapper to false if you really know you need it, if in
// doubt use true. Setting it to false disables security wrappers.
bool
@ -488,18 +529,18 @@ WrapObject<JSObject>(JSContext* cx, JSObject* scope, JSObject* p, JS::Value* vp)
return true;
}
template<class T>
template<typename T>
static inline JSObject*
WrapNativeParent(JSContext* cx, JSObject* scope, T* p)
WrapNativeParent(JSContext* cx, JSObject* scope, const T& p)
{
if (!p)
if (!GetParentPointer(p))
return scope;
nsWrapperCache* cache = GetWrapperCache(p);
JSObject* obj;
if (cache && (obj = cache->GetWrapper())) {
#ifdef DEBUG
qsObjectHelper helper(p, cache);
qsObjectHelper helper(GetParentPointer(p), cache);
JS::Value debugVal;
bool ok = XPCOMObjectToJsval(cx, scope, helper, NULL, false, &debugVal);
@ -509,7 +550,7 @@ WrapNativeParent(JSContext* cx, JSObject* scope, T* p)
return obj;
}
qsObjectHelper helper(p, cache);
qsObjectHelper helper(GetParentPointer(p), cache);
JS::Value v;
return XPCOMObjectToJsval(cx, scope, helper, NULL, false, &v) ?
JSVAL_TO_OBJECT(v) :

Просмотреть файл

@ -39,6 +39,126 @@
DOMInterfaces = {
'Blob': [
{
'nativeType': 'nsIDOMBlob',
'headerFile': 'nsIDOMFile.h',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'Document': [
{
'nativeType': 'nsIDocument',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'Event': [
{
'nativeType': 'nsIDOMEvent',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'EventListener': [
{
'nativeType': 'nsIDOMEventListener',
'prefable': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h'
}],
'EventTarget': [
{
'nativeType': 'nsDOMEventTargetHelper',
'hasInstanceInterface': 'nsIDOMEventTarget',
'concrete': False,
'prefable': True,
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::EventTarget',
'headerFile': 'mozilla/dom/workers/bindings/EventTarget.h',
'concrete': False
}],
'FormData': [
{
'nativeType': 'nsIDOMFormData',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'IID': [
{
'nativeType': 'nsIJSIID',
'headerFile': 'xpcjsid.h',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'InputStream': [
{
'nativeType': 'nsIInputStream',
'prefable': True,
'castable': False,
'notflattened': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'MozChannel': [
{
'nativeType': 'nsIChannel',
'prefable': True,
'castable': False,
'notflattened': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'XMLHttpRequest': [
{
'nativeType': 'nsXMLHttpRequest',
@ -75,124 +195,6 @@ DOMInterfaces = {
}],
'XMLHttpRequestUpload': [
{
'nativeType': 'nsXMLHttpRequestUpload',
'headerFile': 'nsXMLHttpRequest.h',
'prefable': True
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::XMLHttpRequestUpload',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestUpload.h'
}],
'MozChannel': [
{
'nativeType': 'nsIChannel',
'prefable': True,
'castable': False,
'notflattened': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'InputStream': [
{
'nativeType': 'nsIInputStream',
'prefable': True,
'castable': False,
'notflattened': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'Document': [
{
'nativeType': 'nsIDocument',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'Blob': [
{
'nativeType': 'nsIDOMBlob',
'headerFile': 'nsIDOMFile.h',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'FormData': [
{
'nativeType': 'nsIDOMFormData',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'EventTarget': [
{
'nativeType': 'nsDOMEventTargetHelper',
'hasInstanceInterface': 'nsIDOMEventTarget',
'concrete': False,
'prefable': True,
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::EventTarget',
'headerFile': 'mozilla/dom/workers/bindings/EventTarget.h',
'concrete': False
}],
'Event': [
{
'nativeType': 'nsIDOMEvent',
'prefable': True,
'castable': False
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
}],
'EventListener': [
{
'nativeType': 'nsIDOMEventListener',
'prefable': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h'
}],
'XMLHttpRequestEventTarget': [
{
'nativeType': 'nsXHREventTarget',
@ -219,18 +221,16 @@ DOMInterfaces = {
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestEventTarget.h'
}],
'IID': [
'XMLHttpRequestUpload': [
{
'nativeType': 'nsIJSIID',
'headerFile': 'xpcjsid.h',
'prefable': True,
'castable': False
'nativeType': 'nsXMLHttpRequestUpload',
'headerFile': 'nsXMLHttpRequest.h',
'prefable': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
'castable': False
'nativeType': 'mozilla::dom::workers::XMLHttpRequestUpload',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestUpload.h'
}],
}

Просмотреть файл

@ -1414,132 +1414,173 @@ class CGArgumentConverter(CGThing):
self.descriptor))
).substitute(self.replacementVariables)
def getWrapTemplateForTypeImpl(type, result, descriptorProvider,
resultAlreadyAddRefed):
def getWrapTemplateForType(type, descriptorProvider, result, successCode):
"""
Reflect a C++ value stored in "result", of IDL type "type" into JS. The
"successCode" is the code to run once we have successfully done the
conversion. The resulting string should be used with string.Template, it
needs the following keys when substituting: jsvalPtr/jsvalRef/obj.
"""
haveSuccessCode = successCode is not None
if not haveSuccessCode:
successCode = "return true;"
def setValue(value, callWrapValue=False):
"""
Returns the code to set the jsval to value. If "callWrapValue" is true
JS_WrapValue will be called on the jsval.
"""
if not callWrapValue:
tail = successCode
elif haveSuccessCode:
tail = ("if (!JS_WrapValue(cx, ${jsvalPtr})) {\n" +
" return false;\n" +
"}\n" +
successCode)
else:
tail = "return JS_WrapValue(cx, ${jsvalPtr});"
return ("${jsvalRef} = %s;\n" +
tail) % (value)
def wrapAndSetPtr(wrapCall, failureCode=None):
"""
Returns the code to set the jsval by calling "wrapCall". "failureCode"
is the code to run if calling "wrapCall" fails
"""
if failureCode is None:
if not haveSuccessCode:
return "return " + wrapCall + ";"
failureCode = "return false;"
str = ("if (!%s) {\n" +
CGIndenter(CGGeneric(failureCode)).define() + "\n" +
"}\n" +
successCode) % (wrapCall)
return str
if type is None or type.isVoid():
return """
${jsvalRef} = JSVAL_VOID;
return true;"""
return setValue("JSVAL_VOID")
if type.isSequence() or type.isArray():
raise TypeError("Can't handle sequence or array return values yet")
if type.isInterface() and not type.isArrayBuffer():
descriptor = descriptorProvider.getDescriptor(type.unroll().inner.identifier.name)
wrappingCode = ("""
if (!%s) {
${jsvalRef} = JSVAL_NULL;
return true;
}""" % result) if type.nullable() else ""
if type.nullable():
wrappingCode = ("if (!%s) {\n" % (result) +
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
"}\n")
else:
wrappingCode = ""
if descriptor.castable and not type.unroll().inner.isExternal():
wrappingCode += """
if (WrapNewBindingObject(cx, obj, %s, ${jsvalPtr})) {
return true;
}""" % result
wrap = "WrapNewBindingObject(cx, ${obj}, %s, ${jsvalPtr})" % result
# We don't support prefable stuff in workers.
assert(not descriptor.prefable or not descriptor.workers)
if not descriptor.prefable:
# Non-prefable bindings can only fail to wrap as a new-binding object
# if they already threw an exception. Same thing for
# non-prefable bindings.
wrappingCode += """
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;"""
failed = ("MOZ_ASSERT(JS_IsExceptionPending(cx));\n" +
"return false;")
else:
# Try old-style wrapping for bindings which might be preffed off.
wrappingCode += """
return HandleNewBindingWrappingFailure(cx, obj, %s, ${jsvalPtr});""" % result
failed = wrapAndSetPtr("HandleNewBindingWrappingFailure(cx, ${obj}, %s, ${jsvalPtr})" % result)
wrappingCode += wrapAndSetPtr(wrap, failed)
else:
if descriptor.notflattened:
getIID = "&NS_GET_IID(%s), " % descriptor.nativeType
else:
getIID = ""
wrappingCode += """
return WrapObject(cx, obj, %s, %s${jsvalPtr});""" % (result, getIID)
wrap = "WrapObject(cx, ${obj}, %s, %s${jsvalPtr})" % (result, getIID)
wrappingCode += wrapAndSetPtr(wrap)
return wrappingCode
if type.isString():
if type.nullable():
return """
return xpc::StringToJsval(cx, %s, ${jsvalPtr});""" % result
return wrapAndSetPtr("xpc::StringToJsval(cx, %s, ${jsvalPtr})" % result)
else:
return """
return xpc::NonVoidStringToJsval(cx, %s, ${jsvalPtr});""" % result
return wrapAndSetPtr("xpc::NonVoidStringToJsval(cx, %s, ${jsvalPtr})" % result)
if type.isEnum():
if type.nullable():
raise TypeError("We don't support nullable enumerated return types "
"yet")
return """
MOZ_ASSERT(uint32_t(%(result)s) < ArrayLength(%(strings)s));
JSString* result_str = JS_NewStringCopyN(cx, %(strings)s[uint32_t(%(result)s)].value, %(strings)s[uint32_t(%(result)s)].length);
if (!result_str) {
return false;
}
${jsvalRef} = JS::StringValue(result_str);
return true;""" % { "result" : result,
"strings" : type.inner.identifier.name + "Values::strings" }
return """MOZ_ASSERT(uint32_t(%(result)s) < ArrayLength(%(strings)s));
JSString* %(resultStr)s = JS_NewStringCopyN(cx, %(strings)s[uint32_t(%(result)s)].value, %(strings)s[uint32_t(%(result)s)].length);
if (!%(resultStr)s) {
return false;
}
""" % { "result" : result,
"resultStr" : result + "_str",
"strings" : type.inner.identifier.name + "Values::strings" } + setValue("JS::StringValue(%s_str)" % result)
if type.isCallback() and not type.isInterface():
# XXXbz we're going to assume that callback types are always
# nullable and always have [TreatNonCallableAsNull] for now.
# See comments in WrapNewBindingObject explaining why we need
# to wrap here.
return """
${jsvalRef} = JS::ObjectOrNullValue(%s);
return JS_WrapValue(cx, ${jsvalPtr});""" % result
return setValue("JS::ObjectOrNullValue(%s)" % result, True)
if type.tag() == IDLType.Tags.any:
# See comments in WrapNewBindingObject explaining why we need
# to wrap here.
return """
${jsvalRef} = %s;\n
return JS_WrapValue(cx, ${jsvalPtr});""" % result
return setValue(result, True)
if not type.isPrimitive():
raise TypeError("Need to learn to wrap %s" % type)
if type.nullable():
return """
if (%s.IsNull()) {
${jsvalRef} = JSVAL_NULL;
return true;
}
%s""" % (result, getWrapTemplateForTypeImpl(type.inner, "%s.Value()" % result,
descriptorProvider,
resultAlreadyAddRefed))
return ("if (%s.IsNull()) {\n" % result +
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
"}\n" +
getWrapTemplateForType(type.inner, descriptorProvider,
"%s.Value()" % result, successCode))
tag = type.tag()
if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16,
IDLType.Tags.uint16, IDLType.Tags.int32]:
return """
${jsvalRef} = INT_TO_JSVAL(int32_t(%s));
return true;""" % result
return setValue("INT_TO_JSVAL(int32_t(%s))" % result)
elif tag in [IDLType.Tags.int64, IDLType.Tags.uint64, IDLType.Tags.float,
IDLType.Tags.double]:
# XXXbz will cast to double do the "even significand" thing that webidl
# calls for for 64-bit ints? Do we care?
return """
return JS_NewNumberValue(cx, double(%s), ${jsvalPtr});""" % result
return wrapAndSetPtr("JS_NewNumberValue(cx, double(%s), ${jsvalPtr})" % result)
elif tag == IDLType.Tags.uint32:
return """
${jsvalRef} = UINT_TO_JSVAL(%s);
return true;""" % result
return setValue("UINT_TO_JSVAL(%s)" % result)
elif tag == IDLType.Tags.bool:
return """
${jsvalRef} = BOOLEAN_TO_JSVAL(%s);
return true;""" % result
return setValue("BOOLEAN_TO_JSVAL(%s)" % result)
else:
raise TypeError("Need to learn to wrap primitive: %s" % type)
def getWrapTemplateForType(type, descriptorProvider, resultAlreadyAddRefed):
return getWrapTemplateForTypeImpl(type, "result", descriptorProvider,
resultAlreadyAddRefed)
def wrapForType(type, descriptorProvider, templateValues):
"""
Reflect a C++ value of IDL type "type" into JS. TemplateValues is a dict
that should contain:
* 'jsvalRef': a C++ reference to the jsval in which to store the result of
the conversion
* 'jsvalPtr': a C++ pointer to the jsval in which to store the result of
the conversion
* 'obj' (optional): the name of the variable that contains the JSObject to
use as a scope when wrapping, if not supplied 'obj'
will be used as the name
* 'result' (optional): the name of the variable in which the C++ value is
stored, if not supplied 'result' will be used as
the name
* 'successCode' (optional): the code to run once we have successfully done
the conversion, if not supplied 'return true;'
will be used as the code
"""
wrap = getWrapTemplateForType(type, descriptorProvider,
templateValues.get('result', 'result'),
templateValues.get('successCode', None))
defaultValues = {'obj': 'obj'}
return string.Template(wrap).substitute(defaultValues, **templateValues)
class CGCallGenerator(CGThing):
"""
@ -1681,12 +1722,8 @@ class CGPerSignatureCall(CGThing):
def wrap_return_value(self):
resultTemplateValues = {'jsvalRef': '*vp', 'jsvalPtr': 'vp'}
return string.Template(
re.sub(unindenter,
"",
getWrapTemplateForType(self.returnType, self.descriptor,
self.resultAlreadyAddRefed))
).substitute(resultTemplateValues)
return wrapForType(self.returnType, self.descriptor,
resultTemplateValues)
def getErrorReport(self):
return 'return ThrowMethodFailedWithDetails<%s>(cx, rv, "%s", "%s");'\
@ -1695,7 +1732,7 @@ class CGPerSignatureCall(CGThing):
self.idlNode.identifier.name)
def define(self):
return (self.cgRoot.define() + self.wrap_return_value())
return (self.cgRoot.define() + "\n" + self.wrap_return_value())
class CGSwitch(CGList):
"""

Просмотреть файл

@ -72,9 +72,8 @@ let DOMContactManager = {
x = a.properties[msg.findOptions.sortBy][0].toLowerCase();
if (b.properties[msg.findOptions.sortBy])
y = b.properties[msg.findOptions.sortBy][0].toLowerCase();
if (msg.findOptions == 'ascending')
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
let result = x.localeCompare(y);
return msg.findOptions.sortOrder == 'ascending' ? result : -result;
}
debug("Fallback DOMContactManager::receiveMessage " + aMessage.name);
let msg = aMessage.json;

Просмотреть файл

@ -131,15 +131,20 @@ USING_INDEXEDDB_NAMESPACE
const int MaxArrayCollapse = 3;
const int MaxRecursionDepth = 256;
nsresult
Key::EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset)
Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
PRUint8 aTypeOffset, PRUint16 aRecursionDepth)
{
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
PR_STATIC_ASSERT(eMaxType * MaxArrayCollapse < 256);
if (JSVAL_IS_STRING(aVal)) {
nsDependentJSString str;
if (!str.init(aCx, aVal)) {
return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
EncodeString(str, aTypeOffset);
return NS_OK;
@ -183,7 +188,8 @@ Key::EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset)
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
nsresult rv = EncodeJSVal(aCx, val, aTypeOffset);
nsresult rv = EncodeJSValInternal(aCx, val, aTypeOffset,
aRecursionDepth + 1);
NS_ENSURE_SUCCESS(rv, rv);
aTypeOffset = 0;
@ -205,9 +211,12 @@ Key::EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset)
// static
nsresult
Key::DecodeJSVal(const unsigned char*& aPos, const unsigned char* aEnd,
JSContext* aCx, PRUint8 aTypeOffset, jsval* aVal)
Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
JSContext* aCx, PRUint8 aTypeOffset, jsval* aVal,
PRUint16 aRecursionDepth)
{
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
if (*aPos - aTypeOffset >= eArray) {
JSObject* array = JS_NewArrayObject(aCx, 0, nsnull);
if (!array) {
@ -225,7 +234,8 @@ Key::DecodeJSVal(const unsigned char*& aPos, const unsigned char* aEnd,
uint32_t index = 0;
while (aPos < aEnd && *aPos - aTypeOffset != eTerminator) {
jsval val;
nsresult rv = DecodeJSVal(aPos, aEnd, aCx, aTypeOffset, &val);
nsresult rv = DecodeJSValInternal(aPos, aEnd, aCx, aTypeOffset,
&val, aRecursionDepth + 1);
NS_ENSURE_SUCCESS(rv, rv);
aTypeOffset = 0;
@ -269,7 +279,6 @@ Key::DecodeJSVal(const unsigned char*& aPos, const unsigned char* aEnd,
return NS_OK;
}
#define ONE_BYTE_LIMIT 0x7E
#define TWO_BYTE_LIMIT (0x3FFF+0x7F)

Просмотреть файл

@ -291,15 +291,23 @@ private:
}
// Encoding functions. These append the encoded value to the end of mBuffer
nsresult EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset);
inline nsresult EncodeJSVal(JSContext* aCx, const jsval aVal,
PRUint8 aTypeOffset)
{
return EncodeJSValInternal(aCx, aVal, aTypeOffset, 0);
}
void EncodeString(const nsAString& aString, PRUint8 aTypeOffset);
void EncodeNumber(double aFloat, PRUint8 aType);
// Decoding functions. aPos points into mBuffer and is adjusted to point
// past the consumed value.
static nsresult DecodeJSVal(const unsigned char*& aPos,
const unsigned char* aEnd, JSContext* aCx,
PRUint8 aTypeOffset, jsval* aVal);
static inline nsresult DecodeJSVal(const unsigned char*& aPos,
const unsigned char* aEnd, JSContext* aCx,
PRUint8 aTypeOffset, jsval* aVal)
{
return DecodeJSValInternal(aPos, aEnd, aCx, aTypeOffset, aVal, 0);
}
static void DecodeString(const unsigned char*& aPos,
const unsigned char* aEnd,
nsString& aString);
@ -307,6 +315,15 @@ private:
const unsigned char* aEnd);
nsCString mBuffer;
private:
nsresult EncodeJSValInternal(JSContext* aCx, const jsval aVal,
PRUint8 aTypeOffset, PRUint16 aRecursionDepth);
static nsresult DecodeJSValInternal(const unsigned char*& aPos,
const unsigned char* aEnd,
JSContext* aCx, PRUint8 aTypeOffset,
jsval* aVal, PRUint16 aRecursionDepth);
};
END_INDEXEDDB_NAMESPACE

Просмотреть файл

@ -0,0 +1,7 @@
<script>
var a = [];
a[0] = a;
mozIndexedDB.cmp.bind(mozIndexedDB)(a, a);
</script>

Просмотреть файл

@ -0,0 +1 @@
load 726376-1.html

Просмотреть файл

@ -70,7 +70,7 @@ interface nsIDOMFile;
interface nsIFile;
interface nsIDOMTouch;
[scriptable, uuid(f75d0a14-e278-4716-a151-637862451a2f)]
[scriptable, uuid(2e5a1f37-786b-4a52-b0e3-f711ee2268a8)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -1149,4 +1149,13 @@ interface nsIDOMWindowUtils : nsISupports {
* The caller of this method must have UniversalXPConnect privileges.
*/
void setScrollPositionClampingScrollPortSize(in float aWidth, in float aHeight);
/**
* Mark if the window is an application window or not.
* This should only be set for top-level mozApp or mozBrowser frames.
* It should not be set for other frames unless you want a frame (and its
* children) to have a different value for IsPartOfApp than the frame's
* parent.
*/
void setIsApp(in boolean value);
};

Просмотреть файл

@ -444,7 +444,7 @@ ContentParent::ContentParent()
nsCString buildID(gAppData->buildID);
//Sending all information to content process
SendAppInfo(version, buildID);
unused << SendAppInfo(version, buildID);
}
}
@ -730,10 +730,10 @@ ContentParent::Observe(nsISupports* aSubject,
unused << SendPMemoryReportRequestConstructor();
}
else if (!strcmp(aTopic, "child-gc-request")){
SendGarbageCollect();
unused << SendGarbageCollect();
}
else if (!strcmp(aTopic, "child-cc-request")){
SendCycleCollect();
unused << SendCycleCollect();
}
else if (!strcmp(aTopic, "last-pb-context-exited")) {
unused << SendLastPrivateDocShellDestroyed();

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsCoreAnimationSupport.h"
#endif
#include "mozilla/unused.h"
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsDataHashtable.h"
@ -305,7 +306,7 @@ public:
nsresult HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled);
#endif
void DidComposite() { SendNPP_DidComposite(); }
void DidComposite() { unused << SendNPP_DidComposite(); }
private:
// Create an appropriate platform surface for a background of size

Просмотреть файл

@ -90,11 +90,11 @@ public:
NSOpenGLPFAAccelerated,
NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFADoubleBuffer,
(NSOpenGLPixelFormatAttribute)nil
0
};
if (!gUseDoubleBufferedWindows) {
attribs[2] = (NSOpenGLPixelFormatAttribute)nil;
attribs[2] = 0;
}
mPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];

Просмотреть файл

@ -20,10 +20,10 @@ include pngsuite-transparency/reftest.list
include pngsuite-zlib/reftest.list
# BMP tests
include bmp/reftest.list
skip-if(Android) include bmp/reftest.list
# ICO tests
include ico/reftest.list
skip-if(Android) include ico/reftest.list
# JPEG tests
include jpeg/reftest.list
@ -44,5 +44,5 @@ include generic/reftest.list
include color-management/reftest.list
# Lossless encoders
include encoders-lossless/reftest.list
skip-if(Android) include encoders-lossless/reftest.list

Просмотреть файл

@ -321,47 +321,19 @@ endif
endif
ifeq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU)))
VPATH += $(srcdir)/assembler \
$(srcdir)/assembler/wtf \
$(srcdir)/assembler/jit \
$(srcdir)/yarr \
$(NULL)
CPPSRCS += ExecutableAllocator.cpp \
ExecutableAllocatorPosix.cpp \
OSAllocatorOS2.cpp \
OSAllocatorPosix.cpp \
OSAllocatorWin.cpp \
PageBlock.cpp \
YarrInterpreter.cpp \
YarrPattern.cpp \
YarrSyntaxChecker.cpp \
$(NULL)
else
###############################################
# BEGIN include sources for the Nitro assembler
#
ENABLE_YARR_JIT = 1
VPATH += $(srcdir)/assembler \
$(srcdir)/assembler/wtf \
$(srcdir)/assembler/jit \
$(srcdir)/assembler/assembler \
$(srcdir)/methodjit \
$(srcdir)/yarr \
$(NONE)
CPPSRCS += ExecutableAllocator.cpp \
ARMAssembler.cpp \
MacroAssemblerARM.cpp \
MacroAssemblerX86Common.cpp \
PageBlock.cpp \
YarrInterpreter.cpp \
YarrJIT.cpp \
YarrPattern.cpp \
YarrSyntaxChecker.cpp \
$(NONE)
@ -386,6 +358,19 @@ CPPSRCS += ExecutableAllocatorOS2.cpp \
$(NONE)
endif
ifneq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU)))
ENABLE_YARR_JIT = 1
VPATH += $(srcdir)/assembler/assembler \
$(srcdir)/methodjit \
$(NONE)
CPPSRCS += ARMAssembler.cpp \
MacroAssemblerARM.cpp \
MacroAssemblerX86Common.cpp \
YarrJIT.cpp \
$(NONE)
ifeq (86, $(findstring 86,$(TARGET_CPU)))
ifeq (x86_64, $(TARGET_CPU))
#CPPSRCS += only_on_x86_64.cpp
@ -396,12 +381,13 @@ endif
ifeq (arm, $(TARGET_CPU))
#CPPSRCS += only_on_arm.cpp
endif
endif
#
# END enclude sources for the Nitro assembler
#############################################
endif
ifdef JS_HAS_CTYPES
VPATH += $(srcdir)/ctypes

Просмотреть файл

@ -15,6 +15,8 @@
#include "methodjit/MethodJIT.h"
#include "vm/Stack-inl.h"
using namespace js;
using namespace JS;

Просмотреть файл

@ -117,6 +117,7 @@ xpcshell-tests:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--tests-root-dir=$(testxpcobjdir) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
--xunit-suite-name=xpcshell \
$(EXTRA_TEST_ARGS) \
@ -147,6 +148,7 @@ check-interactive:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--test-path=$(SOLO_FILE) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--profile-name=$(MOZ_APP_NAME) \
--interactive \
$(LIBXUL_DIST)/bin/xpcshell \
@ -160,6 +162,7 @@ check-one:
--symbols-path=$(DIST)/crashreporter-symbols \
--build-info-json=$(DEPTH)/mozinfo.json \
--test-path=$(SOLO_FILE) \
--testing-modules-dir=$(DEPTH)/_tests/modules \
--profile-name=$(MOZ_APP_NAME) \
--verbose \
$(EXTRA_TEST_ARGS) \
@ -1549,6 +1552,25 @@ endif
endif
################################################################################
# Copy testing-only JS modules to appropriate destination.
#
# For each file defined in TESTING_JS_MODULES, copy it to
# objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path
# wlll be appended to the output directory.
ifdef TESTING_JS_MODULES
testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
GENERATED_DIRS += $(testmodulesdir)
libs:: $(TESTING_JS_MODULES)
ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
endif
endif
################################################################################
# SDK

Просмотреть файл

@ -280,7 +280,16 @@ if test -n "$gonkdir" ; then
STLPORT_CPPFLAGS="-I$gonkdir/external/stlport/stlport"
STLPORT_LIBS="-lstlport"
CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/arch-arm/include -isystem $gonkdir/bionic/libc/kernel/arch-arm -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic $CPPFLAGS"
case "$target_cpu" in
arm)
ARCH_DIR=arch-arm
;;
i?86)
ARCH_DIR=arch-x86
;;
esac
CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic $CPPFLAGS"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS $STLPORT_CPPFLAGS"
LIBS="$LIBS $STLPORT_LIBS"
@ -1634,12 +1643,16 @@ if test "$GNU_CC"; then
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
# -Werror=unused-result - enforces __attribute__((warn_unused_result));
# Seldom used in system headers, but frequently in Mozilla code to
# enforce checking of fallible methods.
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
MOZ_C_SUPPORTS_WARNING(-W, error=unused-result, ac_c_has_werror_unused_result)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-unused - lots of violations in third-party code
# -Wno-overlength-strings - we exceed the minimum maximum length frequently
@ -1698,11 +1711,13 @@ if test "$GNU_CXX"; then
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
# -Werror=unused-result - see above
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
MOZ_CXX_SUPPORTS_WARNING(-W, error=unused-result, ac_cxx_has_werror_unused_result)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-ctor-dtor-privacy - ???

Просмотреть файл

@ -166,23 +166,29 @@ HeapValue::set(JSCompartment *comp, const Value &v)
}
inline void
HeapValue::writeBarrierPost(const Value &value, void *addr)
HeapValue::writeBarrierPost(const Value &value, Value *addr)
{
#ifdef JSGC_GENERATIONAL
#endif
}
inline void
HeapValue::writeBarrierPost(JSCompartment *comp, const Value &value, void *addr)
HeapValue::writeBarrierPost(JSCompartment *comp, const Value &value, Value *addr)
{
#ifdef JSGC_GENERATIONAL
#endif
}
inline void
HeapValue::post()
{
writeBarrierPost(value, &value);
}
inline void
HeapValue::post(JSCompartment *comp)
{
writeBarrierPost(comp, value, &value);
}
inline
@ -196,6 +202,7 @@ RelocatableValue::RelocatableValue(const Value &v)
: EncapsulatedValue(v)
{
JS_ASSERT(!IsPoisonedValue(v));
post();
}
inline
@ -203,12 +210,14 @@ RelocatableValue::RelocatableValue(const RelocatableValue &v)
: EncapsulatedValue(v.value)
{
JS_ASSERT(!IsPoisonedValue(v.value));
post();
}
inline
RelocatableValue::~RelocatableValue()
{
pre();
relocate();
}
inline RelocatableValue &
@ -217,6 +226,7 @@ RelocatableValue::operator=(const Value &v)
pre();
JS_ASSERT(!IsPoisonedValue(v));
value = v;
post();
return *this;
}
@ -226,9 +236,31 @@ RelocatableValue::operator=(const RelocatableValue &v)
pre();
JS_ASSERT(!IsPoisonedValue(v.value));
value = v.value;
post();
return *this;
}
inline void
RelocatableValue::post()
{
#ifdef JSGC_GENERATIONAL
#endif
}
inline void
RelocatableValue::post(JSCompartment *comp)
{
#ifdef JSGC_GENERATIONAL
#endif
}
inline void
RelocatableValue::relocate()
{
#ifdef JSGC_GENERATIONAL
#endif
}
inline
HeapSlot::HeapSlot(JSObject *obj, uint32_t slot, const Value &v)
: EncapsulatedValue(v)

Просмотреть файл

@ -357,8 +357,8 @@ class HeapValue : public EncapsulatedValue
*/
inline void set(JSCompartment *comp, const Value &v);
static inline void writeBarrierPost(const Value &v, void *addr);
static inline void writeBarrierPost(JSCompartment *comp, const Value &v, void *addr);
static inline void writeBarrierPost(const Value &v, Value *addr);
static inline void writeBarrierPost(JSCompartment *comp, const Value &v, Value *addr);
private:
inline void post();
@ -375,6 +375,14 @@ class RelocatableValue : public EncapsulatedValue
inline RelocatableValue &operator=(const Value &v);
inline RelocatableValue &operator=(const RelocatableValue &v);
static inline void writeBarrierPost(const Value &v, Value *addr);
static inline void writeBarrierPost(JSCompartment *comp, const Value &v, Value *addr);
private:
inline void post();
inline void post(JSCompartment *comp);
inline void relocate();
};
class HeapSlot : public EncapsulatedValue

Просмотреть файл

@ -599,6 +599,9 @@ Statistics::endSlice()
void
Statistics::beginPhase(Phase phase)
{
/* Guard against re-entry */
JS_ASSERT(!phaseStartTimes[phase]);
phaseStartTimes[phase] = PRMJ_Now();
phaseStartFaults[phase] = gc::GetPageFaultCount();
@ -614,6 +617,7 @@ Statistics::endPhase(Phase phase)
int64_t t = PRMJ_Now() - phaseStartTimes[phase];
slices.back().phaseTimes[phase] += t;
phaseTimes[phase] += t;
phaseStartTimes[phase] = 0;
size_t faults = gc::GetPageFaultCount() - phaseStartFaults[phase];
slices.back().phaseFaults[phase] += faults;

Просмотреть файл

@ -3501,9 +3501,6 @@ JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind,
extern JS_PUBLIC_API(void)
JS_GC(JSRuntime *rt);
extern JS_PUBLIC_API(void)
JS_CompartmentGC(JSRuntime *rt, JSCompartment *comp);
extern JS_PUBLIC_API(void)
JS_MaybeGC(JSContext *cx);

Просмотреть файл

@ -3449,7 +3449,6 @@ IncrementalMarkSlice(JSRuntime *rt, int64_t budget, JSGCInvocationKind gckind, b
*shouldSweep = false;
if (rt->gcIncrementalState == MARK) {
gcstats::AutoPhase ap(rt->gcStats, gcstats::PHASE_MARK);
SliceBudget sliceBudget(budget);
/* If we needed delayed marking for gray roots, then collect until done. */
@ -3466,7 +3465,11 @@ IncrementalMarkSlice(JSRuntime *rt, int64_t budget, JSGCInvocationKind gckind, b
}
#endif
bool finished = rt->gcMarker.drainMarkStack(sliceBudget);
bool finished;
{
gcstats::AutoPhase ap(rt->gcStats, gcstats::PHASE_MARK);
finished = rt->gcMarker.drainMarkStack(sliceBudget);
}
if (finished) {
JS_ASSERT(rt->gcMarker.isDrained());
if (initialState == MARK && !rt->gcLastMarkSlice && budget != SliceBudget::Unlimited) {

Просмотреть файл

@ -48,6 +48,7 @@
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "RegExpStatics-inl.h"
inline js::RegExpObject &

Просмотреть файл

@ -1,12 +0,0 @@
Originally written by: Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2005 University of Cambridge. All rights reserved.
Adapted for JavaScriptCore and WebKit by Apple Inc.
Copyright (c) 2005, 2006, 2007 Apple Inc. All rights reserved.

Просмотреть файл

@ -1,35 +0,0 @@
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed.
Copyright (c) 1997-2005 University of Cambridge. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the name of Apple
Inc. nor the names of their contributors may be used to endorse or
promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Просмотреть файл

@ -1,96 +0,0 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This file is automatically written by the dftables auxiliary
program. If you edit it by hand, you might like to edit the Makefile to
prevent its ever being regenerated.
This file contains the default tables for characters with codes less than
128 (ASCII characters). These tables are used when no external tables are
passed to PCRE. */
const unsigned char jsc_pcre_default_tables[480] = {
/* This table is a lower casing table. */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* This table is a case flipping table. */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* This table contains bit maps for various character classes.
Each map is 32 bytes long and the bits run from the least
significant end of each byte. The classes are: space, digit, word. */
0x00, 0x3E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
0xFE, 0xFF, 0xFF, 0x87, 0xFE, 0xFF, 0xFF, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* This table identifies various classes of character by individual bits:
0x01 white space character
0x08 hexadecimal digit
0x10 alphanumeric or '_'
*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - ' */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ( - / */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /* 0 - 7 */
0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 - ? */
0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, /* @ - G */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* H - O */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* P - W */
0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, /* X - _ */
0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, /* ` - g */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* h - o */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* p - w */
0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}; /* x -127 */
/* End of chartables.c */

Просмотреть файл

@ -1,273 +0,0 @@
#!/usr/bin/perl -w
#
# This is JavaScriptCore's variant of the PCRE library. While this library
# started out as a copy of PCRE, many of the features of PCRE have been
# removed. This library now supports only the regular expression features
# required by the JavaScript language specification, and has only the functions
# needed by JavaScriptCore and the rest of WebKit.
#
# Originally written by Philip Hazel
# Copyright (c) 1997-2006 University of Cambridge
# Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# -----------------------------------------------------------------------------
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the University of Cambridge nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# This is a freestanding support program to generate a file containing
# character tables. The tables are built according to the default C
# locale.
use strict;
use File::Basename;
use File::Spec;
use File::Temp qw(tempfile);
use Getopt::Long;
sub readHeaderValues();
my %pcre_internal;
if (scalar(@ARGV) < 1) {
print STDERR "Usage: ", basename($0), " [--preprocessor=program] output-file\n";
exit 1;
}
my $outputFile;
my $preprocessor;
GetOptions('preprocessor=s' => \$preprocessor);
if (not $preprocessor) {
$preprocessor = "cpp";
}
$outputFile = $ARGV[0];
die('Must specify output file.') unless defined($outputFile);
readHeaderValues();
open(OUT, ">", $outputFile) or die "$!";
binmode(OUT);
printf(OUT
"/*************************************************\n" .
"* Perl-Compatible Regular Expressions *\n" .
"*************************************************/\n\n" .
"/* This file is automatically written by the dftables auxiliary \n" .
"program. If you edit it by hand, you might like to edit the Makefile to \n" .
"prevent its ever being regenerated.\n\n");
printf(OUT
"This file contains the default tables for characters with codes less than\n" .
"128 (ASCII characters). These tables are used when no external tables are\n" .
"passed to PCRE. */\n\n" .
"const unsigned char jsc_pcre_default_tables[%d] = {\n\n" .
"/* This table is a lower casing table. */\n\n", $pcre_internal{tables_length});
if ($pcre_internal{lcc_offset} != 0) {
die "lcc_offset != 0";
}
printf(OUT " ");
for (my $i = 0; $i < 128; $i++) {
if (($i & 7) == 0 && $i != 0) {
printf(OUT "\n ");
}
printf(OUT "0x%02X", ord(lc(chr($i))));
if ($i != 127) {
printf(OUT ", ");
}
}
printf(OUT ",\n\n");
printf(OUT "/* This table is a case flipping table. */\n\n");
if ($pcre_internal{fcc_offset} != 128) {
die "fcc_offset != 128";
}
printf(OUT " ");
for (my $i = 0; $i < 128; $i++) {
if (($i & 7) == 0 && $i != 0) {
printf(OUT "\n ");
}
my $c = chr($i);
printf(OUT "0x%02X", $c =~ /[[:lower:]]/ ? ord(uc($c)) : ord(lc($c)));
if ($i != 127) {
printf(OUT ", ");
}
}
printf(OUT ",\n\n");
printf(OUT
"/* This table contains bit maps for various character classes.\n" .
"Each map is 32 bytes long and the bits run from the least\n" .
"significant end of each byte. The classes are: space, digit, word. */\n\n");
if ($pcre_internal{cbits_offset} != $pcre_internal{fcc_offset} + 128) {
die "cbits_offset != fcc_offset + 128";
}
my @cbit_table = (0) x $pcre_internal{cbit_length};
for (my $i = ord('0'); $i <= ord('9'); $i++) {
$cbit_table[$pcre_internal{cbit_digit} + $i / 8] |= 1 << ($i & 7);
}
$cbit_table[$pcre_internal{cbit_word} + ord('_') / 8] |= 1 << (ord('_') & 7);
for (my $i = 0; $i < 128; $i++) {
my $c = chr($i);
if ($c =~ /[[:alnum:]]/) {
$cbit_table[$pcre_internal{cbit_word} + $i / 8] |= 1 << ($i & 7);
}
if ($c =~ /[[:space:]]/) {
$cbit_table[$pcre_internal{cbit_space} + $i / 8] |= 1 << ($i & 7);
}
}
printf(OUT " ");
for (my $i = 0; $i < $pcre_internal{cbit_length}; $i++) {
if (($i & 7) == 0 && $i != 0) {
if (($i & 31) == 0) {
printf(OUT "\n");
}
printf(OUT "\n ");
}
printf(OUT "0x%02X", $cbit_table[$i]);
if ($i != $pcre_internal{cbit_length} - 1) {
printf(OUT ", ");
}
}
printf(OUT ",\n\n");
printf(OUT
"/* This table identifies various classes of character by individual bits:\n" .
" 0x%02x white space character\n" .
" 0x%02x hexadecimal digit\n" .
" 0x%02x alphanumeric or '_'\n*/\n\n",
$pcre_internal{ctype_space}, $pcre_internal{ctype_xdigit}, $pcre_internal{ctype_word});
if ($pcre_internal{ctypes_offset} != $pcre_internal{cbits_offset} + $pcre_internal{cbit_length}) {
die "ctypes_offset != cbits_offset + cbit_length";
}
printf(OUT " ");
for (my $i = 0; $i < 128; $i++) {
my $x = 0;
my $c = chr($i);
if ($c =~ /[[:space:]]/) {
$x += $pcre_internal{ctype_space};
}
if ($c =~ /[[:xdigit:]]/) {
$x += $pcre_internal{ctype_xdigit};
}
if ($c =~ /[[:alnum:]_]/) {
$x += $pcre_internal{ctype_word};
}
printf(OUT "0x%02X", $x);
if ($i != 127) {
printf(OUT ", ");
} else {
printf(OUT "};");
}
if (($i & 7) == 7) {
printf(OUT " /* ");
my $d = chr($i - 7);
if ($d =~ /[[:print:]]/) {
printf(OUT " %c -", $i - 7);
} else {
printf(OUT "%3d-", $i - 7);
}
if ($c =~ m/[[:print:]]/) {
printf(OUT " %c ", $i);
} else {
printf(OUT "%3d", $i);
}
printf(OUT " */\n");
if ($i != 127) {
printf(OUT " ");
}
}
}
if ($pcre_internal{tables_length} != $pcre_internal{ctypes_offset} + 128) {
die "tables_length != ctypes_offset + 128";
}
printf(OUT "\n\n/* End of chartables.c */\n");
close(OUT);
exit 0;
sub readHeaderValues()
{
my @variables = qw(
cbit_digit
cbit_length
cbit_space
cbit_word
cbits_offset
ctype_space
ctype_word
ctype_xdigit
ctypes_offset
fcc_offset
lcc_offset
tables_length
);
local $/ = undef;
my $headerPath = File::Spec->catfile(dirname($0), "pcre_internal.h");
my ($fh, $tempFile) = tempfile(
basename($0) . "-XXXXXXXX",
DIR => File::Spec->tmpdir(),
SUFFIX => ".in",
UNLINK => 0,
);
print $fh "#define DFTABLES\n\n";
open(HEADER, "<", $headerPath) or die "$!";
print $fh <HEADER>;
close(HEADER);
print $fh "\n\n";
for my $v (@variables) {
print $fh "\$pcre_internal{\"$v\"} = $v;\n";
}
close($fh);
open(CPP, "$preprocessor \"$tempFile\" |") or die "$!";
my $content = <CPP>;
close(CPP);
eval $content;
die "$@" if $@;
unlink $tempFile;
}

Просмотреть файл

@ -1,76 +0,0 @@
/* This is the public header file for JavaScriptCore's variant of the PCRE
library. While this library started out as a copy of PCRE, many of the
features of PCRE have been removed. This library now supports only the
regular expression features required by the JavaScript language
specification, and has only the functions needed by JavaScriptCore and the
rest of WebKit.
Copyright (c) 1997-2005 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
// FIXME: This file needs to be renamed to JSRegExp.h; it's no longer PCRE.
#ifndef JSRegExp_h
#define JSRegExp_h
// Last remnants from the JSWTFBridge.
#include "assembler/wtf/Platform.h"
#include "jsstr.h"
#include "jsprvtd.h"
#include "jstl.h"
typedef jschar UChar;
typedef JSLinearString UString;
struct JSRegExp;
struct JSContext;
enum JSRegExpIgnoreCaseOption { JSRegExpDoNotIgnoreCase, JSRegExpIgnoreCase };
enum JSRegExpMultilineOption { JSRegExpSingleLine, JSRegExpMultiline };
/* jsRegExpExecute error codes */
const int JSRegExpErrorNoMatch = -1;
const int JSRegExpErrorHitLimit = -2;
const int JSRegExpErrorInternal = -4;
JSRegExp* jsRegExpCompile(
const UChar* pattern, int patternLength,
JSRegExpIgnoreCaseOption, JSRegExpMultilineOption,
unsigned* numSubpatterns, int *error);
int jsRegExpExecute(JSContext *, const JSRegExp*,
const UChar* subject, int subjectLength, int startOffset,
int* offsetsVector, int offsetsVectorLength);
void jsRegExpFree(JSRegExp*);
#endif

Просмотреть файл

@ -1,12 +0,0 @@
# Perl Compatible Regular Expressions - Qt4 build info
VPATH += $$PWD
INCLUDEPATH += $$PWD $$OUTPUT_DIR/JavaScriptCore/tmp
DEPENDPATH += $$PWD
SOURCES += \
pcre_compile.cpp \
pcre_exec.cpp \
pcre_tables.cpp \
pcre_ucp_searchfuncs.cpp \
pcre_xclass.cpp

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,434 +0,0 @@
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This header contains definitions that are shared between the different
modules, but which are not relevant to the exported API. This includes some
functions whose names all begin with "_pcre_". */
#ifndef PCRE_INTERNAL_H
#define PCRE_INTERNAL_H
/* Bit definitions for entries in the pcre_ctypes table. */
#define ctype_space 0x01
#define ctype_xdigit 0x08
#define ctype_word 0x10 /* alphameric or '_' */
/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
of bits for a class map. Some classes are built by combining these tables. */
#define cbit_space 0 /* \s */
#define cbit_digit 32 /* \d */
#define cbit_word 64 /* \w */
#define cbit_length 96 /* Length of the cbits table */
/* Offsets of the various tables from the base tables pointer, and
total length. */
#define lcc_offset 0
#define fcc_offset 128
#define cbits_offset 256
#define ctypes_offset (cbits_offset + cbit_length)
#define tables_length (ctypes_offset + 128)
#ifndef DFTABLES
#include "pcre.h"
/* The value of LINK_SIZE determines the number of bytes used to store links as
offsets within the compiled regex. The default is 2, which allows for compiled
patterns up to 64K long. */
#define LINK_SIZE 3
/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
inline, and there are *still* stupid compilers about that don't like indented
pre-processor statements, or at least there were when I first wrote this. After
all, it had only been about 10 years then... */
#ifdef DEBUG
#define DPRINTF(p) /*printf p; fflush(stdout);*/
#else
#define DPRINTF(p) /*nothing*/
#endif
/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
in big-endian order) by default. These are used, for example, to link from the
start of a subpattern to its alternatives and its end. The use of 2 bytes per
offset limits the size of the compiled regex to around 64K, which is big enough
for almost everybody. However, I received a request for an even bigger limit.
For this reason, and also to make the code easier to maintain, the storing and
loading of offsets from the byte string is now handled by the functions that are
defined here. */
/* PCRE uses some other 2-byte quantities that do not change when the size of
offsets changes. There are used for repeat counts and for other things such as
capturing parenthesis numbers in back references. */
static inline void put2ByteValue(unsigned char* opcodePtr, int value)
{
JS_ASSERT(value >= 0 && value <= 0xFFFF);
opcodePtr[0] = value >> 8;
opcodePtr[1] = value;
}
static inline void put3ByteValue(unsigned char* opcodePtr, int value)
{
JS_ASSERT(value >= 0 && value <= 0xFFFFFF);
opcodePtr[0] = value >> 16;
opcodePtr[1] = value >> 8;
opcodePtr[2] = value;
}
static inline int get2ByteValue(const unsigned char* opcodePtr)
{
return (opcodePtr[0] << 8) | opcodePtr[1];
}
static inline int get3ByteValue(const unsigned char* opcodePtr)
{
return (opcodePtr[0] << 16) | (opcodePtr[1] << 8) | opcodePtr[2];
}
static inline void put2ByteValueAndAdvance(unsigned char*& opcodePtr, int value)
{
put2ByteValue(opcodePtr, value);
opcodePtr += 2;
}
static inline void put3ByteValueAndAdvance(unsigned char*& opcodePtr, int value)
{
put3ByteValue(opcodePtr, value);
opcodePtr += 3;
}
static inline void putLinkValueAllowZero(unsigned char* opcodePtr, int value)
{
#if LINK_SIZE == 3
put3ByteValue(opcodePtr, value);
#elif LINK_SIZE == 2
put2ByteValue(opcodePtr, value);
#else
# error LINK_SIZE not supported.
#endif
}
static inline int getLinkValueAllowZero(const unsigned char* opcodePtr)
{
#if LINK_SIZE == 3
return get3ByteValue(opcodePtr);
#elif LINK_SIZE == 2
return get2ByteValue(opcodePtr);
#else
# error LINK_SIZE not supported.
#endif
}
#define MAX_PATTERN_SIZE 4096 * 1024 // Derived by empirical testing of compile time in PCRE and WREC.
JS_STATIC_ASSERT(MAX_PATTERN_SIZE < (1 << (8 * LINK_SIZE)));
static inline void putLinkValue(unsigned char* opcodePtr, int value)
{
JS_ASSERT(value);
putLinkValueAllowZero(opcodePtr, value);
}
static inline int getLinkValue(const unsigned char* opcodePtr)
{
int value = getLinkValueAllowZero(opcodePtr);
JS_ASSERT(value);
return value;
}
static inline void putLinkValueAndAdvance(unsigned char*& opcodePtr, int value)
{
putLinkValue(opcodePtr, value);
opcodePtr += LINK_SIZE;
}
static inline void putLinkValueAllowZeroAndAdvance(unsigned char*& opcodePtr, int value)
{
putLinkValueAllowZero(opcodePtr, value);
opcodePtr += LINK_SIZE;
}
// FIXME: These are really more of a "compiled regexp state" than "regexp options"
enum RegExpOptions {
UseFirstByteOptimizationOption = 0x40000000, /* firstByte is set */
UseRequiredByteOptimizationOption = 0x20000000, /* reqByte is set */
UseMultiLineFirstByteOptimizationOption = 0x10000000, /* start after \n for multiline */
IsAnchoredOption = 0x02000000, /* can't use partial with this regex */
IgnoreCaseOption = 0x00000001,
MatchAcrossMultipleLinesOption = 0x00000002
};
/* Flags added to firstByte or reqByte; a "non-literal" item is either a
variable-length repeat, or a anything other than literal characters. */
#define REQ_IGNORE_CASE 0x0100 /* indicates should ignore case */
#define REQ_VARY 0x0200 /* reqByte followed non-literal item */
/* Miscellaneous definitions */
/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain UTF-8 characters with values greater than 255. */
#define XCL_NOT 0x01 /* Flag: this is a negative class */
#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
#define XCL_END 0 /* Marks end of individual items */
#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
their negation. Also, they must appear in the same order as in the opcode
definitions below, up to ESC_w. The final one must be
ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
tests in the code for an escape > ESC_b and <= ESC_w to
detect the types that may be repeated. These are the types that consume
characters. If any new escapes are put in between that don't consume a
character, that code will have to change. */
enum { ESC_B = 1, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w, ESC_REF };
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above.
Note that whenever this list is updated, the two macro definitions that follow
must also be updated to match. */
#define FOR_EACH_OPCODE(macro) \
macro(END) \
\
, macro(NOT_WORD_BOUNDARY) \
, macro(WORD_BOUNDARY) \
, macro(NOT_DIGIT) \
, macro(DIGIT) \
, macro(NOT_WHITESPACE) \
, macro(WHITESPACE) \
, macro(NOT_WORDCHAR) \
, macro(WORDCHAR) \
\
, macro(NOT_NEWLINE) \
\
, macro(CIRC) \
, macro(DOLL) \
, macro(BOL) \
, macro(EOL) \
, macro(CHAR) \
, macro(CHAR_IGNORING_CASE) \
, macro(ASCII_CHAR) \
, macro(ASCII_LETTER_IGNORING_CASE) \
, macro(NOT) \
\
, macro(STAR) \
, macro(MINSTAR) \
, macro(PLUS) \
, macro(MINPLUS) \
, macro(QUERY) \
, macro(MINQUERY) \
, macro(UPTO) \
, macro(MINUPTO) \
, macro(EXACT) \
\
, macro(NOTSTAR) \
, macro(NOTMINSTAR) \
, macro(NOTPLUS) \
, macro(NOTMINPLUS) \
, macro(NOTQUERY) \
, macro(NOTMINQUERY) \
, macro(NOTUPTO) \
, macro(NOTMINUPTO) \
, macro(NOTEXACT) \
\
, macro(TYPESTAR) \
, macro(TYPEMINSTAR) \
, macro(TYPEPLUS) \
, macro(TYPEMINPLUS) \
, macro(TYPEQUERY) \
, macro(TYPEMINQUERY) \
, macro(TYPEUPTO) \
, macro(TYPEMINUPTO) \
, macro(TYPEEXACT) \
\
, macro(CRSTAR) \
, macro(CRMINSTAR) \
, macro(CRPLUS) \
, macro(CRMINPLUS) \
, macro(CRQUERY) \
, macro(CRMINQUERY) \
, macro(CRRANGE) \
, macro(CRMINRANGE) \
\
, macro(CLASS) \
, macro(NCLASS) \
, macro(XCLASS) \
\
, macro(REF) \
\
, macro(ALT) \
, macro(KET) \
, macro(KETRMAX) \
, macro(KETRMIN) \
\
, macro(ASSERT) \
, macro(ASSERT_NOT) \
\
, macro(BRAZERO) \
, macro(BRAMINZERO) \
, macro(BRANUMBER) \
, macro(BRA)
#define OPCODE_ENUM_VALUE(opcode) OP_##opcode
enum { FOR_EACH_OPCODE(OPCODE_ENUM_VALUE) };
/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and
study.c that all opcodes are less than 128 in value. This makes handling UTF-8
character sequences easier. */
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts higher than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */
/* FIXME: Note that OP_BRA + 100 is > 128, so the two comments above
are in conflict! */
#define EXTRACT_BASIC_MAX 100
/* The code vector runs on as long as necessary after the end. */
struct JSRegExp {
unsigned options;
unsigned short topBracket;
unsigned short topBackref;
unsigned short firstByte;
unsigned short reqByte;
};
/* Internal shared data tables. These are tables that are used by more than one
of the exported public functions. They have to be "external" in the C sense,
but are not part of the PCRE public API. The data for these tables is in the
pcre_tables.c module. */
#define jsc_pcre_utf8_table1_size 6
extern const int jsc_pcre_utf8_table1[6];
extern const int jsc_pcre_utf8_table2[6];
extern const int jsc_pcre_utf8_table3[6];
extern const unsigned char jsc_pcre_utf8_table4[0x40];
extern const unsigned char jsc_pcre_default_tables[tables_length];
static inline unsigned char toLowerCase(unsigned char c)
{
static const unsigned char* lowerCaseChars = jsc_pcre_default_tables + lcc_offset;
return lowerCaseChars[c];
}
static inline unsigned char flipCase(unsigned char c)
{
static const unsigned char* flippedCaseChars = jsc_pcre_default_tables + fcc_offset;
return flippedCaseChars[c];
}
static inline unsigned char classBitmapForChar(unsigned char c)
{
static const unsigned char* charClassBitmaps = jsc_pcre_default_tables + cbits_offset;
return charClassBitmaps[c];
}
static inline unsigned char charTypeForChar(unsigned char c)
{
const unsigned char* charTypeMap = jsc_pcre_default_tables + ctypes_offset;
return charTypeMap[c];
}
static inline bool isWordChar(UChar c)
{
return c < 128 && (charTypeForChar(c) & ctype_word);
}
static inline bool isSpaceChar(UChar c)
{
return (c < 128 && (charTypeForChar(c) & ctype_space)) || c == 0x00A0;
}
static inline bool isNewline(UChar nl)
{
return (nl == 0xA || nl == 0xD || nl == 0x2028 || nl == 0x2029);
}
static inline bool isBracketStartOpcode(unsigned char opcode)
{
if (opcode >= OP_BRA)
return true;
switch (opcode) {
case OP_ASSERT:
case OP_ASSERT_NOT:
return true;
default:
return false;
}
}
static inline void advanceToEndOfBracket(const unsigned char*& opcodePtr)
{
JS_ASSERT(isBracketStartOpcode(*opcodePtr) || *opcodePtr == OP_ALT);
do
opcodePtr += getLinkValue(opcodePtr + 1);
while (*opcodePtr == OP_ALT);
}
/* Internal shared functions. These are functions that are used in more
that one of the source files. They have to have external linkage, but
but are not part of the public API and so not exported from the library. */
extern int jsc_pcre_ucp_othercase(unsigned);
extern bool jsc_pcre_xclass(int, const unsigned char*);
#endif
#endif
/* End of pcre_internal.h */

Просмотреть файл

@ -1,71 +0,0 @@
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains some fixed tables that are used by more than one of the
PCRE code modules. */
#include "pcre_internal.h"
/*************************************************
* Tables for UTF-8 support *
*************************************************/
/* These are the breakpoints for different numbers of bytes in a UTF-8
character. */
const int jsc_pcre_utf8_table1[6] =
{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
/* These are the indicator bits and the mask for the data bits to set in the
first byte of a character, indexed by the number of additional bytes. */
const int jsc_pcre_utf8_table2[6] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
const int jsc_pcre_utf8_table3[6] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
/* Table of the number of extra characters, indexed by the first character
masked with 0x3f. The highest number for a valid UTF-8 character is in fact
0x3d. */
const unsigned char jsc_pcre_utf8_table4[0x40] = {
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
#include "chartables.c"

Просмотреть файл

@ -1,98 +0,0 @@
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains code for searching the table of Unicode character
properties. */
#include "pcre_internal.h"
#include "ucpinternal.h" /* Internal table details */
#include "ucptable.cpp" /* The table itself */
/*************************************************
* Search table and return other case *
*************************************************/
/* If the given character is a letter, and there is another case for the
letter, return the other case. Otherwise, return -1.
Arguments:
c the character value
Returns: the other case or -1 if none
*/
int jsc_pcre_ucp_othercase(unsigned c)
{
int bot = 0;
int top = sizeof(ucp_table) / sizeof(cnode);
int mid;
/* The table is searched using a binary chop. You might think that using
intermediate variables to hold some of the common expressions would speed
things up, but tests with gcc 3.4.4 on Linux showed that, on the contrary, it
makes things a lot slower. */
for (;;) {
if (top <= bot)
return -1;
mid = (bot + top) >> 1;
if (c == (ucp_table[mid].f0 & f0_charmask))
break;
if (c < (ucp_table[mid].f0 & f0_charmask))
top = mid;
else {
if ((ucp_table[mid].f0 & f0_rangeflag) && (c <= (ucp_table[mid].f0 & f0_charmask) + (ucp_table[mid].f1 & f1_rangemask)))
break;
bot = mid + 1;
}
}
/* Found an entry in the table. Return -1 for a range entry. Otherwise return
the other case if there is one, else -1. */
if (ucp_table[mid].f0 & f0_rangeflag)
return -1;
int offset = ucp_table[mid].f1 & f1_casemask;
if (offset & f1_caseneg)
offset |= f1_caseneg;
return !offset ? -1 : c + offset;
}

Просмотреть файл

@ -1,114 +0,0 @@
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains an internal function that is used to match an extended
class (one that contains characters whose values are > 255). */
#include "pcre_internal.h"
/*************************************************
* Match character against an XCLASS *
*************************************************/
/* This function is called to match a character against an extended class that
might contain values > 255.
Arguments:
c the character
data points to the flag byte of the XCLASS data
Returns: true if character matches, else false
*/
/* Get the next UTF-8 character, advancing the pointer. This is called when we
know we are in UTF-8 mode. */
static inline void getUTF8CharAndAdvancePointer(int& c, const unsigned char*& subjectPtr)
{
c = *subjectPtr++;
if ((c & 0xc0) == 0xc0) {
int gcaa = jsc_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
int gcss = 6 * gcaa;
c = (c & jsc_pcre_utf8_table3[gcaa]) << gcss;
while (gcaa-- > 0) {
gcss -= 6;
c |= (*subjectPtr++ & 0x3f) << gcss;
}
}
}
bool jsc_pcre_xclass(int c, const unsigned char* data)
{
bool negated = (*data & XCL_NOT);
/* Character values < 256 are matched against a bitmap, if one is present. If
not, we still carry on, because there may be ranges that start below 256 in the
additional data. */
if (c < 256) {
if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)
return !negated; /* char found */
}
/* First skip the bit map if present. Then match against the list of Unicode
properties or large chars or ranges that end with a large char. We won't ever
encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
if ((*data++ & XCL_MAP) != 0)
data += 32;
int t;
while ((t = *data++) != XCL_END) {
if (t == XCL_SINGLE) {
int x;
getUTF8CharAndAdvancePointer(x, data);
if (c == x)
return !negated;
}
else if (t == XCL_RANGE) {
int x, y;
getUTF8CharAndAdvancePointer(x, data);
getUTF8CharAndAdvancePointer(y, data);
if (c >= x && c <= y)
return !negated;
}
}
return negated; /* char did not match */
}

Просмотреть файл

@ -1,126 +0,0 @@
/* This is JavaScriptCore's variant of the PCRE library. While this library
started out as a copy of PCRE, many of the features of PCRE have been
removed. This library now supports only the regular expression features
required by the JavaScript language specification, and has only the functions
needed by JavaScriptCore and the rest of WebKit.
Originally written by Philip Hazel
Copyright (c) 1997-2006 University of Cambridge
Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/*************************************************
* Unicode Property Table handler *
*************************************************/
/* Internal header file defining the layout of the bits in each pair of 32-bit
words that form a data item in the table. */
typedef struct cnode {
unsigned f0;
unsigned f1;
} cnode;
/* Things for the f0 field */
#define f0_scriptmask 0xff000000 /* Mask for script field */
#define f0_scriptshift 24 /* Shift for script value */
#define f0_rangeflag 0x00f00000 /* Flag for a range item */
#define f0_charmask 0x001fffff /* Mask for code point value */
/* Things for the f1 field */
#define f1_typemask 0xfc000000 /* Mask for char type field */
#define f1_typeshift 26 /* Shift for the type field */
#define f1_rangemask 0x0000ffff /* Mask for a range offset */
#define f1_casemask 0x0000ffff /* Mask for a case offset */
#define f1_caseneg 0xffff8000 /* Bits for negation */
/* The data consists of a vector of structures of type cnode. The two unsigned
32-bit integers are used as follows:
(f0) (1) The most significant byte holds the script number. The numbers are
defined by the enum in ucp.h.
(2) The 0x00800000 bit is set if this entry defines a range of characters.
It is not set if this entry defines a single character
(3) The 0x00600000 bits are spare.
(4) The 0x001fffff bits contain the code point. No Unicode code point will
ever be greater than 0x0010ffff, so this should be OK for ever.
(f1) (1) The 0xfc000000 bits contain the character type number. The numbers are
defined by an enum in ucp.h.
(2) The 0x03ff0000 bits are spare.
(3) The 0x0000ffff bits contain EITHER the unsigned offset to the top of
range if this entry defines a range, OR the *signed* offset to the
character's "other case" partner if this entry defines a single
character. There is no partner if the value is zero.
-------------------------------------------------------------------------------
| script (8) |.|.|.| codepoint (21) || type (6) |.|.| spare (8) | offset (16) |
-------------------------------------------------------------------------------
| | | | |
| | |-> spare | |-> spare
| | |
| |-> spare |-> spare
|
|-> range flag
The upper/lower casing information is set only for characters that come in
pairs. The non-one-to-one mappings in the Unicode data are ignored.
When searching the data, proceed as follows:
(1) Set up for a binary chop search.
(2) If the top is not greater than the bottom, the character is not in the
table. Its type must therefore be "Cn" ("Undefined").
(3) Find the middle vector element.
(4) Extract the code point and compare. If equal, we are done.
(5) If the test character is smaller, set the top to the current point, and
goto (2).
(6) If the current entry defines a range, compute the last character by adding
the offset, and see if the test character is within the range. If it is,
we are done.
(7) Otherwise, set the bottom to one element past the current point and goto
(2).
*/
/* End of ucpinternal.h */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -204,7 +204,7 @@ xpc_UnmarkGrayContext(JSContext *cx)
if (cx) {
JSObject *global = JS_GetGlobalObject(cx);
xpc_UnmarkGrayObject(global);
if (JS_IsInRequest(JS_GetRuntime(cx))) {
if (global && JS_IsInRequest(JS_GetRuntime(cx))) {
JSObject *scope = JS_GetGlobalForScopeChain(cx);
if (scope != global)
xpc_UnmarkGrayObject(scope);

Просмотреть файл

@ -644,7 +644,7 @@ RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
}
nsRefPtr<LayerManager> lm =
nsContentUtils::LayerManagerForDocument(mFrameLoader->OwnerDoc());
nsContentUtils::LayerManagerForDocument(mFrameLoader->GetOwnerDoc());
ShadowLayerManager* slm = lm->AsShadowManager();
if (!slm) {
*aBackendType = LayerManager::LAYERS_NONE;

Просмотреть файл

@ -631,21 +631,21 @@ nsSVGOuterSVGFrame::AttributeChanged(PRInt32 aNameSpaceID,
} else if (aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height) {
nsIFrame* embeddingFrame;
if (IsRootOfReplacedElementSubDoc(&embeddingFrame) && embeddingFrame) {
if (DependsOnIntrinsicSize(embeddingFrame)) {
// Tell embeddingFrame's presShell it needs to be reflowed (which takes
// care of reflowing us too).
embeddingFrame->PresContext()->PresShell()->
FrameNeedsReflow(embeddingFrame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
}
// else our width and height is overridden - don't reflow anything
} else {
// We are not embedded by reference, so our 'width' and 'height'
// attributes are not overridden - we need to reflow.
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
nsIFrame* embeddingFrame;
if (IsRootOfReplacedElementSubDoc(&embeddingFrame) && embeddingFrame) {
if (DependsOnIntrinsicSize(embeddingFrame)) {
// Tell embeddingFrame's presShell it needs to be reflowed (which takes
// care of reflowing us too).
embeddingFrame->PresContext()->PresShell()->
FrameNeedsReflow(embeddingFrame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
}
// else our width and height is overridden - don't reflow anything
} else {
// We are not embedded by reference, so our 'width' and 'height'
// attributes are not overridden - we need to reflow.
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
}
}
}

Просмотреть файл

@ -71,6 +71,7 @@ endif
EXPORTS_NAMESPACES = mozilla
EXPORTS_mozilla = \
fallible.h \
mozalloc.h \
mozalloc_abort.h \
mozalloc_macro_wrappers.h \

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_fallible_h
#define mozilla_fallible_h
namespace mozilla {
struct fallible_t { };
} // namespace mozilla
#endif // mozilla_fallible_h

Просмотреть файл

@ -52,6 +52,10 @@
#endif
#include "xpcom-config.h"
#if defined(__cplusplus)
#include "mozilla/fallible.h"
#endif
#define MOZALLOC_HAVE_XMALLOC
#if defined(MOZALLOC_EXPORT)
@ -291,12 +295,6 @@ void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_E
* (4) the matching system |operator delete(void*) throw(std::bad_alloc)|
*/
namespace mozilla {
struct MOZALLOC_EXPORT fallible_t { };
} /* namespace mozilla */
MOZALLOC_INLINE
void* operator new(size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
{

Просмотреть файл

@ -761,3 +761,6 @@ pref("ui.zooming.animation_frames", "");
// Enable accessibility mode if platform accessibility is enabled.
pref("accessibility.accessfu", 2);
// Mobile manages state by autodetection
pref("network.manage-offline-status", true);

Просмотреть файл

@ -1063,6 +1063,23 @@ abstract public class GeckoApp
accessibilityManager.sendAccessibilityEvent(accEvent);
}
});
} else if (event.equals("Accessibility:Ready")) {
mMainHandler.post(new Runnable() {
public void run() {
JSONObject ret = new JSONObject();
AccessibilityManager accessibilityManager =
(AccessibilityManager) mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
try {
ret.put("enabled", accessibilityManager.isEnabled());
// XXX: A placeholder for future explore by touch support.
ret.put("exploreByTouch", false);
} catch (Exception ex) {
Log.e(LOGTAG, "Error building JSON arguments for Accessibility:Ready:", ex);
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:Settings",
ret.toString()));
}
});
}
} catch (Exception e) {
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
@ -1695,6 +1712,7 @@ abstract public class GeckoApp
GeckoAppShell.registerGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Bookmark:Insert", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Accessibility:Event", GeckoApp.mAppContext);
GeckoAppShell.registerGeckoEventListener("Accessibility:Ready", GeckoApp.mAppContext);
if (SmsManager.getInstance() != null) {
SmsManager.getInstance().start();
@ -2039,6 +2057,8 @@ abstract public class GeckoApp
GeckoAppShell.unregisterGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Bookmark:Insert", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Accessibility:Event", GeckoApp.mAppContext);
GeckoAppShell.unregisterGeckoEventListener("Accessibility:Ready", GeckoApp.mAppContext);
if (mFavicons != null)
mFavicons.close();

Просмотреть файл

@ -73,7 +73,6 @@ import android.webkit.MimeTypeMap;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.provider.Settings;
import android.view.accessibility.AccessibilityManager;
import android.opengl.GLES20;
import android.util.*;
@ -1844,16 +1843,6 @@ public class GeckoAppShell
return promptServiceResult;
}
if (type.equals("Accessibility:IsEnabled")) {
JSONObject ret = new JSONObject();
AccessibilityManager accessibilityManager =
(AccessibilityManager) GeckoApp.mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
try {
ret.put("enabled", accessibilityManager.isEnabled());
} catch (Exception ex) { }
return ret.toString();
}
CopyOnWriteArrayList<GeckoEventListener> listeners;
synchronized (mEventListeners) {
listeners = mEventListeners.get(type);

Просмотреть файл

@ -134,6 +134,14 @@ public class ProfileMigrator {
// We use this to ignore the tags folder during migration.
private static final String ROOT_TAGS_FOLDER_NAME = "tags";
// Find the Mobile bookmarks root in places (bug 746860).
// We cannot rely on the name as that is locale-dependent.
// If it exists, it will have Id=6, fk=null, type=folder.
private static final String MOBILE_ROOT_QUERY =
"SELECT id FROM moz_bookmarks " +
"WHERE id=6 AND type=2 AND fk IS NULL AND parent=1";
private static final String MOBILE_ROOT_ID = "id";
private static final String BOOKMARK_QUERY_SELECT =
"SELECT places.url AS p_url," +
" bookmark.guid AS b_guid," +
@ -806,6 +814,22 @@ public class ProfileMigrator {
cursor.moveToNext();
}
cursor.close();
// XUL Fennec doesn't mark the Mobile folder as a root,
// so fix that up here.
cursor = db.rawQuery(MOBILE_ROOT_QUERY, null);
if (cursor.moveToFirst()) {
Log.v(LOGTAG, "Mobile root found, adding to known roots.");
final int idCol = cursor.getColumnIndex(MOBILE_ROOT_ID);
final long mobileRootId = cursor.getLong(idCol);
mRerootMap.put(mobileRootId, getFolderId(Bookmarks.MOBILE_FOLDER_GUID));
Log.v(LOGTAG, "Name: mobile, pid=" + mobileRootId
+ ", nid=" + mRerootMap.get(mobileRootId));
} else {
Log.v(LOGTAG, "Mobile root not found, is this a desktop profile?");
}
cursor.close();
} catch (SQLiteBridgeException e) {
Log.e(LOGTAG, "Failed to get bookmark roots: ", e);
// Do not try again.

Просмотреть файл

@ -127,10 +127,10 @@ public class Tabs implements GeckoEventListener {
else
GeckoApp.mAppContext.hideAboutHome();
selectedTab = tab;
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mFormAssistPopup.hide();
// Do we need to do this check?
if (isSelectedTab(tab)) {
String url = tab.getURL();
GeckoApp.mBrowserToolbar.setTitle(tab.getDisplayTitle());
@ -149,7 +149,7 @@ public class Tabs implements GeckoEventListener {
// Pass a message to Gecko to update tab state in BrowserApp
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Selected", String.valueOf(tab.getId())));
return selectedTab = tab;
return tab;
}
public int getIndexOf(Tab tab) {

Просмотреть файл

@ -40,6 +40,7 @@
package org.mozilla.gecko.db;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
import org.mozilla.gecko.db.BrowserContract.History;
@ -74,7 +75,9 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
}
private final String mProfile;
private long mMobileFolderId;
// Map of folder GUIDs to IDs. Used for caching.
private HashMap<String, Long> mFolderIdMap;
// Use wrapped Boolean so that we can have a null state
private Boolean mDesktopBookmarksExist;
@ -99,7 +102,7 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
public LocalBrowserDB(String profile) {
mProfile = profile;
mMobileFolderId = -1;
mFolderIdMap = new HashMap<String, Long>();
mDesktopBookmarksExist = null;
mBookmarksUriWithProfile = appendProfile(Bookmarks.CONTENT_URI);
@ -297,7 +300,7 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
// We always want to show mobile bookmarks in the root view.
if (folderId == Bookmarks.FIXED_ROOT_ID) {
folderId = getMobileBookmarksFolderId(cr);
folderId = getFolderIdFromGuid(cr, Bookmarks.MOBILE_FOLDER_GUID);
// We'll add a fake "Desktop Bookmarks" folder to the root view if desktop
// bookmarks exist, so that the user can still access non-mobile bookmarks.
@ -346,12 +349,16 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
Cursor c = null;
int count = 0;
try {
// Check to see if there are any bookmarks in one of our three
// fixed "Desktop Boomarks" folders.
c = cr.query(bookmarksUriWithLimit(1),
new String[] { Bookmarks._ID },
Bookmarks.PARENT + " != ? AND " +
Bookmarks.PARENT + " != ?",
new String[] { String.valueOf(getMobileBookmarksFolderId(cr)),
String.valueOf(Bookmarks.FIXED_ROOT_ID) },
Bookmarks.PARENT + " = ? OR " +
Bookmarks.PARENT + " = ? OR " +
Bookmarks.PARENT + " = ?",
new String[] { String.valueOf(getFolderIdFromGuid(cr, Bookmarks.TOOLBAR_FOLDER_GUID)),
String.valueOf(getFolderIdFromGuid(cr, Bookmarks.MENU_FOLDER_GUID)),
String.valueOf(getFolderIdFromGuid(cr, Bookmarks.UNFILED_FOLDER_GUID)) },
null);
count = c.getCount();
} finally {
@ -394,15 +401,10 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
return url;
}
private long getMobileBookmarksFolderId(ContentResolver cr) {
if (mMobileFolderId >= 0)
return mMobileFolderId;
private synchronized long getFolderIdFromGuid(ContentResolver cr, String guid) {
if (mFolderIdMap.containsKey(guid))
return mFolderIdMap.get(guid);
mMobileFolderId = getFolderIdFromGuid(cr, Bookmarks.MOBILE_FOLDER_GUID);
return mMobileFolderId;
}
private long getFolderIdFromGuid(ContentResolver cr, String guid) {
long folderId = -1;
Cursor c = null;
@ -420,6 +422,7 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
c.close();
}
mFolderIdMap.put(guid, folderId);
return folderId;
}
@ -438,7 +441,7 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
}
public void addBookmark(ContentResolver cr, String title, String uri) {
long folderId = getMobileBookmarksFolderId(cr);
long folderId = getFolderIdFromGuid(cr, Bookmarks.MOBILE_FOLDER_GUID);
if (folderId < 0)
return;

Просмотреть файл

@ -48,7 +48,7 @@ public class BufferedCairoImage extends CairoImage {
private ByteBuffer mBuffer;
private IntSize mSize;
private int mFormat;
private boolean mNeedToFreeBuffer = false;
private boolean mNeedToFreeBuffer;
/** Creates a buffered Cairo image from a byte buffer. */
public BufferedCairoImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
@ -60,18 +60,22 @@ public class BufferedCairoImage extends CairoImage {
setBitmap(bitmap);
}
protected void finalize() throws Throwable {
private void freeBuffer() {
if (mNeedToFreeBuffer && mBuffer != null)
GeckoAppShell.freeDirectBuffer(mBuffer);
mNeedToFreeBuffer = false;
mBuffer = null;
}
protected void finalize() throws Throwable {
try {
if (mNeedToFreeBuffer && mBuffer != null)
GeckoAppShell.freeDirectBuffer(mBuffer);
mNeedToFreeBuffer = false;
mBuffer = null;
freeBuffer();
} finally {
super.finalize();
}
}
@Override
@Override
public ByteBuffer getBuffer() { return mBuffer; }
@Override
public IntSize getSize() { return mSize; }
@ -80,6 +84,7 @@ public class BufferedCairoImage extends CairoImage {
public void setBuffer(ByteBuffer buffer, int width, int height, int format) {
freeBuffer();
mBuffer = buffer;
mSize = new IntSize(width, height);
mFormat = format;

Просмотреть файл

@ -146,6 +146,7 @@ public class CheckerboardImage extends CairoImage {
try {
if (mBuffer != null) {
GeckoAppShell.freeDirectBuffer(mBuffer);
mBuffer = null;
}
} finally {
super.finalize();

Просмотреть файл

@ -97,7 +97,8 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
private final ScrollbarLayer mHorizScrollLayer;
private final ScrollbarLayer mVertScrollLayer;
private final FadeRunnable mFadeRunnable;
private final FloatBuffer mCoordBuffer;
private ByteBuffer mCoordByteBuffer;
private FloatBuffer mCoordBuffer;
private RenderContext mLastPageContext;
private int mMaxTextureSize;
private int mBackgroundColor;
@ -214,9 +215,22 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
// Initialize the FloatBuffer that will be used to store all vertices and texture
// coordinates in draw() commands.
ByteBuffer byteBuffer = GeckoAppShell.allocateDirectBuffer(COORD_BUFFER_SIZE * 4);
byteBuffer.order(ByteOrder.nativeOrder());
mCoordBuffer = byteBuffer.asFloatBuffer();
mCoordByteBuffer = GeckoAppShell.allocateDirectBuffer(COORD_BUFFER_SIZE * 4);
mCoordByteBuffer.order(ByteOrder.nativeOrder());
mCoordBuffer = mCoordByteBuffer.asFloatBuffer();
}
@Override
protected void finalize() throws Throwable {
try {
if (mCoordByteBuffer != null) {
GeckoAppShell.freeDirectBuffer(mCoordByteBuffer);
mCoordByteBuffer = null;
mCoordBuffer = null;
}
} finally {
super.finalize();
}
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

Просмотреть файл

@ -115,6 +115,10 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
@Override
public boolean onTouchEvent(MotionEvent event) {
/** We need to manually hide FormAssistPopup because it is not a regular PopupWindow. */
if (GeckoApp.mFormAssistPopup != null)
GeckoApp.mFormAssistPopup.hide();
return mTouchEventHandler.handleEvent(event);
}

Просмотреть файл

@ -99,14 +99,18 @@ public class ScreenshotLayer extends SingleTileLayer {
/** Creates a buffered Cairo image from a byte buffer. */
public ScreenshotImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
mBuffer = inBuffer; mSize = new IntSize(inWidth, inHeight); mFormat = inFormat;
mBuffer = inBuffer;
mSize = new IntSize(inWidth, inHeight);
mFormat = inFormat;
}
@Override
protected void finalize() throws Throwable {
try {
if (mBuffer != null)
if (mBuffer != null) {
GeckoAppShell.freeDirectBuffer(mBuffer);
mBuffer = null;
}
} finally {
super.finalize();
}

Просмотреть файл

@ -65,11 +65,9 @@ public class ScrollbarLayer extends TileLayer {
private static final int CAP_RADIUS = (BAR_SIZE / 2);
private final boolean mVertical;
private final ByteBuffer mBuffer;
private final Bitmap mBitmap;
private final Canvas mCanvas;
private float mOpacity;
private boolean mFinalized = false;
private LayerRenderer mRenderer;
private int mProgram;
@ -143,7 +141,6 @@ public class ScrollbarLayer extends TileLayer {
private ScrollbarLayer(LayerRenderer renderer, CairoImage image, boolean vertical, ByteBuffer buffer) {
super(image, TileLayer.PaintMode.NORMAL);
mVertical = vertical;
mBuffer = buffer;
mRenderer = renderer;
IntSize size = image.getSize();
@ -159,17 +156,7 @@ public class ScrollbarLayer extends TileLayer {
mCanvas.drawColor(Color.argb(0, 0, 0, 0), PorterDuff.Mode.CLEAR);
mCanvas.drawCircle(CAP_RADIUS, CAP_RADIUS, CAP_RADIUS, foregroundPaint);
mBitmap.copyPixelsToBuffer(mBuffer.asIntBuffer());
}
protected void finalize() throws Throwable {
try {
if (!mFinalized && mBuffer != null)
GeckoAppShell.freeDirectBuffer(mBuffer);
mFinalized = true;
} finally {
super.finalize();
}
mBitmap.copyPixelsToBuffer(buffer.asIntBuffer());
}
public static ScrollbarLayer create(LayerRenderer renderer, boolean vertical) {

Просмотреть файл

@ -165,19 +165,23 @@ public class SurfaceTextureLayer extends Layer implements SurfaceTexture.OnFrame
@Override
protected void finalize() throws Throwable {
if (mSurfaceTexture != null) {
try {
SurfaceTexture.class.getDeclaredMethod("release").invoke(mSurfaceTexture);
} catch (NoSuchMethodException nsme) {
Log.e(LOGTAG, "error finding release method on mSurfaceTexture", nsme);
} catch (IllegalAccessException iae) {
Log.e(LOGTAG, "error invoking release method on mSurfaceTexture", iae);
} catch (Exception e) {
Log.e(LOGTAG, "some other exception while invoking release method on mSurfaceTexture", e);
try {
if (mSurfaceTexture != null) {
try {
SurfaceTexture.class.getDeclaredMethod("release").invoke(mSurfaceTexture);
} catch (NoSuchMethodException nsme) {
Log.e(LOGTAG, "error finding release method on mSurfaceTexture", nsme);
} catch (IllegalAccessException iae) {
Log.e(LOGTAG, "error invoking release method on mSurfaceTexture", iae);
} catch (Exception e) {
Log.e(LOGTAG, "some other exception while invoking release method on mSurfaceTexture", e);
}
}
if (mTextureId > 0)
TextureReaper.get().add(mTextureId);
} finally {
super.finalize();
}
if (mTextureId > 0)
TextureReaper.get().add(mTextureId);
}
@Override

Просмотреть файл

@ -55,9 +55,8 @@ import java.nio.IntBuffer;
* Draws text on a layer. This is used for the frame rate meter.
*/
public class TextLayer extends SingleTileLayer {
private final ByteBuffer mBuffer;
private final ByteBuffer mBuffer; // this buffer is owned by the BufferedCairoImage
private final IntSize mSize;
private boolean mFinalized = false;
/*
* This awkward pattern is necessary due to Java's restrictions on when one can call superclass
@ -70,16 +69,6 @@ public class TextLayer extends SingleTileLayer {
renderText(text);
}
protected void finalize() throws Throwable {
try {
if (!mFinalized && mBuffer != null)
GeckoAppShell.freeDirectBuffer(mBuffer);
mFinalized = true;
} finally {
super.finalize();
}
}
public static TextLayer create(IntSize size, String text) {
ByteBuffer buffer = GeckoAppShell.allocateDirectBuffer(size.width * size.height * 4);
BufferedCairoImage image = new BufferedCairoImage(buffer, size.width, size.height,

Просмотреть файл

@ -81,8 +81,12 @@ public abstract class TileLayer extends Layer {
@Override
protected void finalize() throws Throwable {
if (mTextureIDs != null)
TextureReaper.get().add(mTextureIDs);
try {
if (mTextureIDs != null)
TextureReaper.get().add(mTextureIDs);
} finally {
super.finalize();
}
}
public void setPaintMode(PaintMode mode) {
@ -182,24 +186,6 @@ public abstract class TileLayer extends Layer {
// Our texture has been expanded to the next power of two.
// XXX We probably never want to take this path, so throw an exception.
throw new RuntimeException("Buffer/image size mismatch in TileLayer!");
/*
int bpp = CairoUtils.bitsPerPixelForCairoFormat(cairoFormat)/8;
ByteBuffer tempBuffer =
GeckoAppShell.allocateDirectBuffer(mSize.width * mSize.height * bpp);
for (int y = 0; y < bufferSize.height; y++) {
tempBuffer.position(y * mSize.width * bpp);
imageBuffer.limit((y + 1) * bufferSize.width * bpp);
imageBuffer.position(y * bufferSize.width * bpp);
tempBuffer.put(imageBuffer);
}
imageBuffer.position(0);
tempBuffer.position(0);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, glInfo.internalFormat, mSize.width,
mSize.height, 0, glInfo.format, glInfo.type, tempBuffer);
GeckoAppShell.freeDirectBuffer(tempBuffer);
*/
}
}

Просмотреть файл

@ -369,12 +369,10 @@ public class PanZoomController
}
cancelTouch();
startPanning(event.getX(0), event.getY(0), event.getEventTime());
GeckoApp.mFormAssistPopup.hide();
track(event);
return true;
case PANNING_HOLD_LOCKED:
GeckoApp.mFormAssistPopup.hide();
mState = PanZoomState.PANNING_LOCKED;
// fall through
case PANNING_LOCKED:
@ -382,7 +380,6 @@ public class PanZoomController
return true;
case PANNING_HOLD:
GeckoApp.mFormAssistPopup.hide();
mState = PanZoomState.PANNING;
// fall through
case PANNING:
@ -839,7 +836,6 @@ public class PanZoomController
mState = PanZoomState.PINCHING;
mLastZoomFocus = new PointF(detector.getFocusX(), detector.getFocusY());
GeckoApp.mFormAssistPopup.hide();
cancelTouch();
return true;
@ -949,7 +945,6 @@ public class PanZoomController
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
GeckoApp.mFormAssistPopup.hide();
sendPointToGecko("Gesture:SingleTap", motionEvent);
return true;
}
@ -972,8 +967,6 @@ public class PanZoomController
* pixels.
*/
private boolean animatedZoomTo(RectF zoomToRect) {
GeckoApp.mFormAssistPopup.hide();
mState = PanZoomState.ANIMATED_ZOOM;
final float startZoom = mController.getZoomFactor();

Просмотреть файл

@ -744,7 +744,7 @@ SessionStore.prototype = {
matchingEntry = {shEntry: shEntry, childDocIdents: childDocIdents};
aDocIdentMap[aEntry.docIdentifier] = matchingEntry;
} else {
shEntry.adoptBFCacheEntry(matchingEntry);
shEntry.adoptBFCacheEntry(matchingEntry.shEntry);
childDocIdents = matchingEntry.childDocIdents;
}
}

Просмотреть файл

@ -691,3 +691,6 @@ pref("browser.dom.window.dump.enabled", false);
// controls if we want camera support
pref("device.camera.enabled", true);
pref("media.realtime_decoder.enabled", true);
// Mobile manages state by autodetection
pref("network.manage-offline-status", true);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше