зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to mozilla-central a=merge
This commit is contained in:
Коммит
fd0ee7c9b8
|
@ -439,31 +439,31 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cssparser"
|
||||
version = "0.23.4"
|
||||
version = "0.23.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cssparser-macros 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.12.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cssparser-macros"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.12.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -798,7 +798,7 @@ name = "geckoservo"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1134,7 +1134,7 @@ name = "malloc_size_of"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hashglobe 0.1.0",
|
||||
"selectors 0.19.0",
|
||||
|
@ -1770,7 +1770,7 @@ name = "selectors"
|
|||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1908,7 +1908,7 @@ dependencies = [
|
|||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fallible 0.0.1",
|
||||
|
@ -1963,7 +1963,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"malloc_size_of 0.0.1",
|
||||
"malloc_size_of_derive 0.0.1",
|
||||
|
@ -1976,7 +1976,7 @@ name = "stylo_tests"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2542,8 +2542,8 @@ dependencies = [
|
|||
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
|
||||
"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
|
||||
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
|
||||
"checksum cssparser 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b906ac3f6108d8d0bfd4158469abe5909df1497116c8400346b5e08944579edd"
|
||||
"checksum cssparser-macros 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ce714f82ed2ca0e026ee351b7f25b2d70f81cf6f0f3214537a2edb67cd4d4d0"
|
||||
"checksum cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)" = "205647ffe2b63a9726a4c3bb6f31c7325e8ceff10e2f1b75a6fb7609e20419ea"
|
||||
"checksum cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f3a5383ae18dbfdeb569ed62019f5bddb2a95cd2d3833313c475a0d014777805"
|
||||
"checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea"
|
||||
"checksum cstr-macros 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f9f316203d1ea36f4f18316822806f6999aa3dc5ed1adf51e35b77e3b3933d78"
|
||||
"checksum cubeb 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a3502aafa1bf95c524f65d2ba46d8741700c6a8a9543ea52c6da3d8b69a2896"
|
||||
|
|
|
@ -172,8 +172,7 @@ XULMAP(
|
|||
return nullptr;
|
||||
|
||||
RefPtr<nsTreeColumns> treeCols = treeFrame->Columns();
|
||||
int32_t count = 0;
|
||||
treeCols->GetCount(&count);
|
||||
uint32_t count = treeCols->Count();
|
||||
|
||||
// Outline of list accessible.
|
||||
if (count == 1) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLLabelElement.h"
|
||||
#include "mozilla/dom/MouseEventBinding.h"
|
||||
|
@ -522,13 +522,12 @@ nsCoreUtils::GetTreeBoxObject(nsIContent *aContent)
|
|||
already_AddRefed<nsITreeColumn>
|
||||
nsCoreUtils::GetFirstSensibleColumn(nsITreeBoxObject *aTree)
|
||||
{
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
RefPtr<nsTreeColumns> cols;
|
||||
aTree->GetColumns(getter_AddRefs(cols));
|
||||
if (!cols)
|
||||
return nullptr;
|
||||
|
||||
nsCOMPtr<nsITreeColumn> column;
|
||||
cols->GetFirstColumn(getter_AddRefs(column));
|
||||
RefPtr<nsTreeColumn> column = cols->GetFirstColumn();
|
||||
if (column && IsColumnHidden(column))
|
||||
return GetNextSensibleColumn(column);
|
||||
|
||||
|
@ -540,21 +539,18 @@ nsCoreUtils::GetSensibleColumnCount(nsITreeBoxObject *aTree)
|
|||
{
|
||||
uint32_t count = 0;
|
||||
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
RefPtr<nsTreeColumns> cols;
|
||||
aTree->GetColumns(getter_AddRefs(cols));
|
||||
if (!cols)
|
||||
return count;
|
||||
|
||||
nsCOMPtr<nsITreeColumn> column;
|
||||
cols->GetFirstColumn(getter_AddRefs(column));
|
||||
nsTreeColumn* column = cols->GetFirstColumn();
|
||||
|
||||
while (column) {
|
||||
if (!IsColumnHidden(column))
|
||||
count++;
|
||||
|
||||
nsCOMPtr<nsITreeColumn> nextColumn;
|
||||
column->GetNext(getter_AddRefs(nextColumn));
|
||||
column.swap(nextColumn);
|
||||
column = column->GetNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
|
|
|
@ -124,12 +124,12 @@ XULTreeAccessible::Value(nsString& aValue) const
|
|||
int32_t currentIndex;
|
||||
selection->GetCurrentIndex(¤tIndex);
|
||||
if (currentIndex >= 0) {
|
||||
nsCOMPtr<nsITreeColumn> keyCol;
|
||||
RefPtr<nsTreeColumn> keyCol;
|
||||
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
RefPtr<nsTreeColumns> cols;
|
||||
mTree->GetColumns(getter_AddRefs(cols));
|
||||
if (cols)
|
||||
cols->GetKeyColumn(getter_AddRefs(keyCol));
|
||||
keyCol = cols->GetKeyColumn();
|
||||
|
||||
mTreeView->GetCellText(currentIndex, keyCol, aValue);
|
||||
}
|
||||
|
@ -166,8 +166,7 @@ XULTreeAccessible::NativeRole() const
|
|||
return roles::LIST;
|
||||
|
||||
RefPtr<nsTreeColumns> cols = treeFrame->Columns();
|
||||
nsCOMPtr<nsITreeColumn> primaryCol;
|
||||
cols->GetPrimaryColumn(getter_AddRefs(primaryCol));
|
||||
nsTreeColumn* primaryCol = cols->GetPrimaryColumn();
|
||||
|
||||
return primaryCol ? roles::OUTLINE : roles::LIST;
|
||||
}
|
||||
|
@ -618,7 +617,7 @@ XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow,
|
|||
endRow = rowCount - 1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITreeColumns> treeColumns;
|
||||
RefPtr<nsTreeColumns> treeColumns;
|
||||
mTree->GetColumns(getter_AddRefs(treeColumns));
|
||||
if (!treeColumns)
|
||||
return;
|
||||
|
@ -626,12 +625,9 @@ XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow,
|
|||
int32_t endCol = aEndCol;
|
||||
|
||||
if (endCol == -1) {
|
||||
int32_t colCount = 0;
|
||||
rv = treeColumns->GetCount(&colCount);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
endCol = colCount - 1;
|
||||
// We need to make sure to cast to int32_t before we do the subtraction, in
|
||||
// case the column count is 0.
|
||||
endCol = static_cast<int32_t>(treeColumns->Count()) - 1;
|
||||
}
|
||||
|
||||
for (int32_t rowIdx = aStartRow; rowIdx <= endRow; ++rowIdx) {
|
||||
|
@ -983,21 +979,21 @@ XULTreeItemAccessibleBase::DispatchClickEvent(nsIContent* aContent,
|
|||
if (IsDefunct())
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsITreeColumns> columns;
|
||||
RefPtr<nsTreeColumns> columns;
|
||||
mTree->GetColumns(getter_AddRefs(columns));
|
||||
if (!columns)
|
||||
return;
|
||||
|
||||
// Get column and pseudo element.
|
||||
nsCOMPtr<nsITreeColumn> column;
|
||||
RefPtr<nsTreeColumn> column;
|
||||
nsAutoString pseudoElm;
|
||||
|
||||
if (aActionIndex == eAction_Click) {
|
||||
// Key column is visible and clickable.
|
||||
columns->GetKeyColumn(getter_AddRefs(column));
|
||||
column = columns->GetKeyColumn();
|
||||
} else {
|
||||
// Primary column contains a twisty we should click on.
|
||||
columns->GetPrimaryColumn(getter_AddRefs(column));
|
||||
column = columns->GetPrimaryColumn();
|
||||
pseudoElm = NS_LITERAL_STRING("twisty");
|
||||
}
|
||||
|
||||
|
@ -1028,11 +1024,10 @@ XULTreeItemAccessibleBase::IsExpandable() const
|
|||
bool isEmpty = false;
|
||||
mTreeView->IsContainerEmpty(mRow, &isEmpty);
|
||||
if (!isEmpty) {
|
||||
nsCOMPtr<nsITreeColumns> columns;
|
||||
RefPtr<nsTreeColumns> columns;
|
||||
mTree->GetColumns(getter_AddRefs(columns));
|
||||
nsCOMPtr<nsITreeColumn> primaryColumn;
|
||||
if (columns) {
|
||||
columns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
||||
nsTreeColumn* primaryColumn = columns->GetPrimaryColumn();
|
||||
if (primaryColumn &&
|
||||
!nsCoreUtils::IsColumnHidden(primaryColumn))
|
||||
return true;
|
||||
|
@ -1116,15 +1111,14 @@ XULTreeItemAccessible::Shutdown()
|
|||
role
|
||||
XULTreeItemAccessible::NativeRole() const
|
||||
{
|
||||
nsCOMPtr<nsITreeColumns> columns;
|
||||
RefPtr<nsTreeColumns> columns;
|
||||
mTree->GetColumns(getter_AddRefs(columns));
|
||||
if (!columns) {
|
||||
NS_ERROR("No tree columns object in the tree!");
|
||||
return roles::NOTHING;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITreeColumn> primaryColumn;
|
||||
columns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
||||
nsTreeColumn* primaryColumn = columns->GetPrimaryColumn();
|
||||
|
||||
return primaryColumn ? roles::OUTLINEITEM : roles::LISTITEM;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsITreeView.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "XULListboxAccessible.h"
|
||||
|
||||
class nsTreeBodyFrame;
|
||||
class nsITreeColumn;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Role.h"
|
||||
#include "States.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsTreeColumns.h"
|
||||
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIMutableArray.h"
|
||||
|
@ -211,15 +212,14 @@ XULTreeGridAccessible::UnselectRow(uint32_t aRowIdx)
|
|||
role
|
||||
XULTreeGridAccessible::NativeRole() const
|
||||
{
|
||||
nsCOMPtr<nsITreeColumns> treeColumns;
|
||||
RefPtr<nsTreeColumns> treeColumns;
|
||||
mTree->GetColumns(getter_AddRefs(treeColumns));
|
||||
if (!treeColumns) {
|
||||
NS_ERROR("No treecolumns object for tree!");
|
||||
return roles::NOTHING;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITreeColumn> primaryColumn;
|
||||
treeColumns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
||||
nsTreeColumn* primaryColumn = treeColumns->GetPrimaryColumn();
|
||||
|
||||
return primaryColumn ? roles::TREE_TABLE : roles::TABLE;
|
||||
}
|
||||
|
@ -391,15 +391,14 @@ void
|
|||
XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
|
||||
int32_t aEndColIdx)
|
||||
{
|
||||
nsCOMPtr<nsITreeColumns> treeColumns;
|
||||
RefPtr<nsTreeColumns> treeColumns;
|
||||
mTree->GetColumns(getter_AddRefs(treeColumns));
|
||||
if (!treeColumns)
|
||||
return;
|
||||
|
||||
bool nameChanged = false;
|
||||
for (int32_t colIdx = aStartColIdx; colIdx <= aEndColIdx; ++colIdx) {
|
||||
nsCOMPtr<nsITreeColumn> column;
|
||||
treeColumns->GetColumnAt(colIdx, getter_AddRefs(column));
|
||||
nsTreeColumn* column = treeColumns->GetColumnAt(colIdx);
|
||||
if (column && !nsCoreUtils::IsColumnHidden(column)) {
|
||||
XULTreeGridCellAccessible* cell = GetCellAccessible(column);
|
||||
if (cell)
|
||||
|
|
|
@ -863,6 +863,9 @@ nsContextMenu.prototype = {
|
|||
|
||||
// Open clicked-in frame in the same window.
|
||||
showOnlyThisFrame() {
|
||||
urlSecurityCheck(gContextMenuContentData.docLocation,
|
||||
this.browser.contentPrincipal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
let referrer = gContextMenuContentData.referrer;
|
||||
openWebLinkIn(gContextMenuContentData.docLocation, "current", {
|
||||
disallowInheritPrincipal: true,
|
||||
|
@ -921,6 +924,9 @@ nsContextMenu.prototype = {
|
|||
},
|
||||
|
||||
viewImageDesc(e) {
|
||||
urlSecurityCheck(this.imageDescURL,
|
||||
this.principal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
openUILink(this.imageDescURL, e, { disallowInheritPrincipal: true,
|
||||
referrerURI: gContextMenuContentData.documentURIObject,
|
||||
triggeringPrincipal: this.principal,
|
||||
|
@ -933,6 +939,10 @@ nsContextMenu.prototype = {
|
|||
},
|
||||
|
||||
reloadImage() {
|
||||
urlSecurityCheck(this.mediaURL,
|
||||
this.principal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
|
||||
this.browser.messageManager.sendAsyncMessage("ContextMenu:ReloadImage",
|
||||
null, { target: this.target });
|
||||
},
|
||||
|
@ -961,10 +971,13 @@ nsContextMenu.prototype = {
|
|||
triggeringPrincipal: systemPrincipal});
|
||||
}, Cu.reportError);
|
||||
} else {
|
||||
urlSecurityCheck(this.mediaURL,
|
||||
this.principal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
openUILink(this.mediaURL, e, { disallowInheritPrincipal: true,
|
||||
referrerURI,
|
||||
forceAllowDataURI: true,
|
||||
triggeringPrincipal: this.browser.contentPrincipal
|
||||
triggeringPrincipal: this.principal,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -1005,9 +1018,13 @@ nsContextMenu.prototype = {
|
|||
|
||||
// Change current window to the URL of the background image.
|
||||
viewBGImage(e) {
|
||||
urlSecurityCheck(this.bgImageURL,
|
||||
this.principal,
|
||||
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
|
||||
openUILink(this.bgImageURL, e, { disallowInheritPrincipal: true,
|
||||
referrerURI: gContextMenuContentData.documentURIObject,
|
||||
triggeringPrincipal: this.browser.contentPrincipal
|
||||
triggeringPrincipal: this.principal,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -394,6 +394,12 @@ var pktUI = (function() {
|
|||
// Open a new tab with a given url
|
||||
var _openTabWithUrlMessageId = "openTabWithUrl";
|
||||
pktUIMessaging.addMessageListener(iframe, _openTabWithUrlMessageId, function(panelId, data, contentPrincipal) {
|
||||
try {
|
||||
urlSecurityCheck(data.url, contentPrincipal, Services.scriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
||||
} catch (ex) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = data.url;
|
||||
openTabWithUrl(url, contentPrincipal);
|
||||
pktUIMessaging.sendResponseMessageToPanel(panelId, _openTabWithUrlMessageId, url);
|
||||
|
|
|
@ -11,6 +11,10 @@ const TEST_URI = `
|
|||
#grid {
|
||||
display: grid;
|
||||
}
|
||||
#subgrid {
|
||||
display: grid;
|
||||
grid: subgrid;
|
||||
}
|
||||
#flex {
|
||||
display: flex;
|
||||
}
|
||||
|
@ -18,13 +22,18 @@ const TEST_URI = `
|
|||
display: block;
|
||||
}
|
||||
</style>
|
||||
<div id="grid">Grid</div>
|
||||
<div id="grid">
|
||||
<div id="subgrid"></div>
|
||||
</div>
|
||||
<div id="flex">Flex</div>
|
||||
<div id="block">Block</div>
|
||||
<span>HELLO WORLD</span>
|
||||
`;
|
||||
|
||||
add_task(async function() {
|
||||
info("Enable subgrid in order to see the subgrid display type.");
|
||||
await pushPref("layout.css.grid-template-subgrid-value.enabled", true);
|
||||
|
||||
const {inspector} = await openInspectorForURL("data:text/html;charset=utf-8," +
|
||||
encodeURIComponent(TEST_URI));
|
||||
|
||||
|
@ -35,6 +44,15 @@ add_task(async function() {
|
|||
is(gridDisplayNode.textContent, "grid", "Got the correct display type for #grid.");
|
||||
is(gridDisplayNode.style.display, "inline-block", "#grid display node is shown.");
|
||||
|
||||
info("Check the display node is shown and the value of #subgrid.");
|
||||
await selectNode("#subgrid", inspector);
|
||||
const subgridContainer = await getContainerForSelector("#subgrid", inspector);
|
||||
const subgridDisplayNode = subgridContainer.elt.querySelector(
|
||||
".markupview-display-badge");
|
||||
is(subgridDisplayNode.textContent, "subgrid",
|
||||
"Got the correct display type for #subgrid");
|
||||
is(subgridDisplayNode.style.display, "inline-block", "#subgrid display node is shown");
|
||||
|
||||
info("Check the display node is shown and the value of #flex.");
|
||||
await selectNode("#flex", inspector);
|
||||
const flexContainer = await getContainerForSelector("#flex", inspector);
|
||||
|
|
|
@ -42,6 +42,7 @@ const DISPLAY_TYPES = {
|
|||
"inline-flex": INSPECTOR_L10N.getStr("markupView.display.flex.tooltiptext"),
|
||||
"grid": INSPECTOR_L10N.getStr("markupView.display.grid.tooltiptext"),
|
||||
"inline-grid": INSPECTOR_L10N.getStr("markupView.display.inlineGrid.tooltiptext"),
|
||||
"subgrid": INSPECTOR_L10N.getStr("markupView.display.subgrid.tooltiptiptext"),
|
||||
"flow-root": INSPECTOR_L10N.getStr("markupView.display.flowRoot.tooltiptext"),
|
||||
"contents": INSPECTOR_L10N.getStr("markupView.display.contents.tooltiptext2"),
|
||||
};
|
||||
|
|
|
@ -58,6 +58,11 @@ markupView.display.grid.tooltiptext=This element behaves like a block element an
|
|||
# the markup view.
|
||||
markupView.display.inlineGrid.tooltiptext=This element behaves like an inline element and lays out its content according to the grid model.
|
||||
|
||||
# LOCALIZATION NOTE (markupView.display.subgrid.tooltiptext)
|
||||
# Used in a tooltip that appears when the user hovers over the display type button in
|
||||
# the markup view.
|
||||
markupView.display.subgrid.tooltiptiptext=This element lays out its content according to the grid model but defers the definition of its rows and/or columns to its parent grid container.
|
||||
|
||||
# LOCALIZATION NOTE (markupView.display.flowRoot.tooltiptext)
|
||||
# Used in a tooltip that appears when the user hovers over the display type button in
|
||||
# the markup view.
|
||||
|
|
|
@ -41,6 +41,7 @@ tags = usercontextid
|
|||
[browser_storage_cookies_edit.js]
|
||||
[browser_storage_cookies_edit_keyboard.js]
|
||||
[browser_storage_cookies_samesite.js]
|
||||
skip-if = (os == "win" && os_version == "10.0" && !debug) # Bug 1448484
|
||||
[browser_storage_cookies_tab_navigation.js]
|
||||
[browser_storage_delete.js]
|
||||
[browser_storage_delete_all.js]
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Cu} = require("chrome");
|
||||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {nodeSpec, nodeListSpec} = require("devtools/shared/specs/node");
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { nodeSpec, nodeListSpec } = require("devtools/shared/specs/node");
|
||||
|
||||
loader.lazyRequireGetter(this, "colorUtils", "devtools/shared/css/color", true);
|
||||
|
||||
|
@ -28,6 +27,9 @@ loader.lazyRequireGetter(this, "getFontPreviewData", "devtools/server/actors/sty
|
|||
loader.lazyRequireGetter(this, "CssLogic", "devtools/server/actors/inspector/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "EventParsers", "devtools/server/actors/inspector/event-parsers", true);
|
||||
|
||||
const SUBGRID_ENABLED =
|
||||
Services.prefs.getBoolPref("layout.css.grid-template-subgrid-value.enabled");
|
||||
|
||||
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
|
||||
const FONT_FAMILY_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
|
||||
const FONT_FAMILY_PREVIEW_TEXT_SIZE = 20;
|
||||
|
@ -256,6 +258,14 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
} catch (e) {
|
||||
// Fails for <scrollbar> elements.
|
||||
}
|
||||
|
||||
if (SUBGRID_ENABLED &&
|
||||
(display === "grid" || display === "inline-grid") &&
|
||||
(style.gridTemplateRows === "subgrid" ||
|
||||
style.gridTemplateColumns === "subgrid")) {
|
||||
display = "subgrid";
|
||||
}
|
||||
|
||||
return display;
|
||||
},
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ function runTests()
|
|||
});
|
||||
|
||||
// Test if data:font is same-origin.
|
||||
let p7 = new Promise(resolve => {
|
||||
let p7 = new Promise((resolve, reject) => {
|
||||
let text = document.createElement('p');
|
||||
// Cross-domain font will not load according to [1] so we try to apply
|
||||
// data:font to this text and see if the font can be loaded.
|
||||
|
@ -154,13 +154,17 @@ function runTests()
|
|||
text.innerHTML = "This text should trigger 'TestFont' to load.";
|
||||
document.body.appendChild(text);
|
||||
|
||||
document.fonts.onloadingdone = function (fontFaceSetEvent) {
|
||||
is(fontFaceSetEvent.fontfaces.length, 1);
|
||||
document.fonts.ready.then(fontFaces => {
|
||||
is(fontFaces.size, 1, "should FontFace entry for data:font");
|
||||
fontFaces.forEach(fontFace => {
|
||||
is(fontFace.status, "loaded", "data:font should be same-origin");
|
||||
});
|
||||
resolve();
|
||||
};
|
||||
document.fonts.onloadingerror = function (fontFaceSetEvent) {
|
||||
},
|
||||
_ => {
|
||||
ok(false, "data:font is not same-origin.");
|
||||
};
|
||||
reject();
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all([p1, p2, p3, p4, p5, p6, p7]).then(() => {
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
function serviceWorkerTestExec(testFile) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
function setupSW(registration) {
|
||||
var worker = registration.waiting ||
|
||||
var worker = registration.installing ||
|
||||
registration.waiting ||
|
||||
registration.active;
|
||||
var iframe;
|
||||
|
||||
window.addEventListener("message",function onMessage(event) {
|
||||
if (event.data.context != "ServiceWorker") {
|
||||
|
@ -13,6 +15,7 @@ function serviceWorkerTestExec(testFile) {
|
|||
}
|
||||
if (event.data.type == 'finish') {
|
||||
window.removeEventListener("message", onMessage);
|
||||
iframe.remove();
|
||||
registration.unregister()
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
|
@ -23,7 +26,7 @@ function serviceWorkerTestExec(testFile) {
|
|||
|
||||
worker.onerror = reject;
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = "message_receiver.html";
|
||||
iframe.onload = function() {
|
||||
worker.postMessage({ script: testFile });
|
||||
|
@ -31,7 +34,7 @@ function serviceWorkerTestExec(testFile) {
|
|||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
navigator.serviceWorker.ready.then(setupSW);
|
||||
navigator.serviceWorker.register("worker_wrapper.js", {scope: "."});
|
||||
navigator.serviceWorker.register("worker_wrapper.js", {scope: "."})
|
||||
.then(setupSW);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -92,6 +92,8 @@ function workerTestGetUserAgent(cb) {
|
|||
});
|
||||
}
|
||||
|
||||
var completeInstall = null;
|
||||
|
||||
addEventListener('message', function workerWrapperOnMessage(e) {
|
||||
removeEventListener('message', workerWrapperOnMessage);
|
||||
var data = e.data;
|
||||
|
@ -108,7 +110,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
}
|
||||
}
|
||||
if ("ServiceWorker" in self) {
|
||||
self.clients.matchAll().then(function(clients) {
|
||||
self.clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
|
||||
for (var i = 0; i < clients.length; ++i) {
|
||||
if (clients[i].url.indexOf("message_receiver.html") > -1) {
|
||||
client = clients[i];
|
||||
|
@ -120,6 +122,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
}
|
||||
context = "ServiceWorker";
|
||||
runScript();
|
||||
completeInstall();
|
||||
});
|
||||
} else {
|
||||
client = self;
|
||||
|
@ -127,3 +130,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
runScript();
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener("install", e => {
|
||||
e.waitUntil(new Promise(resolve => completeInstall = resolve));
|
||||
})
|
||||
|
|
|
@ -1478,6 +1478,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement,
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mErrorSink->mError)
|
||||
for (uint32_t i = 0; i < tmp->mOutputStreams.Length(); ++i) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOutputStreams[i].mStream)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOutputStreams[i].mPreCreatedTracks)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlayed);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextTrackManager)
|
||||
|
@ -1725,6 +1726,14 @@ HTMLMediaElement::ShutdownDecoder()
|
|||
if (mMediaSource) {
|
||||
mMediaSource->CompletePendingTransactions();
|
||||
}
|
||||
for (OutputMediaStream& out : mOutputStreams) {
|
||||
if (!out.mCapturingDecoder) {
|
||||
continue;
|
||||
}
|
||||
out.mNextAvailableTrackID = std::max<TrackID>(
|
||||
mDecoder->NextAvailableTrackIDFor(out.mStream->GetInputStream()),
|
||||
out.mNextAvailableTrackID);
|
||||
}
|
||||
mDecoder->Shutdown();
|
||||
DDUNLINKCHILD(mDecoder.get());
|
||||
mDecoder = nullptr;
|
||||
|
@ -3538,6 +3547,7 @@ HTMLMediaElement::CaptureStreamInternal(StreamCaptureBehavior aFinishBehavior,
|
|||
out->mCapturingDecoder = true;
|
||||
mDecoder->AddOutputStream(
|
||||
out->mStream->GetInputStream()->AsProcessedStream(),
|
||||
out->mNextAvailableTrackID,
|
||||
aFinishBehavior == StreamCaptureBehavior::FINISH_WHEN_ENDED);
|
||||
} else if (mSrcStream) {
|
||||
out->mCapturingMediaStream = true;
|
||||
|
@ -3551,21 +3561,23 @@ HTMLMediaElement::CaptureStreamInternal(StreamCaptureBehavior aFinishBehavior,
|
|||
|
||||
if (mDecoder) {
|
||||
if (HasAudio()) {
|
||||
TrackID audioTrackId = mMediaInfo.mAudio.mTrackId;
|
||||
TrackID audioTrackId = out->mNextAvailableTrackID++;
|
||||
RefPtr<MediaStreamTrackSource> trackSource =
|
||||
getter->GetMediaStreamTrackSource(audioTrackId);
|
||||
RefPtr<MediaStreamTrack> track = out->mStream->CreateDOMTrack(
|
||||
audioTrackId, MediaSegment::AUDIO, trackSource);
|
||||
out->mPreCreatedTracks.AppendElement(track);
|
||||
out->mStream->AddTrackInternal(track);
|
||||
LOG(LogLevel::Debug,
|
||||
("Created audio track %d for captured decoder", audioTrackId));
|
||||
}
|
||||
if (IsVideo() && HasVideo() && !out->mCapturingAudioOnly) {
|
||||
TrackID videoTrackId = mMediaInfo.mVideo.mTrackId;
|
||||
TrackID videoTrackId = out->mNextAvailableTrackID++;
|
||||
RefPtr<MediaStreamTrackSource> trackSource =
|
||||
getter->GetMediaStreamTrackSource(videoTrackId);
|
||||
RefPtr<MediaStreamTrack> track = out->mStream->CreateDOMTrack(
|
||||
videoTrackId, MediaSegment::VIDEO, trackSource);
|
||||
out->mPreCreatedTracks.AppendElement(track);
|
||||
out->mStream->AddTrackInternal(track);
|
||||
LOG(LogLevel::Debug,
|
||||
("Created video track %d for captured decoder", videoTrackId));
|
||||
|
@ -4238,11 +4250,11 @@ HTMLMediaElement::WakeLockRelease()
|
|||
}
|
||||
|
||||
HTMLMediaElement::OutputMediaStream::OutputMediaStream()
|
||||
: mFinishWhenEnded(false)
|
||||
: mNextAvailableTrackID(1)
|
||||
, mFinishWhenEnded(false)
|
||||
, mCapturingAudioOnly(false)
|
||||
, mCapturingDecoder(false)
|
||||
, mCapturingMediaStream(false)
|
||||
, mNextAvailableTrackID(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4968,6 +4980,7 @@ HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder)
|
|||
|
||||
ms.mCapturingDecoder = true;
|
||||
aDecoder->AddOutputStream(ms.mStream->GetInputStream()->AsProcessedStream(),
|
||||
ms.mNextAvailableTrackID,
|
||||
ms.mFinishWhenEnded);
|
||||
}
|
||||
|
||||
|
@ -7944,6 +7957,21 @@ HTMLMediaElement::RemoveMediaTracks()
|
|||
}
|
||||
|
||||
mMediaTracksConstructed = false;
|
||||
|
||||
for (OutputMediaStream& ms : mOutputStreams) {
|
||||
if (!ms.mCapturingDecoder) {
|
||||
continue;
|
||||
}
|
||||
for (RefPtr<MediaStreamTrack>& t : ms.mPreCreatedTracks) {
|
||||
if (t->Ended()) {
|
||||
continue;
|
||||
}
|
||||
mAbstractMainThread->Dispatch(NewRunnableMethod(
|
||||
"dom::HTMLMediaElement::RemoveMediaTracks",
|
||||
t, &MediaStreamTrack::OverrideEnded));
|
||||
}
|
||||
ms.mPreCreatedTracks.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
class MediaElementGMPCrashHelper : public GMPCrashHelper
|
||||
|
|
|
@ -867,13 +867,18 @@ protected:
|
|||
~OutputMediaStream();
|
||||
|
||||
RefPtr<DOMMediaStream> mStream;
|
||||
TrackID mNextAvailableTrackID;
|
||||
bool mFinishWhenEnded;
|
||||
bool mCapturingAudioOnly;
|
||||
bool mCapturingDecoder;
|
||||
bool mCapturingMediaStream;
|
||||
|
||||
// The following members are keeping state for a captured MediaDecoder.
|
||||
// Tracks that were created on main thread before MediaDecoder fed them
|
||||
// to the MediaStreamGraph.
|
||||
nsTArray<RefPtr<MediaStreamTrack>> mPreCreatedTracks;
|
||||
|
||||
// The following members are keeping state for a captured MediaStream.
|
||||
TrackID mNextAvailableTrackID;
|
||||
nsTArray<Pair<nsString, RefPtr<MediaInputPort>>> mTrackPorts;
|
||||
};
|
||||
|
||||
|
|
|
@ -170,12 +170,14 @@ MediaDecoder::SetVolume(double aVolume)
|
|||
|
||||
void
|
||||
MediaDecoder::AddOutputStream(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mDecoderStateMachine, "Must be called after Load().");
|
||||
AbstractThread::AutoEnter context(AbstractMainThread());
|
||||
mDecoderStateMachine->AddOutputStream(aStream, aFinishWhenEnded);
|
||||
mDecoderStateMachine->AddOutputStream(
|
||||
aStream, aNextAvailableTrackID, aFinishWhenEnded);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -187,6 +189,15 @@ MediaDecoder::RemoveOutputStream(MediaStream* aStream)
|
|||
mDecoderStateMachine->RemoveOutputStream(aStream);
|
||||
}
|
||||
|
||||
TrackID
|
||||
MediaDecoder::NextAvailableTrackIDFor(MediaStream* aOutputStream) const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mDecoderStateMachine, "Must be called after Load().");
|
||||
AbstractThread::AutoEnter context(AbstractMainThread());
|
||||
return mDecoderStateMachine->NextAvailableTrackIDFor(aOutputStream);
|
||||
}
|
||||
|
||||
double
|
||||
MediaDecoder::GetDuration()
|
||||
{
|
||||
|
|
|
@ -170,9 +170,12 @@ public:
|
|||
// The stream is initially blocked. The decoder is responsible for unblocking
|
||||
// it while it is playing back.
|
||||
virtual void AddOutputStream(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded);
|
||||
// Remove an output stream added with AddOutputStream.
|
||||
virtual void RemoveOutputStream(MediaStream* aStream);
|
||||
// The next TrackID that can be used without risk of a collision.
|
||||
virtual TrackID NextAvailableTrackIDFor(MediaStream* aOutputStream) const;
|
||||
|
||||
// Return the duration of the video in seconds.
|
||||
virtual double GetDuration();
|
||||
|
|
|
@ -3448,6 +3448,10 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame()
|
|||
RefPtr<ShutdownPromise>
|
||||
MediaDecoderStateMachine::BeginShutdown()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mOutputStreamManager) {
|
||||
mOutputStreamManager->Clear();
|
||||
}
|
||||
return InvokeAsync(OwnerThread(), this, __func__,
|
||||
&MediaDecoderStateMachine::Shutdown);
|
||||
}
|
||||
|
@ -3826,11 +3830,12 @@ MediaDecoderStateMachine::RequestDebugInfo()
|
|||
}
|
||||
|
||||
void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
LOG("AddOutputStream aStream=%p!", aStream);
|
||||
mOutputStreamManager->Add(aStream, aFinishWhenEnded);
|
||||
mOutputStreamManager->Add(aStream, aNextAvailableTrackID, aFinishWhenEnded);
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NewRunnableMethod<bool>("MediaDecoderStateMachine::SetAudioCaptured",
|
||||
this,
|
||||
|
@ -3858,6 +3863,13 @@ void MediaDecoderStateMachine::RemoveOutputStream(MediaStream* aStream)
|
|||
}
|
||||
}
|
||||
|
||||
TrackID
|
||||
MediaDecoderStateMachine::NextAvailableTrackIDFor(MediaStream* aOutputStream) const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return mOutputStreamManager->NextAvailableTrackIDFor(aOutputStream);
|
||||
}
|
||||
|
||||
class VideoQueueMemoryFunctor : public nsDequeFunctor
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -201,9 +201,12 @@ public:
|
|||
|
||||
RefPtr<MediaDecoder::DebugInfoPromise> RequestDebugInfo();
|
||||
|
||||
void AddOutputStream(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
|
||||
void AddOutputStream(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded);
|
||||
// Remove an output stream added with AddOutputStream.
|
||||
void RemoveOutputStream(MediaStream* aStream);
|
||||
TrackID NextAvailableTrackIDFor(MediaStream* aOutputStream) const;
|
||||
|
||||
// Seeks to the decoder to aTarget asynchronously.
|
||||
RefPtr<MediaDecoder::SeekPromise> InvokeSeek(const SeekTarget& aTarget);
|
||||
|
|
|
@ -193,17 +193,22 @@ DecodedStreamData::DecodedStreamData(OutputStreamManager* aOutputStreamManager,
|
|||
, mAbstractMainThread(aMainThread)
|
||||
{
|
||||
mStream->AddListener(mListener);
|
||||
mOutputStreamManager->Connect(mStream);
|
||||
TrackID audioTrack = TRACK_NONE;
|
||||
TrackID videoTrack = TRACK_NONE;
|
||||
|
||||
// Initialize tracks.
|
||||
if (aInit.mInfo.HasAudio()) {
|
||||
mStream->AddAudioTrack(aInit.mInfo.mAudio.mTrackId,
|
||||
audioTrack = aInit.mInfo.mAudio.mTrackId;
|
||||
mStream->AddAudioTrack(audioTrack,
|
||||
aInit.mInfo.mAudio.mRate,
|
||||
0, new AudioSegment());
|
||||
}
|
||||
if (aInit.mInfo.HasVideo()) {
|
||||
mStream->AddTrack(aInit.mInfo.mVideo.mTrackId, 0, new VideoSegment());
|
||||
videoTrack = aInit.mInfo.mVideo.mTrackId;
|
||||
mStream->AddTrack(videoTrack, 0, new VideoSegment());
|
||||
}
|
||||
|
||||
mOutputStreamManager->Connect(mStream, audioTrack, videoTrack);
|
||||
}
|
||||
|
||||
DecodedStreamData::~DecodedStreamData()
|
||||
|
|
|
@ -13,29 +13,41 @@ OutputStreamData::~OutputStreamData()
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// Break the connection to the input stream if necessary.
|
||||
if (mPort) {
|
||||
mPort->Destroy();
|
||||
for (RefPtr<MediaInputPort>& port : mPorts) {
|
||||
port->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OutputStreamData::Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStream)
|
||||
OutputStreamData::Init(OutputStreamManager* aOwner,
|
||||
ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mStream = aStream;
|
||||
mNextAvailableTrackID = aNextAvailableTrackID;
|
||||
}
|
||||
|
||||
bool
|
||||
OutputStreamData::Connect(MediaStream* aStream)
|
||||
OutputStreamData::Connect(MediaStream* aStream,
|
||||
TrackID aInputAudioTrackID,
|
||||
TrackID aInputVideoTrackID)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mPort, "Already connected?");
|
||||
MOZ_ASSERT(mPorts.IsEmpty(), "Already connected?");
|
||||
|
||||
if (mStream->IsDestroyed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mPort = mStream->AllocateInputPort(aStream);
|
||||
for (TrackID tid : {aInputAudioTrackID, aInputVideoTrackID}) {
|
||||
if (tid == TRACK_NONE) {
|
||||
continue;
|
||||
}
|
||||
MOZ_ASSERT(IsTrackIDExplicit(tid));
|
||||
mPorts.AppendElement(mStream->AllocateInputPort(
|
||||
aStream, tid, mNextAvailableTrackID++));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -51,11 +63,11 @@ OutputStreamData::Disconnect()
|
|||
return false;
|
||||
}
|
||||
|
||||
// Disconnect the existing port if necessary.
|
||||
if (mPort) {
|
||||
mPort->Destroy();
|
||||
mPort = nullptr;
|
||||
// Disconnect any existing port.
|
||||
for (RefPtr<MediaInputPort>& port : mPorts) {
|
||||
port->Destroy();
|
||||
}
|
||||
mPorts.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,8 +83,16 @@ OutputStreamData::Graph() const
|
|||
return mStream->Graph();
|
||||
}
|
||||
|
||||
TrackID
|
||||
OutputStreamData::NextAvailableTrackID() const
|
||||
{
|
||||
return mNextAvailableTrackID;
|
||||
}
|
||||
|
||||
void
|
||||
OutputStreamManager::Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded)
|
||||
OutputStreamManager::Add(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// All streams must belong to the same graph.
|
||||
|
@ -84,12 +104,12 @@ OutputStreamManager::Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded)
|
|||
}
|
||||
|
||||
OutputStreamData* p = mStreams.AppendElement();
|
||||
p->Init(this, aStream);
|
||||
p->Init(this, aStream, aNextAvailableTrackID);
|
||||
|
||||
// Connect to the input stream if we have one. Otherwise the output stream
|
||||
// will be connected in Connect().
|
||||
if (mInputStream) {
|
||||
p->Connect(mInputStream);
|
||||
p->Connect(mInputStream, mInputAudioTrackID, mInputVideoTrackID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,12 +126,35 @@ OutputStreamManager::Remove(MediaStream* aStream)
|
|||
}
|
||||
|
||||
void
|
||||
OutputStreamManager::Connect(MediaStream* aStream)
|
||||
OutputStreamManager::Clear()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mStreams.Clear();
|
||||
}
|
||||
|
||||
TrackID
|
||||
OutputStreamManager::NextAvailableTrackIDFor(MediaStream* aOutputStream) const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
for (const OutputStreamData& out : mStreams) {
|
||||
if (out.Equals(aOutputStream)) {
|
||||
return out.NextAvailableTrackID();
|
||||
}
|
||||
}
|
||||
return TRACK_INVALID;
|
||||
}
|
||||
|
||||
void
|
||||
OutputStreamManager::Connect(MediaStream* aStream,
|
||||
TrackID aAudioTrackID,
|
||||
TrackID aVideoTrackID)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mInputStream = aStream;
|
||||
mInputAudioTrackID = aAudioTrackID;
|
||||
mInputVideoTrackID = aVideoTrackID;
|
||||
for (int32_t i = mStreams.Length() - 1; i >= 0; --i) {
|
||||
if (!mStreams[i].Connect(aStream)) {
|
||||
if (!mStreams[i].Connect(aStream, mInputAudioTrackID, mInputVideoTrackID)) {
|
||||
// Probably the DOMMediaStream was GCed. Clean up.
|
||||
mStreams.RemoveElementAt(i);
|
||||
}
|
||||
|
@ -123,6 +166,8 @@ OutputStreamManager::Disconnect()
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mInputStream = nullptr;
|
||||
mInputAudioTrackID = TRACK_INVALID;
|
||||
mInputVideoTrackID = TRACK_INVALID;
|
||||
for (int32_t i = mStreams.Length() - 1; i >= 0; --i) {
|
||||
if (!mStreams[i].Disconnect()) {
|
||||
// Probably the DOMMediaStream was GCed. Clean up.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "TrackID.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -21,11 +22,13 @@ class ProcessedMediaStream;
|
|||
class OutputStreamData {
|
||||
public:
|
||||
~OutputStreamData();
|
||||
void Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStream);
|
||||
void Init(OutputStreamManager* aOwner,
|
||||
ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID);
|
||||
|
||||
// Connect mStream to the input stream.
|
||||
// Connect the given input stream's audio and video tracks to mStream.
|
||||
// Return false is mStream is already destroyed, otherwise true.
|
||||
bool Connect(MediaStream* aStream);
|
||||
bool Connect(MediaStream* aStream, TrackID aAudioTrackID, TrackID aVideoTrackID);
|
||||
// Disconnect mStream from its input stream.
|
||||
// Return false is mStream is already destroyed, otherwise true.
|
||||
bool Disconnect();
|
||||
|
@ -34,12 +37,16 @@ public:
|
|||
bool Equals(MediaStream* aStream) const;
|
||||
// Return the graph mStream belongs to.
|
||||
MediaStreamGraph* Graph() const;
|
||||
// The next TrackID that will not cause a collision in mStream.
|
||||
TrackID NextAvailableTrackID() const;
|
||||
|
||||
private:
|
||||
OutputStreamManager* mOwner;
|
||||
RefPtr<ProcessedMediaStream> mStream;
|
||||
// mPort connects our mStream to an input stream.
|
||||
RefPtr<MediaInputPort> mPort;
|
||||
// mPort connects an input stream to our mStream.
|
||||
nsTArray<RefPtr<MediaInputPort>> mPorts;
|
||||
// For guaranteeing TrackID uniqueness in our mStream.
|
||||
TrackID mNextAvailableTrackID = TRACK_INVALID;
|
||||
};
|
||||
|
||||
class OutputStreamManager {
|
||||
|
@ -47,18 +54,26 @@ class OutputStreamManager {
|
|||
|
||||
public:
|
||||
// Add the output stream to the collection.
|
||||
void Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
|
||||
void Add(ProcessedMediaStream* aStream,
|
||||
TrackID aNextAvailableTrackID,
|
||||
bool aFinishWhenEnded);
|
||||
// Remove the output stream from the collection.
|
||||
void Remove(MediaStream* aStream);
|
||||
// Clear all output streams from the collection.
|
||||
void Clear();
|
||||
// The next TrackID that will not cause a collision in aOutputStream.
|
||||
TrackID NextAvailableTrackIDFor(MediaStream* aOutputStream) const;
|
||||
// Return true if the collection empty.
|
||||
bool IsEmpty() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return mStreams.IsEmpty();
|
||||
}
|
||||
// Connect all output streams in the collection to the input stream.
|
||||
void Connect(MediaStream* aStream);
|
||||
// Disconnect all output streams from the input stream.
|
||||
// Connect the given input stream's tracks to all output streams.
|
||||
void Connect(MediaStream* aStream,
|
||||
TrackID aAudioTrackID,
|
||||
TrackID aVideoTrackID);
|
||||
// Disconnect the input stream to all output streams.
|
||||
void Disconnect();
|
||||
// Return the graph these streams belong to or null if empty.
|
||||
MediaStreamGraph* Graph() const
|
||||
|
@ -72,6 +87,8 @@ private:
|
|||
// Keep the input stream so we can connect the output streams that
|
||||
// are added after Connect().
|
||||
RefPtr<MediaStream> mInputStream;
|
||||
TrackID mInputAudioTrackID = TRACK_INVALID;
|
||||
TrackID mInputVideoTrackID = TRACK_INVALID;
|
||||
nsTArray<OutputStreamData> mStreams;
|
||||
};
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ ServiceWorkerRegistrationWorkerThread::Update()
|
|||
// Avoid infinite update loops by ignoring update() calls during top
|
||||
// level script evaluation. See:
|
||||
// https://github.com/slightlyoff/ServiceWorker/issues/800
|
||||
if (workerRef->Private()->LoadScriptAsPartOfLoadingServiceWorkerScript()) {
|
||||
if (workerRef->Private()->IsLoadingWorkerScript()) {
|
||||
return ServiceWorkerRegistrationPromise::CreateAndResolve(mDescriptor,
|
||||
__func__);
|
||||
}
|
||||
|
|
|
@ -27,11 +27,20 @@ onmessage = function(e) {
|
|||
}
|
||||
|
||||
try {
|
||||
importScripts(['importscript.sjs']);
|
||||
// new unique script should fail
|
||||
importScripts(['importscript.sjs?unique=true']);
|
||||
res[0].postMessage("KO");
|
||||
return;
|
||||
} catch(e) {}
|
||||
|
||||
res[0].postMessage(counter == 2 ? "OK" : "KO");
|
||||
try {
|
||||
// duplicate script previously offlined should succeed
|
||||
importScripts(['importscript.sjs']);
|
||||
} catch(e) {
|
||||
res[0].postMessage("KO");
|
||||
return;
|
||||
}
|
||||
|
||||
res[0].postMessage(counter == 3 ? "OK" : "KO");
|
||||
});
|
||||
};
|
||||
|
|
|
@ -83,11 +83,18 @@ function workerTestGetStorageManager(cb) {
|
|||
});
|
||||
}
|
||||
|
||||
var completeInstall;
|
||||
|
||||
addEventListener('message', function workerWrapperOnMessage(e) {
|
||||
removeEventListener('message', workerWrapperOnMessage);
|
||||
var data = e.data;
|
||||
self.clients.matchAll().then(function(clients) {
|
||||
client = clients[0];
|
||||
self.clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
|
||||
for (var i = 0; i < clients.length; ++i) {
|
||||
if (clients[i].url.includes("message_receiver.html")) {
|
||||
client = clients[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
importScripts(data.script);
|
||||
} catch(e) {
|
||||
|
@ -97,5 +104,10 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
msg: 'worker failed to import ' + data.script + "; error: " + e.message
|
||||
});
|
||||
}
|
||||
completeInstall();
|
||||
});
|
||||
});
|
||||
|
||||
addEventListener('install', e => {
|
||||
e.waitUntil(new Promise(resolve => completeInstall = resolve));
|
||||
});
|
||||
|
|
|
@ -12,10 +12,13 @@
|
|||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function setupSW(registration) {
|
||||
var worker = registration.waiting ||
|
||||
var iframe;
|
||||
var worker = registration.installing ||
|
||||
registration.waiting ||
|
||||
registration.active;
|
||||
window.onmessage = function(event) {
|
||||
if (event.data.type == 'finish') {
|
||||
iframe.remove();
|
||||
registration.unregister().then(function(success) {
|
||||
ok(success, "The service worker should be unregistered successfully");
|
||||
|
||||
|
@ -63,7 +66,7 @@
|
|||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = "message_receiver.html";
|
||||
iframe.onload = function() {
|
||||
worker.postMessage({ script: "test_serviceworker_interfaces.js" });
|
||||
|
@ -72,8 +75,8 @@
|
|||
}
|
||||
|
||||
function runTest() {
|
||||
navigator.serviceWorker.ready.then(setupSW);
|
||||
navigator.serviceWorker.register("serviceworker_wrapper.js", {scope: "."});
|
||||
navigator.serviceWorker.register("serviceworker_wrapper.js", {scope: "."})
|
||||
.then(setupSW);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
@ -74,8 +74,10 @@ function testScript(script) {
|
|||
}
|
||||
return new Promise(function(resolve, reject) {
|
||||
function setupSW(registration) {
|
||||
var worker = registration.waiting ||
|
||||
var worker = registration.installing ||
|
||||
registration.waiting ||
|
||||
registration.active;
|
||||
var iframe;
|
||||
|
||||
window.addEventListener("message",function onMessage(event) {
|
||||
if (event.data.context != "ServiceWorker") {
|
||||
|
@ -83,6 +85,7 @@ function testScript(script) {
|
|||
}
|
||||
if (event.data.type == 'finish') {
|
||||
window.removeEventListener("message", onMessage);
|
||||
iframe.remove();
|
||||
registration.unregister()
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
|
@ -93,7 +96,7 @@ function testScript(script) {
|
|||
|
||||
worker.onerror = reject;
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = "message_receiver.html";
|
||||
iframe.onload = function() {
|
||||
worker.postMessage({ script: script });
|
||||
|
@ -102,7 +105,6 @@ function testScript(script) {
|
|||
}
|
||||
|
||||
navigator.serviceWorker.register("worker_wrapper.js", {scope: "."})
|
||||
.then(swr => waitForState(swr.installing, 'activated', swr))
|
||||
.then(setupSW);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
var gRegistration;
|
||||
var iframe;
|
||||
|
||||
function testScript(script) {
|
||||
var scope = "./reroute.html?" + script.replace(".js", "");
|
||||
function setupSW(registration) {
|
||||
gRegistration = registration;
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "reroute.html?" + script.replace(".js", "");
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = scope;
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
|
@ -16,13 +18,14 @@ function testScript(script) {
|
|||
}, function() {
|
||||
var scriptURL = location.href.includes("sw_empty_reroute.html")
|
||||
? "empty.js" : "reroute.js";
|
||||
navigator.serviceWorker.register(scriptURL, {scope: "/"})
|
||||
navigator.serviceWorker.register(scriptURL, {scope: scope})
|
||||
.then(swr => waitForState(swr.installing, 'activated', swr))
|
||||
.then(setupSW);
|
||||
});
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
iframe.remove();
|
||||
gRegistration.unregister().then(SimpleTest.finish, function(e) {
|
||||
dump("unregistration failed: " + e + "\n");
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -12,6 +12,8 @@ function is(a, b, msg) {
|
|||
msg: a + " === " + b + ": " + msg, context: context});
|
||||
}
|
||||
|
||||
var completeInstall;
|
||||
|
||||
addEventListener('message', function workerWrapperOnMessage(e) {
|
||||
removeEventListener('message', workerWrapperOnMessage);
|
||||
var data = e.data;
|
||||
|
@ -44,7 +46,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
// Fetch requests from a service worker are not intercepted.
|
||||
self.isSWPresent = false;
|
||||
|
||||
e.waitUntil(self.clients.matchAll().then(function(clients) {
|
||||
e.waitUntil(self.clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
|
||||
for (var i = 0; i < clients.length; ++i) {
|
||||
if (clients[i].url.indexOf("message_receiver.html") > -1) {
|
||||
client = clients[i];
|
||||
|
@ -56,6 +58,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
}
|
||||
context = "ServiceWorker";
|
||||
loadTest(e);
|
||||
completeInstall();
|
||||
}));
|
||||
} else {
|
||||
client = self;
|
||||
|
@ -63,3 +66,7 @@ addEventListener('message', function workerWrapperOnMessage(e) {
|
|||
loadTest(e);
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener("install", e => {
|
||||
e.waitUntil(new Promise(resolve => completeInstall = resolve));
|
||||
});
|
||||
|
|
|
@ -409,7 +409,6 @@ public:
|
|||
, mOriginAttributes(aWorkerPrivate->GetOriginAttributes())
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
|
||||
MOZ_ASSERT(aWorkerPrivate->LoadScriptAsPartOfLoadingServiceWorkerScript());
|
||||
AssertIsOnMainThread();
|
||||
}
|
||||
|
||||
|
@ -837,6 +836,12 @@ private:
|
|||
return mIsMainScript && mWorkerScriptType == WorkerScript;
|
||||
}
|
||||
|
||||
bool
|
||||
IsDebuggerScript() const
|
||||
{
|
||||
return mWorkerScriptType == DebuggerScript;
|
||||
}
|
||||
|
||||
void
|
||||
CancelMainThreadWithBindingAborted()
|
||||
{
|
||||
|
@ -908,12 +913,11 @@ private:
|
|||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (IsMainWorkerScript() && mWorkerPrivate->IsServiceWorker()) {
|
||||
if (IsMainWorkerScript()) {
|
||||
mWorkerPrivate->SetLoadingWorkerScript(true);
|
||||
}
|
||||
|
||||
if (!mWorkerPrivate->IsServiceWorker() ||
|
||||
!mWorkerPrivate->LoadScriptAsPartOfLoadingServiceWorkerScript()) {
|
||||
if (!mWorkerPrivate->IsServiceWorker() || IsDebuggerScript()) {
|
||||
for (uint32_t index = 0, len = mLoadInfos.Length(); index < len;
|
||||
++index) {
|
||||
nsresult rv = LoadScript(index);
|
||||
|
@ -1789,9 +1793,12 @@ CacheScriptLoader::ResolvedCallback(JSContext* aCx,
|
|||
// must handle loading and offlining new importScripts() here, however.
|
||||
if (aValue.isUndefined()) {
|
||||
// If this is the main script or we're not loading a new service worker
|
||||
// then this is an error. The storage was probably wiped without
|
||||
// removing the service worker registration.
|
||||
if (NS_WARN_IF(mIsWorkerScript || mState != ServiceWorkerState::Parsed)) {
|
||||
// then this is an error. This can happen for internal reasons, like
|
||||
// storage was probably wiped without removing the service worker
|
||||
// registration. It can also happen for exposed reasons like the
|
||||
// service worker script calling importScripts() after install.
|
||||
if (NS_WARN_IF(mIsWorkerScript || (mState != ServiceWorkerState::Parsed &&
|
||||
mState != ServiceWorkerState::Installing))) {
|
||||
Fail(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -2179,7 +2186,7 @@ ScriptExecutorRunnable::ShutdownScriptLoader(JSContext* aCx,
|
|||
|
||||
MOZ_ASSERT(mLastIndex == mScriptLoader.mLoadInfos.Length() - 1);
|
||||
|
||||
if (mIsWorkerScript && aWorkerPrivate->IsServiceWorker()) {
|
||||
if (mIsWorkerScript) {
|
||||
aWorkerPrivate->SetLoadingWorkerScript(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1043,26 +1043,19 @@ public:
|
|||
return mLoadInfo.mServiceWorkersTestingInWindow;
|
||||
}
|
||||
|
||||
// This is used to handle importScripts(). When the worker is first loaded
|
||||
// and executed, it happens in a sync loop. At this point it sets
|
||||
// mLoadingWorkerScript to true. importScripts() calls that occur during the
|
||||
// execution run in nested sync loops and so this continues to return true,
|
||||
// leading to these scripts being cached offline.
|
||||
// mLoadingWorkerScript is set to false when the top level loop ends.
|
||||
// importScripts() in function calls or event handlers are always fetched
|
||||
// from the network.
|
||||
// Determine if the worker is currently loading its top level script.
|
||||
bool
|
||||
LoadScriptAsPartOfLoadingServiceWorkerScript()
|
||||
IsLoadingWorkerScript() const
|
||||
{
|
||||
MOZ_ASSERT(IsServiceWorker());
|
||||
return mLoadingWorkerScript;
|
||||
}
|
||||
|
||||
// Called by ScriptLoader to track when this worker is loading its
|
||||
// top level script.
|
||||
void
|
||||
SetLoadingWorkerScript(bool aLoadingWorkerScript)
|
||||
{
|
||||
// any thread
|
||||
MOZ_ASSERT(IsServiceWorker());
|
||||
mLoadingWorkerScript = aLoadingWorkerScript;
|
||||
}
|
||||
|
||||
|
|
78
hal/Hal.cpp
78
hal/Hal.cpp
|
@ -587,84 +587,6 @@ UnlockScreenOrientation()
|
|||
PROXY_IF_SANDBOXED(UnlockScreenOrientation());
|
||||
}
|
||||
|
||||
void
|
||||
EnableSwitchNotifications(SwitchDevice aDevice) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(EnableSwitchNotifications(aDevice));
|
||||
}
|
||||
|
||||
void
|
||||
DisableSwitchNotifications(SwitchDevice aDevice) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(DisableSwitchNotifications(aDevice));
|
||||
}
|
||||
|
||||
typedef mozilla::ObserverList<SwitchEvent> SwitchObserverList;
|
||||
|
||||
static SwitchObserverList *sSwitchObserverLists = nullptr;
|
||||
|
||||
static SwitchObserverList&
|
||||
GetSwitchObserverList(SwitchDevice aDevice) {
|
||||
MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE);
|
||||
if (sSwitchObserverLists == nullptr) {
|
||||
sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE];
|
||||
}
|
||||
return sSwitchObserverLists[aDevice];
|
||||
}
|
||||
|
||||
static void
|
||||
ReleaseObserversIfNeeded() {
|
||||
for (int i = 0; i < NUM_SWITCH_DEVICE; i++) {
|
||||
if (sSwitchObserverLists[i].Length() != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
//The length of every list is 0, no observer in the list.
|
||||
delete [] sSwitchObserverLists;
|
||||
sSwitchObserverLists = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
RegisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
SwitchObserverList& observer = GetSwitchObserverList(aDevice);
|
||||
observer.AddObserver(aObserver);
|
||||
if (observer.Length() == 1) {
|
||||
EnableSwitchNotifications(aDevice);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UnregisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
|
||||
if (!sSwitchObserverLists) {
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchObserverList& observer = GetSwitchObserverList(aDevice);
|
||||
if (!observer.RemoveObserver(aObserver) || observer.Length() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
DisableSwitchNotifications(aDevice);
|
||||
ReleaseObserversIfNeeded();
|
||||
}
|
||||
|
||||
void
|
||||
NotifySwitchChange(const SwitchEvent& aEvent)
|
||||
{
|
||||
// When callback this notification, main thread may call unregister function
|
||||
// first. We should check if this pointer is valid.
|
||||
if (!sSwitchObserverLists)
|
||||
return;
|
||||
|
||||
SwitchObserverList& observer = GetSwitchObserverList(aEvent.device());
|
||||
observer.Broadcast(aEvent);
|
||||
}
|
||||
|
||||
bool
|
||||
SetProcessPrioritySupported()
|
||||
{
|
||||
|
|
20
hal/Hal.h
20
hal/Hal.h
|
@ -261,26 +261,6 @@ MOZ_MUST_USE bool LockScreenOrientation(const dom::ScreenOrientationInternal& aO
|
|||
*/
|
||||
void UnlockScreenOrientation();
|
||||
|
||||
/**
|
||||
* Register an observer for the switch of given SwitchDevice.
|
||||
*
|
||||
* The observer will receive data whenever the data generated by the
|
||||
* given switch.
|
||||
*/
|
||||
void RegisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aSwitchObserver);
|
||||
|
||||
/**
|
||||
* Unregister an observer for the switch of given SwitchDevice.
|
||||
*/
|
||||
void UnregisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aSwitchObserver);
|
||||
|
||||
/**
|
||||
* Notify the state of the switch.
|
||||
*
|
||||
* This API is internal to hal; clients shouldn't call it directly.
|
||||
*/
|
||||
void NotifySwitchChange(const hal::SwitchEvent& aEvent);
|
||||
|
||||
/**
|
||||
* Return true if the current platform supports the setting of process
|
||||
* priority.
|
||||
|
|
|
@ -54,16 +54,6 @@ void EnableScreenConfigurationNotifications();
|
|||
*/
|
||||
void DisableScreenConfigurationNotifications();
|
||||
|
||||
/**
|
||||
* Enable switch notifications from the backend
|
||||
*/
|
||||
void EnableSwitchNotifications(hal::SwitchDevice aDevice);
|
||||
|
||||
/**
|
||||
* Disable switch notifications from the backend
|
||||
*/
|
||||
void DisableSwitchNotifications(hal::SwitchDevice aDevice);
|
||||
|
||||
/**
|
||||
* Has the child-side HAL IPC object been destroyed? If so, you shouldn't send
|
||||
* messages to hal_sandbox.
|
||||
|
|
|
@ -20,26 +20,6 @@ namespace hal {
|
|||
const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
|
||||
const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
|
||||
|
||||
class SwitchEvent;
|
||||
|
||||
enum SwitchDevice {
|
||||
SWITCH_DEVICE_UNKNOWN = -1,
|
||||
SWITCH_HEADPHONES,
|
||||
SWITCH_USB,
|
||||
NUM_SWITCH_DEVICE
|
||||
};
|
||||
|
||||
enum SwitchState {
|
||||
SWITCH_STATE_UNKNOWN = -1,
|
||||
SWITCH_STATE_ON,
|
||||
SWITCH_STATE_OFF,
|
||||
SWITCH_STATE_HEADSET, // Headphone with microphone
|
||||
SWITCH_STATE_HEADPHONE, // without microphone
|
||||
NUM_SWITCH_STATE
|
||||
};
|
||||
|
||||
typedef Observer<SwitchEvent> SwitchObserver;
|
||||
|
||||
// Note that we rely on the order of this enum's entries. Higher priorities
|
||||
// should have larger int values.
|
||||
enum ProcessPriority {
|
||||
|
@ -95,28 +75,6 @@ struct ParamTraits<mozilla::hal::WakeLockControl>
|
|||
mozilla::hal::NUM_WAKE_LOCK>
|
||||
{};
|
||||
|
||||
/**
|
||||
* Serializer for SwitchState
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::SwitchState>:
|
||||
public ContiguousEnumSerializer<
|
||||
mozilla::hal::SwitchState,
|
||||
mozilla::hal::SWITCH_STATE_UNKNOWN,
|
||||
mozilla::hal::NUM_SWITCH_STATE> {
|
||||
};
|
||||
|
||||
/**
|
||||
* Serializer for SwitchDevice
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::SwitchDevice>:
|
||||
public ContiguousEnumSerializer<
|
||||
mozilla::hal::SwitchDevice,
|
||||
mozilla::hal::SWITCH_DEVICE_UNKNOWN,
|
||||
mozilla::hal::NUM_SWITCH_DEVICE> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::ProcessPriority>:
|
||||
public ContiguousEnumSerializer<
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
EnableSwitchNotifications(SwitchDevice aDevice)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSwitchNotifications(SwitchDevice aDevice)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace hal_impl
|
||||
} // namespace mozilla
|
|
@ -99,7 +99,6 @@ else:
|
|||
UNIFIED_SOURCES += [
|
||||
'fallback/FallbackDiskSpaceWatcher.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
'fallback/FallbackSwitch.cpp',
|
||||
]
|
||||
|
||||
# Fallbacks for backends implemented on Android only.
|
||||
|
|
|
@ -13,8 +13,6 @@ using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientatio
|
|||
using mozilla::hal::SensorType from "mozilla/HalSensor.h";
|
||||
using mozilla::hal::SensorAccuracyType from "mozilla/HalSensor.h";
|
||||
using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h";
|
||||
using mozilla::hal::SwitchState from "mozilla/HalTypes.h";
|
||||
using mozilla::hal::SwitchDevice from "mozilla/HalTypes.h";
|
||||
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
|
||||
using nsIntRect from "nsRect.h";
|
||||
using PRTime from "prtime.h";
|
||||
|
@ -41,11 +39,6 @@ struct NetworkInformation {
|
|||
uint32_t dhcpGateway;
|
||||
};
|
||||
|
||||
struct SwitchEvent {
|
||||
SwitchDevice device;
|
||||
SwitchState status;
|
||||
};
|
||||
|
||||
struct WakeLockInformation {
|
||||
nsString topic;
|
||||
uint32_t numLocks;
|
||||
|
@ -73,7 +66,6 @@ child:
|
|||
async NotifyNetworkChange(NetworkInformation aNetworkInfo);
|
||||
async NotifyWakeLockChange(WakeLockInformation aWakeLockInfo);
|
||||
async NotifyScreenConfigurationChange(ScreenConfiguration aScreenOrientation);
|
||||
async NotifySwitchChange(SwitchEvent aEvent);
|
||||
|
||||
parent:
|
||||
async Vibrate(uint32_t[] pattern, uint64_t[] id, PBrowser browser);
|
||||
|
@ -103,9 +95,6 @@ parent:
|
|||
sync LockScreenOrientation(ScreenOrientationInternal aOrientation)
|
||||
returns (bool allowed);
|
||||
async UnlockScreenOrientation();
|
||||
|
||||
async EnableSwitchNotifications(SwitchDevice aDevice);
|
||||
async DisableSwitchNotifications(SwitchDevice aDevice);
|
||||
|
||||
child:
|
||||
async NotifySensorChange(SensorData aSensorData);
|
||||
|
|
|
@ -174,18 +174,6 @@ GetWakeLockInfo(const nsAString &aTopic, WakeLockInformation *aWakeLockInfo)
|
|||
Hal()->SendGetWakeLockInfo(nsString(aTopic), aWakeLockInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EnableSwitchNotifications(SwitchDevice aDevice)
|
||||
{
|
||||
Hal()->SendEnableSwitchNotifications(aDevice);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSwitchNotifications(SwitchDevice aDevice)
|
||||
{
|
||||
Hal()->SendDisableSwitchNotifications(aDevice);
|
||||
}
|
||||
|
||||
bool
|
||||
EnableAlarm()
|
||||
{
|
||||
|
@ -234,7 +222,6 @@ class HalParent : public PHalParent
|
|||
, public ISensorObserver
|
||||
, public WakeLockObserver
|
||||
, public ScreenConfigurationObserver
|
||||
, public SwitchObserver
|
||||
{
|
||||
public:
|
||||
virtual void
|
||||
|
@ -250,10 +237,6 @@ public:
|
|||
hal::UnregisterSensorObserver(SensorType(sensor), this);
|
||||
}
|
||||
hal::UnregisterWakeLockObserver(this);
|
||||
for (int32_t switchDevice = SWITCH_DEVICE_UNKNOWN + 1;
|
||||
switchDevice < NUM_SWITCH_DEVICE; ++switchDevice) {
|
||||
hal::UnregisterSwitchObserver(SwitchDevice(switchDevice), this);
|
||||
}
|
||||
}
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
|
@ -426,26 +409,6 @@ public:
|
|||
{
|
||||
Unused << SendNotifyWakeLockChange(aWakeLockInfo);
|
||||
}
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvEnableSwitchNotifications(const SwitchDevice& aDevice) override
|
||||
{
|
||||
// Content has no reason to listen to switch events currently.
|
||||
hal::RegisterSwitchObserver(aDevice, this);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvDisableSwitchNotifications(const SwitchDevice& aDevice) override
|
||||
{
|
||||
hal::UnregisterSwitchObserver(aDevice, this);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void Notify(const SwitchEvent& aSwitchEvent) override
|
||||
{
|
||||
Unused << SendNotifySwitchChange(aSwitchEvent);
|
||||
}
|
||||
};
|
||||
|
||||
class HalChild : public PHalChild {
|
||||
|
@ -482,12 +445,6 @@ public:
|
|||
hal::NotifyScreenConfigurationChange(aScreenConfiguration);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvNotifySwitchChange(const mozilla::hal::SwitchEvent& aEvent) override {
|
||||
hal::NotifySwitchChange(aEvent);
|
||||
return IPC_OK();
|
||||
}
|
||||
};
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
|
|
@ -517,12 +517,16 @@ SourceBuffer::AppendFromInputStream(nsIInputStream* aInputStream,
|
|||
}
|
||||
|
||||
if (bytesRead != aCount) {
|
||||
// Only some of the given data was read. We must have failed in
|
||||
// SourceBuffer::Append but ReadSegments swallowed the error.
|
||||
// Only some of the given data was read. We may have failed in
|
||||
// SourceBuffer::Append but ReadSegments swallowed the error. Otherwise the
|
||||
// stream itself failed to yield the data.
|
||||
MutexAutoLock lock(mMutex);
|
||||
MOZ_ASSERT(mStatus);
|
||||
MOZ_ASSERT(NS_FAILED(*mStatus));
|
||||
return *mStatus;
|
||||
if (mStatus) {
|
||||
MOZ_ASSERT(NS_FAILED(*mStatus));
|
||||
return *mStatus;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("AppendToSourceBuffer should consume everything");
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -418,8 +418,6 @@ static inline void js_free(void* p)
|
|||
// js_malloc().
|
||||
free(p);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(char*) js_strdup(const char* s);
|
||||
#endif/* JS_USE_CUSTOM_ALLOCATOR */
|
||||
|
||||
#include <new>
|
||||
|
|
|
@ -2387,8 +2387,8 @@ ReadGeckoProfilingStack(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
struct InlineFrameInfo
|
||||
{
|
||||
InlineFrameInfo(const char* kind, char* label)
|
||||
: kind(kind), label(label) {}
|
||||
InlineFrameInfo(const char* kind, UniqueChars label)
|
||||
: kind(kind), label(std::move(label)) {}
|
||||
const char* kind;
|
||||
UniqueChars label;
|
||||
};
|
||||
|
@ -2422,11 +2422,11 @@ ReadGeckoProfilingStack(JSContext* cx, unsigned argc, Value* vp)
|
|||
frameKindStr = "unknown";
|
||||
}
|
||||
|
||||
char* label = JS_strdup(cx, frames[i].label);
|
||||
UniqueChars label = DuplicateString(cx, frames[i].label);
|
||||
if (!label)
|
||||
return false;
|
||||
|
||||
if (!frameInfo.back().emplaceBack(frameKindStr, label))
|
||||
if (!frameInfo.back().emplaceBack(frameKindStr, std::move(label)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4380,7 +4380,7 @@ GetLcovInfo(JSContext* cx, unsigned argc, Value* vp)
|
|||
return false;
|
||||
|
||||
JSString* str = JS_NewStringCopyN(cx, content, length);
|
||||
free(content);
|
||||
js_free(content);
|
||||
|
||||
if (!str)
|
||||
return false;
|
||||
|
|
|
@ -4666,6 +4666,9 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoTraceSession& session)
|
|||
|
||||
gc->waitBackgroundSweepEnd();
|
||||
|
||||
/* Wait for off-thread parsing which can allocate. */
|
||||
HelperThreadState().waitForAllThreads();
|
||||
|
||||
/* Save existing mark bits. */
|
||||
{
|
||||
AutoLockGC lock(runtime);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// |jit-test| allow-overrecursed
|
||||
if (helperThreadCount() === 0)
|
||||
quit();
|
||||
function eval(source) {
|
||||
offThreadCompileModule(source);
|
||||
let get = (eval("function w(){}") ++);
|
||||
};
|
||||
gczeal(21, 10);
|
||||
gczeal(11, 8);
|
||||
eval("");
|
|
@ -1382,13 +1382,6 @@ JS_updateMallocCounter(JSContext* cx, size_t nbytes)
|
|||
return cx->updateMallocCounter(nbytes);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(char*)
|
||||
JS_strdup(JSContext* cx, const char* s)
|
||||
{
|
||||
AssertHeapIsIdle();
|
||||
return DuplicateString(cx, s).release();
|
||||
}
|
||||
|
||||
#undef JS_AddRoot
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
@ -3993,7 +3986,7 @@ JS::OwningCompileOptions::setFile(JSContext* cx, const char* f)
|
|||
{
|
||||
char* copy = nullptr;
|
||||
if (f) {
|
||||
copy = JS_strdup(cx, f);
|
||||
copy = DuplicateString(cx, f).release();
|
||||
if (!copy)
|
||||
return false;
|
||||
}
|
||||
|
@ -4037,7 +4030,7 @@ JS::OwningCompileOptions::setIntroducerFilename(JSContext* cx, const char* s)
|
|||
{
|
||||
char* copy = nullptr;
|
||||
if (s) {
|
||||
copy = JS_strdup(cx, s);
|
||||
copy = DuplicateString(cx, s).release();
|
||||
if (!copy)
|
||||
return false;
|
||||
}
|
||||
|
@ -6851,7 +6844,7 @@ JS_GetDefaultLocale(JSContext* cx)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
if (const char* locale = cx->runtime()->getDefaultLocale())
|
||||
return UniqueChars(JS_strdup(cx, locale));
|
||||
return DuplicateString(cx, locale);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1357,9 +1357,6 @@ JS_freeop(JSFreeOp* fop, void* p);
|
|||
extern JS_PUBLIC_API(void)
|
||||
JS_updateMallocCounter(JSContext* cx, size_t nbytes);
|
||||
|
||||
extern JS_PUBLIC_API(char*)
|
||||
JS_strdup(JSContext* cx, const char* s);
|
||||
|
||||
/**
|
||||
* Set the size of the native stack that should not be exceed. To disable
|
||||
* stack size checking pass 0.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include <chrono>
|
||||
#ifdef JS_POSIX_NSPR
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#ifdef XP_UNIX
|
||||
# include <sys/mman.h>
|
||||
# include <sys/stat.h>
|
||||
|
@ -4970,11 +4972,12 @@ class AutoCStringVector
|
|||
for (size_t i = 0; i < argv_.length(); i++)
|
||||
js_free(argv_[i]);
|
||||
}
|
||||
bool append(char* arg) {
|
||||
if (!argv_.append(arg)) {
|
||||
js_free(arg);
|
||||
bool append(UniqueChars&& arg) {
|
||||
if (!argv_.append(arg.get()))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now owned by this vector.
|
||||
mozilla::Unused << arg.release();
|
||||
return true;
|
||||
}
|
||||
char* const* get() const {
|
||||
|
@ -4986,22 +4989,22 @@ class AutoCStringVector
|
|||
char* operator[](size_t i) const {
|
||||
return argv_[i];
|
||||
}
|
||||
void replace(size_t i, char* arg) {
|
||||
void replace(size_t i, UniqueChars arg) {
|
||||
js_free(argv_[i]);
|
||||
argv_[i] = arg;
|
||||
argv_[i] = arg.release();
|
||||
}
|
||||
char* back() const {
|
||||
const char* back() const {
|
||||
return argv_.back();
|
||||
}
|
||||
void replaceBack(char* arg) {
|
||||
void replaceBack(UniqueChars arg) {
|
||||
js_free(argv_.back());
|
||||
argv_.back() = arg;
|
||||
argv_.back() = arg.release();
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(XP_WIN)
|
||||
static bool
|
||||
EscapeForShell(AutoCStringVector& argv)
|
||||
EscapeForShell(JSContext* cx, AutoCStringVector& argv)
|
||||
{
|
||||
// Windows will break arguments in argv by various spaces, so we wrap each
|
||||
// argument in quotes and escape quotes within. Even with quotes, \ will be
|
||||
|
@ -5018,12 +5021,12 @@ EscapeForShell(AutoCStringVector& argv)
|
|||
newLen++;
|
||||
}
|
||||
|
||||
char* escaped = (char*)js_malloc(newLen);
|
||||
UniqueChars escaped(cx->pod_malloc<char>(newLen));
|
||||
if (!escaped)
|
||||
return false;
|
||||
|
||||
char* src = argv[i];
|
||||
char* dst = escaped;
|
||||
char* dst = escaped.get();
|
||||
*dst++ = '\"';
|
||||
while (*src) {
|
||||
if (*src == '\"' || *src == '\\')
|
||||
|
@ -5032,9 +5035,9 @@ EscapeForShell(AutoCStringVector& argv)
|
|||
}
|
||||
*dst++ = '\"';
|
||||
*dst++ = '\0';
|
||||
MOZ_ASSERT(escaped + newLen == dst);
|
||||
MOZ_ASSERT(escaped.get() + newLen == dst);
|
||||
|
||||
argv.replace(i, escaped);
|
||||
argv.replace(i, std::move(escaped));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5063,13 +5066,14 @@ NestedShell(JSContext* cx, unsigned argc, Value* vp)
|
|||
JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_NESTED_FAIL);
|
||||
return false;
|
||||
}
|
||||
if (!argv.append(js_strdup(sArgv[0])))
|
||||
UniqueChars shellPath = DuplicateString(cx, sArgv[0]);
|
||||
if (!shellPath || !argv.append(std::move(shellPath)))
|
||||
return false;
|
||||
|
||||
// Propagate selected flags from the current shell
|
||||
for (unsigned i = 0; i < sPropagatedFlags.length(); i++) {
|
||||
char* cstr = js_strdup(sPropagatedFlags[i]);
|
||||
if (!cstr || !argv.append(cstr))
|
||||
UniqueChars flags = DuplicateString(cx, sPropagatedFlags[i]);
|
||||
if (!flags || !argv.append(std::move(flags)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5077,16 +5081,22 @@ NestedShell(JSContext* cx, unsigned argc, Value* vp)
|
|||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = ToString(cx, args[i]);
|
||||
if (!str || !argv.append(JS_EncodeString(cx, str)))
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
UniqueChars arg(JS_EncodeString(cx, str));
|
||||
if (!arg || !argv.append(std::move(arg)))
|
||||
return false;
|
||||
|
||||
// As a special case, if the caller passes "--js-cache", replace that
|
||||
// with "--js-cache=$(jsCacheDir)"
|
||||
if (!strcmp(argv.back(), "--js-cache") && jsCacheDir) {
|
||||
UniqueChars newArg = JS_smprintf("--js-cache=%s", jsCacheDir);
|
||||
if (!newArg)
|
||||
if (!newArg) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
argv.replaceBack(newArg.release());
|
||||
}
|
||||
argv.replaceBack(std::move(newArg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5096,7 +5106,7 @@ NestedShell(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
int status = 0;
|
||||
#if defined(XP_WIN)
|
||||
if (!EscapeForShell(argv))
|
||||
if (!EscapeForShell(cx, argv))
|
||||
return false;
|
||||
status = _spawnv(_P_WAIT, sArgv[0], argv.get());
|
||||
#else
|
||||
|
@ -8776,14 +8786,15 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
|
|||
enableDisassemblyDumps = op.getBoolOption('D');
|
||||
cx->runtime()->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
|
||||
|
||||
jsCacheDir = op.getStringOption("js-cache");
|
||||
if (jsCacheDir) {
|
||||
if (const char* jsCacheOpt = op.getStringOption("js-cache")) {
|
||||
UniqueChars jsCacheChars;
|
||||
if (!op.getBoolOption("no-js-cache-per-process"))
|
||||
jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid()).release();
|
||||
jsCacheChars = JS_smprintf("%s/%u", jsCacheOpt, (unsigned)getpid());
|
||||
else
|
||||
jsCacheDir = JS_strdup(cx, jsCacheDir);
|
||||
if (!jsCacheDir)
|
||||
jsCacheChars = DuplicateString(jsCacheOpt);
|
||||
if (!jsCacheChars)
|
||||
return false;
|
||||
jsCacheDir = jsCacheChars.release();
|
||||
jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir).release();
|
||||
}
|
||||
|
||||
|
@ -8915,6 +8926,9 @@ Shell(JSContext* cx, OptionParser* op, char** envp)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Used to allocate memory when jemalloc isn't yet initialized.
|
||||
JS_DECLARE_NEW_METHODS(SystemAlloc_New, malloc, static)
|
||||
|
||||
static void
|
||||
SetOutputFile(const char* const envVar,
|
||||
RCFile* defaultOut,
|
||||
|
@ -8925,10 +8939,13 @@ SetOutputFile(const char* const envVar,
|
|||
const char* outPath = getenv(envVar);
|
||||
FILE* newfp;
|
||||
if (outPath && *outPath && (newfp = fopen(outPath, "w")))
|
||||
outFile = js_new<RCFile>(newfp);
|
||||
outFile = SystemAlloc_New<RCFile>(newfp);
|
||||
else
|
||||
outFile = defaultOut;
|
||||
|
||||
if (!outFile)
|
||||
MOZ_CRASH("Failed to allocate output file");
|
||||
|
||||
outFile->acquire();
|
||||
*outFileP = outFile;
|
||||
}
|
||||
|
|
|
@ -36,12 +36,6 @@ js_strchr_limit(const Latin1Char* s, char16_t c, const Latin1Char* limit);
|
|||
template const char16_t*
|
||||
js_strchr_limit(const char16_t* s, char16_t c, const char16_t* limit);
|
||||
|
||||
JS_PUBLIC_API(char*)
|
||||
js_strdup(const char* s)
|
||||
{
|
||||
return DuplicateString(s).release();
|
||||
}
|
||||
|
||||
int32_t
|
||||
js_fputs(const char16_t* s, FILE* f)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "js/CharacterEncoding.h"
|
||||
#include "js/Printf.h"
|
||||
#include "util/StringBuffer.h"
|
||||
#include "util/Text.h"
|
||||
#include "vm/CodeCoverage.h"
|
||||
#include "vm/EnvironmentObject.h"
|
||||
#include "vm/JSAtom.h"
|
||||
|
@ -2319,10 +2320,10 @@ js::DecompileValueGenerator(JSContext* cx, int spindex, HandleValue v,
|
|||
}
|
||||
if (!fallback) {
|
||||
if (v.isUndefined())
|
||||
return UniqueChars(JS_strdup(cx, js_undefined_str)); // Prevent users from seeing "(void 0)"
|
||||
return DuplicateString(cx, js_undefined_str); // Prevent users from seeing "(void 0)"
|
||||
fallback = ValueToSource(cx, v);
|
||||
if (!fallback)
|
||||
return UniqueChars(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return UniqueChars(JS_EncodeString(cx, fallback));
|
||||
|
@ -2397,7 +2398,7 @@ DecompileArgumentFromStack(JSContext* cx, int formalIndex, char** res)
|
|||
return ed.getOutput(res);
|
||||
}
|
||||
|
||||
char*
|
||||
UniqueChars
|
||||
js::DecompileArgument(JSContext* cx, int formalIndex, HandleValue v)
|
||||
{
|
||||
{
|
||||
|
@ -2406,18 +2407,18 @@ js::DecompileArgument(JSContext* cx, int formalIndex, HandleValue v)
|
|||
return nullptr;
|
||||
if (result) {
|
||||
if (strcmp(result, "(intermediate value)"))
|
||||
return result;
|
||||
return UniqueChars(result);
|
||||
js_free(result);
|
||||
}
|
||||
}
|
||||
if (v.isUndefined())
|
||||
return JS_strdup(cx, js_undefined_str); // Prevent users from seeing "(void 0)"
|
||||
return DuplicateString(cx, js_undefined_str); // Prevent users from seeing "(void 0)"
|
||||
|
||||
RootedString fallback(cx, ValueToSource(cx, v));
|
||||
if (!fallback)
|
||||
return nullptr;
|
||||
|
||||
return JS_EncodeString(cx, fallback);
|
||||
return UniqueChars(JS_EncodeString(cx, fallback));
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -609,7 +609,7 @@ DecompileValueGenerator(JSContext* cx, int spindex, HandleValue v,
|
|||
* Decompile the formal argument at formalIndex in the nearest non-builtin
|
||||
* stack frame, falling back with converting v to source.
|
||||
*/
|
||||
char*
|
||||
UniqueChars
|
||||
DecompileArgument(JSContext* cx, int formalIndex, HandleValue v);
|
||||
|
||||
extern bool
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
namespace js {
|
||||
namespace coverage {
|
||||
|
||||
LCovSource::LCovSource(LifoAlloc* alloc, const char* name)
|
||||
: name_(name),
|
||||
LCovSource::LCovSource(LifoAlloc* alloc, UniqueChars name)
|
||||
: name_(std::move(name)),
|
||||
outFN_(alloc),
|
||||
outFNDA_(alloc),
|
||||
numFunctionsFound_(0),
|
||||
|
@ -80,7 +80,7 @@ LCovSource::LCovSource(LifoAlloc* alloc, const char* name)
|
|||
}
|
||||
|
||||
LCovSource::LCovSource(LCovSource&& src)
|
||||
: name_(src.name_),
|
||||
: name_(std::move(src.name_)),
|
||||
outFN_(src.outFN_),
|
||||
outFNDA_(src.outFNDA_),
|
||||
numFunctionsFound_(src.numFunctionsFound_),
|
||||
|
@ -94,12 +94,6 @@ LCovSource::LCovSource(LCovSource&& src)
|
|||
maxLineHit_(src.maxLineHit_),
|
||||
hasTopLevelScript_(src.hasTopLevelScript_)
|
||||
{
|
||||
src.name_ = nullptr;
|
||||
}
|
||||
|
||||
LCovSource::~LCovSource()
|
||||
{
|
||||
js_delete(name_);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -109,7 +103,7 @@ LCovSource::exportInto(GenericPrinter& out) const
|
|||
if (!hasTopLevelScript_)
|
||||
return;
|
||||
|
||||
out.printf("SF:%s\n", name_);
|
||||
out.printf("SF:%s\n", name_.get());
|
||||
|
||||
outFN_.exportInto(out);
|
||||
outFNDA_.exportInto(out);
|
||||
|
@ -509,14 +503,14 @@ LCovRealm::lookupOrAdd(JS::Realm* realm, const char* name)
|
|||
}
|
||||
}
|
||||
|
||||
char* source_name = js_strdup(name);
|
||||
UniqueChars source_name = DuplicateString(name);
|
||||
if (!source_name) {
|
||||
outTN_.reportOutOfMemory();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Allocate a new LCovSource for the current top-level.
|
||||
if (!sources_->append(LCovSource(&alloc_, source_name))) {
|
||||
if (!sources_->emplaceBack(&alloc_, std::move(source_name))) {
|
||||
outTN_.reportOutOfMemory();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "js/HashTable.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
#include "vm/Printer.h"
|
||||
|
||||
|
@ -25,13 +26,13 @@ namespace coverage {
|
|||
class LCovSource
|
||||
{
|
||||
public:
|
||||
LCovSource(LifoAlloc* alloc, const char* name);
|
||||
LCovSource(LifoAlloc* alloc, JS::UniqueChars name);
|
||||
LCovSource(LCovSource&& src);
|
||||
~LCovSource();
|
||||
~LCovSource() = default;
|
||||
|
||||
// Whether the given script name matches this LCovSource.
|
||||
bool match(const char* name) const {
|
||||
return strcmp(name_, name) == 0;
|
||||
return strcmp(name_.get(), name) == 0;
|
||||
}
|
||||
|
||||
// Whether the current source is complete and if it can be flushed.
|
||||
|
@ -53,7 +54,7 @@ class LCovSource
|
|||
|
||||
private:
|
||||
// Name of the source file.
|
||||
const char* name_;
|
||||
JS::UniqueChars name_;
|
||||
|
||||
// LifoAlloc strings which hold the filename of each function as
|
||||
// well as the number of hits for each function.
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsnum.h"
|
||||
|
||||
|
@ -28,6 +30,7 @@
|
|||
#include "js/Vector.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "proxy/ScriptedProxyHandler.h"
|
||||
#include "util/Text.h"
|
||||
#include "vm/ArgumentsObject.h"
|
||||
#include "vm/AsyncFunction.h"
|
||||
#include "vm/AsyncIteration.h"
|
||||
|
@ -448,25 +451,17 @@ ValueToStableChars(JSContext* cx, const char *fnname, HandleValue value,
|
|||
return true;
|
||||
}
|
||||
|
||||
EvalOptions::~EvalOptions()
|
||||
{
|
||||
js_free(const_cast<char*>(filename_));
|
||||
}
|
||||
|
||||
bool
|
||||
EvalOptions::setFilename(JSContext* cx, const char* filename)
|
||||
{
|
||||
char* copy = nullptr;
|
||||
JS::UniqueChars copy;
|
||||
if (filename) {
|
||||
copy = JS_strdup(cx, filename);
|
||||
copy = DuplicateString(cx, filename);
|
||||
if (!copy)
|
||||
return false;
|
||||
}
|
||||
|
||||
// EvalOptions always owns filename_, so this cast is okay.
|
||||
js_free(const_cast<char*>(filename_));
|
||||
|
||||
filename_ = copy;
|
||||
filename_ = std::move(copy);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "js/Debug.h"
|
||||
#include "js/GCVariant.h"
|
||||
#include "js/HashTable.h"
|
||||
#include "js/Utility.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "vm/GlobalObject.h"
|
||||
#include "vm/JSCompartment.h"
|
||||
|
@ -255,13 +256,13 @@ class AutoSuppressDebuggeeNoExecuteChecks
|
|||
};
|
||||
|
||||
class MOZ_RAII EvalOptions {
|
||||
const char* filename_;
|
||||
unsigned lineno_;
|
||||
JS::UniqueChars filename_;
|
||||
unsigned lineno_ = 1;
|
||||
|
||||
public:
|
||||
EvalOptions() : filename_(nullptr), lineno_(1) {}
|
||||
~EvalOptions();
|
||||
const char* filename() const { return filename_; }
|
||||
EvalOptions() = default;
|
||||
~EvalOptions() = default;
|
||||
const char* filename() const { return filename_.get(); }
|
||||
unsigned lineno() const { return lineno_; }
|
||||
MOZ_MUST_USE bool setFilename(JSContext* cx, const char* filename);
|
||||
void setLineno(unsigned lineno) { lineno_ = lineno; }
|
||||
|
|
|
@ -2702,7 +2702,7 @@ JSScript::initScriptName(JSContext* cx)
|
|||
realm()->scriptNameMap = std::move(map);
|
||||
}
|
||||
|
||||
UniqueChars name(js_strdup(filename()));
|
||||
UniqueChars name = DuplicateString(filename());
|
||||
if (!name) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
|
|
|
@ -527,9 +527,14 @@ JSRuntime::setDefaultLocale(const char* locale)
|
|||
{
|
||||
if (!locale)
|
||||
return false;
|
||||
|
||||
char* newLocale = DuplicateString(mainContextFromOwnThread(), locale).release();
|
||||
if (!newLocale)
|
||||
return false;
|
||||
|
||||
resetDefaultLocale();
|
||||
defaultLocale = JS_strdup(mainContextFromOwnThread(), locale);
|
||||
return defaultLocale != nullptr;
|
||||
defaultLocale = newLocale;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -551,7 +556,7 @@ JSRuntime::getDefaultLocale()
|
|||
if (!locale || !strcmp(locale, "C"))
|
||||
locale = "und";
|
||||
|
||||
char* lang = JS_strdup(mainContextFromOwnThread(), locale);
|
||||
char* lang = DuplicateString(mainContextFromOwnThread(), locale).release();
|
||||
if (!lang)
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -524,14 +524,14 @@ intrinsic_DecompileArg(JSContext* cx, unsigned argc, Value* vp)
|
|||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 2);
|
||||
|
||||
RootedValue value(cx, args[1]);
|
||||
ScopedJSFreePtr<char> str(DecompileArgument(cx, args[0].toInt32(), value));
|
||||
HandleValue value = args[1];
|
||||
UniqueChars str = DecompileArgument(cx, args[0].toInt32(), value);
|
||||
if (!str)
|
||||
return false;
|
||||
JSAtom* atom = Atomize(cx, str, strlen(str));
|
||||
if (!atom)
|
||||
JSString* result = NewStringCopyZ<CanGC>(cx, str.get());
|
||||
if (!result)
|
||||
return false;
|
||||
args.rval().setString(atom);
|
||||
args.rval().setString(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ class SharedImmutableStringsCache
|
|||
struct Hasher;
|
||||
|
||||
public:
|
||||
using OwnedChars = mozilla::UniquePtr<char[], JS::FreePolicy>;
|
||||
using OwnedTwoByteChars = mozilla::UniquePtr<char16_t[], JS::FreePolicy>;
|
||||
using OwnedChars = JS::UniqueChars;
|
||||
using OwnedTwoByteChars = JS::UniqueTwoByteChars;
|
||||
|
||||
/**
|
||||
* Get the canonical, shared, and de-duplicated version of the given `const
|
||||
|
@ -55,8 +55,8 @@ class SharedImmutableStringsCache
|
|||
* `intoOwnedChars` must create an owned version of the given string, and
|
||||
* must have one of the following types:
|
||||
*
|
||||
* mozilla::UniquePtr<char[], JS::FreePolicy> intoOwnedChars();
|
||||
* mozilla::UniquePtr<char[], JS::FreePolicy>&& intoOwnedChars();
|
||||
* JS::UniqueChars intoOwnedChars();
|
||||
* JS::UniqueChars&& intoOwnedChars();
|
||||
*
|
||||
* It can be used by callers to elide a copy of the string when it is safe
|
||||
* to give up ownership of the lookup string to the cache. It must return a
|
||||
|
@ -98,8 +98,8 @@ class SharedImmutableStringsCache
|
|||
* `intoOwnedTwoByteChars` must create an owned version of the given string,
|
||||
* and must have one of the following types:
|
||||
*
|
||||
* mozilla::UniquePtr<char16_t[], JS::FreePolicy> intoOwnedTwoByteChars();
|
||||
* mozilla::UniquePtr<char16_t[], JS::FreePolicy>&& intoOwnedTwoByteChars();
|
||||
* JS::UniqueTwoByteChars intoOwnedTwoByteChars();
|
||||
* JS::UniqueTwoByteChars&& intoOwnedTwoByteChars();
|
||||
*
|
||||
* It can be used by callers to elide a copy of the string when it is safe
|
||||
* to give up ownership of the lookup string to the cache. It must return a
|
||||
|
|
|
@ -12,12 +12,15 @@
|
|||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "jit/BaselineJIT.h"
|
||||
#include "jit/CompileWrappers.h"
|
||||
#include "js/Printf.h"
|
||||
#include "threading/LockGuard.h"
|
||||
#include "util/Text.h"
|
||||
#include "vm/JSScript.h"
|
||||
#include "vm/Runtime.h"
|
||||
#include "vm/Time.h"
|
||||
|
@ -418,17 +421,15 @@ TraceLoggerThreadState::getOrCreateEventPayload(const char* text)
|
|||
return p->value();
|
||||
}
|
||||
|
||||
char* str = js_strdup(text);
|
||||
UniqueChars str = DuplicateString(text);
|
||||
if (!str)
|
||||
return nullptr;
|
||||
|
||||
uint32_t textId = nextTextId;
|
||||
|
||||
TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, str);
|
||||
if (!payload) {
|
||||
js_free(str);
|
||||
auto* payload = js_new<TraceLoggerEventPayload>(textId, std::move(str));
|
||||
if (!payload)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!textIdPayloads.putNew(textId, payload)) {
|
||||
js_delete(payload);
|
||||
|
@ -450,7 +451,7 @@ TraceLoggerThreadState::getOrCreateEventPayload(const char* text)
|
|||
|
||||
TraceLoggerEventPayload*
|
||||
TraceLoggerThreadState::getOrCreateEventPayload(const char* filename,
|
||||
size_t lineno, size_t colno, const void* ptr)
|
||||
uint32_t lineno, uint32_t colno, const void* ptr)
|
||||
{
|
||||
if (!filename)
|
||||
filename = "<unknown>";
|
||||
|
@ -467,29 +468,14 @@ TraceLoggerThreadState::getOrCreateEventPayload(const char* filename,
|
|||
}
|
||||
}
|
||||
|
||||
// Compute the length of the string to create.
|
||||
size_t lenFilename = strlen(filename);
|
||||
size_t lenLineno = 1;
|
||||
for (size_t i = lineno; i /= 10; lenLineno++);
|
||||
size_t lenColno = 1;
|
||||
for (size_t i = colno; i /= 10; lenColno++);
|
||||
|
||||
size_t len = 7 + lenFilename + 1 + lenLineno + 1 + lenColno;
|
||||
char* str = js_pod_malloc<char>(len + 1);
|
||||
UniqueChars str = JS_smprintf("script %s:%u:%u", filename, lineno, colno);
|
||||
if (!str)
|
||||
return nullptr;
|
||||
|
||||
DebugOnly<size_t> ret =
|
||||
snprintf(str, len + 1, "script %s:%zu:%zu", filename, lineno, colno);
|
||||
MOZ_ASSERT(ret == len);
|
||||
MOZ_ASSERT(strlen(str) == len);
|
||||
|
||||
uint32_t textId = nextTextId;
|
||||
TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, str);
|
||||
if (!payload) {
|
||||
js_free(str);
|
||||
auto* payload = js_new<TraceLoggerEventPayload>(textId, std::move(str));
|
||||
if (!payload)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!textIdPayloads.putNew(textId, payload)) {
|
||||
js_delete(payload);
|
||||
|
@ -1030,8 +1016,8 @@ TraceLoggerEvent::TraceLoggerEvent(TraceLoggerTextId type, JSScript* script)
|
|||
: TraceLoggerEvent(type, script->filename(), script->lineno(), script->column())
|
||||
{ }
|
||||
|
||||
TraceLoggerEvent::TraceLoggerEvent(TraceLoggerTextId type, const char* filename, size_t line,
|
||||
size_t column)
|
||||
TraceLoggerEvent::TraceLoggerEvent(TraceLoggerTextId type, const char* filename, uint32_t line,
|
||||
uint32_t column)
|
||||
: payload_()
|
||||
{
|
||||
MOZ_ASSERT(type == TraceLogger_Scripts || type == TraceLogger_AnnotateScripts ||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "js/AllocPolicy.h"
|
||||
#include "js/HashTable.h"
|
||||
#include "js/TypeDecls.h"
|
||||
|
@ -131,7 +133,7 @@ class TraceLoggerEvent {
|
|||
{}
|
||||
explicit TraceLoggerEvent(TraceLoggerTextId textId);
|
||||
TraceLoggerEvent(TraceLoggerTextId type, JSScript* script);
|
||||
TraceLoggerEvent(TraceLoggerTextId type, const char* filename, size_t line, size_t column);
|
||||
TraceLoggerEvent(TraceLoggerTextId type, const char* filename, uint32_t line, uint32_t column);
|
||||
explicit TraceLoggerEvent(const char* text);
|
||||
TraceLoggerEvent(const TraceLoggerEvent& event);
|
||||
TraceLoggerEvent& operator=(const TraceLoggerEvent& other);
|
||||
|
@ -154,7 +156,7 @@ class TraceLoggerEvent {
|
|||
TraceLoggerEvent() {}
|
||||
explicit TraceLoggerEvent(TraceLoggerTextId textId) {}
|
||||
TraceLoggerEvent(TraceLoggerTextId type, JSScript* script) {}
|
||||
TraceLoggerEvent(TraceLoggerTextId type, const char* filename, size_t line, size_t column) {}
|
||||
TraceLoggerEvent(TraceLoggerTextId type, const char* filename, uint32_t line, uint32_t column) {}
|
||||
explicit TraceLoggerEvent(const char* text) {}
|
||||
TraceLoggerEvent(const TraceLoggerEvent& event) {}
|
||||
TraceLoggerEvent& operator=(const TraceLoggerEvent& other) { return *this; };
|
||||
|
@ -185,9 +187,9 @@ class TraceLoggerEventPayload {
|
|||
mozilla::Atomic<uint32_t> pointerCount_;
|
||||
|
||||
public:
|
||||
TraceLoggerEventPayload(uint32_t textId, char* string)
|
||||
TraceLoggerEventPayload(uint32_t textId, UniqueChars string)
|
||||
: textId_(textId),
|
||||
string_(string),
|
||||
string_(std::move(string)),
|
||||
uses_(0)
|
||||
{ }
|
||||
|
||||
|
@ -442,8 +444,8 @@ class TraceLoggerThreadState
|
|||
// Note: it is not allowed to use them in logTimestamp.
|
||||
TraceLoggerEventPayload* getOrCreateEventPayload(const char* text);
|
||||
TraceLoggerEventPayload* getOrCreateEventPayload(JSScript* script);
|
||||
TraceLoggerEventPayload* getOrCreateEventPayload(const char* filename, size_t lineno,
|
||||
size_t colno, const void* p);
|
||||
TraceLoggerEventPayload* getOrCreateEventPayload(const char* filename, uint32_t lineno,
|
||||
uint32_t colno, const void* p);
|
||||
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) {
|
||||
|
|
|
@ -788,7 +788,7 @@ ByAllocationStack::report(JSContext* cx, CountBase& countBase, MutableHandleValu
|
|||
|
||||
// A count type that categorizes nodes by their script's filename.
|
||||
class ByFilename : public CountType {
|
||||
using UniqueCString = UniquePtr<char, JS::FreePolicy>;
|
||||
using UniqueCString = JS::UniqueChars;
|
||||
|
||||
struct UniqueCStringHasher {
|
||||
using Lookup = UniqueCString;
|
||||
|
@ -880,7 +880,7 @@ ByFilename::count(CountBase& countBase, mozilla::MallocSizeOf mallocSizeOf, cons
|
|||
if (!filename)
|
||||
return count.noFilename->count(mallocSizeOf, node);
|
||||
|
||||
UniqueCString myFilename(js_strdup(filename));
|
||||
UniqueCString myFilename = DuplicateString(filename);
|
||||
if (!myFilename)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
#include "nsIBoxObject.h"
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsMenuPopupFrame.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "nsIDOMXULMultSelectCntrlEl.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "nsIDOMXULMenuListElement.h"
|
||||
|
@ -8364,11 +8364,10 @@ PresShell::GetCurrentItemAndPositionForElement(Element* aFocusedElement,
|
|||
(currentIndex - firstVisibleRow + 1) * rowHeight);
|
||||
istree = true;
|
||||
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
RefPtr<nsTreeColumns> cols;
|
||||
treeBox->GetColumns(getter_AddRefs(cols));
|
||||
if (cols) {
|
||||
nsCOMPtr<nsITreeColumn> col;
|
||||
cols->GetFirstColumn(getter_AddRefs(col));
|
||||
nsTreeColumn* col = cols->GetFirstColumn();
|
||||
if (col) {
|
||||
RefPtr<Element> colElement;
|
||||
col->GetElement(getter_AddRefs(colElement));
|
||||
|
|
|
@ -2202,7 +2202,7 @@ RestyleManager::PostRestyleEventForAnimations(
|
|||
|
||||
if (!elementToRestyle) {
|
||||
// FIXME: Bug 1371107: When reframing happens,
|
||||
// EffectCompositor::mElementsToRestyle still has unbinded old pseudo
|
||||
// EffectCompositor::mElementsToRestyle still has unbound old pseudo
|
||||
// element. We should drop it.
|
||||
return;
|
||||
}
|
||||
|
@ -2216,8 +2216,8 @@ void
|
|||
RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
|
||||
nsRestyleHint aRestyleHint)
|
||||
{
|
||||
// NOTE(emilio): GeckoRestlyeManager does a sync style flush, which seems not
|
||||
// to be needed in my testing.
|
||||
// NOTE(emilio): GeckoRestlyeManager does a sync style flush, which seems not
|
||||
// to be needed in my testing.
|
||||
PostRebuildAllStyleDataEvent(aExtraHint, aRestyleHint);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/css/ErrorReporter.h"
|
||||
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
@ -68,7 +69,6 @@ private:
|
|||
|
||||
} // namespace
|
||||
|
||||
bool ErrorReporter::sReportErrors = false;
|
||||
bool ErrorReporter::sInitialized = false;
|
||||
|
||||
static nsIConsoleService *sConsoleService;
|
||||
|
@ -76,8 +76,6 @@ static nsIFactory *sScriptErrorFactory;
|
|||
static nsIStringBundle *sStringBundle;
|
||||
static ShortTermURISpecCache *sSpecCache;
|
||||
|
||||
#define CSS_ERRORS_PREF "layout.css.report_errors"
|
||||
|
||||
void
|
||||
ErrorReporter::InitGlobals()
|
||||
{
|
||||
|
@ -86,12 +84,6 @@ ErrorReporter::InitGlobals()
|
|||
|
||||
sInitialized = true;
|
||||
|
||||
if (NS_FAILED(Preferences::AddBoolVarCache(&sReportErrors,
|
||||
CSS_ERRORS_PREF,
|
||||
true))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
if (!cs) {
|
||||
return;
|
||||
|
@ -131,17 +123,33 @@ ErrorReporter::ReleaseGlobals()
|
|||
NS_IF_RELEASE(sSpecCache);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
FindInnerWindowID(const StyleSheet* aSheet, const Loader* aLoader)
|
||||
{
|
||||
uint64_t innerWindowID = 0;
|
||||
if (aSheet) {
|
||||
innerWindowID = aSheet->FindOwningWindowInnerID();
|
||||
}
|
||||
if (innerWindowID == 0 && aLoader) {
|
||||
if (nsIDocument* doc = aLoader->GetDocument()) {
|
||||
innerWindowID = doc->InnerWindowID();
|
||||
}
|
||||
}
|
||||
return innerWindowID;
|
||||
}
|
||||
|
||||
ErrorReporter::ErrorReporter(const StyleSheet* aSheet,
|
||||
const Loader* aLoader,
|
||||
nsIURI* aURI)
|
||||
: mSheet(aSheet)
|
||||
, mLoader(aLoader)
|
||||
, mURI(aURI)
|
||||
, mInnerWindowID(0)
|
||||
, mErrorLineNumber(0)
|
||||
, mPrevErrorLineNumber(0)
|
||||
, mErrorColNumber(0)
|
||||
{
|
||||
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
|
||||
EnsureGlobalsInitialized();
|
||||
}
|
||||
|
||||
ErrorReporter::~ErrorReporter()
|
||||
|
@ -189,30 +197,24 @@ SheetOwner(const StyleSheet& aSheet)
|
|||
}
|
||||
|
||||
bool
|
||||
ErrorReporter::ShouldReportErrors()
|
||||
ErrorReporter::ShouldReportErrors(const StyleSheet* aSheet,
|
||||
const Loader* aLoader)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
EnsureGlobalsInitialized();
|
||||
if (!sReportErrors) {
|
||||
if (!StaticPrefs::layout_css_report_errors()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mInnerWindowID) {
|
||||
// We already reported an error, and that has cleared mSheet and mLoader, so
|
||||
// we'd get the bogus value otherwise.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mSheet) {
|
||||
nsINode* owner = SheetOwner(*mSheet);
|
||||
if (aSheet) {
|
||||
nsINode* owner = SheetOwner(*aSheet);
|
||||
if (owner && ShouldReportErrors(*owner->OwnerDoc())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLoader && mLoader->GetDocument() &&
|
||||
ShouldReportErrors(*mLoader->GetDocument())) {
|
||||
if (aLoader && aLoader->GetDocument() &&
|
||||
ShouldReportErrors(*aLoader->GetDocument())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,27 +225,12 @@ void
|
|||
ErrorReporter::OutputError()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(ShouldReportErrors());
|
||||
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
|
||||
|
||||
if (mError.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInnerWindowID == 0 && (mSheet || mLoader)) {
|
||||
if (mSheet) {
|
||||
mInnerWindowID = mSheet->FindOwningWindowInnerID();
|
||||
}
|
||||
if (mInnerWindowID == 0 && mLoader) {
|
||||
nsIDocument* doc = mLoader->GetDocument();
|
||||
if (doc) {
|
||||
mInnerWindowID = doc->InnerWindowID();
|
||||
}
|
||||
}
|
||||
// don't attempt this again, even if we failed
|
||||
mSheet = nullptr;
|
||||
mLoader = nullptr;
|
||||
}
|
||||
|
||||
if (mFileName.IsEmpty()) {
|
||||
if (mURI) {
|
||||
if (!sSpecCache) {
|
||||
|
@ -271,7 +258,7 @@ ErrorReporter::OutputError()
|
|||
mErrorColNumber,
|
||||
nsIScriptError::warningFlag,
|
||||
"CSS Parser",
|
||||
mInnerWindowID);
|
||||
FindInnerWindowID(mSheet, mLoader));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
sConsoleService->LogMessage(errorObject);
|
||||
}
|
||||
|
@ -319,7 +306,7 @@ ErrorReporter::ClearError()
|
|||
void
|
||||
ErrorReporter::AddToError(const nsString &aErrorText)
|
||||
{
|
||||
MOZ_ASSERT(ShouldReportErrors());
|
||||
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
|
||||
|
||||
if (mError.IsEmpty()) {
|
||||
mError = aErrorText;
|
||||
|
@ -332,7 +319,7 @@ ErrorReporter::AddToError(const nsString &aErrorText)
|
|||
void
|
||||
ErrorReporter::ReportUnexpected(const char *aMessage)
|
||||
{
|
||||
MOZ_ASSERT(ShouldReportErrors());
|
||||
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
|
||||
|
||||
nsAutoString str;
|
||||
sStringBundle->GetStringFromName(aMessage, str);
|
||||
|
@ -343,7 +330,7 @@ void
|
|||
ErrorReporter::ReportUnexpectedUnescaped(const char *aMessage,
|
||||
const nsAutoString& aParam)
|
||||
{
|
||||
MOZ_ASSERT(ShouldReportErrors());
|
||||
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
|
||||
|
||||
const char16_t *params[1] = { aParam.get() };
|
||||
|
||||
|
|
|
@ -22,11 +22,14 @@ namespace css {
|
|||
|
||||
class Loader;
|
||||
|
||||
class ErrorReporter {
|
||||
// FIXME(emilio): Probably better to call this ErrorBuilder or something?
|
||||
class MOZ_STACK_CLASS ErrorReporter final
|
||||
{
|
||||
public:
|
||||
ErrorReporter(const StyleSheet* aSheet,
|
||||
const Loader* aLoader,
|
||||
nsIURI* aURI);
|
||||
|
||||
~ErrorReporter();
|
||||
|
||||
static void ReleaseGlobals();
|
||||
|
@ -38,8 +41,8 @@ public:
|
|||
}
|
||||
|
||||
static bool ShouldReportErrors(const nsIDocument&);
|
||||
|
||||
bool ShouldReportErrors();
|
||||
static bool ShouldReportErrors(const StyleSheet* aSheet,
|
||||
const Loader* aLoader);
|
||||
|
||||
void OutputError(uint32_t aLineNumber,
|
||||
uint32_t aLineOffset,
|
||||
|
@ -64,13 +67,12 @@ private:
|
|||
static bool sInitialized;
|
||||
static bool sReportErrors;
|
||||
|
||||
nsAutoString mError;
|
||||
nsString mError;
|
||||
nsString mErrorLine;
|
||||
nsString mFileName;
|
||||
const StyleSheet* mSheet;
|
||||
const Loader* mLoader;
|
||||
nsIURI *mURI;
|
||||
uint64_t mInnerWindowID;
|
||||
nsIURI* mURI;
|
||||
uint32_t mErrorLineNumber;
|
||||
uint32_t mPrevErrorLineNumber;
|
||||
uint32_t mErrorColNumber;
|
||||
|
|
|
@ -122,13 +122,6 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowInner* aWindow, nsIDocument* aDocument)
|
|||
mStandardFontLoadPrincipal =
|
||||
new gfxFontSrcPrincipal(mDocument->NodePrincipal());
|
||||
|
||||
// If the pref is not set, don't create the Promise (which the page wouldn't
|
||||
// be able to get to anyway) as it causes the window.FontFaceSet constructor
|
||||
// to be created.
|
||||
if (aWindow && PrefEnabled()) {
|
||||
mResolveLazilyCreatedReadyPromise = true;
|
||||
}
|
||||
|
||||
// Record the state of the "bypass cache" flags from the docshell now,
|
||||
// since we want to look at them from style worker threads, and we can
|
||||
// only get to the docshell through a weak pointer (which is only
|
||||
|
@ -1698,9 +1691,12 @@ FontFaceSet::DispatchLoadingEventAndReplaceReadyPromise()
|
|||
mReady = Promise::Create(GetParentObject(), rv);
|
||||
}
|
||||
}
|
||||
if (!mReady) {
|
||||
mResolveLazilyCreatedReadyPromise = false;
|
||||
}
|
||||
|
||||
// We may previously have been in a state where all fonts had finished
|
||||
// loading and we'd set mResolveLazilyCreatedReadyPromise to make sure that
|
||||
// if we lazily create mReady for a consumer that we resolve it before
|
||||
// returning it. We're now loading fonts, so we need to clear that flag.
|
||||
mResolveLazilyCreatedReadyPromise = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2785,24 +2785,16 @@ Gecko_SetJemallocThreadLocalArena(bool enabled)
|
|||
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
|
||||
ErrorReporter*
|
||||
Gecko_CreateCSSErrorReporter(StyleSheet* aSheet,
|
||||
Loader* aLoader,
|
||||
nsIURI* aURI)
|
||||
bool
|
||||
Gecko_ErrorReportingEnabled(const StyleSheet* aSheet, const Loader* aLoader)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return new ErrorReporter(aSheet, aLoader, aURI);
|
||||
return ErrorReporter::ShouldReportErrors(aSheet, aLoader);
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_DestroyCSSErrorReporter(ErrorReporter* reporter)
|
||||
{
|
||||
delete reporter;
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_ReportUnexpectedCSSError(ErrorReporter* reporter,
|
||||
Gecko_ReportUnexpectedCSSError(const StyleSheet* aSheet,
|
||||
const Loader* aLoader,
|
||||
nsIURI* aURI,
|
||||
const char* message,
|
||||
const char* param,
|
||||
uint32_t paramLen,
|
||||
|
@ -2815,35 +2807,33 @@ Gecko_ReportUnexpectedCSSError(ErrorReporter* reporter,
|
|||
uint32_t lineNumber,
|
||||
uint32_t colNumber)
|
||||
{
|
||||
if (!reporter->ShouldReportErrors()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
ErrorReporter reporter(aSheet, aLoader, aURI);
|
||||
|
||||
if (prefix) {
|
||||
if (prefixParam) {
|
||||
nsDependentCSubstring paramValue(prefixParam, prefixParamLen);
|
||||
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
|
||||
reporter->ReportUnexpectedUnescaped(prefix, wideParam);
|
||||
reporter.ReportUnexpectedUnescaped(prefix, wideParam);
|
||||
} else {
|
||||
reporter->ReportUnexpected(prefix);
|
||||
reporter.ReportUnexpected(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
if (param) {
|
||||
nsDependentCSubstring paramValue(param, paramLen);
|
||||
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
|
||||
reporter->ReportUnexpectedUnescaped(message, wideParam);
|
||||
reporter.ReportUnexpectedUnescaped(message, wideParam);
|
||||
} else {
|
||||
reporter->ReportUnexpected(message);
|
||||
reporter.ReportUnexpected(message);
|
||||
}
|
||||
|
||||
if (suffix) {
|
||||
reporter->ReportUnexpected(suffix);
|
||||
reporter.ReportUnexpected(suffix);
|
||||
}
|
||||
nsDependentCSubstring sourceValue(source, sourceLen);
|
||||
reporter->OutputError(lineNumber, colNumber, sourceValue);
|
||||
reporter.OutputError(lineNumber, colNumber, sourceValue);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -687,11 +687,11 @@ void Gecko_AnnotateCrashReport(const char* key_str, const char* value_str);
|
|||
#include "mozilla/ServoBindingList.h"
|
||||
#undef SERVO_BINDING_FUNC
|
||||
|
||||
mozilla::css::ErrorReporter* Gecko_CreateCSSErrorReporter(mozilla::StyleSheet* sheet,
|
||||
mozilla::css::Loader* loader,
|
||||
nsIURI* uri);
|
||||
void Gecko_DestroyCSSErrorReporter(mozilla::css::ErrorReporter* reporter);
|
||||
void Gecko_ReportUnexpectedCSSError(mozilla::css::ErrorReporter* reporter,
|
||||
bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
|
||||
const mozilla::css::Loader* loader);
|
||||
void Gecko_ReportUnexpectedCSSError(const mozilla::StyleSheet* sheet,
|
||||
const mozilla::css::Loader* loader,
|
||||
nsIURI* uri,
|
||||
const char* message,
|
||||
const char* param,
|
||||
uint32_t paramLen,
|
||||
|
|
|
@ -67,7 +67,6 @@ headers = [
|
|||
"mozilla/Keyframe.h",
|
||||
"mozilla/ServoElementSnapshot.h",
|
||||
"mozilla/ServoElementSnapshotTable.h",
|
||||
"mozilla/css/ErrorReporter.h",
|
||||
"mozilla/dom/Element.h",
|
||||
"mozilla/dom/ChildIterator.h",
|
||||
"mozilla/dom/NameSpaceConstants.h",
|
||||
|
@ -224,7 +223,6 @@ whitelist-types = [
|
|||
"mozilla::ServoStyleSheetInner",
|
||||
"mozilla::ServoStyleSetSizes",
|
||||
"mozilla::ServoTraversalStatistics",
|
||||
"mozilla::css::ErrorReporter",
|
||||
"mozilla::css::LoaderReusableStyleSheets",
|
||||
"mozilla::css::SheetLoadData",
|
||||
"mozilla::css::SheetLoadDataHolder",
|
||||
|
@ -453,7 +451,6 @@ raw-lines = [
|
|||
whitelist-functions = ["Servo_.*", "Gecko_.*"]
|
||||
structs-types = [
|
||||
"mozilla::css::GridTemplateAreasValue",
|
||||
"mozilla::css::ErrorReporter",
|
||||
"mozilla::css::ImageValue",
|
||||
"mozilla::css::URLValue",
|
||||
"mozilla::css::URLValueData",
|
||||
|
|
|
@ -224,12 +224,12 @@ function runTest() {
|
|||
|
||||
}).then(function() {
|
||||
|
||||
// (TEST 3) Test that document.fonts.ready starts out resolved with the
|
||||
// FontFaceSet.
|
||||
// (TEST 3) Test that document.fonts.ready is resolved with the
|
||||
// document.fonts FontFaceSet.
|
||||
var p = Promise.resolve();
|
||||
sourceDocuments.forEach(function({ doc, what }) {
|
||||
p = p.then(function() {
|
||||
return is_resolved_with(doc.fonts.ready, doc.fonts, "initial value of document.fonts", "(TEST 3) (" + what + ")");
|
||||
p = p.then(doc.fonts.ready).then(function() {
|
||||
return is_resolved_with(doc.fonts.ready, doc.fonts, "document.fonts.ready resolves with document.fonts", "(TEST 3) (" + what + ")");
|
||||
});
|
||||
});
|
||||
return p;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#endif
|
||||
#include "nsIRootBox.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
#include "nsString.h"
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#endif
|
||||
#include "nsWeakPtr.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsITreeColumn;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "nsError.h"
|
||||
#include "nsTreeBodyFrame.h"
|
||||
#include "mozilla/dom/TreeBoxObjectBinding.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -237,7 +236,7 @@ TreeBoxObject::GetColumns()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TreeBoxObject::GetColumns(nsITreeColumns** aColumns)
|
||||
NS_IMETHODIMP TreeBoxObject::GetColumns(nsTreeColumns** aColumns)
|
||||
{
|
||||
*aColumns = GetColumns().take();
|
||||
return NS_OK;
|
||||
|
|
|
@ -10,7 +10,6 @@ with Files('**'):
|
|||
XPIDL_SOURCES += [
|
||||
'nsITreeBoxObject.idl',
|
||||
'nsITreeColumns.idl',
|
||||
'nsITreeContentView.idl',
|
||||
'nsITreeSelection.idl',
|
||||
'nsITreeView.idl',
|
||||
]
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
interface nsITreeView;
|
||||
interface nsITreeSelection;
|
||||
interface nsITreeColumn;
|
||||
interface nsITreeColumns;
|
||||
interface nsIScriptableRegion;
|
||||
|
||||
webidl Element;
|
||||
webidl TreeColumns;
|
||||
|
||||
/**
|
||||
* This interface cannot become builtinclass until bug 1438525 is fixed.
|
||||
|
@ -22,7 +22,7 @@ interface nsITreeBoxObject : nsISupports
|
|||
/**
|
||||
* Obtain the columns.
|
||||
*/
|
||||
readonly attribute nsITreeColumns columns;
|
||||
readonly attribute TreeColumns columns;
|
||||
|
||||
/**
|
||||
* The view that backs the tree and that supplies it with its data.
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsITreeColumns;
|
||||
|
||||
webidl Element;
|
||||
webidl TreeColumns;
|
||||
|
||||
[scriptable, uuid(ae835ecf-6b32-4660-9b43-8a270df56e02)]
|
||||
interface nsITreeColumn : nsISupports
|
||||
{
|
||||
readonly attribute Element element;
|
||||
|
||||
readonly attribute nsITreeColumns columns;
|
||||
readonly attribute TreeColumns columns;
|
||||
|
||||
readonly attribute long x;
|
||||
readonly attribute long width;
|
||||
|
@ -38,57 +37,3 @@ interface nsITreeColumn : nsISupports
|
|||
|
||||
void invalidate();
|
||||
};
|
||||
|
||||
interface nsITreeBoxObject;
|
||||
|
||||
[scriptable, uuid(f8a8d6b4-6788-438d-9009-7142798767ab)]
|
||||
interface nsITreeColumns : nsISupports
|
||||
{
|
||||
/**
|
||||
* The tree widget for these columns.
|
||||
*/
|
||||
readonly attribute nsITreeBoxObject tree;
|
||||
|
||||
/**
|
||||
* The number of columns.
|
||||
*/
|
||||
readonly attribute long count;
|
||||
|
||||
/**
|
||||
* An alias for count (for the benefit of scripts which treat this as an
|
||||
* array).
|
||||
*/
|
||||
readonly attribute long length;
|
||||
|
||||
/**
|
||||
* Get the first/last column.
|
||||
*/
|
||||
nsITreeColumn getFirstColumn();
|
||||
nsITreeColumn getLastColumn();
|
||||
|
||||
/**
|
||||
* Attribute based column getters.
|
||||
*/
|
||||
nsITreeColumn getPrimaryColumn();
|
||||
nsITreeColumn getSortedColumn();
|
||||
nsITreeColumn getKeyColumn();
|
||||
|
||||
/**
|
||||
* Get the column for the given element.
|
||||
*/
|
||||
nsITreeColumn getColumnFor(in Element element);
|
||||
|
||||
/**
|
||||
* Parametric column getters.
|
||||
*/
|
||||
nsITreeColumn getNamedColumn(in AString id);
|
||||
nsITreeColumn getColumnAt(in long index);
|
||||
|
||||
/**
|
||||
* This method is called whenever a treecol is added or removed and
|
||||
* the column cache needs to be rebuilt.
|
||||
*/
|
||||
void invalidateColumns();
|
||||
|
||||
void restoreNaturalOrder();
|
||||
};
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
webidl Element;
|
||||
|
||||
[scriptable, uuid(5ef62896-0c0a-41f1-bb3c-44a60f5dfdab)]
|
||||
interface nsITreeContentView : nsISupports
|
||||
{
|
||||
/**
|
||||
* Retrieve the content item associated with the specified index.
|
||||
*/
|
||||
Element getItemAtIndex(in long index);
|
||||
|
||||
/**
|
||||
* Retrieve the index associated with the specified content item.
|
||||
*/
|
||||
long getIndexOfItem(in Element item);
|
||||
};
|
|
@ -13,7 +13,7 @@
|
|||
#include "nsIBoxObject.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/TreeBoxObject.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsTreeBodyFrame.h"
|
||||
#include "nsXULElement.h"
|
||||
|
@ -185,7 +185,7 @@ nsTreeColFrame::InvalidateColumns(bool aCanWalkFrameTree)
|
|||
{
|
||||
nsITreeBoxObject* treeBoxObject = GetTreeBoxObject();
|
||||
if (treeBoxObject) {
|
||||
nsCOMPtr<nsITreeColumns> columns;
|
||||
RefPtr<nsTreeColumns> columns;
|
||||
|
||||
if (aCanWalkFrameTree) {
|
||||
treeBoxObject->GetColumns(getter_AddRefs(columns));
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
nsITreeBoxObject* GetTreeBoxObject();
|
||||
|
||||
/**
|
||||
* Helper method that gets the nsITreeColumns object this column belongs to
|
||||
* Helper method that gets the TreeColumns object this column belongs to
|
||||
* and calls InvalidateColumns() on it.
|
||||
*/
|
||||
void InvalidateColumns(bool aCanWalkFrameTree = true);
|
||||
|
|
|
@ -157,7 +157,7 @@ nsTreeColumn::GetElement(Element** aElement)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumn::GetColumns(nsITreeColumns** aColumns)
|
||||
nsTreeColumn::GetColumns(nsTreeColumns** aColumns)
|
||||
{
|
||||
NS_IF_ADDREF(*aColumns = mColumns);
|
||||
return NS_OK;
|
||||
|
@ -404,7 +404,6 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(nsTreeColumns)
|
|||
// QueryInterface implementation for nsTreeColumns
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumns)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsITreeColumns)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -429,13 +428,6 @@ nsTreeColumns::GetTree() const
|
|||
return mTree ? static_cast<mozilla::dom::TreeBoxObject*>(mTree->GetTreeBoxObject()) : nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetTree(nsITreeBoxObject** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetTree());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsTreeColumns::Count()
|
||||
{
|
||||
|
@ -447,27 +439,6 @@ nsTreeColumns::Count()
|
|||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetCount(int32_t* _retval)
|
||||
{
|
||||
*_retval = Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetLength(int32_t* _retval)
|
||||
{
|
||||
*_retval = Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetFirstColumn(nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetFirstColumn());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
nsTreeColumns::GetLastColumn()
|
||||
{
|
||||
|
@ -483,20 +454,6 @@ nsTreeColumns::GetLastColumn()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetLastColumn(nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetLastColumn());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetPrimaryColumn(nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetPrimaryColumn());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
nsTreeColumns::GetSortedColumn()
|
||||
{
|
||||
|
@ -511,13 +468,6 @@ nsTreeColumns::GetSortedColumn()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetSortedColumn(nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetSortedColumn());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
nsTreeColumns::GetKeyColumn()
|
||||
{
|
||||
|
@ -562,13 +512,6 @@ nsTreeColumns::GetKeyColumn()
|
|||
return first;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetKeyColumn(nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetKeyColumn());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
nsTreeColumns::GetColumnFor(dom::Element* aElement)
|
||||
{
|
||||
|
@ -581,13 +524,6 @@ nsTreeColumns::GetColumnFor(dom::Element* aElement)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetColumnFor(dom::Element* aElement, nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetColumnFor(aElement));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
nsTreeColumns::NamedGetter(const nsAString& aId, bool& aFound)
|
||||
{
|
||||
|
@ -609,13 +545,6 @@ nsTreeColumns::GetNamedColumn(const nsAString& aId)
|
|||
return NamedGetter(aId, dummy);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetNamedColumn(const nsAString& aId, nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetNamedColumn(aId));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeColumns::GetSupportedNames(nsTArray<nsString>& aNames)
|
||||
{
|
||||
|
@ -646,14 +575,7 @@ nsTreeColumns::GetColumnAt(uint32_t aIndex)
|
|||
return IndexedGetter(aIndex, dummy);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeColumns::GetColumnAt(int32_t aIndex, nsITreeColumn** _retval)
|
||||
{
|
||||
NS_IF_ADDREF(*_retval = GetColumnAt(static_cast<uint32_t>(aIndex)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeColumns::InvalidateColumns()
|
||||
{
|
||||
for (nsTreeColumn* currCol = mFirstColumn; currCol;
|
||||
|
@ -661,22 +583,23 @@ nsTreeColumns::InvalidateColumns()
|
|||
currCol->SetColumns(nullptr);
|
||||
}
|
||||
mFirstColumn = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeColumns::RestoreNaturalOrder()
|
||||
{
|
||||
if (!mTree)
|
||||
return NS_OK;
|
||||
if (!mTree) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIContent* content = mTree->GetBaseElement();
|
||||
|
||||
// Strong ref, since we'll be setting attributes
|
||||
nsCOMPtr<nsIContent> colsContent =
|
||||
nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treecols);
|
||||
if (!colsContent)
|
||||
return NS_OK;
|
||||
if (!colsContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t i = 0;
|
||||
for (nsINode* child = colsContent->GetFirstChild();
|
||||
|
@ -694,7 +617,6 @@ nsTreeColumns::RestoreNaturalOrder()
|
|||
if (mTree) {
|
||||
mTree->Invalidate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTreeColumn*
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "nsWrapperCache.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsAtom;
|
||||
class nsTreeBodyFrame;
|
||||
class nsTreeColumns;
|
||||
class nsIFrame;
|
||||
|
@ -160,7 +161,7 @@ private:
|
|||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
|
||||
|
||||
class nsTreeColumns final : public nsITreeColumns
|
||||
class nsTreeColumns final : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
private:
|
||||
|
@ -171,7 +172,6 @@ public:
|
|||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns)
|
||||
NS_DECL_NSITREECOLUMNS
|
||||
|
||||
nsIContent* GetParentObject() const;
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
@ -199,8 +199,8 @@ public:
|
|||
nsTreeColumn* GetNamedColumn(const nsAString& aId);
|
||||
void GetSupportedNames(nsTArray<nsString>& aNames);
|
||||
|
||||
// Uses XPCOM InvalidateColumns().
|
||||
// Uses XPCOM RestoreNaturalOrder().
|
||||
void InvalidateColumns();
|
||||
void RestoreNaturalOrder();
|
||||
|
||||
friend class nsTreeBodyFrame;
|
||||
protected:
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsError.h"
|
||||
#include "nsIXULSortService.h"
|
||||
#include "nsTreeBodyFrame.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/TreeContentViewBinding.h"
|
||||
|
@ -116,10 +117,9 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeContentView)
|
|||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeContentView)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITreeView)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITreeContentView)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITreeContentView)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITreeView)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -875,32 +875,12 @@ nsTreeContentView::GetItemAtIndex(int32_t aIndex, ErrorResult& aError)
|
|||
return mRows[aIndex]->mContent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeContentView::GetItemAtIndex(int32_t aIndex, Element** _retval)
|
||||
{
|
||||
ErrorResult rv;
|
||||
RefPtr<Element> element = GetItemAtIndex(aIndex, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
element.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsTreeContentView::GetIndexOfItem(Element* aItem)
|
||||
{
|
||||
return FindContent(aItem);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeContentView::GetIndexOfItem(Element* aItem, int32_t* _retval)
|
||||
{
|
||||
*_retval = GetIndexOfItem(aItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeContentView::AttributeChanged(dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
|
@ -972,11 +952,10 @@ nsTreeContentView::AttributeChanged(dom::Element* aElement,
|
|||
if (aElement->IsXULElement(nsGkAtoms::treecol)) {
|
||||
if (aAttribute == nsGkAtoms::properties) {
|
||||
if (mBoxObject) {
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
RefPtr<nsTreeColumns> cols;
|
||||
mBoxObject->GetColumns(getter_AddRefs(cols));
|
||||
if (cols) {
|
||||
nsCOMPtr<nsITreeColumn> col;
|
||||
cols->GetColumnFor(aElement, getter_AddRefs(col));
|
||||
RefPtr<nsTreeColumn> col = cols->GetColumnFor(aElement);
|
||||
mBoxObject->InvalidateColumn(col);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsITreeView.h"
|
||||
#include "nsITreeContentView.h"
|
||||
#include "nsITreeSelection.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
@ -33,7 +32,6 @@ class TreeBoxObject;
|
|||
nsresult NS_NewTreeContentView(nsITreeView** aResult);
|
||||
|
||||
class nsTreeContentView final : public nsITreeView,
|
||||
public nsITreeContentView,
|
||||
public nsStubDocumentObserver,
|
||||
public nsWrapperCache
|
||||
{
|
||||
|
@ -119,8 +117,6 @@ class nsTreeContentView final : public nsITreeView,
|
|||
|
||||
NS_DECL_NSITREEVIEW
|
||||
|
||||
NS_DECL_NSITREECONTENTVIEW
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTreeColumns.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTreeImageListener, imgINotificationObserver)
|
||||
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsTreeBodyFrame.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsITreeColumn;
|
||||
|
||||
// This class handles image load observation.
|
||||
class nsTreeImageListener final : public imgINotificationObserver
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsNameSpaceManager.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsTreeColumns.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
#define nsTreeSelection_h__
|
||||
|
||||
#include "nsITreeSelection.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsITreeBoxObject;
|
||||
class nsITreeColumn;
|
||||
struct nsTreeRange;
|
||||
|
||||
class nsTreeSelection final : public nsINativeTreeSelection
|
||||
|
|
|
@ -81,8 +81,9 @@ namespace mozilla {
|
|||
*/
|
||||
class CorruptionCanary {
|
||||
public:
|
||||
CorruptionCanary() {
|
||||
mValue = kCanarySet;
|
||||
constexpr CorruptionCanary()
|
||||
: mValue(kCanarySet)
|
||||
{
|
||||
}
|
||||
|
||||
~CorruptionCanary() {
|
||||
|
|
|
@ -170,6 +170,13 @@ VARCACHE_PREF(
|
|||
bool, true
|
||||
)
|
||||
|
||||
// Is CSS error reporting enabled?
|
||||
VARCACHE_PREF(
|
||||
"layout.css.report_errors",
|
||||
layout_css_report_errors,
|
||||
bool, true
|
||||
)
|
||||
|
||||
// Is support for the font-display @font-face descriptor enabled?
|
||||
VARCACHE_PREF(
|
||||
"layout.css.font-display.enabled",
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "nsArrayUtils.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsITreeColumns.h"
|
||||
#include "nsIX509CertDB.h"
|
||||
#include "nsIX509Cert.h"
|
||||
#include "nsIX509CertValidity.h"
|
||||
|
@ -23,6 +22,7 @@
|
|||
#include "nsUnicharUtils.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTreeColumns.h"
|
||||
#include "pkix/pkixtypes.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
|
@ -9,21 +9,25 @@
|
|||
use cssparser::{CowRcStr, serialize_identifier, ToCss};
|
||||
use cssparser::{SourceLocation, ParseError, ParseErrorKind, Token, BasicParseErrorKind};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::cell::Cell;
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use style::gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter};
|
||||
use style::gecko_bindings::bindings::Gecko_ReportUnexpectedCSSError;
|
||||
use style::gecko_bindings::bindings;
|
||||
use style::gecko_bindings::structs::{Loader, StyleSheet as DomStyleSheet, nsIURI};
|
||||
use style::gecko_bindings::structs::ErrorReporter as GeckoErrorReporter;
|
||||
use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData;
|
||||
use style::stylesheets::UrlExtraData;
|
||||
use style_traits::{StyleParseErrorKind, ValueParseErrorKind};
|
||||
|
||||
pub type ErrorKind<'i> = ParseErrorKind<'i, StyleParseErrorKind<'i>>;
|
||||
|
||||
/// Wrapper around an instance of Gecko's CSS error reporter.
|
||||
pub struct ErrorReporter(*mut GeckoErrorReporter);
|
||||
/// An error reporter with all the data we need to report errors.
|
||||
pub struct ErrorReporter {
|
||||
sheet: *const DomStyleSheet,
|
||||
loader: *const Loader,
|
||||
uri: *mut nsIURI,
|
||||
cached_error_reporting_enabled: Cell<Option<bool>>,
|
||||
}
|
||||
|
||||
impl ErrorReporter {
|
||||
/// Create a new instance of the Gecko error reporter.
|
||||
|
@ -32,19 +36,17 @@ impl ErrorReporter {
|
|||
loader: *mut Loader,
|
||||
extra_data: *mut RawUrlExtraData,
|
||||
) -> Self {
|
||||
unsafe {
|
||||
let url = extra_data.as_ref()
|
||||
let uri = unsafe {
|
||||
extra_data.as_ref()
|
||||
.map(|d| d.mBaseURI.raw::<nsIURI>())
|
||||
.unwrap_or(ptr::null_mut());
|
||||
ErrorReporter(Gecko_CreateCSSErrorReporter(sheet, loader, url))
|
||||
}
|
||||
}
|
||||
}
|
||||
.unwrap_or(ptr::null_mut())
|
||||
};
|
||||
|
||||
impl Drop for ErrorReporter {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
Gecko_DestroyCSSErrorReporter(self.0);
|
||||
ErrorReporter {
|
||||
sheet,
|
||||
loader,
|
||||
uri,
|
||||
cached_error_reporting_enabled: Cell::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +393,22 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
|
|||
}
|
||||
|
||||
impl ErrorReporter {
|
||||
fn reporting_enabled(&self) -> bool {
|
||||
if let Some(enabled) = self.cached_error_reporting_enabled.get() {
|
||||
return enabled;
|
||||
}
|
||||
let enabled = unsafe {
|
||||
bindings::Gecko_ErrorReportingEnabled(self.sheet, self.loader)
|
||||
};
|
||||
self.cached_error_reporting_enabled.set(Some(enabled));
|
||||
enabled
|
||||
}
|
||||
|
||||
pub fn report(&self, location: SourceLocation, error: ContextualParseError) {
|
||||
if !self.reporting_enabled() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (pre, name, action) = error.to_gecko_message();
|
||||
let suffix = match action {
|
||||
Action::Nothing => ptr::null(),
|
||||
|
@ -408,18 +425,22 @@ impl ErrorReporter {
|
|||
// The CSS source text is unused and will be removed in bug 1381188.
|
||||
let source = "";
|
||||
unsafe {
|
||||
Gecko_ReportUnexpectedCSSError(self.0,
|
||||
name.as_ptr() as *const _,
|
||||
param_ptr as *const _,
|
||||
param.as_ref().map_or(0, |p| p.len()) as u32,
|
||||
pre.map_or(ptr::null(), |p| p.as_ptr()) as *const _,
|
||||
pre_param_ptr as *const _,
|
||||
pre_param.as_ref().map_or(0, |p| p.len()) as u32,
|
||||
suffix as *const _,
|
||||
source.as_ptr() as *const _,
|
||||
source.len() as u32,
|
||||
location.line,
|
||||
location.column);
|
||||
bindings::Gecko_ReportUnexpectedCSSError(
|
||||
self.sheet,
|
||||
self.loader,
|
||||
self.uri,
|
||||
name.as_ptr() as *const _,
|
||||
param_ptr as *const _,
|
||||
param.as_ref().map_or(0, |p| p.len()) as u32,
|
||||
pre.map_or(ptr::null(), |p| p.as_ptr()) as *const _,
|
||||
pre_param_ptr as *const _,
|
||||
pre_param.as_ref().map_or(0, |p| p.len()) as u32,
|
||||
suffix as *const _,
|
||||
source.as_ptr() as *const _,
|
||||
source.len() as u32,
|
||||
location.line,
|
||||
location.column,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,8 +161,6 @@ job-template:
|
|||
# no default, so we fail on new entries
|
||||
options:
|
||||
- revision=$GECKO_HEAD_REV
|
||||
- total-chunks=1
|
||||
- this-chunk=1
|
||||
actions:
|
||||
by-build-platform:
|
||||
default: ['clone-locales', 'list-locales', 'setup', 'repack',
|
||||
|
@ -181,6 +179,7 @@ job-template:
|
|||
- testing/mozharness/configs/single_locale/**
|
||||
- testing/mozharness/mozharness/mozilla/l10n/locales.py
|
||||
- testing/mozharness/scripts/desktop_l10n.py
|
||||
- testing/mozharness/scripts/mobile_l10n.py
|
||||
- third_party/python/compare-locales/**
|
||||
- toolkit/locales/**
|
||||
- toolkit/mozapps/installer/**
|
||||
|
|
|
@ -218,10 +218,10 @@ job-template:
|
|||
actions:
|
||||
by-build-platform:
|
||||
default: ['clone-locales', 'list-locales', 'setup', 'repack',
|
||||
'submit-to-balrog', 'summary']
|
||||
'summary']
|
||||
android-api-16-nightly: ['get-secrets',
|
||||
'clone-locales', 'list-locales', 'setup', 'repack',
|
||||
'upload-repacks', 'submit-to-balrog', 'summary']
|
||||
'upload-repacks', 'summary']
|
||||
script:
|
||||
by-build-platform:
|
||||
default: mozharness/scripts/desktop_l10n.py
|
||||
|
|
|
@ -24,7 +24,6 @@ releng.manifest",
|
|||
'TOOLTOOL_HOME': '/c/builds',
|
||||
},
|
||||
'mozconfig_variant': 'debug-static-analysis',
|
||||
'purge_minsize': 9,
|
||||
'artifact_flag_build_variant_in_try': None,
|
||||
#######################
|
||||
}
|
||||
|
|
|
@ -6,15 +6,6 @@
|
|||
"locales_platform": "android-multilocale",
|
||||
"locales_dir": "mobile/android/locales",
|
||||
"ignore_locales": ["en-US", "multi"],
|
||||
"repos": [{
|
||||
"repo": "https://hg.mozilla.org/projects/ash",
|
||||
"branch": "default",
|
||||
"dest": "build"
|
||||
},{
|
||||
"repo": "https://hg.mozilla.org/build/tools",
|
||||
"branch": "default",
|
||||
"dest": "tools"
|
||||
}],
|
||||
"vcs_share_base": "/builds/hg-shared",
|
||||
"hg_l10n_base": "https://hg.mozilla.org/l10n-central",
|
||||
"hg_l10n_tag": "default",
|
||||
|
|
|
@ -6,15 +6,6 @@
|
|||
"locales_platform": "android-multilocale",
|
||||
"locales_dir": "mobile/android/locales",
|
||||
"ignore_locales": ["en-US", "multi"],
|
||||
"repos": [{
|
||||
"repo": "https://hg.mozilla.org/projects/ash",
|
||||
"branch": "default",
|
||||
"dest": "build"
|
||||
},{
|
||||
"repo": "https://hg.mozilla.org/build/tools",
|
||||
"branch": "default",
|
||||
"dest": "tools"
|
||||
}],
|
||||
"vcs_share_base": "/builds/hg-shared",
|
||||
"hg_l10n_base": "https://hg.mozilla.org/l10n-central",
|
||||
"hg_l10n_tag": "default",
|
||||
|
|
|
@ -5,15 +5,6 @@
|
|||
"locales_file": "build/mobile/locales/l10n-changesets.json",
|
||||
"locales_dir": "mobile/android/locales",
|
||||
"ignore_locales": ["en-US", "multi"],
|
||||
"repos": [{
|
||||
"repo": "https://hg.mozilla.org/jamun",
|
||||
"branch": "default",
|
||||
"dest": "build"
|
||||
},{
|
||||
"repo": "https://hg.mozilla.org/build/tools",
|
||||
"branch": "default",
|
||||
"dest": "tools"
|
||||
}],
|
||||
"vcs_share_base": "/builds/hg-shared",
|
||||
"hg_l10n_base": "https://hg.mozilla.org/l10n-central",
|
||||
"hg_l10n_tag": "default",
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче