Merge inbound to mozilla-central. a=merge

This commit is contained in:
Narcis Beleuzu 2018-06-06 20:00:09 +03:00
commit cf464eabfe
111 changed files with 1222 additions and 1430 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1253064 - Prefer Clang to GCC in local developer builds
Bug 1459785 - ANGLE update; moved files require clobber due to bug 1421146.

View File

@ -70,7 +70,7 @@ nsCoreUtils::HasClickListener(nsIContent *aContent)
void
nsCoreUtils::DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj,
int32_t aRowIndex, nsITreeColumn *aColumn,
int32_t aRowIndex, nsTreeColumn *aColumn,
const nsAString& aPseudoElt)
{
RefPtr<dom::Element> tcElm;
@ -519,7 +519,7 @@ nsCoreUtils::GetTreeBoxObject(nsIContent *aContent)
return nullptr;
}
already_AddRefed<nsITreeColumn>
already_AddRefed<nsTreeColumn>
nsCoreUtils::GetFirstSensibleColumn(nsITreeBoxObject *aTree)
{
RefPtr<nsTreeColumns> cols;
@ -556,12 +556,12 @@ nsCoreUtils::GetSensibleColumnCount(nsITreeBoxObject *aTree)
return count;
}
already_AddRefed<nsITreeColumn>
already_AddRefed<nsTreeColumn>
nsCoreUtils::GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex)
{
uint32_t idx = aIndex;
nsCOMPtr<nsITreeColumn> column = GetFirstSensibleColumn(aTree);
nsCOMPtr<nsTreeColumn> column = GetFirstSensibleColumn(aTree);
while (column) {
if (idx == 0)
return column.forget();
@ -573,41 +573,34 @@ nsCoreUtils::GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex)
return nullptr;
}
already_AddRefed<nsITreeColumn>
nsCoreUtils::GetNextSensibleColumn(nsITreeColumn *aColumn)
already_AddRefed<nsTreeColumn>
nsCoreUtils::GetNextSensibleColumn(nsTreeColumn* aColumn)
{
nsCOMPtr<nsITreeColumn> nextColumn;
aColumn->GetNext(getter_AddRefs(nextColumn));
RefPtr<nsTreeColumn> nextColumn = aColumn->GetNext();
while (nextColumn && IsColumnHidden(nextColumn)) {
nsCOMPtr<nsITreeColumn> tempColumn;
nextColumn->GetNext(getter_AddRefs(tempColumn));
nextColumn.swap(tempColumn);
nextColumn = nextColumn->GetNext();
}
return nextColumn.forget();
}
already_AddRefed<nsITreeColumn>
nsCoreUtils::GetPreviousSensibleColumn(nsITreeColumn *aColumn)
already_AddRefed<nsTreeColumn>
nsCoreUtils::GetPreviousSensibleColumn(nsTreeColumn* aColumn)
{
nsCOMPtr<nsITreeColumn> prevColumn;
aColumn->GetPrevious(getter_AddRefs(prevColumn));
RefPtr<nsTreeColumn> prevColumn = aColumn->GetPrevious();
while (prevColumn && IsColumnHidden(prevColumn)) {
nsCOMPtr<nsITreeColumn> tempColumn;
prevColumn->GetPrevious(getter_AddRefs(tempColumn));
prevColumn.swap(tempColumn);
prevColumn = prevColumn->GetPrevious();
}
return prevColumn.forget();
}
bool
nsCoreUtils::IsColumnHidden(nsITreeColumn *aColumn)
nsCoreUtils::IsColumnHidden(nsTreeColumn* aColumn)
{
RefPtr<Element> element;
aColumn->GetElement(getter_AddRefs(element));
Element* element = aColumn->Element();
return element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
nsGkAtoms::_true, eCaseMatters);
}

View File

@ -17,10 +17,10 @@
#include "nsTArray.h"
class nsRange;
class nsTreeColumn;
class nsIBoxObject;
class nsIFrame;
class nsIDocShell;
class nsITreeColumn;
class nsITreeBoxObject;
class nsIWidget;
@ -51,7 +51,7 @@ public:
* nsITreeBoxObject for available values
*/
static void DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj,
int32_t aRowIndex, nsITreeColumn *aColumn,
int32_t aRowIndex, nsTreeColumn *aColumn,
const nsAString& aPseudoElt = EmptyString());
/**
@ -249,7 +249,7 @@ public:
/**
* Return first sensible column for the given tree box object.
*/
static already_AddRefed<nsITreeColumn>
static already_AddRefed<nsTreeColumn>
GetFirstSensibleColumn(nsITreeBoxObject *aTree);
/**
@ -260,25 +260,25 @@ public:
/**
* Return sensible column at the given index for the given tree box object.
*/
static already_AddRefed<nsITreeColumn>
static already_AddRefed<nsTreeColumn>
GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex);
/**
* Return next sensible column for the given column.
*/
static already_AddRefed<nsITreeColumn>
GetNextSensibleColumn(nsITreeColumn *aColumn);
static already_AddRefed<nsTreeColumn>
GetNextSensibleColumn(nsTreeColumn *aColumn);
/**
* Return previous sensible column for the given column.
*/
static already_AddRefed<nsITreeColumn>
GetPreviousSensibleColumn(nsITreeColumn *aColumn);
static already_AddRefed<nsTreeColumn>
GetPreviousSensibleColumn(nsTreeColumn *aColumn);
/**
* Return true if the given column is hidden (i.e. not sensible).
*/
static bool IsColumnHidden(nsITreeColumn *aColumn);
static bool IsColumnHidden(nsTreeColumn *aColumn);
/**
* Scroll content into view.

View File

@ -7,7 +7,6 @@ support-files =
doc_content_text.html
!/accessible/tests/mochitest/*.js
!/accessible/tests/mochitest/moz.png
skip-if = (os == 'win' && (os_version == '5.1' || os_version == '5.2'))
[test_alive.html]
[test_content_integration.html]

View File

@ -52,7 +52,7 @@ public:
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree,
nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn) :
int32_t aRow, nsTreeColumn* aColumn) :
XULTreeGridCellAccessible(aContent, aDoc, aRowAcc, aTree, aTreeView, aRow,
aColumn), ia2AccessibleTableCell(this) {}

View File

@ -194,7 +194,7 @@ XULTreeAccessible::ChildAtPoint(int32_t aX, int32_t aY,
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
nsCOMPtr<nsITreeColumn> column;
RefPtr<nsTreeColumn> column;
nsAutoString childEltUnused;
mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column),
childEltUnused);
@ -724,7 +724,7 @@ XULTreeItemAccessibleBase::BoundsInCSSPixels() const
return nsIntRect();
}
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = mTree->GetCoordsForCellItem(mRow, column, EmptyString(),
@ -1039,7 +1039,7 @@ XULTreeItemAccessibleBase::IsExpandable() const
}
void
XULTreeItemAccessibleBase::GetCellName(nsITreeColumn* aColumn, nsAString& aName) const
XULTreeItemAccessibleBase::GetCellName(nsTreeColumn* aColumn, nsAString& aName) const
{
mTreeView->GetCellText(mRow, aColumn, aName);

View File

@ -11,7 +11,7 @@
#include "XULListboxAccessible.h"
class nsTreeBodyFrame;
class nsITreeColumn;
class nsTreeColumn;
namespace mozilla {
namespace a11y {
@ -177,7 +177,7 @@ public:
* Return cell accessible for the given column. If XUL tree accessible is not
* accessible table then return null.
*/
virtual XULTreeGridCellAccessible* GetCellAccessible(nsITreeColumn* aColumn) const
virtual XULTreeGridCellAccessible* GetCellAccessible(nsTreeColumn* aColumn) const
{ return nullptr; }
/**
@ -206,7 +206,7 @@ protected:
/**
* Return name for cell at the given column.
*/
void GetCellName(nsITreeColumn* aColumn, nsAString& aName) const;
void GetCellName(nsTreeColumn* aColumn, nsAString& aName) const;
nsCOMPtr<nsITreeBoxObject> mTree;
nsITreeView* mTreeView;
@ -244,7 +244,7 @@ protected:
virtual ~XULTreeItemAccessible();
// XULTreeItemAccessible
nsCOMPtr<nsITreeColumn> mColumn;
RefPtr<nsTreeColumn> mColumn;
nsString mCachedName;
};

View File

@ -22,6 +22,7 @@
#include "nsITreeSelection.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TreeColumnBinding.h"
using namespace mozilla::a11y;
using namespace mozilla;
@ -126,7 +127,7 @@ XULTreeGridAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex)
if (!row)
return nullptr;
nsCOMPtr<nsITreeColumn> column =
RefPtr<nsTreeColumn> column =
nsCoreUtils::GetSensibleColumnAt(mTree, aColumnIndex);
if (!column)
return nullptr;
@ -298,7 +299,7 @@ XULTreeGridRowAccessible::Name(nsString& aName) const
aName.Truncate();
// XXX: the row name sholdn't be a concatenation of cell names (bug 664384).
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
while (column) {
if (!aName.IsEmpty())
aName.Append(' ');
@ -333,7 +334,7 @@ XULTreeGridRowAccessible::ChildAtPoint(int32_t aX, int32_t aY,
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
nsCOMPtr<nsITreeColumn> column;
RefPtr<nsTreeColumn> column;
nsAutoString childEltUnused;
mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column),
childEltUnused);
@ -351,7 +352,7 @@ XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex) const
if (IsDefunct())
return nullptr;
nsCOMPtr<nsITreeColumn> column =
RefPtr<nsTreeColumn> column =
nsCoreUtils::GetSensibleColumnAt(mTree, aIndex);
if (!column)
return nullptr;
@ -369,7 +370,7 @@ XULTreeGridRowAccessible::ChildCount() const
// XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
XULTreeGridCellAccessible*
XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
XULTreeGridRowAccessible::GetCellAccessible(nsTreeColumn* aColumn) const
{
MOZ_ASSERT(aColumn, "No tree column!");
@ -420,7 +421,7 @@ XULTreeGridCellAccessible::
XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree, nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn) :
int32_t aRow, nsTreeColumn* aColumn) :
LeafAccessible(aContent, aDoc), mTree(aTree),
mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
{
@ -430,9 +431,7 @@ XULTreeGridCellAccessible::
NS_ASSERTION(mTreeView, "mTreeView is null");
int16_t type = -1;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX)
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX)
mTreeView->GetCellValue(mRow, mColumn, mCachedTextEquiv);
else
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
@ -536,14 +535,10 @@ XULTreeGridCellAccessible::BoundsInAppUnits() const
uint8_t
XULTreeGridCellAccessible::ActionCount() const
{
bool isCycler = false;
mColumn->GetCycler(&isCycler);
if (isCycler)
if (mColumn->Cycler())
return 1;
int16_t type;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX && IsEditable())
return 1;
return 0;
@ -557,16 +552,13 @@ XULTreeGridCellAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
if (aIndex != eAction_Click || !mTreeView)
return;
bool isCycler = false;
mColumn->GetCycler(&isCycler);
if (isCycler) {
if (mColumn->Cycler()) {
aName.AssignLiteral("cycle");
return;
}
int16_t type = 0;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX &&
IsEditable()) {
nsAutoString value;
mTreeView->GetCellValue(mRow, mColumn, value);
if (value.EqualsLiteral("true"))
@ -582,16 +574,13 @@ XULTreeGridCellAccessible::DoAction(uint8_t aIndex) const
if (aIndex != eAction_Click)
return false;
bool isCycler = false;
mColumn->GetCycler(&isCycler);
if (isCycler) {
if (mColumn->Cycler()) {
DoCommand();
return true;
}
int16_t type;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX &&
IsEditable()) {
DoCommand();
return true;
}
@ -616,7 +605,7 @@ uint32_t
XULTreeGridCellAccessible::ColIdx() const
{
uint32_t colIdx = 0;
nsCOMPtr<nsITreeColumn> column = mColumn;
RefPtr<nsTreeColumn> column = mColumn;
while ((column = nsCoreUtils::GetPreviousSensibleColumn(column)))
colIdx++;
@ -632,8 +621,7 @@ XULTreeGridCellAccessible::RowIdx() const
void
XULTreeGridCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aHeaderCells)
{
RefPtr<dom::Element> columnElm;
mColumn->GetElement(getter_AddRefs(columnElm));
dom::Element* columnElm = mColumn->Element();
Accessible* headerCell = mDoc->GetAccessible(columnElm);
if (headerCell)
@ -671,9 +659,7 @@ XULTreeGridCellAccessible::NativeAttributes()
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
// "cycles" attribute
bool isCycler = false;
nsresult rv = mColumn->GetCycler(&isCycler);
if (NS_SUCCEEDED(rv) && isCycler)
if (mColumn->Cycler())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles,
NS_LITERAL_STRING("true"));
@ -705,9 +691,7 @@ XULTreeGridCellAccessible::NativeState() const
}
// checked state
int16_t type;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX) {
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX) {
states |= states::CHECKABLE;
nsAutoString checked;
mTreeView->GetCellValue(mRow, mColumn, checked);
@ -745,9 +729,7 @@ XULTreeGridCellAccessible::CellInvalidated()
nsAutoString textEquiv;
int16_t type;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX) {
if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX) {
mTreeView->GetCellValue(mRow, mColumn, textEquiv);
if (mCachedTextEquiv != textEquiv) {
bool isEnabled = textEquiv.EqualsLiteral("true");
@ -782,7 +764,7 @@ XULTreeGridCellAccessible::GetSiblingAtOffset(int32_t aOffset,
if (aError)
*aError = NS_OK; // fail peacefully
nsCOMPtr<nsITreeColumn> columnAtOffset(mColumn), column;
RefPtr<nsTreeColumn> columnAtOffset(mColumn), column;
if (aOffset < 0) {
for (int32_t index = aOffset; index < 0 && columnAtOffset; index++) {
column = nsCoreUtils::GetPreviousSensibleColumn(columnAtOffset);
@ -826,10 +808,7 @@ XULTreeGridCellAccessible::IsEditable() const
if (NS_FAILED(rv) || !isEditable)
return false;
RefPtr<dom::Element> columnElm;
mColumn->GetElement(getter_AddRefs(columnElm));
if (!columnElm)
return false;
dom::Element* columnElm = mColumn->Element();
if (!columnElm->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::editable,

View File

@ -90,7 +90,7 @@ public:
virtual uint32_t ChildCount() const override;
// XULTreeItemAccessibleBase
XULTreeGridCellAccessible* GetCellAccessible(nsITreeColumn* aColumn)
XULTreeGridCellAccessible* GetCellAccessible(nsTreeColumn* aColumn)
const final;
virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) override;
@ -116,7 +116,7 @@ public:
XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree, nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn);
int32_t aRow, nsTreeColumn* aColumn);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -179,7 +179,7 @@ protected:
nsITreeView* mTreeView;
int32_t mRow;
nsCOMPtr<nsITreeColumn> mColumn;
RefPtr<nsTreeColumn> mColumn;
nsString mCachedTextEquiv;
};

View File

@ -29,9 +29,11 @@ add_task(async function() {
ok(gBrowser.tabs.length > 1, "we have more than one tab");
let view = browser.contentDocument.getElementById("tabList").view;
let tree = browser.contentDocument.getElementById("tabList");
let view = tree.view;
ok(view.isContainer(0), "first entry is the window");
is(view.getCellProperties(1, { id: "title" }), "icon",
let titleColumn = tree.columns.title;
is(view.getCellProperties(1, titleColumn), "icon",
"second entry is the tab and has a favicon");
browser.messageManager.loadFrameScript(FRAME_SCRIPT, true);

View File

@ -110,7 +110,7 @@ WindowDestroyedEvent::Run()
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, currentInner->FastGetGlobalJSObject());
if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
if (obj && !js::IsSystemRealm(js::GetNonCCWObjectRealm(obj))) {
JSCompartment* cpt = js::GetObjectCompartment(obj);
nsCOMPtr<nsIPrincipal> pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(cpt));

View File

@ -184,7 +184,7 @@ function compartment_test(finish)
function is(a, b, msg) { results.push({ result: a === b ? "PASS" : "FAIL", message: msg }) };
function ok(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }) };
let cpowLocation = Cu.getCompartmentLocation(obj);
let cpowLocation = Cu.getRealmLocation(obj);
ok(/Privileged Junk/.test(cpowLocation),
"child->parent CPOWs should live in the privileged junk scope: " + cpowLocation);
is(obj(), 42, "child->parent CPOW is invokable");

View File

@ -301,7 +301,7 @@
is(Cu.getGlobalForObject(getUnprivilegedObject),
Cu.getGlobalForObject(unprivilegedObject),
"all parent->child CPOWs should live in the same scope");
let cpowLocation = Cu.getCompartmentLocation(getUnprivilegedObject);
let cpowLocation = Cu.getRealmLocation(getUnprivilegedObject);
ok(/Privileged Junk/.test(cpowLocation),
"parent->child CPOWs should live in the privileged junk scope: " + cpowLocation);

View File

@ -43,13 +43,13 @@ namespace dom {
*
* Since we want [SecureContext] exposure to depend on the privileges of the
* running code (rather than the privileges of an object's creator), this
* function checks to see whether the given JSContext's Compartment is flagged
* function checks to see whether the given JSContext's Realm is flagged
* as a Secure Context. That allows us to make sure that system principal code
* (which is marked as a Secure Context) can access Secure Context API on an
* object in a different compartment, regardless of whether the other
* compartment is a Secure Context or not.
* object in a different realm, regardless of whether the other realm is a
* Secure Context or not.
*
* Checking the JSContext's Compartment doesn't work for expanded principal
* Checking the JSContext's Realm doesn't work for expanded principal
* globals accessing a Secure Context web page though (e.g. those used by frame
* scripts). To handle that we fall back to checking whether the JSObject came
* from a Secure Context.
@ -61,8 +61,9 @@ namespace dom {
inline bool
IsSecureContextOrObjectIsFromSecureContext(JSContext* aCx, JSObject* aObj)
{
return JS::RealmCreationOptionsRef(js::GetContextCompartment(aCx)).secureContext() ||
JS::RealmCreationOptionsRef(js::GetObjectCompartment(aObj)).secureContext();
MOZ_ASSERT(!js::IsWrapper(aObj));
return JS::GetIsSecureContext(js::GetContextRealm(aCx)) ||
JS::GetIsSecureContext(js::GetNonCCWObjectRealm(aObj));
}
typedef bool

View File

@ -83,6 +83,7 @@ interface TreeBoxObject : BoxObject {
/**
* Ensures that a given cell in the tree is visible.
*/
[Throws]
void ensureCellIsVisible(long row, TreeColumn? col);
/**
@ -105,23 +106,6 @@ interface TreeBoxObject : BoxObject {
*/
void scrollByPages(long numPages);
/**
* Scrolls such that a given cell is visible (if possible)
* at the top left corner of the visible view.
*/
void scrollToCell(long row, TreeColumn? col);
/**
* Scrolls horizontally so that the specified column is
* at the left of the view (if possible).
*/
void scrollToColumn(TreeColumn? col);
/**
* Scroll to a specific horizontal pixel position.
*/
void scrollToHorizontalPosition(long horizontalPosition);
/**
* Invalidation methods for fine-grained painting control.
*/
@ -130,7 +114,6 @@ interface TreeBoxObject : BoxObject {
void invalidateRow(long index);
void invalidateCell(long row, TreeColumn? col);
void invalidateRange(long startIndex, long endIndex);
void invalidateColumnRange(long startIndex, long endIndex, TreeColumn? col);
/**
* A hit test that can tell you what row the mouse is over.

View File

@ -4,8 +4,7 @@
[Func="IsChromeOrXBL"]
interface TreeColumn {
[Throws]
readonly attribute Element? element;
readonly attribute Element element;
readonly attribute TreeColumns? columns;

View File

@ -1207,10 +1207,9 @@ public:
xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras;
// This is the |jsPathPrefix|. Each worker has exactly one realm.
JSCompartment* compartment = JS::GetCompartmentForRealm(aRealm);
extras->jsPathPrefix.Assign(mRtPath);
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/",
(void *)js::GetCompartmentZone(compartment));
(void *)js::GetRealmZone(aRealm));
extras->jsPathPrefix += NS_LITERAL_CSTRING("realm(web-worker)/");
// This should never be used when reporting with workers (hence the "?!").

View File

@ -43,6 +43,25 @@ using ::testing::MockFunction;
using ::testing::InSequence;
typedef mozilla::layers::GeckoContentController::TapType TapType;
// Some helper functions for constructing input event objects suitable to be
// passed either to an APZC (which expects an transformed point), or to an APZTM
// (which expects an untransformed point). We handle both cases by setting both
// the transformed and untransformed fields to the same value.
SingleTouchData
CreateSingleTouchData(int32_t aIdentifier, const ScreenIntPoint& aPoint)
{
SingleTouchData touch(aIdentifier, aPoint, ScreenSize(0, 0), 0, 0);
touch.mLocalScreenPoint = ParentLayerPoint(aPoint.x, aPoint.y);
return touch;
}
// Convenience wrapper for CreateSingleTouchData() that takes loose coordinates.
SingleTouchData
CreateSingleTouchData(int32_t aIdentifier, ScreenIntCoord aX, ScreenIntCoord aY)
{
return CreateSingleTouchData(aIdentifier, ScreenIntPoint(aX, aY));
}
template<class T>
class ScopedGfxPref {
public:
@ -332,6 +351,19 @@ public:
ExactCoordinates = 0x2
};
enum class PinchOptions {
None = 0,
LiftFinger1 = 0x1,
LiftFinger2 = 0x2,
/*
* The bitwise OR result of (LiftFinger1 | LiftFinger2).
* Defined explicitly here because it is used as the default
* argument for PinchWithTouchInput which is defined BEFORE the
* definition of operator| for this class.
*/
LiftBothFingers = 0x3
};
template<class InputReceiver>
void Tap(const RefPtr<InputReceiver>& aTarget, const ScreenIntPoint& aPoint,
TimeDuration aTapLength,
@ -390,11 +422,38 @@ public:
const ScreenIntPoint& aPoint,
uint64_t (*aOutInputBlockIds)[2] = nullptr);
template<class InputReceiver>
void PinchWithTouchInput(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, const ScreenIntPoint& aSecondFocus,
float aScale,
int& inputId,
nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr,
nsEventStatus (*aOutEventStatuses)[4] = nullptr,
uint64_t* aOutInputBlockId = nullptr,
PinchOptions aOptions = PinchOptions::LiftBothFingers);
// Pinch with one focus point. Zooms in place with no panning
template<class InputReceiver>
void PinchWithTouchInput(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId,
nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr,
nsEventStatus (*aOutEventStatuses)[4] = nullptr,
uint64_t* aOutInputBlockId = nullptr,
PinchOptions aOptions = PinchOptions::LiftBothFingers);
template<class InputReceiver>
void PinchWithTouchInputAndCheckStatus(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId, bool aShouldTriggerPinch,
nsTArray<uint32_t>* aAllowedTouchBehaviors);
protected:
RefPtr<MockContentControllerDelayed> mcc;
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(APZCTesterBase::PanOptions)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(APZCTesterBase::PinchOptions)
template<class InputReceiver>
void
@ -634,6 +693,119 @@ APZCTesterBase::DoubleTapAndCheckStatus(const RefPtr<InputReceiver>& aTarget,
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[3]);
}
template<class InputReceiver>
void
APZCTesterBase::PinchWithTouchInput(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId,
nsTArray<uint32_t>* aAllowedTouchBehaviors,
nsEventStatus (*aOutEventStatuses)[4],
uint64_t* aOutInputBlockId,
PinchOptions aOptions)
{
//Perform a pinch gesture with the same start & end focus point
PinchWithTouchInput(aTarget, aFocus, aFocus, aScale, inputId,
aAllowedTouchBehaviors, aOutEventStatuses,
aOutInputBlockId, aOptions);
}
template<class InputReceiver>
void
APZCTesterBase::PinchWithTouchInput(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, const ScreenIntPoint& aSecondFocus,
float aScale,
int& inputId,
nsTArray<uint32_t>* aAllowedTouchBehaviors,
nsEventStatus (*aOutEventStatuses)[4],
uint64_t* aOutInputBlockId,
PinchOptions aOptions)
{
// Having pinch coordinates in float type may cause problems with high-precision scale values
// since SingleTouchData accepts integer value. But for trivial tests it should be ok.
float pinchLength = 100.0;
float pinchLengthScaled = pinchLength * aScale;
// Even if the caller doesn't care about the block id, we need it to set the
// allowed touch behaviour below, so make sure aOutInputBlockId is non-null.
uint64_t blockId;
if (!aOutInputBlockId) {
aOutInputBlockId = &blockId;
}
const TimeDuration TIME_BETWEEN_TOUCH_EVENT = TimeDuration::FromMilliseconds(50);
MultiTouchInput mtiStart = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, 0, mcc->Time(), 0);
mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus));
mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus));
nsEventStatus status = aTarget->ReceiveInputEvent(mtiStart, aOutInputBlockId);
if (aOutEventStatuses) {
(*aOutEventStatuses)[0] = status;
}
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
if (aAllowedTouchBehaviors) {
EXPECT_EQ(2UL, aAllowedTouchBehaviors->Length());
aTarget->SetAllowedTouchBehavior(*aOutInputBlockId, *aAllowedTouchBehaviors);
} else if (gfxPrefs::TouchActionEnabled()) {
SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId, 2);
}
MultiTouchInput mtiMove1 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus.x - pinchLength, aFocus.y));
mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus.x + pinchLength, aFocus.y));
status = aTarget->ReceiveInputEvent(mtiMove1, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
}
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
MultiTouchInput mtiMove2 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId, aSecondFocus.x - pinchLengthScaled, aSecondFocus.y));
mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aSecondFocus.x + pinchLengthScaled, aSecondFocus.y));
status = aTarget->ReceiveInputEvent(mtiMove2, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = status;
}
if (aOptions & (PinchOptions::LiftFinger1 | PinchOptions::LiftFinger2)) {
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
MultiTouchInput mtiEnd = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, 0, mcc->Time(), 0);
if (aOptions & PinchOptions::LiftFinger1) {
mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId, aSecondFocus.x - pinchLengthScaled, aSecondFocus.y));
}
if (aOptions & PinchOptions::LiftFinger2) {
mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aSecondFocus.x + pinchLengthScaled, aSecondFocus.y));
}
status = aTarget->ReceiveInputEvent(mtiEnd, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[3] = status;
}
}
inputId += 2;
}
template<class InputReceiver>
void
APZCTesterBase::PinchWithTouchInputAndCheckStatus(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId, bool aShouldTriggerPinch,
nsTArray<uint32_t>* aAllowedTouchBehaviors)
{
nsEventStatus statuses[4]; // down, move, move, up
PinchWithTouchInput(aTarget, aFocus, aScale, inputId, aAllowedTouchBehaviors, &statuses);
nsEventStatus expectedMoveStatus = aShouldTriggerPinch
? nsEventStatus_eConsumeDoDefault
: nsEventStatus_eIgnore;
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[0]);
EXPECT_EQ(expectedMoveStatus, statuses[1]);
EXPECT_EQ(expectedMoveStatus, statuses[2]);
}
AsyncPanZoomController*
TestAPZCTreeManager::NewAPZCInstance(LayersId aLayersId,
GeckoContentController* aController)

View File

@ -28,25 +28,6 @@
* code to dispatch input events.
*/
// Some helper functions for constructing input event objects suitable to be
// passed either to an APZC (which expects an transformed point), or to an APZTM
// (which expects an untransformed point). We handle both cases by setting both
// the transformed and untransformed fields to the same value.
SingleTouchData
CreateSingleTouchData(int32_t aIdentifier, const ScreenIntPoint& aPoint)
{
SingleTouchData touch(aIdentifier, aPoint, ScreenSize(0, 0), 0, 0);
touch.mLocalScreenPoint = ParentLayerPoint(aPoint.x, aPoint.y);
return touch;
}
// Convenience wrapper for CreateSingleTouchData() that takes loose coordinates.
SingleTouchData
CreateSingleTouchData(int32_t aIdentifier, ScreenIntCoord aX, ScreenIntCoord aY)
{
return CreateSingleTouchData(aIdentifier, ScreenIntPoint(aX, aY));
}
PinchGestureInput
CreatePinchGestureInput(PinchGestureInput::PinchGestureType aType,
const ScreenPoint& aFocus,
@ -160,87 +141,6 @@ PinchWithPinchInputAndCheckStatus(const RefPtr<InputReceiver>& aTarget,
EXPECT_EQ(expectedStatus, statuses[1]);
}
template<class InputReceiver>
void
PinchWithTouchInput(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId,
nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr,
nsEventStatus (*aOutEventStatuses)[4] = nullptr,
uint64_t* aOutInputBlockId = nullptr)
{
// Having pinch coordinates in float type may cause problems with high-precision scale values
// since SingleTouchData accepts integer value. But for trivial tests it should be ok.
float pinchLength = 100.0;
float pinchLengthScaled = pinchLength * aScale;
// Even if the caller doesn't care about the block id, we need it to set the
// allowed touch behaviour below, so make sure aOutInputBlockId is non-null.
uint64_t blockId;
if (!aOutInputBlockId) {
aOutInputBlockId = &blockId;
}
MultiTouchInput mtiStart = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, 0, TimeStamp(), 0);
mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus));
mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus));
nsEventStatus status = aTarget->ReceiveInputEvent(mtiStart, aOutInputBlockId);
if (aOutEventStatuses) {
(*aOutEventStatuses)[0] = status;
}
if (aAllowedTouchBehaviors) {
EXPECT_EQ(2UL, aAllowedTouchBehaviors->Length());
aTarget->SetAllowedTouchBehavior(*aOutInputBlockId, *aAllowedTouchBehaviors);
} else if (gfxPrefs::TouchActionEnabled()) {
SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId, 2);
}
MultiTouchInput mtiMove1 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, TimeStamp(), 0);
mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus.x - pinchLength, aFocus.y));
mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus.x + pinchLength, aFocus.y));
status = aTarget->ReceiveInputEvent(mtiMove1, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
}
MultiTouchInput mtiMove2 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, TimeStamp(), 0);
mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus.x - pinchLengthScaled, aFocus.y));
mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus.x + pinchLengthScaled, aFocus.y));
status = aTarget->ReceiveInputEvent(mtiMove2, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = status;
}
MultiTouchInput mtiEnd = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, 0, TimeStamp(), 0);
mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId, aFocus.x - pinchLengthScaled, aFocus.y));
mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, aFocus.x + pinchLengthScaled, aFocus.y));
status = aTarget->ReceiveInputEvent(mtiEnd, nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[3] = status;
}
inputId += 2;
}
template<class InputReceiver>
void
PinchWithTouchInputAndCheckStatus(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aFocus, float aScale,
int& inputId, bool aShouldTriggerPinch,
nsTArray<uint32_t>* aAllowedTouchBehaviors)
{
nsEventStatus statuses[4]; // down, move, move, up
PinchWithTouchInput(aTarget, aFocus, aScale, inputId, aAllowedTouchBehaviors, &statuses);
nsEventStatus expectedMoveStatus = aShouldTriggerPinch
? nsEventStatus_eConsumeDoDefault
: nsEventStatus_eIgnore;
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[0]);
EXPECT_EQ(expectedMoveStatus, statuses[1]);
EXPECT_EQ(expectedMoveStatus, statuses[2]);
}
template<class InputReceiver>
nsEventStatus
Wheel(const RefPtr<InputReceiver>& aTarget, const ScreenIntPoint& aPoint,

View File

@ -270,6 +270,58 @@ TEST_F(APZCPinchGestureDetectorTester, Pinch_PreventDefault_NoAPZZoom) {
DoPinchWithPreventDefaultTest();
}
TEST_F(APZCPinchGestureDetectorTester, Panning_TwoFingerFling_ZoomDisabled) {
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
apzc->SetFrameMetrics(GetPinchableFrameMetrics());
MakeApzcUnzoomable();
// Perform a two finger pan
int touchInputId = 0;
uint64_t blockId = 0;
PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
1, touchInputId, nullptr, nullptr, &blockId);
// Expect to be in a flinging state
apzc->AssertStateIsFling();
}
TEST_F(APZCPinchGestureDetectorTester, Panning_TwoFingerFling_ZoomEnabled) {
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
apzc->SetFrameMetrics(GetPinchableFrameMetrics());
MakeApzcZoomable();
// Perform a two finger pan
int touchInputId = 0;
uint64_t blockId = 0;
PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
1, touchInputId, nullptr, nullptr, &blockId);
// Expect to NOT be in flinging state
apzc->AssertStateIsReset();
}
TEST_F(APZCPinchGestureDetectorTester, Panning_TwoThenOneFingerFling_ZoomEnabled) {
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
apzc->SetFrameMetrics(GetPinchableFrameMetrics());
MakeApzcZoomable();
// Perform a two finger pan lifting only the first finger
int touchInputId = 0;
uint64_t blockId = 0;
PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
1, touchInputId, nullptr, nullptr, &blockId, PinchOptions::LiftFinger2);
// Lift second finger after a pause
mcc->AdvanceBy(TimeDuration::FromMilliseconds(50));
TouchUp(apzc, ScreenIntPoint(100, 100), mcc->Time());
// Expect to NOT be in flinging state
apzc->AssertStateIsReset();
}
TEST_F(APZCPinchTester, Panning_TwoFinger_ZoomDisabled) {
// set up APZ
apzc->SetFrameMetrics(GetPinchableFrameMetrics());

View File

@ -1,6 +1,6 @@
# 468496-1 will also detect bugs in video drivers.
== 468496-1.html 468496-1-ref.html
fuzzy(175,443) == 611498-1.html 611498-ref.html
fuzzy(175,443) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 611498-1.html 611498-ref.html # Bug 1392106
fuzzy-if(Android,8,1000) == 709477-1.html 709477-1-ref.html
skip-if(!asyncPan) == 1086723.html 1086723-ref.html
== 853889-1.html 853889-1-ref.html

View File

@ -711,7 +711,10 @@ struct ZoneStats
macro(Other, MallocHeap, baselineStubsOptimized) \
macro(Other, MallocHeap, cachedCFG) \
macro(Other, MallocHeap, uniqueIdMap) \
macro(Other, MallocHeap, shapeTables)
macro(Other, MallocHeap, shapeTables) \
macro(Other, MallocHeap, compartmentObjects) \
macro(Other, MallocHeap, crossCompartmentWrappersTables) \
macro(Other, MallocHeap, compartmentsPrivateData)
ZoneStats()
: FOR_EACH_SIZE(ZERO_SIZE)
@ -827,12 +830,10 @@ struct RealmStats
macro(Other, MallocHeap, innerViewsTable) \
macro(Other, MallocHeap, lazyArrayBuffersTable) \
macro(Other, MallocHeap, objectMetadataTable) \
macro(Other, MallocHeap, crossCompartmentWrappersTable) \
macro(Other, MallocHeap, savedStacksSet) \
macro(Other, MallocHeap, varNamesSet) \
macro(Other, MallocHeap, nonSyntacticLexicalScopesTable) \
macro(Other, MallocHeap, jitRealm) \
macro(Other, MallocHeap, privateData) \
macro(Other, MallocHeap, scriptCountsMap)
RealmStats()

View File

@ -44,21 +44,33 @@ struct GCPolicy<Realm*> : public NonGCPointerPolicy<Realm*>
extern JS_PUBLIC_API(Realm*)
GetCurrentRealmOrNull(JSContext* cx);
namespace shadow {
class Realm
{
protected:
JSCompartment* compartment_;
explicit Realm(JSCompartment* comp)
: compartment_(comp)
{}
public:
JSCompartment* compartment() {
return compartment_;
}
static shadow::Realm* get(JS::Realm* realm) {
return reinterpret_cast<shadow::Realm*>(realm);
}
};
}; // namespace shadow
// Return the compartment that contains a given realm.
inline JSCompartment*
GetCompartmentForRealm(Realm* realm) {
// Implementation note: For now, realms are a fiction; we treat realms and
// compartments as being one-to-one, but they are actually identical.
return reinterpret_cast<JSCompartment*>(realm);
}
// Return the realm in a given compartment.
//
// Deprecated. There is currently exactly one realm per compartment, but this
// will change.
inline Realm*
GetRealmForCompartment(JSCompartment* compartment) {
return reinterpret_cast<Realm*>(compartment);
GetCompartmentForRealm(Realm* realm)
{
return shadow::Realm::get(realm)->compartment();
}
// Return an object's realm. All objects except cross-compartment wrappers are

View File

@ -1063,7 +1063,9 @@ GetContextRealm(const JSContext* cx)
inline JSCompartment*
GetContextCompartment(const JSContext* cx)
{
return GetCompartmentForRealm(GetContextRealm(cx));
if (JS::Realm* realm = GetContextRealm(cx))
return GetCompartmentForRealm(realm);
return nullptr;
}
inline JS::Zone*

View File

@ -438,17 +438,29 @@ static inline void js_free(void* p)
* (that is, finalizing the GC-thing will free the allocation), call one of
* the following functions:
*
* JSContext::{malloc_,realloc_,calloc_,new_}
* JSRuntime::{malloc_,realloc_,calloc_,new_}
* JSContext::{pod_malloc,pod_calloc,pod_realloc}
* Zone::{pod_malloc,pod_calloc,pod_realloc}
*
* These functions accumulate the number of bytes allocated which is used as
* part of the GC-triggering heuristic.
* part of the GC-triggering heuristics.
*
* The difference between the JSContext and JSRuntime versions is that the
* cx version reports an out-of-memory error on OOM. (This follows from the
* The difference between the JSContext and Zone versions is that the
* cx version report an out-of-memory error on OOM. (This follows from the
* general SpiderMonkey idiom that a JSContext-taking function reports its
* own errors.)
*
* If you don't want to report an error on failure, there are maybe_ versions
* of these methods available too, e.g. maybe_pod_malloc.
*
* The methods above use templates to allow allocating memory suitable for an
* array of a given type and number of elements. There are _with_extra
* versions to allow allocating an area of memory which is larger by a
* specified number of bytes, e.g. pod_malloc_with_extra.
*
* These methods are available on a JSRuntime, but calling them is
* discouraged. Memory attributed to a runtime can only be reclaimed by full
* GCs, and we try to avoid those where possible.
*
* - Otherwise, use js_malloc/js_realloc/js_calloc/js_new
*
* Deallocation:
@ -459,9 +471,6 @@ static inline void js_free(void* p)
* operations on the FreeOp provided to the finalizer:
*
* FreeOp::{free_,delete_}
*
* The advantage of these operations is that the memory is batched and freed
* on another thread.
*/
/*

View File

@ -236,6 +236,7 @@ const WHITELIST_TYPES: &'static [&'static str] = &[
"JS::TransferableOwnership",
"JS::Value",
"JS::WarningReporter",
"JS::shadow::Realm",
"JS::shadow::Zone",
"JS::Zone",
];

View File

@ -1055,7 +1055,8 @@ pub unsafe fn get_object_class(obj: *mut JSObject) -> *const JSClass {
#[inline]
pub unsafe fn get_object_compartment(obj: *mut JSObject) -> *mut JSCompartment {
(*get_object_group(obj)).realm as *mut JSCompartment
let realm = (*get_object_group(obj)).realm as *const JS::shadow::Realm;
(*realm).compartment_
}
#[inline]

View File

@ -1655,7 +1655,11 @@ js::GetOrCreateModuleMetaObject(JSContext* cx, HandleObject moduleArg)
return nullptr;
JS::ModuleMetadataHook func = cx->runtime()->moduleMetadataHook;
MOZ_ASSERT(func);
if (!func) {
JS_ReportErrorASCII(cx, "Module metadata hook not set");
return nullptr;
}
if (!func(cx, module, metaObject))
return nullptr;

View File

@ -506,7 +506,7 @@ SimdTypeDescr::call(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp);
Rooted<SimdTypeDescr*> descr(cx, &args.callee().as<SimdTypeDescr>());
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, descr, 0));
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, descr));
if (!result)
return false;
@ -702,7 +702,7 @@ js::CreateSimd(JSContext* cx, const typename V::Elem* data)
if (!typeDescr)
return nullptr;
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, typeDescr, 0));
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, typeDescr));
if (!result)
return nullptr;
@ -1492,7 +1492,7 @@ Load(JSContext* cx, unsigned argc, Value* vp)
if (!typeDescr)
return false;
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, typeDescr, 0));
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, typeDescr));
if (!result)
return false;

View File

@ -1398,13 +1398,12 @@ TypedObject::GetByteOffset(JSContext* cx, unsigned argc, Value* vp)
/*static*/ OutlineTypedObject*
OutlineTypedObject::createUnattached(JSContext* cx,
HandleTypeDescr descr,
int32_t length,
gc::InitialHeap heap)
{
if (descr->opaque())
return createUnattachedWithClass(cx, &OutlineOpaqueTypedObject::class_, descr, length, heap);
return createUnattachedWithClass(cx, &OutlineOpaqueTypedObject::class_, descr, heap);
else
return createUnattachedWithClass(cx, &OutlineTransparentTypedObject::class_, descr, length, heap);
return createUnattachedWithClass(cx, &OutlineTransparentTypedObject::class_, descr, heap);
}
void
@ -1430,7 +1429,6 @@ OutlineTypedObject::setOwnerAndData(JSObject* owner, uint8_t* data)
OutlineTypedObject::createUnattachedWithClass(JSContext* cx,
const Class* clasp,
HandleTypeDescr descr,
int32_t length,
gc::InitialHeap heap)
{
MOZ_ASSERT(clasp == &OutlineTransparentTypedObject::class_ ||
@ -1503,24 +1501,6 @@ OutlineTypedObject::attach(JSContext* cx, TypedObject& typedObj, uint32_t offset
}
}
// Returns a suitable JS_TYPEDOBJ_SLOT_LENGTH value for an instance of
// the type `type`.
static uint32_t
TypedObjLengthFromType(TypeDescr& descr)
{
switch (descr.kind()) {
case type::Scalar:
case type::Reference:
case type::Struct:
case type::Simd:
return 0;
case type::Array:
return descr.as<ArrayTypeDescr>().length();
}
MOZ_CRASH("Invalid kind");
}
/*static*/ OutlineTypedObject*
OutlineTypedObject::createDerived(JSContext* cx, HandleTypeDescr type,
HandleTypedObject typedObj, uint32_t offset)
@ -1528,13 +1508,11 @@ OutlineTypedObject::createDerived(JSContext* cx, HandleTypeDescr type,
MOZ_ASSERT(offset <= typedObj->size());
MOZ_ASSERT(offset + type->size() <= typedObj->size());
int32_t length = TypedObjLengthFromType(*type);
const js::Class* clasp = typedObj->opaque()
? &OutlineOpaqueTypedObject::class_
: &OutlineTransparentTypedObject::class_;
Rooted<OutlineTypedObject*> obj(cx);
obj = createUnattachedWithClass(cx, clasp, type, length);
obj = createUnattachedWithClass(cx, clasp, type);
if (!obj)
return nullptr;
@ -1543,10 +1521,10 @@ OutlineTypedObject::createDerived(JSContext* cx, HandleTypeDescr type,
}
/*static*/ TypedObject*
TypedObject::createZeroed(JSContext* cx, HandleTypeDescr descr, int32_t length, gc::InitialHeap heap)
TypedObject::createZeroed(JSContext* cx, HandleTypeDescr descr, gc::InitialHeap heap)
{
// If possible, create an object with inline data.
if (descr->size() <= InlineTypedObject::MaximumSize) {
if (InlineTypedObject::canAccommodateType(descr)) {
AutoSetNewObjectMetadata metadata(cx);
InlineTypedObject* obj = InlineTypedObject::create(cx, descr, heap);
@ -1558,7 +1536,7 @@ TypedObject::createZeroed(JSContext* cx, HandleTypeDescr descr, int32_t length,
}
// Create unattached wrapper object.
Rooted<OutlineTypedObject*> obj(cx, OutlineTypedObject::createUnattached(cx, descr, length, heap));
Rooted<OutlineTypedObject*> obj(cx, OutlineTypedObject::createUnattached(cx, descr, heap));
if (!obj)
return nullptr;
@ -2258,23 +2236,6 @@ DEFINE_TYPEDOBJ_CLASS(InlineOpaqueTypedObject,
InlineTypedObject::obj_trace,
InlineTypedObject::obj_moved);
static int32_t
LengthForType(TypeDescr& descr)
{
switch (descr.kind()) {
case type::Scalar:
case type::Reference:
case type::Struct:
case type::Simd:
return 0;
case type::Array:
return descr.as<ArrayTypeDescr>().length();
}
MOZ_CRASH("Invalid kind");
}
/*static*/ bool
TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp)
{
@ -2290,8 +2251,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp)
// Zero argument constructor:
if (args.length() == 0) {
int32_t length = LengthForType(*callee);
Rooted<TypedObject*> obj(cx, createZeroed(cx, callee, length));
Rooted<TypedObject*> obj(cx, createZeroed(cx, callee));
if (!obj)
return false;
args.rval().setObject(*obj);
@ -2301,8 +2261,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp)
// Data constructor.
if (args[0].isObject()) {
// Create the typed object.
int32_t length = LengthForType(*callee);
Rooted<TypedObject*> obj(cx, createZeroed(cx, callee, length));
Rooted<TypedObject*> obj(cx, createZeroed(cx, callee));
if (!obj)
return false;
@ -2355,9 +2314,8 @@ js::NewOpaqueTypedObject(JSContext* cx, unsigned argc, Value* vp)
MOZ_ASSERT(args[0].isObject() && args[0].toObject().is<TypeDescr>());
Rooted<TypeDescr*> descr(cx, &args[0].toObject().as<TypeDescr>());
int32_t length = TypedObjLengthFromType(*descr);
Rooted<OutlineTypedObject*> obj(cx);
obj = OutlineTypedObject::createUnattachedWithClass(cx, &OutlineOpaqueTypedObject::class_, descr, length);
obj = OutlineTypedObject::createUnattachedWithClass(cx, &OutlineOpaqueTypedObject::class_, descr);
if (!obj)
return false;
args.rval().setObject(*obj);
@ -2935,7 +2893,7 @@ CreateTraceList(JSContext* cx, HandleTypeDescr descr)
// for larger objects, both to limit the size of the trace lists and
// because tracing outline typed objects is considerably more complicated
// than inline ones.
if (descr->size() > InlineTypedObject::MaximumSize || descr->transparent())
if (!InlineTypedObject::canAccommodateType(descr) || descr->transparent())
return true;
TraceListVisitor visitor;

View File

@ -582,7 +582,7 @@ class TypedObject : public ShapedObject
// Creates a new typed object whose memory is freshly allocated and
// initialized with zeroes (or, in the case of references, an appropriate
// default value).
static TypedObject* createZeroed(JSContext* cx, HandleTypeDescr typeObj, int32_t length,
static TypedObject* createZeroed(JSContext* cx, HandleTypeDescr typeObj,
gc::InitialHeap heap = gc::DefaultHeap);
// User-accessible constructor (`new TypeDescriptor(...)`). Note that the
@ -643,7 +643,6 @@ class OutlineTypedObject : public TypedObject
static OutlineTypedObject* createUnattachedWithClass(JSContext* cx,
const Class* clasp,
HandleTypeDescr type,
int32_t length,
gc::InitialHeap heap = gc::DefaultHeap);
// Creates an unattached typed object or handle (depending on the
@ -653,9 +652,8 @@ class OutlineTypedObject : public TypedObject
//
// Arguments:
// - type: type object for resulting object
// - length: 0 unless this is an array, otherwise the length
static OutlineTypedObject* createUnattached(JSContext* cx, HandleTypeDescr type,
int32_t length, gc::InitialHeap heap = gc::DefaultHeap);
gc::InitialHeap heap = gc::DefaultHeap);
// Creates a typedObj that aliases the memory pointed at by `owner`
// at the given offset. The typedObj will be a handle iff type is a
@ -702,16 +700,24 @@ class InlineTypedObject : public TypedObject
// Start of the inline data, which immediately follows the shape and type.
uint8_t data_[1];
static const size_t MaximumSize = JSObject::MAX_BYTE_SIZE - sizeof(TypedObject);
protected:
uint8_t* inlineTypedMem() const {
return (uint8_t*) &data_;
}
public:
static const size_t MaximumSize = JSObject::MAX_BYTE_SIZE - sizeof(TypedObject);
static inline gc::AllocKind allocKindForTypeDescriptor(TypeDescr* descr);
static bool canAccommodateSize(size_t size) {
return size <= MaximumSize;
}
static bool canAccommodateType(TypeDescr* type) {
return type->size() <= MaximumSize;
}
uint8_t* inlineTypedMem(const JS::AutoRequireNoGC&) const {
return inlineTypedMem();
}

View File

@ -1338,8 +1338,12 @@ GCRuntime::finish()
if (rt->gcInitialized) {
AutoSetThreadIsSweeping threadIsSweeping;
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
js_delete(JS::GetRealmForCompartment(comp.get()));
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) {
for (RealmsInCompartmentIter realm(comp); !realm.done(); realm.next())
js_delete(realm.get());
comp->realms().clear();
js_delete(comp.get());
}
zone->compartments().clear();
js_delete(zone.get());
}
@ -3820,11 +3824,18 @@ Realm::destroy(FreeOp* fop)
JSRuntime* rt = fop->runtime();
if (auto callback = rt->destroyRealmCallback)
callback(fop, this);
if (auto callback = rt->destroyCompartmentCallback)
callback(fop, this);
if (principals())
JS_DropPrincipals(rt->mainContextFromOwnThread(), principals());
fop->delete_(this);
}
void
JSCompartment::destroy(FreeOp* fop)
{
JSRuntime* rt = fop->runtime();
if (auto callback = rt->destroyCompartmentCallback)
callback(fop, this);
fop->delete_(this);
rt->gc.stats().sweptCompartment();
}
@ -3856,22 +3867,53 @@ Zone::sweepCompartments(FreeOp* fop, bool keepAtleastOne, bool destroyingRuntime
JSCompartment** write = read;
while (read < end) {
JSCompartment* comp = *read++;
Realm* realm = JS::GetRealmForCompartment(comp);
/*
* Don't delete the last compartment and realm if keepAtleastOne is
* still true, meaning all the other compartments were deleted.
*/
bool keepAtleastOneRealm = read == end && keepAtleastOne;
comp->sweepRealms(fop, keepAtleastOneRealm, destroyingRuntime);
if (!comp->realms().empty()) {
*write++ = comp;
keepAtleastOne = false;
} else {
comp->destroy(fop);
}
}
compartments().shrinkTo(write - compartments().begin());
MOZ_ASSERT_IF(keepAtleastOne, !compartments().empty());
MOZ_ASSERT_IF(destroyingRuntime, compartments().empty());
}
void
JSCompartment::sweepRealms(FreeOp* fop, bool keepAtleastOne, bool destroyingRuntime)
{
MOZ_ASSERT(!realms().empty());
MOZ_ASSERT_IF(destroyingRuntime, !keepAtleastOne);
Realm** read = realms().begin();
Realm** end = realms().end();
Realm** write = read;
while (read < end) {
Realm* realm = *read++;
/*
* Don't delete the last realm if keepAtleastOne is still true, meaning
* all the other realms were deleted.
*/
bool dontDelete = read == end && keepAtleastOne;
if ((realm->marked() || dontDelete) && !destroyingRuntime) {
*write++ = comp;
*write++ = realm;
keepAtleastOne = false;
} else {
realm->destroy(fop);
}
}
compartments().shrinkTo(write - compartments().begin());
MOZ_ASSERT_IF(keepAtleastOne, !compartments().empty());
realms().shrinkTo(write - realms().begin());
MOZ_ASSERT_IF(keepAtleastOne, !realms().empty());
MOZ_ASSERT_IF(destroyingRuntime, realms().empty());
}
void
@ -7952,6 +7994,7 @@ js::NewRealm(JSContext* cx, JSPrincipals* principals, const JS::RealmOptions& op
JS_AbortIfWrongThread(cx);
UniquePtr<Zone> zoneHolder;
UniquePtr<JSCompartment> compHolder;
Zone* zone = nullptr;
JS::ZoneSpecifier zoneSpec = options.creationOptions().zoneSpecifier();
@ -7984,14 +8027,18 @@ js::NewRealm(JSContext* cx, JSPrincipals* principals, const JS::RealmOptions& op
zone = zoneHolder.get();
}
UniquePtr<Realm> realm = cx->make_unique<Realm>(zone, options);
compHolder = cx->make_unique<JSCompartment>(zone);
if (!compHolder || !compHolder->init(cx))
return nullptr;
JSCompartment* comp = compHolder.get();
UniquePtr<Realm> realm(cx->new_<Realm>(comp, options));
if (!realm || !realm->init(cx))
return nullptr;
// Set up the principals.
JS::SetRealmPrincipals(realm.get(), principals);
JSCompartment* comp = realm->compartment();
if (!comp->realms().append(realm.get())) {
ReportOutOfMemory(cx);
return nullptr;
@ -8018,6 +8065,7 @@ js::NewRealm(JSContext* cx, JSPrincipals* principals, const JS::RealmOptions& op
}
}
mozilla::Unused << compHolder.release();
mozilla::Unused << zoneHolder.release();
return realm.release();
}

View File

@ -155,3 +155,16 @@ JS::IterateRealms(JSContext* cx, void* data, JS::IterateRealmCallback realmCallb
(*realmCallback)(cx, data, realm);
}
}
JS_PUBLIC_API(void)
JS::IterateRealmsInCompartment(JSContext* cx, JSCompartment* compartment, void* data,
JS::IterateRealmCallback realmCallback)
{
AutoTraceSession session(cx->runtime());
Rooted<Realm*> realm(cx);
for (RealmsInCompartmentIter r(compartment); !r.done(); r.next()) {
realm = r;
(*realmCallback)(cx, data, realm);
}
}

View File

@ -402,7 +402,9 @@ Zone::deleteEmptyCompartment(JSCompartment* comp)
MOZ_ASSERT(comp->realms().length() == 1);
Realm* realm = comp->realms()[0];
realm->destroy(runtimeFromMainThread()->defaultFreeOp());
FreeOp* fop = runtimeFromMainThread()->defaultFreeOp();
realm->destroy(fop);
comp->destroy(fop);
compartments().clear();
}

View File

@ -201,7 +201,10 @@ struct Zone : public JS::shadow::Zone,
size_t* cachedCFG,
size_t* uniqueIdMap,
size_t* shapeTables,
size_t* atomsMarkBitmaps);
size_t* atomsMarkBitmaps,
size_t* compartmentObjects,
size_t* crossCompartmentWrappersTables,
size_t* compartmentsPrivateData);
// Iterate over all cells in the zone. See the definition of ZoneCellIter
// in gc/GC-inl.h for the possible arguments and documentation.

View File

@ -94,7 +94,7 @@ const I64DivUCode = 0x80;
const I64RemSCode = 0x81;
const I64RemUCode = 0x82;
const FirstInvalidOpcode = wasmThreadsSupported() ? 0xc5 : 0xc0;
const FirstInvalidOpcode = 0xc5;
const LastInvalidOpcode = 0xfb;
const MiscPrefix = 0xfc;
const SimdPrefix = 0xfd;

View File

@ -0,0 +1,7 @@
if (helperThreadCount() === 0)
quit();
evalInWorker(`
let m = parseModule("import.meta;");
m.declarationInstantiation();
m.evaluation();
`);

View File

@ -1897,7 +1897,7 @@ GetTemplateObjectForClassHook(JSContext* cx, JSNative hook, CallArgs& args,
{
if (hook == TypedObject::construct) {
Rooted<TypeDescr*> descr(cx, &args.callee().as<TypeDescr>());
templateObject.set(TypedObject::createZeroed(cx, descr, 1, gc::TenuredHeap));
templateObject.set(TypedObject::createZeroed(cx, descr, gc::TenuredHeap));
return !!templateObject;
}

View File

@ -516,7 +516,7 @@ class JitRealm
JSObject* getSimdTemplateObjectFor(JSContext* cx, Handle<SimdTypeDescr*> descr) {
ReadBarrieredObject& tpl = simdTemplateObjects_[descr->type()];
if (!tpl)
tpl.set(TypedObject::createZeroed(cx, descr, 0, gc::TenuredHeap));
tpl.set(TypedObject::createZeroed(cx, descr, gc::TenuredHeap));
return tpl.get();
}

View File

@ -3770,7 +3770,7 @@ IonBuilder::inlineConstructTypedObject(CallInfo& callInfo, TypeDescr* descr)
return InliningStatus_NotInlined;
}
if (size_t(descr->size()) > InlineTypedObject::MaximumSize)
if (!InlineTypedObject::canAccommodateType(descr))
return InliningStatus_NotInlined;
JSObject* obj = inspector->getTemplateObjectForClassHook(pc, descr->getClass());
@ -3996,7 +3996,7 @@ IonBuilder::inlineConstructSimdObject(CallInfo& callInfo, SimdTypeDescr* descr)
// Take the templateObject out of Baseline ICs, such that we can box
// SIMD value type in the same kind of objects.
MOZ_ASSERT(size_t(descr->size(descr->type())) < InlineTypedObject::MaximumSize);
MOZ_ASSERT(InlineTypedObject::canAccommodateType(descr));
MOZ_ASSERT(descr->getClass() == &SimdTypeDescr::class_,
"getTemplateObjectForSimdCtor needs an update");

View File

@ -622,12 +622,6 @@ JS_SetSizeOfIncludingThisCompartmentCallback(JSContext* cx,
cx->runtime()->sizeOfIncludingThisCompartmentCallback = callback;
}
JS_PUBLIC_API(void)
JS_SetCompartmentNameCallback(JSContext* cx, JSCompartmentNameCallback callback)
{
cx->runtime()->compartmentNameCallback = callback;
}
#if defined(NIGHTLY_BUILD)
JS_PUBLIC_API(void)
JS_SetErrorInterceptorCallback(JSRuntime* rt, JSErrorInterceptor* callback)
@ -1860,9 +1854,9 @@ JS::RealmCreationOptions::setNewZone()
}
const JS::RealmCreationOptions&
JS::RealmCreationOptionsRef(JSCompartment* compartment)
JS::RealmCreationOptionsRef(Realm* realm)
{
return JS::GetRealmForCompartment(compartment)->creationOptions();
return realm->creationOptions();
}
const JS::RealmCreationOptions&

View File

@ -963,9 +963,6 @@ extern JS_PUBLIC_API(void)
JS_SetSizeOfIncludingThisCompartmentCallback(JSContext* cx,
JSSizeOfIncludingThisCompartmentCallback callback);
extern JS_PUBLIC_API(void)
JS_SetCompartmentNameCallback(JSContext* cx, JSCompartmentNameCallback callback);
extern JS_PUBLIC_API(void)
JS_SetWrapObjectCallbacks(JSContext* cx, const JSWrapObjectCallbacks* callbacks);
@ -1108,6 +1105,13 @@ using IterateRealmCallback = void (*)(JSContext* cx, void* data, Handle<Realm*>
extern JS_PUBLIC_API(void)
IterateRealms(JSContext* cx, void* data, IterateRealmCallback realmCallback);
/**
* Like IterateRealms, but only iterates realms in |compartment|.
*/
extern JS_PUBLIC_API(void)
IterateRealmsInCompartment(JSContext* cx, JSCompartment* compartment, void* data,
IterateRealmCallback realmCallback);
} // namespace JS
typedef void (*JSIterateCompartmentCallback)(JSContext* cx, void* data, JSCompartment* compartment);
@ -1952,7 +1956,7 @@ class JS_PUBLIC_API(RealmOptions)
};
JS_PUBLIC_API(const RealmCreationOptions&)
RealmCreationOptionsRef(JSCompartment* compartment);
RealmCreationOptionsRef(JS::Realm* realm);
JS_PUBLIC_API(const RealmCreationOptions&)
RealmCreationOptionsRef(JSContext* cx);

View File

@ -157,8 +157,11 @@ JS::GetIsSecureContext(JS::Realm* realm)
JS_FRIEND_API(JSPrincipals*)
JS_GetCompartmentPrincipals(JSCompartment* compartment)
{
Realm* realm = JS::GetRealmForCompartment(compartment);
return realm->principals();
// Note: for now we assume a single realm per compartment. This API will go
// away after we remove the remaining callers. See bug 1465700.
MOZ_RELEASE_ASSERT(compartment->realms().length() == 1);
return compartment->realms()[0]->principals();
}
JS_FRIEND_API(JSPrincipals*)
@ -206,10 +209,10 @@ JS_GetScriptPrincipals(JSScript* script)
return script->principals();
}
JS_FRIEND_API(JSCompartment*)
js::GetScriptCompartment(JSScript* script)
JS_FRIEND_API(JS::Realm*)
js::GetScriptRealm(JSScript* script)
{
return script->compartment();
return script->realm();
}
JS_FRIEND_API(bool)
@ -338,15 +341,27 @@ js::ObjectClassName(JSContext* cx, HandleObject obj)
}
JS_FRIEND_API(JS::Zone*)
js::GetCompartmentZone(JSCompartment* comp)
js::GetRealmZone(JS::Realm* realm)
{
return comp->zone();
return realm->zone();
}
JS_FRIEND_API(bool)
js::IsSystemCompartment(JSCompartment* comp)
{
return JS::GetRealmForCompartment(comp)->isSystem();
// Note: for now we assume a single realm per compartment. This API will
// hopefully go away once Gecko supports same-compartment realms. Another
// option is to return comp->zone()->isSystem here, but we'd have to make
// sure that's equivalent.
MOZ_RELEASE_ASSERT(comp->realms().length() == 1);
return comp->realms()[0]->isSystem();
}
JS_FRIEND_API(bool)
js::IsSystemRealm(JS::Realm* realm)
{
return realm->isSystem();
}
JS_FRIEND_API(bool)

View File

@ -191,8 +191,8 @@ extern JS_FRIEND_API(JSPrincipals*)
JS_GetScriptPrincipals(JSScript* script);
namespace js {
extern JS_FRIEND_API(JSCompartment*)
GetScriptCompartment(JSScript* script);
extern JS_FRIEND_API(JS::Realm*)
GetScriptRealm(JSScript* script);
} /* namespace js */
extern JS_FRIEND_API(bool)
@ -458,7 +458,7 @@ extern JS_FRIEND_API(void)
RunJobs(JSContext* cx);
extern JS_FRIEND_API(JS::Zone*)
GetCompartmentZone(JSCompartment* comp);
GetRealmZone(JS::Realm* realm);
typedef bool
(* PreserveWrapperCallback)(JSContext* cx, JSObject* obj);
@ -480,6 +480,9 @@ JS_FRIEND_API(bool) obj_defineGetter(JSContext* cx, unsigned argc, JS::Value* vp
JS_FRIEND_API(bool) obj_defineSetter(JSContext* cx, unsigned argc, JS::Value* vp);
#endif
extern JS_FRIEND_API(bool)
IsSystemRealm(JS::Realm* realm);
extern JS_FRIEND_API(bool)
IsSystemCompartment(JSCompartment* comp);

View File

@ -447,7 +447,7 @@ ErrorCopier::~ErrorCopier()
// The provenance of Debugger.DebuggeeWouldRun is the topmost locking
// debugger compartment; it should not be copied around.
if (JS::GetCompartmentForRealm(ar->origin()) != cx->compartment() &&
if (ar->origin()->compartment() != cx->compartment() &&
cx->isExceptionPending() &&
!cx->isThrowingDebuggeeWouldRun())
{

View File

@ -556,13 +556,13 @@ LCovRealm::writeRealmName(JS::Realm* realm)
// thus we escape invalid chracters with a "_" symbol in front of its
// hexadecimal code.
outTN_.put("TN:");
if (cx->runtime()->compartmentNameCallback) {
if (cx->runtime()->realmNameCallback) {
char name[1024];
{
// Hazard analysis cannot tell that the callback does not GC.
JS::AutoSuppressGCAnalysis nogc;
JSCompartment* comp = JS::GetCompartmentForRealm(realm);
(*cx->runtime()->compartmentNameCallback)(cx, comp, name, sizeof(name));
Rooted<Realm*> rootedRealm(cx, realm);
(*cx->runtime()->realmNameCallback)(cx, rootedRealm, name, sizeof(name));
}
for (char *s = name; s < name + sizeof(name) && *s; s++) {
if (('a' <= *s && *s <= 'z') ||

View File

@ -55,14 +55,16 @@ ObjectRealm::~ObjectRealm()
MOZ_ASSERT(enumerators == iteratorSentinel_.get());
}
Realm::Realm(JS::Zone* zone, const JS::RealmOptions& options)
: JSCompartment(zone),
Realm::Realm(JSCompartment* comp, const JS::RealmOptions& options)
: JS::shadow::Realm(comp),
zone_(comp->zone()),
runtime_(comp->runtimeFromMainThread()),
creationOptions_(options.creationOptions()),
behaviors_(options.behaviors()),
global_(nullptr),
objects_(zone),
objects_(zone_),
randomKeyGenerator_(runtime_->forkRandomKeyGenerator()),
wasm(zone->runtimeFromMainThread()),
wasm(runtime_),
performanceMonitoring(runtime_)
{
MOZ_ASSERT_IF(creationOptions_.mergeable(),
@ -120,11 +122,6 @@ ObjectRealm::init(JSContext* cx)
bool
Realm::init(JSContext* cx)
{
// Initialize JSCompartment. This is temporary until Realm and
// JSCompartment are completely separated.
if (!JSCompartment::init(cx))
return false;
/*
* As a hack, we clear our timezone cache every time we create a new realm.
* This ensures that the cache is always relatively fresh, but shouldn't
@ -1037,7 +1034,7 @@ Realm::clearTables()
// No scripts should have run in this realm. This is used when merging
// a realm that has been used off thread into another realm and zone.
JS::GetCompartmentForRealm(this)->assertNoCrossCompartmentWrappers();
compartment()->assertNoCrossCompartmentWrappers();
MOZ_ASSERT(!jitRealm_);
MOZ_ASSERT(!debugEnvs_);
MOZ_ASSERT(objects_.enumerators->next() == objects_.enumerators);
@ -1076,7 +1073,7 @@ void
Realm::setNewObjectMetadata(JSContext* cx, HandleObject obj)
{
MOZ_ASSERT(obj->realm() == this);
assertSameCompartment(cx, JS::GetCompartmentForRealm(this), obj);
assertSameCompartment(cx, compartment(), obj);
AutoEnterOOMUnsafeRegion oomUnsafe;
if (JSObject* metadata = allocationMetadataBuilder_->build(cx, obj, oomUnsafe)) {
@ -1311,13 +1308,16 @@ Realm::clearBreakpointsIn(FreeOp* fop, js::Debugger* dbg, HandleObject handler)
}
void
JSCompartment::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* crossCompartmentWrappersArg)
JSCompartment::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* compartmentObjects,
size_t* crossCompartmentWrappersTables,
size_t* compartmentsPrivateData)
{
// Note that Realm inherits from JSCompartment (for now) so sizeof(*this) is
// included in that.
*compartmentObjects += mallocSizeOf(this);
*crossCompartmentWrappersTables += crossCompartmentWrappers.sizeOfExcludingThis(mallocSizeOf);
*crossCompartmentWrappersArg += crossCompartmentWrappers.sizeOfExcludingThis(mallocSizeOf);
if (auto callback = runtime_->sizeOfIncludingThisCompartmentCallback)
*compartmentsPrivateData += callback(mallocSizeOf, this);
}
void
@ -1349,17 +1349,12 @@ Realm::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* innerViewsArg,
size_t* lazyArrayBuffersArg,
size_t* objectMetadataTablesArg,
size_t* crossCompartmentWrappersArg,
size_t* savedStacksSet,
size_t* varNamesSet,
size_t* nonSyntacticLexicalEnvironmentsArg,
size_t* jitRealm,
size_t* privateData,
size_t* scriptCountsMapArg)
{
// This is temporary until Realm and JSCompartment are completely separated.
JSCompartment::addSizeOfExcludingThis(mallocSizeOf, crossCompartmentWrappersArg);
*realmObject += mallocSizeOf(this);
objectGroups_.addSizeOfExcludingThis(mallocSizeOf, tiAllocationSiteTables,
tiArrayTypeTables, tiObjectTypeTables,
@ -1378,15 +1373,10 @@ Realm::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
if (jitRealm_)
*jitRealm += jitRealm_->sizeOfIncludingThis(mallocSizeOf);
auto callback = runtime_->sizeOfIncludingThisCompartmentCallback;
if (callback)
*privateData += callback(mallocSizeOf, this);
if (scriptCountsMap) {
*scriptCountsMapArg += scriptCountsMap->sizeOfIncludingThis(mallocSizeOf);
for (auto r = scriptCountsMap->all(); !r.empty(); r.popFront()) {
for (auto r = scriptCountsMap->all(); !r.empty(); r.popFront())
*scriptCountsMapArg += r.front().value()->sizeOfIncludingThis(mallocSizeOf);
}
}
}

View File

@ -552,11 +552,10 @@ class WeakMapBase;
struct JSCompartment
{
protected:
private:
JS::Zone* zone_;
JSRuntime* runtime_;
private:
js::WrapperMap crossCompartmentWrappers;
using RealmVector = js::Vector<JS::Realm*, 1, js::SystemAllocPolicy>;
@ -603,11 +602,11 @@ struct JSCompartment
MOZ_ASSERT(crossCompartmentWrappers.empty());
}
protected:
void addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* crossCompartmentWrappersArg);
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* compartmentObjects,
size_t* crossCompartmentWrappersTables,
size_t* compartmentsPrivateData);
public:
#ifdef JSGC_HASH_TABLE_CHECKS
void checkWrapperMapAfterMovingGC();
#endif
@ -616,12 +615,12 @@ struct JSCompartment
bool getNonWrapperObjectForCurrentCompartment(JSContext* cx, js::MutableHandleObject obj);
bool getOrCreateWrapper(JSContext* cx, js::HandleObject existing, js::MutableHandleObject obj);
protected:
public:
explicit JSCompartment(JS::Zone* zone);
MOZ_MUST_USE bool init(JSContext* cx);
void destroy(js::FreeOp* fop);
public:
MOZ_MUST_USE inline bool wrap(JSContext* cx, JS::MutableHandleValue vp);
MOZ_MUST_USE bool wrap(JSContext* cx, js::MutableHandleString strp);
@ -675,8 +674,8 @@ struct JSCompartment
void traceOutgoingCrossCompartmentWrappers(JSTracer* trc);
static void traceIncomingCrossCompartmentEdgesForZoneGC(JSTracer* trc);
void sweepRealms(js::FreeOp* fop, bool keepAtleastOne, bool destroyingRuntime);
void sweepAfterMinorGC(JSTracer* trc);
void sweepCrossCompartmentWrappers();
static void fixupCrossCompartmentWrappersAfterMovingGC(JSTracer* trc);
@ -752,8 +751,11 @@ class ObjectRealm
} // namespace js
class JS::Realm : private JSCompartment
class JS::Realm : public JS::shadow::Realm
{
JS::Zone* zone_;
JSRuntime* runtime_;
const JS::RealmCreationOptions creationOptions_;
JS::RealmBehaviors behaviors_;
@ -885,7 +887,7 @@ class JS::Realm : private JSCompartment
void operator=(const Realm&) = delete;
public:
Realm(JS::Zone* zone, const JS::RealmOptions& options);
Realm(JSCompartment* comp, const JS::RealmOptions& options);
~Realm();
MOZ_MUST_USE bool init(JSContext* cx);
@ -901,18 +903,12 @@ class JS::Realm : private JSCompartment
size_t* innerViews,
size_t* lazyArrayBuffers,
size_t* objectMetadataTables,
size_t* crossCompartmentWrappers,
size_t* savedStacksSet,
size_t* varNamesSet,
size_t* nonSyntacticLexicalScopes,
size_t* jitRealm,
size_t* privateData,
size_t* scriptCountsMapArg);
JSCompartment* compartment() {
return this;
}
JS::Zone* zone() {
return zone_;
}

View File

@ -145,7 +145,7 @@ struct JSContext : public JS::RootingContext,
template <typename T>
inline bool isInsideCurrentCompartment(T thing) const {
return thing->compartment() == GetCompartmentForRealm(realm_);
return thing->compartment() == compartment();
}
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
@ -242,10 +242,11 @@ struct JSContext : public JS::RootingContext,
return nurserySuppressions_;
}
// Threads may freely access any data in their compartment and zone.
// Threads may freely access any data in their realm, compartment and zone.
JSCompartment* compartment() const {
return JS::GetCompartmentForRealm(realm_);
return realm_ ? JS::GetCompartmentForRealm(realm_) : nullptr;
}
JS::Realm* realm() const {
return realm_;
}
@ -256,7 +257,7 @@ struct JSContext : public JS::RootingContext,
JS::Zone* zone() const {
MOZ_ASSERT_IF(!realm() && zone_, inAtomsZone());
MOZ_ASSERT_IF(realm(), js::GetCompartmentZone(GetCompartmentForRealm(realm())) == zone_);
MOZ_ASSERT_IF(realm(), js::GetRealmZone(realm()) == zone_);
return zoneRaw();
}

View File

@ -327,7 +327,10 @@ StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone)
&zStats.cachedCFG,
&zStats.uniqueIdMap,
&zStats.shapeTables,
&rtStats->runtime.atomsMarkBitmaps);
&rtStats->runtime.atomsMarkBitmaps,
&zStats.compartmentObjects,
&zStats.crossCompartmentWrappersTables,
&zStats.compartmentsPrivateData);
}
static void
@ -355,12 +358,10 @@ StatsRealmCallback(JSContext* cx, void* data, Handle<Realm*> realm)
&realmStats.innerViewsTable,
&realmStats.lazyArrayBuffersTable,
&realmStats.objectMetadataTable,
&realmStats.crossCompartmentWrappersTable,
&realmStats.savedStacksSet,
&realmStats.varNamesSet,
&realmStats.nonSyntacticLexicalScopesTable,
&realmStats.jitRealm,
&realmStats.privateData,
&realmStats.scriptCountsMap);
}

View File

@ -107,7 +107,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
allowRelazificationForTesting(false),
destroyCompartmentCallback(nullptr),
sizeOfIncludingThisCompartmentCallback(nullptr),
compartmentNameCallback(nullptr),
destroyRealmCallback(nullptr),
realmNameCallback(nullptr),
externalStringSizeofCallback(nullptr),

View File

@ -354,9 +354,6 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
/* Compartment memory reporting callback. */
js::MainThreadData<JSSizeOfIncludingThisCompartmentCallback> sizeOfIncludingThisCompartmentCallback;
/* Call this to get the name of a compartment. */
js::MainThreadData<JSCompartmentNameCallback> compartmentNameCallback;
/* Realm destroy callback. */
js::MainThreadData<JS::DestroyRealmCallback> destroyRealmCallback;

View File

@ -4595,7 +4595,10 @@ Zone::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
size_t* cachedCFG,
size_t* uniqueIdMap,
size_t* shapeTables,
size_t* atomsMarkBitmaps)
size_t* atomsMarkBitmaps,
size_t* compartmentObjects,
size_t* crossCompartmentWrappersTables,
size_t* compartmentsPrivateData)
{
*typePool += types.typeLifoAlloc().sizeOfExcludingThis(mallocSizeOf);
*regexpZone += regExps.sizeOfExcludingThis(mallocSizeOf);
@ -4605,6 +4608,13 @@ Zone::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
*shapeTables += baseShapes().sizeOfExcludingThis(mallocSizeOf)
+ initialShapes().sizeOfExcludingThis(mallocSizeOf);
*atomsMarkBitmaps += markedAtoms().sizeOfExcludingThis(mallocSizeOf);
for (CompartmentsInZoneIter comp(this); !comp.done(); comp.next()) {
comp->addSizeOfIncludingThis(mallocSizeOf,
compartmentObjects,
crossCompartmentWrappersTables,
compartmentsPrivateData);
}
}
TypeZone::TypeZone(Zone* zone)

View File

@ -651,7 +651,7 @@ interface nsIXPCComponents_Utils : nsISupports
/*
* Gets the URI or identifier string associated with an object's
* compartment (the same one used by the memory reporter machinery).
* realm (the same one used by the memory reporter machinery).
*
* Unwraps cross-compartment wrappers first.
*
@ -659,7 +659,7 @@ interface nsIXPCComponents_Utils : nsISupports
* this from addon code.
*/
[implicit_jscontext]
ACString getCompartmentLocation(in jsval obj);
ACString getRealmLocation(in jsval obj);
/*
* Return a fractional number of milliseconds from process

View File

@ -3011,9 +3011,9 @@ nsXPCComponents_Utils::GetObjectPrincipal(HandleValue val, JSContext* cx,
}
NS_IMETHODIMP
nsXPCComponents_Utils::GetCompartmentLocation(HandleValue val,
JSContext* cx,
nsACString& result)
nsXPCComponents_Utils::GetRealmLocation(HandleValue val,
JSContext* cx,
nsACString& result)
{
if (!val.isObject())
return NS_ERROR_INVALID_ARG;
@ -3021,7 +3021,7 @@ nsXPCComponents_Utils::GetCompartmentLocation(HandleValue val,
obj = js::CheckedUnwrap(obj);
MOZ_ASSERT(obj);
result = xpc::CompartmentPrivate::Get(obj)->GetLocation();
result = xpc::RealmPrivate::Get(obj)->GetLocation();
return NS_OK;
}

View File

@ -206,14 +206,14 @@ RealmPrivate::RealmPrivate(JS::Realm* realm)
static bool
TryParseLocationURICandidate(const nsACString& uristr,
CompartmentPrivate::LocationHint aLocationHint,
RealmPrivate::LocationHint aLocationHint,
nsIURI** aURI)
{
static NS_NAMED_LITERAL_CSTRING(kGRE, "resource://gre/");
static NS_NAMED_LITERAL_CSTRING(kToolkit, "chrome://global/");
static NS_NAMED_LITERAL_CSTRING(kBrowser, "chrome://browser/");
if (aLocationHint == CompartmentPrivate::LocationHintAddon) {
if (aLocationHint == RealmPrivate::LocationHintAddon) {
// Blacklist some known locations which are clearly not add-on related.
if (StringBeginsWith(uristr, kGRE) ||
StringBeginsWith(uristr, kToolkit) ||
@ -249,8 +249,9 @@ TryParseLocationURICandidate(const nsACString& uristr,
return true;
}
bool CompartmentPrivate::TryParseLocationURI(CompartmentPrivate::LocationHint aLocationHint,
nsIURI** aURI)
bool
RealmPrivate::TryParseLocationURI(RealmPrivate::LocationHint aLocationHint,
nsIURI** aURI)
{
if (!aURI)
return false;
@ -576,9 +577,10 @@ NukeAllWrappersForCompartment(JSContext* cx, JSCompartment* compartment,
// unscriptable.
xpc::CompartmentPrivate::Get(compartment)->wasNuked = true;
// TODO: Loop over all realms in the compartment instead.
Realm* realm = GetRealmForCompartment(compartment);
xpc::RealmPrivate::Get(realm)->scriptability.Block();
auto blockScriptability = [](JSContext*, void*, Handle<Realm*> realm) {
xpc::RealmPrivate::Get(realm)->scriptability.Block();
};
JS::IterateRealmsInCompartment(cx, compartment, nullptr, blockScriptability);
}
} // namespace xpc
@ -1073,14 +1075,13 @@ XPCJSRuntime::~XPCJSRuntime()
MOZ_COUNT_DTOR_INHERITED(XPCJSRuntime, CycleCollectedJSRuntime);
}
// If |*anonymizeID| is non-zero and this is a user compartment, the name will
// If |*anonymizeID| is non-zero and this is a user realm, the name will
// be anonymized.
static void
GetCompartmentName(JSCompartment* c, nsCString& name, int* anonymizeID,
bool replaceSlashes)
GetRealmName(JS::Realm* realm, nsCString& name, int* anonymizeID,
bool replaceSlashes)
{
JS::Realm* realm = JS::GetRealmForCompartment(c);
if (*anonymizeID && !js::IsSystemCompartment(c)) {
if (*anonymizeID && !js::IsSystemRealm(realm)) {
name.AppendPrintf("<anonymized-%d>", *anonymizeID);
*anonymizeID += 1;
} else if (JSPrincipals* principals = JS::GetRealmPrincipals(realm)) {
@ -1089,13 +1090,13 @@ GetCompartmentName(JSCompartment* c, nsCString& name, int* anonymizeID,
name.AssignLiteral("(unknown)");
}
// If the compartment's location (name) differs from the principal's
// script location, append the compartment's location to allow
// differentiation of multiple compartments owned by the same principal
// (e.g. components owned by the system or null principal).
CompartmentPrivate* compartmentPrivate = CompartmentPrivate::Get(c);
if (compartmentPrivate) {
const nsACString& location = compartmentPrivate->GetLocation();
// If the realm's location (name) differs from the principal's script
// location, append the realm's location to allow differentiation of
// multiple realms owned by the same principal (e.g. components owned
// by the system or null principal).
RealmPrivate* realmPrivate = RealmPrivate::Get(realm);
if (realmPrivate) {
const nsACString& location = realmPrivate->GetLocation();
if (!location.IsEmpty() && !location.Equals(name)) {
name.AppendLiteral(", ");
name.Append(location);
@ -1156,7 +1157,7 @@ GetCompartmentName(JSCompartment* c, nsCString& name, int* anonymizeID,
}
extern void
xpc::GetCurrentCompartmentName(JSContext* cx, nsCString& name)
xpc::GetCurrentRealmName(JSContext* cx, nsCString& name)
{
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
if (!global) {
@ -1164,9 +1165,9 @@ xpc::GetCurrentCompartmentName(JSContext* cx, nsCString& name)
return;
}
JSCompartment* compartment = GetObjectCompartment(global);
JS::Realm* realm = GetNonCCWObjectRealm(global);
int anonymizeID = 0;
GetCompartmentName(compartment, name, &anonymizeID, false);
GetRealmName(realm, name, &anonymizeID, false);
}
void
@ -1349,6 +1350,19 @@ ReportZoneStats(const JS::ZoneStats& zStats,
zStats.shapeTables,
"Tables storing shape information.");
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("compartments/compartment-objects"),
zStats.compartmentObjects,
"The JSCompartment objects in this zone.");
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("compartments/cross-compartment-wrapper-tables"),
zStats.crossCompartmentWrappersTables,
"The cross-compartment wrapper tables.");
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("compartments/private-data"),
zStats.compartmentsPrivateData,
"Extra data attached to each compartment by XPConnect, including "
"its wrapped-js.");
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/gc-heap"),
zStats.lazyScriptsGCHeap,
"Scripts that haven't executed yet.");
@ -1749,7 +1763,7 @@ ReportRealmStats(const JS::RealmStats& realmStats,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("realm-object"),
realmStats.realmObject,
"The JSCompartment object itself.");
"The JS::Realm object itself.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("realm-tables"),
realmStats.realmTables,
@ -1767,10 +1781,6 @@ ReportRealmStats(const JS::RealmStats& realmStats,
realmStats.objectMetadataTable,
"The table used by debugging tools for tracking object metadata");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("cross-compartment-wrapper-table"),
realmStats.crossCompartmentWrappersTable,
"The cross-compartment wrapper table.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("saved-stacks-set"),
realmStats.savedStacksSet,
"The saved stacks set.");
@ -1783,11 +1793,6 @@ ReportRealmStats(const JS::RealmStats& realmStats,
realmStats.jitRealm,
"The JIT realm.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("private-data"),
realmStats.privateData,
"Extra data attached to the realm by XPConnect, including "
"its wrapped-js.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("script-counts-map"),
realmStats.scriptCountsMap,
"Profiling-related information for scripts.");
@ -2046,11 +2051,10 @@ class JSMainRuntimeRealmsReporter final : public nsIMemoryReporter
static void RealmCallback(JSContext* cx, void* vdata, Handle<Realm*> realm) {
// silently ignore OOM errors
JSCompartment* c = JS::GetCompartmentForRealm(realm);
Data* data = static_cast<Data*>(vdata);
nsCString path;
GetCompartmentName(c, path, &data->anonymizeID, /* replaceSlashes = */ true);
path.Insert(js::IsSystemCompartment(c)
GetRealmName(realm, path, &data->anonymizeID, /* replaceSlashes = */ true);
path.Insert(js::IsSystemRealm(realm)
? NS_LITERAL_CSTRING("js-main-runtime-realms/system/")
: NS_LITERAL_CSTRING("js-main-runtime-realms/user/"),
0);
@ -2194,10 +2198,9 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
virtual void initExtraRealmStats(Handle<Realm*> realm,
JS::RealmStats* realmStats) override
{
JSCompartment* c = JS::GetCompartmentForRealm(realm);
xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras;
nsCString cName;
GetCompartmentName(c, cName, &mAnonymizeID, /* replaceSlashes = */ true);
nsCString rName;
GetRealmName(realm, rName, &mAnonymizeID, /* replaceSlashes = */ true);
// Get the realm's global.
AutoSafeJSContext cx;
@ -2228,9 +2231,9 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
}
if (needZone)
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/", (void*)js::GetCompartmentZone(c));
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/", (void*)js::GetRealmZone(realm));
extras->jsPathPrefix += NS_LITERAL_CSTRING("realm(") + cName + NS_LITERAL_CSTRING(")/");
extras->jsPathPrefix += NS_LITERAL_CSTRING("realm(") + rName + NS_LITERAL_CSTRING(")/");
// extras->jsPathPrefix is used for almost all the realm-specific
// reports. At this point it has the form
@ -2642,14 +2645,14 @@ SetUseCounterCallback(JSObject* obj, JSUseCounter counter)
}
static void
CompartmentNameCallback(JSContext* cx, JSCompartment* comp,
char* buf, size_t bufsize)
GetRealmNameCallback(JSContext* cx, Handle<Realm*> realm,
char* buf, size_t bufsize)
{
nsCString name;
// This is called via the JSAPI and isn't involved in memory reporting, so
// we don't need to anonymize compartment names.
// we don't need to anonymize realm names.
int anonymizeID = 0;
GetCompartmentName(comp, name, &anonymizeID, /* replaceSlashes = */ false);
GetRealmName(realm, name, &anonymizeID, /* replaceSlashes = */ false);
if (name.Length() >= bufsize)
name.Truncate(bufsize - 1);
memcpy(buf, name.get(), name.Length() + 1);
@ -2664,13 +2667,6 @@ DestroyRealm(JSFreeOp* fop, JS::Realm* realm)
JS::SetRealmPrivate(realm, nullptr);
}
static void
GetRealmName(JSContext* cx, Handle<Realm*> realm, char* buf, size_t bufsize)
{
JSCompartment* comp = GetCompartmentForRealm(realm);
CompartmentNameCallback(cx, comp, buf, bufsize);
}
static bool
PreserveWrapper(JSContext* cx, JSObject* obj)
{
@ -2840,9 +2836,8 @@ XPCJSRuntime::Initialize(JSContext* cx)
JS_SetDestroyCompartmentCallback(cx, CompartmentDestroyedCallback);
JS_SetSizeOfIncludingThisCompartmentCallback(cx, CompartmentSizeOfIncludingThisCallback);
JS_SetCompartmentNameCallback(cx, CompartmentNameCallback);
JS::SetDestroyRealmCallback(cx, DestroyRealm);
JS::SetRealmNameCallback(cx, GetRealmName);
JS::SetRealmNameCallback(cx, GetRealmNameCallback);
mPrevGCSliceCallback = JS::SetGCSliceCallback(cx, GCSliceCallback);
mPrevDoCycleCollectionCallback = JS::SetDoCycleCollectionCallback(cx,
DoCycleCollectionCallback);

View File

@ -964,14 +964,14 @@ void
SetLocationForGlobal(JSObject* global, const nsACString& location)
{
MOZ_ASSERT(global);
CompartmentPrivate::Get(global)->SetLocation(location);
RealmPrivate::Get(global)->SetLocation(location);
}
void
SetLocationForGlobal(JSObject* global, nsIURI* locationURI)
{
MOZ_ASSERT(global);
CompartmentPrivate::Get(global)->SetLocationURI(locationURI);
RealmPrivate::Get(global)->SetLocationURI(locationURI);
}
} // namespace xpc

View File

@ -2834,11 +2834,6 @@ class CompartmentPrivate
CompartmentPrivate(const CompartmentPrivate&) = delete;
public:
enum LocationHint {
LocationHintRegular,
LocationHintAddon
};
explicit CompartmentPrivate(JSCompartment* c);
~CompartmentPrivate();
@ -2911,48 +2906,6 @@ public:
// by a security wrapper. See XrayWrapper.cpp.
bool wrapperDenialWarnings[WrapperDenialTypeCount];
const nsACString& GetLocation() {
if (location.IsEmpty() && locationURI) {
nsCOMPtr<nsIXPConnectWrappedJS> jsLocationURI =
do_QueryInterface(locationURI);
if (jsLocationURI) {
// We cannot call into JS-implemented nsIURI objects, because
// we are iterating over the JS heap at this point.
location =
NS_LITERAL_CSTRING("<JS-implemented nsIURI location>");
} else if (NS_FAILED(locationURI->GetSpec(location))) {
location = NS_LITERAL_CSTRING("<unknown location>");
}
}
return location;
}
bool GetLocationURI(nsIURI** aURI) {
return GetLocationURI(LocationHintRegular, aURI);
}
bool GetLocationURI(LocationHint aLocationHint, nsIURI** aURI) {
if (locationURI) {
nsCOMPtr<nsIURI> rval = locationURI;
rval.forget(aURI);
return true;
}
return TryParseLocationURI(aLocationHint, aURI);
}
void SetLocation(const nsACString& aLocation) {
if (aLocation.IsEmpty())
return;
if (!location.IsEmpty() || locationURI)
return;
location = aLocation;
}
void SetLocationURI(nsIURI* aLocationURI) {
if (!aLocationURI)
return;
if (locationURI)
return;
locationURI = aLocationURI;
}
JSObject2WrappedJSMap* GetWrappedJSMap() const { return mWrappedJSMap; }
void UpdateWeakPointersAfterGC();
@ -2961,11 +2914,7 @@ public:
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
private:
nsCString location;
nsCOMPtr<nsIURI> locationURI;
JSObject2WrappedJSMap* mWrappedJSMap;
bool TryParseLocationURI(LocationHint aType, nsIURI** aURI);
};
bool IsUniversalXPConnectEnabled(JSCompartment* compartment);
@ -2984,13 +2933,18 @@ CrashIfNotInAutomation()
//
// Following the ECMAScript spec, a realm contains a global (e.g. an inner
// Window) and its associated scripts and objects; a compartment may contain
// several same-origin, same-principal realms.
// several same-origin realms.
class RealmPrivate
{
RealmPrivate() = delete;
RealmPrivate(const RealmPrivate&) = delete;
public:
enum LocationHint {
LocationHintRegular,
LocationHintAddon
};
explicit RealmPrivate(JS::Realm* realm);
static RealmPrivate* Get(JS::Realm* realm)
@ -3015,6 +2969,55 @@ public:
// Our XPCWrappedNativeScope. This is non-null if and only if this is an
// XPConnect realm.
XPCWrappedNativeScope* scope;
const nsACString& GetLocation() {
if (location.IsEmpty() && locationURI) {
nsCOMPtr<nsIXPConnectWrappedJS> jsLocationURI =
do_QueryInterface(locationURI);
if (jsLocationURI) {
// We cannot call into JS-implemented nsIURI objects, because
// we are iterating over the JS heap at this point.
location =
NS_LITERAL_CSTRING("<JS-implemented nsIURI location>");
} else if (NS_FAILED(locationURI->GetSpec(location))) {
location = NS_LITERAL_CSTRING("<unknown location>");
}
}
return location;
}
bool GetLocationURI(LocationHint aLocationHint, nsIURI** aURI) {
if (locationURI) {
nsCOMPtr<nsIURI> rval = locationURI;
rval.forget(aURI);
return true;
}
return TryParseLocationURI(aLocationHint, aURI);
}
bool GetLocationURI(nsIURI** aURI) {
return GetLocationURI(LocationHintRegular, aURI);
}
void SetLocation(const nsACString& aLocation) {
if (aLocation.IsEmpty())
return;
if (!location.IsEmpty() || locationURI)
return;
location = aLocation;
}
void SetLocationURI(nsIURI* aLocationURI) {
if (!aLocationURI)
return;
if (locationURI)
return;
locationURI = aLocationURI;
}
private:
nsCString location;
nsCOMPtr<nsIURI> locationURI;
bool TryParseLocationURI(LocationHint aType, nsIURI** aURI);
};
inline XPCWrappedNativeScope*

View File

@ -615,11 +615,11 @@ JSObject*
FindExceptionStackForConsoleReport(nsPIDOMWindowInner* win,
JS::HandleValue exceptionValue);
// Return a name for the compartment.
// Return a name for the realm.
// This function makes reasonable efforts to make this name both mostly human-readable
// and unique. However, there are no guarantees of either property.
extern void
GetCurrentCompartmentName(JSContext*, nsCString& name);
GetCurrentRealmName(JSContext*, nsCString& name);
void AddGCCallback(xpcGCCallback cb);
void RemoveGCCallback(xpcGCCallback cb);

View File

@ -8369,13 +8369,10 @@ PresShell::GetCurrentItemAndPositionForElement(Element* aFocusedElement,
if (cols) {
nsTreeColumn* col = cols->GetFirstColumn();
if (col) {
RefPtr<Element> colElement;
col->GetElement(getter_AddRefs(colElement));
if (colElement) {
nsIFrame* frame = colElement->GetPrimaryFrame();
if (frame) {
extraTreeY += frame->GetSize().height;
}
RefPtr<Element> colElement = col->Element();
nsIFrame* frame = colElement->GetPrimaryFrame();
if (frame) {
extraTreeY += frame->GetSize().height;
}
}
}

View File

@ -6,7 +6,7 @@ fuzzy(45,460) fuzzy-if(skiaContent,57,439) fuzzy-if(Android,57,1330) == box-deco
random-if(!gtkWidget) == box-decoration-break-border-image.html box-decoration-break-border-image-ref.html
== box-decoration-break-block-border-padding.html box-decoration-break-block-border-padding-ref.html
== box-decoration-break-block-margin.html box-decoration-break-block-margin-ref.html
fuzzy-if(!Android,1,62) fuzzy-if(Android,8,6627) == box-decoration-break-first-letter.html box-decoration-break-first-letter-ref.html #Bug 1313773
fuzzy-if(!Android,1,62) fuzzy-if(Android,8,6627) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == box-decoration-break-first-letter.html box-decoration-break-first-letter-ref.html #Bug 1313773 # Bug 1392106
== box-decoration-break-with-bidi.html box-decoration-break-with-bidi-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == box-decoration-break-bug-1235152.html box-decoration-break-bug-1235152-ref.html # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == box-decoration-break-bug-1249913.html box-decoration-break-bug-1249913-ref.html # Bug 1392106

View File

@ -16,7 +16,7 @@ fuzzy-if(winWidget,12,100) == display-contents-style-inheritance-1-dom-mutations
== display-contents-visibility-hidden.html display-contents-visibility-hidden-ref.html
== display-contents-visibility-hidden-2.html display-contents-visibility-hidden-ref.html
== display-contents-495385-2d.html display-contents-495385-2d-ref.html
fuzzy-if(Android,7,3935) == display-contents-xbl.xhtml display-contents-xbl-ref.html
fuzzy-if(Android,7,3935) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == display-contents-xbl.xhtml display-contents-xbl-ref.html # bug 1392106
== display-contents-xbl-2.xul display-contents-xbl-2-ref.xul
== display-contents-xbl-3.xul display-contents-xbl-3-ref.xul
skip == display-contents-xbl-4.xul display-contents-xbl-4-ref.xul # fails (not just asserts) due to bug 1089223

View File

@ -89,10 +89,10 @@ skip-if(winWidget) == annotations.html annotations-ref.html # bug 1447257
# requires Japanese font with feature support, WinXP lacks one
random-if(!winWidget&&!cocoaWidget) == fwid-spaces.html fwid-spaces-ref.html
# Arial/Times New Roman on Win7+/OSX 10.6+ have kerning pairs that include spaces
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) != kerning-spaces-arial-nokern.html kerning-spaces-arial-default.html
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) == kerning-spaces-arial-kern.html kerning-spaces-arial-default.html
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) != kerning-spaces-tnr-nokern.html kerning-spaces-tnr-default.html
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) == kerning-spaces-tnr-kern.html kerning-spaces-tnr-default.html
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) != kerning-spaces-arial-nokern.html kerning-spaces-arial-default.html # Bug 1392106
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == kerning-spaces-arial-kern.html kerning-spaces-arial-default.html # Bug 1392106
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) != kerning-spaces-tnr-nokern.html kerning-spaces-tnr-default.html # Bug 1392106
random-if(!winWidget&&!cocoaWidget) fails-if(winWidget||cocoaWidget) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == kerning-spaces-tnr-kern.html kerning-spaces-tnr-default.html # Bug 1392106
# font-variant-caps fallback
# -- sanity check - none of these should look like the default rendering

View File

@ -158,7 +158,7 @@ skip-if(gtkWidget||/^Windows\x20NT\x206\.1/.test(http.oscpu)) == emoji-fallback-
skip-if(!cocoaWidget) == legacy-family-names-1.html legacy-family-names-1-ref.html
skip-if(!winWidget) == legacy-family-names-2.html legacy-family-names-2-ref.html
== descriptor-ranges.html descriptor-ranges-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == descriptor-ranges.html descriptor-ranges-ref.html # Bug 1392106
# Reset default prefs.
default-preferences

View File

@ -1,3 +1,3 @@
== legend.html legend-ref.html
fuzzy-if(Android,255,41) == 1273433.html 1273433-ref.html
fuzzy-if(Android,255,41) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 1273433.html 1273433-ref.html # Bug 1392106
fails == 1339287.html 1339287-ref.html # bug 1383868

View File

@ -152,7 +152,7 @@ random-if(gtkWidget) == mpadded-9.html mpadded-9-ref.html # bug 1309430
== scriptlevel-1.html scriptlevel-1-ref.html
== scriptlevel-movablelimits-1.html scriptlevel-movablelimits-1-ref.html
== munderover-align-accent-false.html munderover-align-accent-false-ref.html
== munderover-align-accent-true.html munderover-align-accent-true-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == munderover-align-accent-true.html munderover-align-accent-true-ref.html # Bug 1392106
== munder-mover-align-accent-true.html munder-mover-align-accent-true-ref.html
== munder-mover-align-accent-false.html munder-mover-align-accent-false-ref.html
== mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml

View File

@ -167,7 +167,7 @@ random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-04.svg dyna
== dynamic-text-06.svg pass.svg
== dynamic-text-07.svg dynamic-text-07-ref.svg
== dynamic-text-08.svg dynamic-text-08-ref.svg
== dynamic-text-attr-01.svg dynamic-text-attr-01-ref.svg
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-attr-01.svg dynamic-text-attr-01-ref.svg # bug 1392106
== dynamic-textPath-01.svg dynamic-textPath-01-ref.svg
== dynamic-textPath-02.svg dynamic-textPath-02-ref.svg
== dynamic-textPath-03.svg dynamic-textPath-03-ref.svg

View File

@ -67,10 +67,10 @@ fails == anim-css-fillopacity-3-clamp-big.svg anim-css-fillopacity-3-ref.svg
fuzzy-if(skiaContent,1,365) == anim-css-fillopacity-3-clamp-small.svg anim-css-fillopacity-3-ref.svg
# 'font' shorthand property
== anim-css-font-1.svg anim-css-font-1-ref.svg
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == anim-css-font-1.svg anim-css-font-1-ref.svg # Bug 1392106
# 'font-size' property, from/by/to with pixel values only
== anim-css-fontsize-1-from-by-px-px.svg anim-css-fontsize-1-ref.svg
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == anim-css-fontsize-1-from-by-px-px.svg anim-css-fontsize-1-ref.svg # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == anim-css-fontsize-1-from-to-px-px.svg anim-css-fontsize-1-ref.svg # Bug 1392106
# 'font-size' property (accepts unitless values)

View File

@ -56,11 +56,24 @@ fails css-writing-modes/float-rgt-orthog-htb-in-vlr-003.xht
fails css-writing-modes/float-rgt-orthog-htb-in-vrl-003.xht
fails css-writing-modes/float-rgt-orthog-vlr-in-htb-003.xht
fails css-writing-modes/float-rgt-orthog-vrl-in-htb-003.xht
fails css-writing-modes/sizing-orthog-htb-in-vrl-001.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-001.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-003.xht
fails css-writing-modes/sizing-orthog-htb-in-vrl-004.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-009.xht
fails css-writing-modes/sizing-orthog-htb-in-vrl-013.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-003.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-004.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-006.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-007.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-009.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-010.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-011.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-012.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-013.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-015.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-016.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-018.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-019.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-02?.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vlr-0??.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vlr-008.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vlr-020.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/sizing-orthog-htb-in-vrl-008.xht
@ -118,6 +131,7 @@ fuzzy-if(OSX||winWidget,223,720) css-writing-modes/vertical-alignment-*.xht
fuzzy-if(OSX||winWidget,158,624) css-writing-modes/writing-mode-vertical-??-00?.*
fuzzy(255,960) css-writing-modes/text-combine-upright-value-all-00?.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/text-combine-upright-compression-00?.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) css-writing-modes/text-combine-upright-inherit-all-00?.html
# Bug 1167911
skip css-writing-modes/abs-pos-non-replaced-icb-vlr-021.xht

View File

@ -916,46 +916,46 @@ fuzzy-if(OSX||winWidget,110,1200) random-if(/^Windows\x20NT\x206\.1/.test(http.o
fuzzy-if(OSX||winWidget,110,1200) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/row-progression-vrl-004.xht css-writing-modes/block-flow-direction-001-ref.xht
fuzzy-if(OSX||winWidget,110,1200) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/row-progression-vrl-006.xht css-writing-modes/block-flow-direction-001-ref.xht
fuzzy-if(OSX||winWidget,110,1200) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/row-progression-vrl-008.xht css-writing-modes/block-flow-direction-001-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-001.xht css-writing-modes/sizing-orthog-htb-in-vlr-001-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-001.xht css-writing-modes/sizing-orthog-htb-in-vlr-001-ref.xht
fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-003.xht css-writing-modes/sizing-orthog-htb-in-vlr-003-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-004.xht css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-006.xht css-writing-modes/sizing-orthog-htb-in-vlr-006-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-007.xht css-writing-modes/sizing-orthog-htb-in-vlr-007-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-004.xht css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-006.xht css-writing-modes/sizing-orthog-htb-in-vlr-006-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-007.xht css-writing-modes/sizing-orthog-htb-in-vlr-007-ref.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-008.xht css-writing-modes/sizing-orthog-htb-in-vlr-008-ref.xht
fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-009.xht css-writing-modes/sizing-orthog-htb-in-vlr-003-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-010.xht css-writing-modes/sizing-orthog-htb-in-vlr-010-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-011.xht css-writing-modes/sizing-orthog-htb-in-vlr-011-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-012.xht css-writing-modes/sizing-orthog-htb-in-vlr-006-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-013.xht css-writing-modes/sizing-orthog-htb-in-vlr-013-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-010.xht css-writing-modes/sizing-orthog-htb-in-vlr-010-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-011.xht css-writing-modes/sizing-orthog-htb-in-vlr-011-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-012.xht css-writing-modes/sizing-orthog-htb-in-vlr-006-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-013.xht css-writing-modes/sizing-orthog-htb-in-vlr-013-ref.xht
fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-015.xht css-writing-modes/sizing-orthog-htb-in-vlr-015-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-016.xht css-writing-modes/sizing-orthog-htb-in-vlr-016-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-018.xht css-writing-modes/sizing-orthog-htb-in-vlr-018-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-019.xht css-writing-modes/sizing-orthog-htb-in-vlr-019-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-016.xht css-writing-modes/sizing-orthog-htb-in-vlr-016-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-018.xht css-writing-modes/sizing-orthog-htb-in-vlr-018-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-019.xht css-writing-modes/sizing-orthog-htb-in-vlr-019-ref.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-020.xht css-writing-modes/sizing-orthog-htb-in-vlr-020-ref.xht
fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-021.xht css-writing-modes/sizing-orthog-htb-in-vlr-015-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-022.xht css-writing-modes/sizing-orthog-htb-in-vlr-022-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-023.xht css-writing-modes/sizing-orthog-htb-in-vlr-023-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vlr-024.xht css-writing-modes/sizing-orthog-htb-in-vlr-018-ref.xht
fails == css-writing-modes/sizing-orthog-htb-in-vrl-001.xht css-writing-modes/sizing-orthog-htb-in-vrl-001-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-022.xht css-writing-modes/sizing-orthog-htb-in-vlr-022-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-023.xht css-writing-modes/sizing-orthog-htb-in-vlr-023-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vlr-024.xht css-writing-modes/sizing-orthog-htb-in-vlr-018-ref.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-001.xht css-writing-modes/sizing-orthog-htb-in-vrl-001-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-003.xht css-writing-modes/sizing-orthog-htb-in-vrl-003-ref.xht
fails == css-writing-modes/sizing-orthog-htb-in-vrl-004.xht css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-006.xht css-writing-modes/sizing-orthog-htb-in-vrl-006-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-007.xht css-writing-modes/sizing-orthog-htb-in-vrl-007-ref.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-004.xht css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-006.xht css-writing-modes/sizing-orthog-htb-in-vrl-006-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-007.xht css-writing-modes/sizing-orthog-htb-in-vrl-007-ref.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-008.xht css-writing-modes/sizing-orthog-htb-in-vrl-008-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-009.xht css-writing-modes/sizing-orthog-htb-in-vrl-003-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-010.xht css-writing-modes/sizing-orthog-htb-in-vrl-010-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-011.xht css-writing-modes/sizing-orthog-htb-in-vrl-011-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-012.xht css-writing-modes/sizing-orthog-htb-in-vrl-006-ref.xht
fails == css-writing-modes/sizing-orthog-htb-in-vrl-013.xht css-writing-modes/sizing-orthog-htb-in-vrl-013-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-015.xht css-writing-modes/sizing-orthog-htb-in-vrl-015-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-016.xht css-writing-modes/sizing-orthog-htb-in-vlr-016-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-018.xht css-writing-modes/sizing-orthog-htb-in-vrl-018-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-019.xht css-writing-modes/sizing-orthog-htb-in-vrl-019-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-010.xht css-writing-modes/sizing-orthog-htb-in-vrl-010-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-011.xht css-writing-modes/sizing-orthog-htb-in-vrl-011-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-012.xht css-writing-modes/sizing-orthog-htb-in-vrl-006-ref.xht
fails random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-013.xht css-writing-modes/sizing-orthog-htb-in-vrl-013-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-015.xht css-writing-modes/sizing-orthog-htb-in-vrl-015-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-016.xht css-writing-modes/sizing-orthog-htb-in-vlr-016-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-018.xht css-writing-modes/sizing-orthog-htb-in-vrl-018-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-019.xht css-writing-modes/sizing-orthog-htb-in-vrl-019-ref.xht
fails-if(OSX||winWidget||Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-020.xht css-writing-modes/sizing-orthog-htb-in-vrl-020-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-021.xht css-writing-modes/sizing-orthog-htb-in-vrl-015-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-022.xht css-writing-modes/sizing-orthog-htb-in-vrl-022-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-023.xht css-writing-modes/sizing-orthog-htb-in-vrl-023-ref.xht
== css-writing-modes/sizing-orthog-htb-in-vrl-024.xht css-writing-modes/sizing-orthog-htb-in-vrl-018-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-021.xht css-writing-modes/sizing-orthog-htb-in-vrl-015-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-022.xht css-writing-modes/sizing-orthog-htb-in-vrl-022-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-023.xht css-writing-modes/sizing-orthog-htb-in-vrl-023-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-htb-in-vrl-024.xht css-writing-modes/sizing-orthog-htb-in-vrl-018-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-prct-htb-in-vlr-001.xht css-writing-modes/sizing-orthog-prct-htb-in-vlr-001-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-prct-htb-in-vlr-002.xht css-writing-modes/sizing-orthog-prct-htb-in-vlr-002-ref.xht
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/sizing-orthog-prct-htb-in-vlr-003.xht css-writing-modes/sizing-orthog-prct-htb-in-vlr-003-ref.xht
@ -1075,8 +1075,8 @@ fuzzy-if(OSX||winWidget,215,780) == css-writing-modes/text-baseline-vrl-002.xht
fuzzy-if(OSX||winWidget,215,780) == css-writing-modes/text-baseline-vrl-004.xht css-writing-modes/text-baseline-vrl-002-ref.xht
fuzzy-if(OSX||winWidget,215,780) == css-writing-modes/text-baseline-vrl-006.xht css-writing-modes/text-baseline-vrl-006-ref.xht
fuzzy-if(OSX,23,16) == css-writing-modes/text-combine-upright-decorations-001.html css-writing-modes/reference/text-combine-upright-decorations-001.html
== css-writing-modes/text-combine-upright-inherit-all-001.html css-writing-modes/reference/text-combine-upright-inherit-all-001.html
== css-writing-modes/text-combine-upright-inherit-all-002.html css-writing-modes/reference/text-combine-upright-inherit-all-002.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/text-combine-upright-inherit-all-001.html css-writing-modes/reference/text-combine-upright-inherit-all-001.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == css-writing-modes/text-combine-upright-inherit-all-002.html css-writing-modes/reference/text-combine-upright-inherit-all-002.html
== css-writing-modes/text-combine-upright-layout-rules-001.html css-writing-modes/reference/text-combine-upright-layout-rules-001-ref.html
== css-writing-modes/text-combine-upright-line-breaking-rules-001.html css-writing-modes/text-combine-upright-line-breaking-rules-001-ref.html
fuzzy(255,960) == css-writing-modes/text-combine-upright-value-all-001.html css-writing-modes/reference/text-combine-upright-value-single-character.html

View File

@ -12,7 +12,7 @@ fails-if(webrender&&cocoaWidget) == system-alphabetic.html system-alphabetic-ref
== system-numeric-invalid.html system-common-invalid2-ref.html
== system-additive-invalid.html system-common-invalid-ref.html
== system-extends-invalid.html system-extends-invalid-ref.html
== descriptor-negative.html descriptor-negative-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == descriptor-negative.html descriptor-negative-ref.html # Bug 1392106
== descriptor-prefix.html descriptor-prefix-ref.html
== descriptor-suffix.html descriptor-suffix-ref.html
== descriptor-range.html descriptor-range-ref.html

View File

@ -31,6 +31,7 @@
#include "mozilla/dom/Event.h" // for Event
#include "mozilla/dom/BoxObject.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/TreeColumnBinding.h"
#include "mozilla/TextEvents.h"
using namespace mozilla;
@ -351,7 +352,7 @@ nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent)
int32_t y = aMouseEvent->ScreenY(CallerType::System);
int32_t row;
nsCOMPtr<nsITreeColumn> col;
RefPtr<nsTreeColumn> col;
nsAutoString obj;
// subtract off the documentElement's boxObject
@ -368,10 +369,10 @@ nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent)
mNeedTitletip = false;
int16_t colType = -1;
if (col) {
col->GetType(&colType);
colType = col->Type();
}
if (row >= 0 && obj.EqualsLiteral("text") &&
colType != nsITreeColumn::TYPE_PASSWORD) {
colType != TreeColumnBinding::TYPE_PASSWORD) {
obx->IsCellCropped(row, col, &mNeedTitletip);
}
@ -456,7 +457,7 @@ nsXULTooltipListener::ShowTooltip()
#ifdef DEBUG_crap
static void
GetTreeCellCoords(nsITreeBoxObject* aTreeBox, nsIContent* aSourceNode,
int32_t aRow, nsITreeColumn* aCol, int32_t* aX, int32_t* aY)
int32_t aRow, nsTreeColumn* aCol, int32_t* aX, int32_t* aY)
{
int32_t junk;
aTreeBox->GetCoordsForCellItem(aRow, aCol, EmptyCString(), aX, aY, &junk, &junk);
@ -472,7 +473,7 @@ GetTreeCellCoords(nsITreeBoxObject* aTreeBox, nsIContent* aSourceNode,
static void
SetTitletipLabel(nsITreeBoxObject* aTreeBox, Element* aTooltip,
int32_t aRow, nsITreeColumn* aCol)
int32_t aRow, nsTreeColumn* aCol)
{
nsCOMPtr<nsITreeView> view;
aTreeBox->GetView(getter_AddRefs(view));

View File

@ -18,7 +18,7 @@
#include "mozilla/Attributes.h"
class nsIContent;
class nsITreeColumn;
class nsTreeColumn;
namespace mozilla {
namespace dom {
@ -99,7 +99,7 @@ protected:
bool mIsSourceTree;
bool mNeedTitletip;
int32_t mLastTreeRow;
nsCOMPtr<nsITreeColumn> mLastTreeCol;
RefPtr<nsTreeColumn> mLastTreeCol;
#endif
};

View File

@ -306,12 +306,6 @@ int32_t TreeBoxObject::HorizontalPosition()
return 0;
}
NS_IMETHODIMP TreeBoxObject::GetHorizontalPosition(int32_t *aHorizontalPosition)
{
*aHorizontalPosition = HorizontalPosition();
return NS_OK;
}
int32_t TreeBoxObject::GetPageLength()
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
@ -320,26 +314,16 @@ int32_t TreeBoxObject::GetPageLength()
return 0;
}
NS_IMETHODIMP TreeBoxObject::GetPageLength(int32_t *aPageLength)
{
*aPageLength = GetPageLength();
return NS_OK;
}
NS_IMETHODIMP TreeBoxObject::GetSelectionRegion(nsIScriptableRegion **aRegion)
{
*aRegion = nullptr;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->GetSelectionRegion(aRegion);
return NS_OK;
}
already_AddRefed<nsIScriptableRegion>
TreeBoxObject::SelectionRegion()
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (!body) {
return nullptr;
}
nsCOMPtr<nsIScriptableRegion> region;
GetSelectionRegion(getter_AddRefs(region));
body->GetSelectionRegion(getter_AddRefs(region));
return region.forget();
}
@ -352,67 +336,45 @@ TreeBoxObject::EnsureRowIsVisible(int32_t aRow)
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
void
TreeBoxObject::EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol, ErrorResult& aRv)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->EnsureCellIsVisible(aRow, aCol);
return NS_OK;
if (body) {
nsresult rv = body->EnsureCellIsVisible(aRow, aCol);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
}
NS_IMETHODIMP
void
TreeBoxObject::ScrollToRow(int32_t aRow)
{
nsTreeBodyFrame* body = GetTreeBodyFrame(true);
if (body)
return body->ScrollToRow(aRow);
return NS_OK;
if (!body) {
return;
}
body->ScrollToRow(aRow);
}
NS_IMETHODIMP
void
TreeBoxObject::ScrollByLines(int32_t aNumLines)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->ScrollByLines(aNumLines);
return NS_OK;
if (!body) {
return;
}
body->ScrollByLines(aNumLines);
}
NS_IMETHODIMP
void
TreeBoxObject::ScrollByPages(int32_t aNumPages)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->ScrollByPages(aNumPages);
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::ScrollToCell(int32_t aRow, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->ScrollToCell(aRow, aCol);
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::ScrollToColumn(nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->ScrollToColumn(aCol);
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::ScrollToHorizontalPosition(int32_t aHorizontalPosition)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->ScrollToHorizontalPosition(aHorizontalPosition);
return NS_OK;
body->ScrollByPages(aNumPages);
}
NS_IMETHODIMP TreeBoxObject::Invalidate()
@ -424,7 +386,7 @@ NS_IMETHODIMP TreeBoxObject::Invalidate()
}
NS_IMETHODIMP
TreeBoxObject::InvalidateColumn(nsITreeColumn* aCol)
TreeBoxObject::InvalidateColumn(nsTreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
@ -442,7 +404,7 @@ TreeBoxObject::InvalidateRow(int32_t aIndex)
}
NS_IMETHODIMP
TreeBoxObject::InvalidateCell(int32_t aRow, nsITreeColumn* aCol)
TreeBoxObject::InvalidateCell(int32_t aRow, nsTreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
@ -459,36 +421,19 @@ TreeBoxObject::InvalidateRange(int32_t aStart, int32_t aEnd)
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->InvalidateColumnRange(aStart, aEnd, aCol);
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::GetRowAt(int32_t x, int32_t y, int32_t *aRow)
{
*aRow = 0;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body)
return body->GetRowAt(x, y, aRow);
return NS_OK;
}
int32_t
TreeBoxObject::GetRowAt(int32_t x, int32_t y)
{
int32_t row;
GetRowAt(x, y, &row);
return row;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (!body) {
return 0;
}
return body->GetRowAt(x, y);
}
NS_IMETHODIMP
TreeBoxObject::GetCellAt(int32_t aX, int32_t aY, int32_t *aRow,
nsITreeColumn** aCol, nsAString& aChildElt)
nsTreeColumn** aCol, nsAString& aChildElt)
{
*aRow = 0;
*aCol = nullptr;
@ -505,9 +450,8 @@ TreeBoxObject::GetCellAt(int32_t aX, int32_t aY, int32_t *aRow,
void
TreeBoxObject::GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv)
{
nsCOMPtr<nsITreeColumn> col;
GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(col), aRetVal.mChildElt);
aRetVal.mCol = col.forget().downcast<nsTreeColumn>();
GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(aRetVal.mCol),
aRetVal.mChildElt);
}
void
@ -519,9 +463,9 @@ TreeBoxObject::GetCellAt(JSContext* cx,
ErrorResult& aRv)
{
int32_t row;
nsITreeColumn* col;
RefPtr<nsTreeColumn> col;
nsAutoString childElt;
GetCellAt(x, y, &row, &col, childElt);
GetCellAt(x, y, &row, getter_AddRefs(col), childElt);
JS::Rooted<JS::Value> v(cx);
@ -543,7 +487,7 @@ TreeBoxObject::GetCellAt(JSContext* cx,
}
NS_IMETHODIMP
TreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsAString& aElement,
TreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol, const nsAString& aElement,
int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight)
{
*aX = *aY = *aWidth = *aHeight = 0;
@ -599,7 +543,7 @@ TreeBoxObject::GetCoordsForCellItem(JSContext* cx,
}
NS_IMETHODIMP
TreeBoxObject::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *aIsCropped)
TreeBoxObject::IsCellCropped(int32_t aRow, nsTreeColumn* aCol, bool *aIsCropped)
{
*aIsCropped = false;
nsTreeBodyFrame* body = GetTreeBodyFrame();
@ -609,7 +553,7 @@ TreeBoxObject::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *aIsCropped
}
bool
TreeBoxObject::IsCellCropped(int32_t row, nsITreeColumn* col, ErrorResult& aRv)
TreeBoxObject::IsCellCropped(int32_t row, nsTreeColumn* col, ErrorResult& aRv)
{
bool ret;
aRv = IsCellCropped(row, col, &ret);
@ -652,22 +596,17 @@ TreeBoxObject::ClearStyleAndImageCaches()
return NS_OK;
}
NS_IMETHODIMP
TreeBoxObject::RemoveImageCacheEntry(int32_t aRowIndex, nsITreeColumn* aCol)
void
TreeBoxObject::RemoveImageCacheEntry(int32_t aRowIndex, nsTreeColumn& aCol, ErrorResult& aRv)
{
NS_ENSURE_ARG(aCol);
NS_ENSURE_TRUE(aRowIndex >= 0, NS_ERROR_INVALID_ARG);
if (NS_WARN_IF(aRowIndex < 0)) {
aRv.Throw(NS_ERROR_INVALID_ARG);
return;
}
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) {
return body->RemoveImageCacheEntry(aRowIndex, aCol);
body->RemoveImageCacheEntry(aRowIndex, &aCol);
}
return NS_OK;
}
void
TreeBoxObject::RemoveImageCacheEntry(int32_t row, nsITreeColumn& col, ErrorResult& aRv)
{
aRv = RemoveImageCacheEntry(row, &col);
}
void

View File

@ -61,6 +61,14 @@ public:
already_AddRefed<nsIScriptableRegion> SelectionRegion();
void EnsureCellIsVisible(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
void ScrollToRow(int32_t aRow);
void ScrollByLines(int32_t aNumLines);
void ScrollByPages(int32_t aNumPages);
int32_t GetFirstVisibleRow();
int32_t GetLastVisibleRow();
@ -76,9 +84,9 @@ public:
const nsAString& element,
ErrorResult& aRv);
bool IsCellCropped(int32_t row, nsITreeColumn* col, ErrorResult& aRv);
bool IsCellCropped(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
void RemoveImageCacheEntry(int32_t row, nsITreeColumn& col, ErrorResult& aRv);
void RemoveImageCacheEntry(int32_t row, nsTreeColumn& col, ErrorResult& aRv);
// Deprecated APIs from old IDL
void GetCellAt(JSContext* cx,
@ -105,18 +113,10 @@ public:
// void ClearStyleAndImageCaches();
// void SetFocused(bool arg);
// void EnsureRowIsVisible(int32_t index);
// void EnsureCellIsVisible(int32_t row, nsITreeColumn* col);
// void ScrollToRow(int32_t index);
// void ScrollByLines(int32_t numLines);
// void ScrollByPages(int32_t numPages);
// void ScrollToCell(int32_t row, nsITreeColumn* col);
// void ScrollToColumn(nsITreeColumn* col);
// void ScrollToHorizontalPosition(int32_t horizontalPosition);
// void InvalidateColumn(nsITreeColumn* col);
// void InvalidateColumn(nsTreeColumn* col);
// void InvalidateRow(int32_t index);
// void InvalidateCell(int32_t row, nsITreeColumn* col);
// void InvalidateCell(int32_t row, nsTreeColumn* col);
// void InvalidateRange(int32_t startIndex, int32_t endIndex);
// void InvalidateColumnRange(int32_t startIndex, int32_t endIndex, nsITreeColumn* col);
// void RowCountChanged(int32_t index, int32_t count);
protected:

View File

@ -9,7 +9,6 @@ with Files('**'):
XPIDL_SOURCES += [
'nsITreeBoxObject.idl',
'nsITreeColumns.idl',
'nsITreeSelection.idl',
'nsITreeView.idl',
]

View File

@ -7,10 +7,10 @@
interface nsITreeView;
interface nsITreeSelection;
interface nsITreeColumn;
interface nsIScriptableRegion;
webidl Element;
webidl TreeColumn;
webidl TreeColumns;
/**
@ -51,16 +51,6 @@ interface nsITreeBoxObject : nsISupports
*/
readonly attribute long rowWidth;
/**
* Get the pixel position of the horizontal scrollbar.
*/
readonly attribute long horizontalPosition;
/**
* Return the region for the visible parts of the selection, in device pixels.
*/
readonly attribute nsIScriptableRegion selectionRegion;
/**
* Get the index of the first visible row.
*/
@ -71,77 +61,19 @@ interface nsITreeBoxObject : nsISupports
*/
long getLastVisibleRow();
/**
* Gets the number of possible visible rows.
*/
long getPageLength();
/**
* Ensures that a row at a given index is visible.
*/
void ensureRowIsVisible(in long index);
/**
* Ensures that a given cell in the tree is visible.
*/
void ensureCellIsVisible(in long row, in nsITreeColumn col);
/**
* Scrolls such that the row at index is at the top of the visible view.
*/
void scrollToRow(in long index);
/**
* Scroll the tree up or down by numLines lines. Positive
* values move down in the tree. Prevents scrolling off the
* end of the tree.
*/
void scrollByLines(in long numLines);
/**
* Scroll the tree up or down by numPages pages. A page
* is considered to be the amount displayed by the tree.
* Positive values move down in the tree. Prevents scrolling
* off the end of the tree.
*/
void scrollByPages(in long numPages);
/**
* Scrolls such that a given cell is visible (if possible)
* at the top left corner of the visible view.
*/
void scrollToCell(in long row, in nsITreeColumn col);
/**
* Scrolls horizontally so that the specified column is
* at the left of the view (if possible).
*/
void scrollToColumn(in nsITreeColumn col);
/**
* Scroll to a specific horizontal pixel position.
*/
void scrollToHorizontalPosition(in long horizontalPosition);
/**
* Invalidation methods for fine-grained painting control.
*/
void invalidate();
void invalidateColumn(in nsITreeColumn col);
void invalidateColumn(in TreeColumn col);
void invalidateRow(in long index);
void invalidateCell(in long row, in nsITreeColumn col);
void invalidateCell(in long row, in TreeColumn col);
void invalidateRange(in long startIndex, in long endIndex);
void invalidateColumnRange(in long startIndex, in long endIndex,
in nsITreeColumn col);
/**
* A hit test that can tell you what row the mouse is over.
* returns -1 for invalid mouse coordinates.
*
* The coordinate system is the client coordinate system for the
* document this boxObject lives in, and the units are CSS pixels.
*/
long getRowAt(in long x, in long y);
/**
* A hit test that can tell you what cell the mouse is over. Row is the row index
@ -152,18 +84,18 @@ interface nsITreeBoxObject : nsISupports
* The coordinate system is the client coordinate system for the
* document this boxObject lives in, and the units are CSS pixels.
*/
void getCellAt(in long x, in long y, out long row, out nsITreeColumn col, out AString childElt);
void getCellAt(in long x, in long y, out long row, out TreeColumn col, out AString childElt);
/**
* Find the coordinates of an element within a specific cell.
*/
void getCoordsForCellItem(in long row, in nsITreeColumn col, in AString element,
void getCoordsForCellItem(in long row, in TreeColumn col, in AString element,
out long x, out long y, out long width, out long height);
/**
* Determine if the text of a cell is being cropped or not.
*/
boolean isCellCropped(in long row, in nsITreeColumn col);
boolean isCellCropped(in long row, in TreeColumn col);
/**
* The view is responsible for calling these notification methods when
@ -190,12 +122,4 @@ interface nsITreeBoxObject : nsISupports
* Called on a theme switch to flush out the tree's style and image caches.
*/
void clearStyleAndImageCaches();
/**
* Remove an image source from the image cache to allow its invalidation.
*
* @note This only affects images supplied by the view, not the ones supplied
* through the styling context, like twisties or checkboxes.
*/
void removeImageCacheEntry(in long row, in nsITreeColumn col);
};

View File

@ -1,39 +0,0 @@
/* 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;
webidl TreeColumns;
[scriptable, uuid(ae835ecf-6b32-4660-9b43-8a270df56e02)]
interface nsITreeColumn : nsISupports
{
readonly attribute Element element;
readonly attribute TreeColumns columns;
readonly attribute long x;
readonly attribute long width;
readonly attribute AString id;
[noscript] void getIdConst([shared] out wstring idConst);
readonly attribute long index;
readonly attribute boolean primary;
readonly attribute boolean cycler;
readonly attribute boolean editable;
readonly attribute boolean selectable;
const short TYPE_TEXT = 1;
const short TYPE_CHECKBOX = 2;
const short TYPE_PASSWORD = 3;
readonly attribute short type;
nsITreeColumn getNext();
nsITreeColumn getPrevious();
void invalidate();
};

View File

@ -4,7 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface nsITreeBoxObject;
interface nsITreeColumn;
webidl TreeColumn;
#include "nsISupports.idl"
@ -109,7 +110,7 @@ interface nsITreeSelection : nsISupports
/**
* The current column.
*/
attribute nsITreeColumn currentColumn;
attribute TreeColumn currentColumn;
/**
* The selection "pivot". This is the first item the user selected as

View File

@ -7,9 +7,9 @@
interface nsITreeBoxObject;
interface nsITreeSelection;
interface nsITreeColumn;
webidl DataTransfer;
webidl TreeColumn;
[scriptable, uuid(091116f0-0bdc-4b32-b9c8-c8d5a37cb088)]
interface nsITreeView : nsISupports
@ -40,13 +40,13 @@ interface nsITreeView : nsISupports
* ::-moz-tree-image(x), ::-moz-tree-cell-text(x). to be matched on the
* cell.
*/
AString getCellProperties(in long row, in nsITreeColumn col);
AString getCellProperties(in long row, in TreeColumn col);
/**
* Called to get properties to paint a column background. For shading the sort
* column, etc.
*/
AString getColumnProperties(in nsITreeColumn col);
AString getColumnProperties(in TreeColumn col);
/**
* Methods that can be used to test whether or not a twisty should be drawn,
@ -113,19 +113,19 @@ interface nsITreeView : nsISupports
* If the empty string is returned, the :moz-tree-image pseudoelement
* will be used.
*/
AString getImageSrc(in long row, in nsITreeColumn col);
AString getImageSrc(in long row, in TreeColumn col);
/**
* The value for a given cell. This method is only called for columns
* of type other than |text|.
*/
AString getCellValue(in long row, in nsITreeColumn col);
AString getCellValue(in long row, in TreeColumn col);
/**
* The text for a given cell. If a column consists only of an image, then
* the empty string is returned.
*/
AString getCellText(in long row, in nsITreeColumn col);
AString getCellText(in long row, in TreeColumn col);
/**
* Called during initialization to link the view to the front end box object.
@ -140,7 +140,7 @@ interface nsITreeView : nsISupports
/**
* Called on the view when a header is clicked.
*/
void cycleHeader(in nsITreeColumn col);
void cycleHeader(in TreeColumn col);
/**
* Should be called from a XUL onselect handler whenever the selection changes.
@ -150,32 +150,32 @@ interface nsITreeView : nsISupports
/**
* Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
*/
void cycleCell(in long row, in nsITreeColumn col);
void cycleCell(in long row, in TreeColumn col);
/**
* isEditable is called to ask the view if the cell contents are editable.
* A value of true will result in the tree popping up a text field when
* the user tries to inline edit the cell.
*/
boolean isEditable(in long row, in nsITreeColumn col);
boolean isEditable(in long row, in TreeColumn col);
/**
* isSelectable is called to ask the view if the cell is selectable.
* This method is only called if the selection style is |cell| or |text|.
* XXXvarga shouldn't this be called isCellSelectable?
*/
boolean isSelectable(in long row, in nsITreeColumn col);
boolean isSelectable(in long row, in TreeColumn col);
/**
* setCellValue is called when the value of the cell has been set by the user.
* This method is only called for columns of type other than |text|.
*/
void setCellValue(in long row, in nsITreeColumn col, in AString value);
void setCellValue(in long row, in TreeColumn col, in AString value);
/**
* setCellText is called when the contents of the cell have been edited by the user.
*/
void setCellText(in long row, in nsITreeColumn col, in AString value);
void setCellText(in long row, in TreeColumn col, in AString value);
/**
* A command API that can be used to invoke commands on the selection. The tree
@ -192,5 +192,5 @@ interface nsITreeView : nsISupports
/**
* A command API that can be used to invoke commands on a specific cell.
*/
void performActionOnCell(in wstring action, in long row, in nsITreeColumn col);
void performActionOnCell(in wstring action, in long row, in TreeColumn col);
};

View File

@ -62,6 +62,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/TreeBoxObject.h"
#include "mozilla/dom/TreeColumnBinding.h"
#include "nsIScriptableRegion.h"
#include <algorithm>
#include "ScrollbarActivity.h"
@ -590,6 +591,8 @@ nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion)
mView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_TRUE(selection, NS_OK);
// XXXbz should we just construct as |new ScriptableRegion()|
// instead, and make this method return void?
nsCOMPtr<nsIScriptableRegion> region = do_CreateInstance("@mozilla.org/gfx/region;1");
NS_ENSURE_TRUE(region, NS_ERROR_FAILURE);
region->Init();
@ -634,13 +637,12 @@ nsTreeBodyFrame::Invalidate()
}
nsresult
nsTreeBodyFrame::InvalidateColumn(nsITreeColumn* aCol)
nsTreeBodyFrame::InvalidateColumn(nsTreeColumn* aCol)
{
if (mUpdateBatchNest)
return NS_OK;
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
if (!aCol)
return NS_ERROR_INVALID_ARG;
#ifdef ACCESSIBILITY
@ -649,7 +651,7 @@ nsTreeBodyFrame::InvalidateColumn(nsITreeColumn* aCol)
#endif
nsRect columnRect;
nsresult rv = col->GetRect(this, mInnerBox.y, mInnerBox.height, &columnRect);
nsresult rv = aCol->GetRect(this, mInnerBox.y, mInnerBox.height, &columnRect);
NS_ENSURE_SUCCESS(rv, rv);
// When false then column is out of view
@ -681,7 +683,7 @@ nsTreeBodyFrame::InvalidateRow(int32_t aIndex)
}
nsresult
nsTreeBodyFrame::InvalidateCell(int32_t aIndex, nsITreeColumn* aCol)
nsTreeBodyFrame::InvalidateCell(int32_t aIndex, nsTreeColumn* aCol)
{
if (mUpdateBatchNest)
return NS_OK;
@ -695,13 +697,12 @@ nsTreeBodyFrame::InvalidateCell(int32_t aIndex, nsITreeColumn* aCol)
if (aIndex < 0 || aIndex > mPageLength)
return NS_OK;
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
if (!aCol)
return NS_ERROR_INVALID_ARG;
nsRect cellRect;
nsresult rv = col->GetRect(this, mInnerBox.y+mRowHeight*aIndex, mRowHeight,
&cellRect);
nsresult rv = aCol->GetRect(this, mInnerBox.y+mRowHeight*aIndex, mRowHeight,
&cellRect);
NS_ENSURE_SUCCESS(rv, rv);
if (OffsetForHorzScroll(cellRect, true))
@ -743,49 +744,6 @@ nsTreeBodyFrame::InvalidateRange(int32_t aStart, int32_t aEnd)
return NS_OK;
}
nsresult
nsTreeBodyFrame::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn* aCol)
{
if (mUpdateBatchNest)
return NS_OK;
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
if (aStart == aEnd)
return InvalidateCell(aStart, col);
int32_t last = LastVisibleRow();
if (aStart > aEnd || aEnd < mTopRowIndex || aStart > last)
return NS_OK;
if (aStart < mTopRowIndex)
aStart = mTopRowIndex;
if (aEnd > last)
aEnd = last;
#ifdef ACCESSIBILITY
if (nsIPresShell::IsAccessibilityActive()) {
int32_t end =
mRowCount > 0 ? ((mRowCount <= aEnd) ? mRowCount - 1 : aEnd) : 0;
FireInvalidateEvent(aStart, end, aCol, aCol);
}
#endif
nsRect rangeRect;
nsresult rv = col->GetRect(this,
mInnerBox.y+mRowHeight*(aStart-mTopRowIndex),
mRowHeight*(aEnd-aStart+1),
&rangeRect);
NS_ENSURE_SUCCESS(rv, rv);
InvalidateFrameWithRect(rangeRect);
return NS_OK;
}
static void
FindScrollParts(nsIFrame* aCurrFrame, nsTreeBodyFrame::ScrollParts* aResult)
{
@ -1021,28 +979,26 @@ nsTreeBodyFrame::AdjustClientCoordsToBoxCoordSpace(int32_t aX, int32_t aY)
return point;
} // AdjustClientCoordsToBoxCoordSpace
nsresult
nsTreeBodyFrame::GetRowAt(int32_t aX, int32_t aY, int32_t* _retval)
int32_t
nsTreeBodyFrame::GetRowAt(int32_t aX, int32_t aY)
{
if (!mView)
return NS_OK;
if (!mView) {
return 0;
}
nsPoint point = AdjustClientCoordsToBoxCoordSpace(aX, aY);
// Check if the coordinates are above our visible space.
if (point.y < 0) {
*_retval = -1;
return NS_OK;
return -1;
}
*_retval = GetRowAt(point.x, point.y);
return NS_OK;
return GetRowAtInternal(point.x, point.y);
}
nsresult
nsTreeBodyFrame::GetCellAt(int32_t aX, int32_t aY, int32_t* aRow, nsITreeColumn** aCol,
nsACString& aChildElt)
nsTreeBodyFrame::GetCellAt(int32_t aX, int32_t aY, int32_t* aRow,
nsTreeColumn** aCol, nsACString& aChildElt)
{
if (!mView)
return NS_OK;
@ -1097,7 +1053,7 @@ nsTreeBodyFrame::GetCellAt(int32_t aX, int32_t aY, int32_t* aRow, nsITreeColumn*
// You need to make sure to add in the image's margins as well.
//
nsresult
nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsACString& aElement,
nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol, const nsACString& aElement,
int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight)
{
*aX = 0;
@ -1285,7 +1241,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n
}
int32_t
nsTreeBodyFrame::GetRowAt(int32_t aX, int32_t aY)
nsTreeBodyFrame::GetRowAtInternal(nscoord aX, nscoord aY)
{
if (mRowHeight <= 0)
return -1;
@ -1642,7 +1598,7 @@ nsTreeBodyFrame::GetCellAt(nscoord aX, nscoord aY, int32_t* aRow,
*aCol = nullptr;
*aChildElt = nullptr;
*aRow = GetRowAt(aX, aY);
*aRow = GetRowAtInternal(aX, aY);
if (*aRow < 0)
return;
@ -1763,19 +1719,18 @@ nsTreeBodyFrame::GetCellWidth(int32_t aRow, nsTreeColumn* aCol,
}
nsresult
nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *_retval)
nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsTreeColumn* aCol, bool *_retval)
{
nscoord currentSize, desiredSize;
nsresult rv;
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
if (!aCol)
return NS_ERROR_INVALID_ARG;
RefPtr<gfxContext> rc =
PresShell()->CreateReferenceRenderingContext();
rv = GetCellWidth(aRow, col, rc, desiredSize, currentSize);
rv = GetCellWidth(aRow, aCol, rc, desiredSize, currentSize);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = desiredSize > currentSize;
@ -1964,7 +1919,7 @@ nsTreeBodyFrame::PrefillPropertyArray(int32_t aRowIndex, nsTreeColumn* aCol)
// active
if (aCol) {
nsCOMPtr<nsITreeColumn> currentColumn;
RefPtr<nsTreeColumn> currentColumn;
selection->GetCurrentColumn(getter_AddRefs(currentColumn));
if (aCol == currentColumn)
mScratchArray.AppendElement(nsGkAtoms::active);
@ -2020,7 +1975,7 @@ nsTreeBodyFrame::PrefillPropertyArray(int32_t aRowIndex, nsTreeColumn* aCol)
if (aCol->IsPrimary())
mScratchArray.AppendElement(nsGkAtoms::primary);
if (aCol->GetType() == nsITreeColumn::TYPE_CHECKBOX) {
if (aCol->GetType() == TreeColumnBinding::TYPE_CHECKBOX) {
mScratchArray.AppendElement(nsGkAtoms::checkbox);
if (aRowIndex != -1) {
@ -2559,7 +2514,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext,
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
int32_t xTwips = pt.x - mInnerBox.x;
int32_t yTwips = pt.y - mInnerBox.y;
int32_t newrow = GetRowAt(xTwips, yTwips);
int32_t newrow = GetRowAtInternal(xTwips, yTwips);
if (mMouseOverRow != newrow) {
// redraw the old and the new row
if (mMouseOverRow != -1)
@ -3391,12 +3346,12 @@ nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
nsRect dirtyRect;
if (dirtyRect.IntersectRect(aDirtyRect, elementRect)) {
switch (aColumn->GetType()) {
case nsITreeColumn::TYPE_TEXT:
case nsITreeColumn::TYPE_PASSWORD:
case TreeColumnBinding::TYPE_TEXT:
case TreeColumnBinding::TYPE_PASSWORD:
result &= PaintText(aRowIndex, aColumn, elementRect, aPresContext,
aRenderingContext, aDirtyRect, currX);
break;
case nsITreeColumn::TYPE_CHECKBOX:
case TreeColumnBinding::TYPE_CHECKBOX:
result &= PaintCheckbox(aRowIndex, aColumn, elementRect, aPresContext,
aRenderingContext, aDirtyRect);
break;
@ -3709,7 +3664,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
nsAutoString text;
mView->GetCellText(aRowIndex, aColumn, text);
if (aColumn->Type() == nsITreeColumn::TYPE_PASSWORD) {
if (aColumn->Type() == TreeColumnBinding::TYPE_PASSWORD) {
TextEditRules::FillBufWithPWChars(&text, text.Length());
}
@ -4065,10 +4020,9 @@ nsresult nsTreeBodyFrame::EnsureRowIsVisibleInternal(const ScrollParts& aParts,
}
nsresult
nsTreeBodyFrame::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
nsTreeBodyFrame::EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol)
{
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
if (!aCol)
return NS_ERROR_INVALID_ARG;
ScrollParts parts = GetScrollParts();
@ -4077,11 +4031,11 @@ nsTreeBodyFrame::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
nsresult rv;
nscoord columnPos;
rv = col->GetXInTwips(this, &columnPos);
rv = aCol->GetXInTwips(this, &columnPos);
if(NS_FAILED(rv)) return rv;
nscoord columnWidth;
rv = col->GetWidthInTwips(this, &columnWidth);
rv = aCol->GetWidthInTwips(this, &columnWidth);
if(NS_FAILED(rv)) return rv;
// If the start of the column is before the
@ -4104,63 +4058,12 @@ nsTreeBodyFrame::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
return rv;
}
nsresult
nsTreeBodyFrame::ScrollToCell(int32_t aRow, nsITreeColumn* aCol)
{
ScrollParts parts = GetScrollParts();
nsresult rv = ScrollToRowInternal(parts, aRow);
NS_ENSURE_SUCCESS(rv, rv);
rv = ScrollToColumnInternal(parts, aCol);
NS_ENSURE_SUCCESS(rv, rv);
UpdateScrollbars(parts);
return rv;
}
nsresult
nsTreeBodyFrame::ScrollToColumn(nsITreeColumn* aCol)
{
ScrollParts parts = GetScrollParts();
nsresult rv = ScrollToColumnInternal(parts, aCol);
NS_ENSURE_SUCCESS(rv, rv);
UpdateScrollbars(parts);
return rv;
}
nsresult nsTreeBodyFrame::ScrollToColumnInternal(const ScrollParts& aParts,
nsITreeColumn* aCol)
{
RefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
nscoord x;
nsresult rv = col->GetXInTwips(this, &x);
if (NS_FAILED(rv))
return rv;
return ScrollHorzInternal(aParts, x);
}
nsresult
nsTreeBodyFrame::ScrollToHorizontalPosition(int32_t aHorizontalPosition)
{
ScrollParts parts = GetScrollParts();
int32_t position = nsPresContext::CSSPixelsToAppUnits(aHorizontalPosition);
nsresult rv = ScrollHorzInternal(parts, position);
NS_ENSURE_SUCCESS(rv, rv);
UpdateScrollbars(parts);
return rv;
}
nsresult
void
nsTreeBodyFrame::ScrollToRow(int32_t aRow)
{
ScrollParts parts = GetScrollParts();
ScrollToRowInternal(parts, aRow);
UpdateScrollbars(parts);
return NS_OK;
}
nsresult nsTreeBodyFrame::ScrollToRowInternal(const ScrollParts& aParts, int32_t aRow)
@ -4170,26 +4073,24 @@ nsresult nsTreeBodyFrame::ScrollToRowInternal(const ScrollParts& aParts, int32_t
return NS_OK;
}
nsresult
void
nsTreeBodyFrame::ScrollByLines(int32_t aNumLines)
{
if (!mView) {
return NS_OK;
return;
}
int32_t newIndex = mTopRowIndex + aNumLines;
ScrollToRow(newIndex);
return NS_OK;
}
nsresult
void
nsTreeBodyFrame::ScrollByPages(int32_t aNumPages)
{
if (!mView) {
return NS_OK;
return;
}
int32_t newIndex = mTopRowIndex + aNumPages * mPageLength;
ScrollToRow(newIndex);
return NS_OK;
}
nsresult
@ -4372,8 +4273,8 @@ nsTreeBodyFrame::ClearStyleAndImageCaches()
return NS_OK;
}
nsresult
nsTreeBodyFrame::RemoveImageCacheEntry(int32_t aRowIndex, nsITreeColumn* aCol)
void
nsTreeBodyFrame::RemoveImageCacheEntry(int32_t aRowIndex, nsTreeColumn* aCol)
{
nsAutoString imageSrc;
if (NS_SUCCEEDED(mView->GetImageSrc(aRowIndex, aCol, imageSrc))) {
@ -4385,7 +4286,6 @@ nsTreeBodyFrame::RemoveImageCacheEntry(int32_t aRowIndex, nsITreeColumn* aCol)
mImageCache.Remove(imageSrc);
}
}
return NS_OK;
}
/* virtual */ void
@ -4470,7 +4370,7 @@ nsTreeBodyFrame::ComputeDropPosition(WidgetGUIEvent* aEvent,
int32_t xTwips = pt.x - mInnerBox.x;
int32_t yTwips = pt.y - mInnerBox.y;
*aRow = GetRowAt(xTwips, yTwips);
*aRow = GetRowAtInternal(xTwips, yTwips);
if (*aRow >=0) {
// Compute the top/bottom of the row in question.
int32_t yOffset = yTwips - mRowHeight * (*aRow - mTopRowIndex);
@ -4713,8 +4613,8 @@ nsTreeBodyFrame::FireRowCountChangedEvent(int32_t aIndex, int32_t aCount)
void
nsTreeBodyFrame::FireInvalidateEvent(int32_t aStartRowIdx, int32_t aEndRowIdx,
nsITreeColumn *aStartCol,
nsITreeColumn *aEndCol)
nsTreeColumn *aStartCol,
nsTreeColumn *aEndCol)
{
nsCOMPtr<nsIContent> content(GetBaseElement());
if (!content)
@ -4748,20 +4648,13 @@ nsTreeBodyFrame::FireInvalidateEvent(int32_t aStartRowIdx, int32_t aEndRowIdx,
if (aStartCol && aEndCol) {
// Set 'startcolumn' data - the start index of invalidated rows.
int32_t startColIdx = 0;
nsresult rv = aStartCol->GetIndex(&startColIdx);
if (NS_FAILED(rv))
return;
int32_t startColIdx = aStartCol->GetIndex();
propBag->SetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"),
startColIdx);
// Set 'endcolumn' data - the start index of invalidated rows.
int32_t endColIdx = 0;
rv = aEndCol->GetIndex(&endColIdx);
if (NS_FAILED(rv))
return;
int32_t endColIdx = aEndCol->GetIndex();
propBag->SetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"),
endColIdx);
}

View File

@ -91,33 +91,28 @@ public:
int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; }
int32_t PageLength() const { return mPageLength; }
nsresult EnsureRowIsVisible(int32_t aRow);
nsresult EnsureCellIsVisible(int32_t aRow, nsITreeColumn *aCol);
nsresult ScrollToRow(int32_t aRow);
nsresult ScrollByLines(int32_t aNumLines);
nsresult ScrollByPages(int32_t aNumPages);
nsresult ScrollToCell(int32_t aRow, nsITreeColumn *aCol);
nsresult ScrollToColumn(nsITreeColumn *aCol);
nsresult ScrollToHorizontalPosition(int32_t aValue);
nsresult EnsureCellIsVisible(int32_t aRow, nsTreeColumn *aCol);
void ScrollToRow(int32_t aRow);
void ScrollByLines(int32_t aNumLines);
void ScrollByPages(int32_t aNumPages);
nsresult Invalidate();
nsresult InvalidateColumn(nsITreeColumn *aCol);
nsresult InvalidateColumn(nsTreeColumn *aCol);
nsresult InvalidateRow(int32_t aRow);
nsresult InvalidateCell(int32_t aRow, nsITreeColumn *aCol);
nsresult InvalidateCell(int32_t aRow, nsTreeColumn *aCol);
nsresult InvalidateRange(int32_t aStart, int32_t aEnd);
nsresult InvalidateColumnRange(int32_t aStart, int32_t aEnd,
nsITreeColumn *aCol);
nsresult GetRowAt(int32_t aX, int32_t aY, int32_t *aValue);
int32_t GetRowAt(int32_t aX, int32_t aY);
nsresult GetCellAt(int32_t aX, int32_t aY, int32_t *aRow,
nsITreeColumn **aCol, nsACString &aChildElt);
nsresult GetCoordsForCellItem(int32_t aRow, nsITreeColumn *aCol,
nsTreeColumn **aCol, nsACString &aChildElt);
nsresult GetCoordsForCellItem(int32_t aRow, nsTreeColumn *aCol,
const nsACString &aElt,
int32_t *aX, int32_t *aY,
int32_t *aWidth, int32_t *aHeight);
nsresult IsCellCropped(int32_t aRow, nsITreeColumn *aCol, bool *aResult);
nsresult IsCellCropped(int32_t aRow, nsTreeColumn *aCol, bool *aResult);
nsresult RowCountChanged(int32_t aIndex, int32_t aCount);
nsresult BeginUpdateBatch();
nsresult EndUpdateBatch();
nsresult ClearStyleAndImageCaches();
nsresult RemoveImageCacheEntry(int32_t aRowIndex, nsITreeColumn* aCol);
void RemoveImageCacheEntry(int32_t aRowIndex, nsTreeColumn* aCol);
void CancelImageRequests();
@ -295,7 +290,7 @@ protected:
// An internal hit test. aX and aY are expected to be in twips in the
// coordinate system of this frame.
int32_t GetRowAt(nscoord aX, nscoord aY);
int32_t GetRowAtInternal(nscoord aX, nscoord aY);
// Check for bidi characters in the text, and if there are any, ensure
// that the prescontext is in bidi mode.
@ -385,7 +380,6 @@ protected:
// Our internal scroll method, used by all the public scroll methods.
nsresult ScrollInternal(const ScrollParts& aParts, int32_t aRow);
nsresult ScrollToRowInternal(const ScrollParts& aParts, int32_t aRow);
nsresult ScrollToColumnInternal(const ScrollParts& aParts, nsITreeColumn* aCol);
nsresult ScrollHorzInternal(const ScrollParts& aParts, int32_t aPosition);
nsresult EnsureRowIsVisibleInternal(const ScrollParts& aParts, int32_t aRow);
@ -430,15 +424,6 @@ protected:
}
public:
static
already_AddRefed<nsTreeColumn> GetColumnImpl(nsITreeColumn* aUnknownCol) {
if (!aUnknownCol)
return nullptr;
nsCOMPtr<nsTreeColumn> col = do_QueryInterface(aUnknownCol);
return col.forget();
}
/**
* Remove an nsITreeImageListener from being tracked by this frame. Only tree
* image listeners that are created by this frame are tracked.
@ -515,7 +500,7 @@ protected:
* been invalidated only
*/
void FireInvalidateEvent(int32_t aStartRow, int32_t aEndRow,
nsITreeColumn *aStartCol, nsITreeColumn *aEndCol);
nsTreeColumn *aStartCol, nsTreeColumn *aEndCol);
#endif
protected: // Data Members

View File

@ -30,7 +30,7 @@ nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, dom::Element* aElement)
kNameSpaceID_XUL),
"nsTreeColumn's content must be a <xul:treecol>");
Invalidate();
Invalidate(IgnoreErrors());
}
nsTreeColumn::~nsTreeColumn()
@ -62,7 +62,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeColumn)
// QueryInterface implementation for nsTreeColumn
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumn)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsITreeColumn)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_CONCRETE(nsTreeColumn)
NS_INTERFACE_MAP_END
@ -70,8 +69,6 @@ NS_INTERFACE_MAP_END
nsIFrame*
nsTreeColumn::GetFrame()
{
NS_ENSURE_TRUE(mContent, nullptr);
return mContent->GetPrimaryFrame();
}
@ -144,120 +141,20 @@ nsTreeColumn::GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult)
}
NS_IMETHODIMP
nsTreeColumn::GetElement(Element** aElement)
{
if (mContent) {
RefPtr<dom::Element> element = mContent;
element.forget(aElement);
return NS_OK;
}
*aElement = nullptr;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsTreeColumn::GetColumns(nsTreeColumns** aColumns)
{
NS_IF_ADDREF(*aColumns = mColumns);
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetX(int32_t* aX)
{
nsIFrame* frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
*aX = nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().x);
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetWidth(int32_t* aWidth)
{
nsIFrame* frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().width);
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetId(nsAString& aId)
void
nsTreeColumn::GetId(nsAString& aId) const
{
aId = GetId();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetIdConst(const char16_t** aIdConst)
{
*aIdConst = mId.get();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetIndex(int32_t* aIndex)
{
*aIndex = GetIndex();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetPrimary(bool* aPrimary)
{
*aPrimary = IsPrimary();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetCycler(bool* aCycler)
{
*aCycler = IsCycler();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetEditable(bool* aEditable)
{
*aEditable = IsEditable();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetSelectable(bool* aSelectable)
{
*aSelectable = IsSelectable();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetType(int16_t* aType)
{
*aType = GetType();
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetNext(nsITreeColumn** _retval)
{
NS_IF_ADDREF(*_retval = GetNext());
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::GetPrevious(nsITreeColumn** _retval)
{
NS_IF_ADDREF(*_retval = GetPrevious());
return NS_OK;
}
NS_IMETHODIMP
nsTreeColumn::Invalidate()
void
nsTreeColumn::Invalidate(ErrorResult& aRv)
{
nsIFrame* frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
if (NS_WARN_IF(!frame)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
// Fetch the Id.
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, mId);
@ -313,7 +210,7 @@ nsTreeColumn::Invalidate()
nsGkAtoms::_true, eCaseMatters);
// Figure out our column type. Default type is text.
mType = nsITreeColumn::TYPE_TEXT;
mType = TreeColumnBinding::TYPE_TEXT;
static Element::AttrValuesArray typestrings[] =
{&nsGkAtoms::checkbox, &nsGkAtoms::password,
nullptr};
@ -321,8 +218,8 @@ nsTreeColumn::Invalidate()
nsGkAtoms::type,
typestrings,
eCaseMatters)) {
case 0: mType = nsITreeColumn::TYPE_CHECKBOX; break;
case 1: mType = nsITreeColumn::TYPE_PASSWORD; break;
case 0: mType = TreeColumnBinding::TYPE_CHECKBOX; break;
case 1: mType = TreeColumnBinding::TYPE_PASSWORD; break;
}
// Fetch the crop style.
@ -340,8 +237,6 @@ nsTreeColumn::Invalidate()
mCropStyle = 2;
break;
}
return NS_OK;
}
nsIContent*
@ -356,37 +251,34 @@ nsTreeColumn::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return dom::TreeColumnBinding::Wrap(aCx, this, aGivenProto);
}
mozilla::dom::Element*
nsTreeColumn::GetElement(mozilla::ErrorResult& aRv)
Element*
nsTreeColumn::Element()
{
RefPtr<Element> element;
aRv = GetElement(getter_AddRefs(element));
if (aRv.Failed()) {
return nullptr;
}
return element;
return mContent;
}
int32_t
nsTreeColumn::GetX(mozilla::ErrorResult& aRv)
{
int32_t x;
aRv = GetX(&x);
return x;
nsIFrame* frame = GetFrame();
if (NS_WARN_IF(!frame)) {
aRv.Throw(NS_ERROR_FAILURE);
return 0;
}
return nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().x);
}
int32_t
nsTreeColumn::GetWidth(mozilla::ErrorResult& aRv)
{
int32_t width;
aRv = GetWidth(&width);
return width;
}
nsIFrame* frame = GetFrame();
if (NS_WARN_IF(!frame)) {
aRv.Throw(NS_ERROR_FAILURE);
return 0;
}
void
nsTreeColumn::Invalidate(mozilla::ErrorResult& aRv)
{
aRv = Invalidate();
return nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().width);
}
nsTreeColumns::nsTreeColumns(nsTreeBodyFrame* aTree)
@ -459,8 +351,7 @@ nsTreeColumns::GetSortedColumn()
{
EnsureColumns();
for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
if (currCol->mContent &&
nsContentUtils::HasNonEmptyAttr(currCol->mContent, kNameSpaceID_None,
if (nsContentUtils::HasNonEmptyAttr(currCol->mContent, kNameSpaceID_None,
nsGkAtoms::sortDirection)) {
return currCol;
}
@ -479,15 +370,14 @@ nsTreeColumns::GetKeyColumn()
for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
// Skip hidden columns.
if (!currCol->mContent ||
currCol->mContent->AttrValueIs(kNameSpaceID_None,
if (currCol->mContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::hidden,
nsGkAtoms::_true,
eCaseMatters))
continue;
// Skip non-text column
if (currCol->GetType() != nsITreeColumn::TYPE_TEXT)
if (currCol->GetType() != TreeColumnBinding::TYPE_TEXT)
continue;
if (!first)

View File

@ -7,7 +7,6 @@
#ifndef nsTreeColumns_h__
#define nsTreeColumns_h__
#include "nsITreeColumns.h"
#include "nsITreeBoxObject.h"
#include "mozilla/Attributes.h"
#include "mozilla/RefPtr.h"
@ -42,7 +41,7 @@ class TreeBoxObject;
// This class is our column info. We use it to iterate our columns and to obtain
// information about each column.
class nsTreeColumn final : public nsITreeColumn
class nsTreeColumn final : public nsISupports
, public nsWrapperCache
{
public:
@ -50,28 +49,21 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID)
static already_AddRefed<nsTreeColumn> From(nsITreeColumn* aColumn)
{
RefPtr<nsTreeColumn> col = do_QueryObject(aColumn);
return col.forget();
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumn)
NS_DECL_NSITREECOLUMN
// WebIDL
nsIContent* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
mozilla::dom::Element* GetElement(mozilla::ErrorResult& aRv);
mozilla::dom::Element* Element();
nsTreeColumns* GetColumns() const { return mColumns; }
int32_t GetX(mozilla::ErrorResult& aRv);
int32_t GetWidth(mozilla::ErrorResult& aRv);
// GetId is fine
void GetId(nsAString& aId) const;
int32_t Index() const { return mIndex; }
bool Primary() const { return mIsPrimary; }
@ -107,9 +99,8 @@ protected:
void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; }
const nsAString& GetId() { return mId; }
public:
const nsAString& GetId() const { return mId; }
nsAtom* GetAtom() { return mAtom; }
int32_t GetIndex() { return mIndex; }

View File

@ -233,14 +233,13 @@ nsTreeContentView::GetCellProperties(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::GetCellProperties(int32_t aRow, nsITreeColumn* aCol,
nsTreeContentView::GetCellProperties(int32_t aRow, nsTreeColumn* aCol,
nsAString& aProps)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
GetCellProperties(aRow, *col, aProps, rv);
GetCellProperties(aRow, *aCol, aProps, rv);
return rv.StealNSResult();
}
@ -248,7 +247,7 @@ void
nsTreeContentView::GetColumnProperties(nsTreeColumn& aColumn,
nsAString& aProperties)
{
RefPtr<Element> element = aColumn.GetElement(IgnoreErrors());
RefPtr<Element> element = aColumn.Element();
if (element) {
element->GetAttribute(NS_LITERAL_STRING("properties"), aProperties);
@ -256,12 +255,11 @@ nsTreeContentView::GetColumnProperties(nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::GetColumnProperties(nsITreeColumn* aCol, nsAString& aProps)
nsTreeContentView::GetColumnProperties(nsTreeColumn* aCol, nsAString& aProps)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
GetColumnProperties(*col, aProps);
GetColumnProperties(*aCol, aProps);
return NS_OK;
}
@ -498,13 +496,12 @@ nsTreeContentView::GetImageSrc(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::GetImageSrc(int32_t aRow, nsITreeColumn* aCol, nsAString& _retval)
nsTreeContentView::GetImageSrc(int32_t aRow, nsTreeColumn* aCol, nsAString& _retval)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
GetImageSrc(aRow, *col, _retval, rv);
GetImageSrc(aRow, *aCol, _retval, rv);
return rv.StealNSResult();
}
@ -529,13 +526,12 @@ nsTreeContentView::GetCellValue(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::GetCellValue(int32_t aRow, nsITreeColumn* aCol, nsAString& _retval)
nsTreeContentView::GetCellValue(int32_t aRow, nsTreeColumn* aCol, nsAString& _retval)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
GetCellValue(aRow, *col, _retval, rv);
GetCellValue(aRow, *aCol, _retval, rv);
return rv.StealNSResult();
}
@ -569,13 +565,12 @@ nsTreeContentView::GetCellText(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::GetCellText(int32_t aRow, nsITreeColumn* aCol, nsAString& _retval)
nsTreeContentView::GetCellText(int32_t aRow, nsTreeColumn* aCol, nsAString& _retval)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
GetCellText(aRow, *col, _retval, rv);
GetCellText(aRow, *aCol, _retval, rv);
return rv.StealNSResult();
}
@ -661,44 +656,40 @@ nsTreeContentView::CycleHeader(nsTreeColumn& aColumn, ErrorResult& aError)
if (!mRoot)
return;
RefPtr<Element> column;
aColumn.GetElement(getter_AddRefs(column));
if (column) {
nsAutoString sort;
column->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, sort);
if (!sort.IsEmpty()) {
nsCOMPtr<nsIXULSortService> xs = do_GetService("@mozilla.org/xul/xul-sort-service;1");
if (xs) {
nsAutoString sortdirection;
static Element::AttrValuesArray strings[] =
{&nsGkAtoms::ascending, &nsGkAtoms::descending, nullptr};
switch (column->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::sortDirection,
strings, eCaseMatters)) {
case 0: sortdirection.AssignLiteral("descending"); break;
case 1: sortdirection.AssignLiteral("natural"); break;
default: sortdirection.AssignLiteral("ascending"); break;
}
nsAutoString hints;
column->GetAttr(kNameSpaceID_None, nsGkAtoms::sorthints, hints);
sortdirection.Append(' ');
sortdirection += hints;
xs->Sort(mRoot, sort, sortdirection);
RefPtr<Element> column = aColumn.Element();
nsAutoString sort;
column->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, sort);
if (!sort.IsEmpty()) {
nsCOMPtr<nsIXULSortService> xs = do_GetService("@mozilla.org/xul/xul-sort-service;1");
if (xs) {
nsAutoString sortdirection;
static Element::AttrValuesArray strings[] =
{&nsGkAtoms::ascending, &nsGkAtoms::descending, nullptr};
switch (column->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::sortDirection,
strings, eCaseMatters)) {
case 0: sortdirection.AssignLiteral("descending"); break;
case 1: sortdirection.AssignLiteral("natural"); break;
default: sortdirection.AssignLiteral("ascending"); break;
}
nsAutoString hints;
column->GetAttr(kNameSpaceID_None, nsGkAtoms::sorthints, hints);
sortdirection.Append(' ');
sortdirection += hints;
xs->Sort(mRoot, sort, sortdirection);
}
}
}
NS_IMETHODIMP
nsTreeContentView::CycleHeader(nsITreeColumn* aCol)
nsTreeContentView::CycleHeader(nsTreeColumn* aCol)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
CycleHeader(*col, rv);
CycleHeader(*aCol, rv);
return rv.StealNSResult();
}
@ -709,7 +700,7 @@ nsTreeContentView::SelectionChanged()
}
NS_IMETHODIMP
nsTreeContentView::CycleCell(int32_t aRow, nsITreeColumn* aCol)
nsTreeContentView::CycleCell(int32_t aRow, nsTreeColumn* aCol)
{
return NS_OK;
}
@ -739,13 +730,12 @@ nsTreeContentView::IsEditable(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::IsEditable(int32_t aRow, nsITreeColumn* aCol, bool* _retval)
nsTreeContentView::IsEditable(int32_t aRow, nsTreeColumn* aCol, bool* _retval)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
*_retval = IsEditable(aRow, *col, rv);
*_retval = IsEditable(aRow, *aCol, rv);
return rv.StealNSResult();
}
@ -774,13 +764,12 @@ nsTreeContentView::IsSelectable(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::IsSelectable(int32_t aRow, nsITreeColumn* aCol, bool* _retval)
nsTreeContentView::IsSelectable(int32_t aRow, nsTreeColumn* aCol, bool* _retval)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
*_retval = IsSelectable(aRow, *col, rv);
*_retval = IsSelectable(aRow, *aCol, rv);
return rv.StealNSResult();
}
@ -805,13 +794,12 @@ nsTreeContentView::SetCellValue(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::SetCellValue(int32_t aRow, nsITreeColumn* aCol, const nsAString& aValue)
nsTreeContentView::SetCellValue(int32_t aRow, nsTreeColumn* aCol, const nsAString& aValue)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
SetCellValue(aRow, *col, aValue, rv);
SetCellValue(aRow, *aCol, aValue, rv);
return rv.StealNSResult();
}
@ -836,13 +824,12 @@ nsTreeContentView::SetCellText(int32_t aRow, nsTreeColumn& aColumn,
}
NS_IMETHODIMP
nsTreeContentView::SetCellText(int32_t aRow, nsITreeColumn* aCol, const nsAString& aValue)
nsTreeContentView::SetCellText(int32_t aRow, nsTreeColumn* aCol, const nsAString& aValue)
{
RefPtr<nsTreeColumn> col = nsTreeColumn::From(aCol);
NS_ENSURE_ARG(col);
NS_ENSURE_ARG(aCol);
ErrorResult rv;
SetCellText(aRow, *col, aValue, rv);
SetCellText(aRow, *aCol, aValue, rv);
return rv.StealNSResult();
}
@ -859,7 +846,7 @@ nsTreeContentView::PerformActionOnRow(const char16_t* aAction, int32_t aRow)
}
NS_IMETHODIMP
nsTreeContentView::PerformActionOnCell(const char16_t* aAction, int32_t aRow, nsITreeColumn* aCol)
nsTreeContentView::PerformActionOnCell(const char16_t* aAction, int32_t aRow, nsTreeColumn* aCol)
{
return NS_OK;
}

View File

@ -47,7 +47,7 @@ nsTreeImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRec
}
void
nsTreeImageListener::AddCell(int32_t aIndex, nsITreeColumn* aCol)
nsTreeImageListener::AddCell(int32_t aIndex, nsTreeColumn* aCol)
{
if (!mInvalidationArea) {
mInvalidationArea = new InvalidationArea(aCol);
@ -90,7 +90,7 @@ nsTreeImageListener::Invalidate()
}
}
nsTreeImageListener::InvalidationArea::InvalidationArea(nsITreeColumn* aCol)
nsTreeImageListener::InvalidationArea::InvalidationArea(nsTreeColumn* aCol)
: mCol(aCol),
mMin(-1), // min should start out "undefined"
mMax(0),

View File

@ -12,7 +12,7 @@
#include "nsTreeBodyFrame.h"
#include "mozilla/Attributes.h"
class nsITreeColumn;
class nsTreeColumn;
// This class handles image load observation.
class nsTreeImageListener final : public imgINotificationObserver
@ -32,7 +32,7 @@ protected:
void UnsuppressInvalidation() { mInvalidationSuppressed = false; }
void Invalidate();
void AddCell(int32_t aIndex, nsITreeColumn* aCol);
void AddCell(int32_t aIndex, nsTreeColumn* aCol);
private:
nsTreeBodyFrame* mTreeFrame;
@ -42,21 +42,21 @@ private:
class InvalidationArea {
public:
explicit InvalidationArea(nsITreeColumn* aCol);
explicit InvalidationArea(nsTreeColumn* aCol);
~InvalidationArea() { delete mNext; }
friend class nsTreeImageListener;
protected:
void AddRow(int32_t aIndex);
nsITreeColumn* GetCol() { return mCol.get(); }
nsTreeColumn* GetCol() { return mCol.get(); }
int32_t GetMin() { return mMin; }
int32_t GetMax() { return mMax; }
InvalidationArea* GetNext() { return mNext; }
void SetNext(InvalidationArea* aNext) { mNext = aNext; }
private:
nsCOMPtr<nsITreeColumn> mCol;
RefPtr<nsTreeColumn> mCol;
int32_t mMin;
int32_t mMax;
InvalidationArea* mNext;

View File

@ -656,13 +656,13 @@ NS_IMETHODIMP nsTreeSelection::SetCurrentIndex(int32_t aIndex)
return asyncDispatcher->PostDOMEvent();
}
NS_IMETHODIMP nsTreeSelection::GetCurrentColumn(nsITreeColumn** aCurrentColumn)
NS_IMETHODIMP nsTreeSelection::GetCurrentColumn(nsTreeColumn** aCurrentColumn)
{
NS_IF_ADDREF(*aCurrentColumn = mCurrentColumn);
return NS_OK;
}
NS_IMETHODIMP nsTreeSelection::SetCurrentColumn(nsITreeColumn* aCurrentColumn)
NS_IMETHODIMP nsTreeSelection::SetCurrentColumn(nsTreeColumn* aCurrentColumn)
{
if (!mTree) {
return NS_ERROR_UNEXPECTED;

View File

@ -13,7 +13,7 @@
#include "mozilla/Attributes.h"
class nsITreeBoxObject;
class nsITreeColumn;
class nsTreeColumn;
struct nsTreeRange;
class nsTreeSelection final : public nsINativeTreeSelection
@ -45,7 +45,7 @@ protected:
bool mSuppressed; // Whether or not we should be firing onselect events.
int32_t mCurrentIndex; // The item to draw the rect around. The last one clicked, etc.
nsCOMPtr<nsITreeColumn> mCurrentColumn;
RefPtr<nsTreeColumn> mCurrentColumn;
int32_t mShiftSelectPivot; // Used when multiple SHIFT+selects are performed to pivot on.
nsTreeRange* mFirstRange; // Our list of ranges.

View File

@ -192,13 +192,13 @@ nsNSSASN1Tree::GetRowProperties(int32_t, nsAString&)
}
NS_IMETHODIMP
nsNSSASN1Tree::GetCellProperties(int32_t, nsITreeColumn*, nsAString&)
nsNSSASN1Tree::GetCellProperties(int32_t, nsTreeColumn*, nsAString&)
{
return NS_OK;
}
NS_IMETHODIMP
nsNSSASN1Tree::GetColumnProperties(nsITreeColumn*, nsAString&)
nsNSSASN1Tree::GetColumnProperties(nsTreeColumn*, nsAString&)
{
return NS_OK;
}
@ -262,19 +262,19 @@ nsNSSASN1Tree::GetLevel(int32_t index, int32_t* _retval)
}
NS_IMETHODIMP
nsNSSASN1Tree::GetImageSrc(int32_t, nsITreeColumn*, nsAString&)
nsNSSASN1Tree::GetImageSrc(int32_t, nsTreeColumn*, nsAString&)
{
return NS_OK;
}
NS_IMETHODIMP
nsNSSASN1Tree::GetCellValue(int32_t, nsITreeColumn*, nsAString&)
nsNSSASN1Tree::GetCellValue(int32_t, nsTreeColumn*, nsAString&)
{
return NS_OK;
}
NS_IMETHODIMP
nsNSSASN1Tree::GetCellText(int32_t row, nsITreeColumn*, nsAString& _retval)
nsNSSASN1Tree::GetCellText(int32_t row, nsTreeColumn*, nsAString& _retval)
{
NS_ENSURE_ARG_MIN(row, 0);
@ -334,7 +334,7 @@ nsNSSASN1Tree::ToggleOpenState(int32_t index)
}
NS_IMETHODIMP
nsNSSASN1Tree::CycleHeader(nsITreeColumn*)
nsNSSASN1Tree::CycleHeader(nsTreeColumn*)
{
return NS_OK;
}
@ -346,13 +346,13 @@ nsNSSASN1Tree::SelectionChanged()
}
NS_IMETHODIMP
nsNSSASN1Tree::CycleCell(int32_t, nsITreeColumn*)
nsNSSASN1Tree::CycleCell(int32_t, nsTreeColumn*)
{
return NS_OK;
}
NS_IMETHODIMP
nsNSSASN1Tree::IsEditable(int32_t, nsITreeColumn*, bool* _retval)
nsNSSASN1Tree::IsEditable(int32_t, nsTreeColumn*, bool* _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = false;
@ -360,7 +360,7 @@ nsNSSASN1Tree::IsEditable(int32_t, nsITreeColumn*, bool* _retval)
}
NS_IMETHODIMP
nsNSSASN1Tree::IsSelectable(int32_t, nsITreeColumn*, bool* _retval)
nsNSSASN1Tree::IsSelectable(int32_t, nsTreeColumn*, bool* _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = false;
@ -368,13 +368,13 @@ nsNSSASN1Tree::IsSelectable(int32_t, nsITreeColumn*, bool* _retval)
}
NS_IMETHODIMP
nsNSSASN1Tree::SetCellValue(int32_t, nsITreeColumn*, const nsAString&)
nsNSSASN1Tree::SetCellValue(int32_t, nsTreeColumn*, const nsAString&)
{
return NS_OK;
}
NS_IMETHODIMP
nsNSSASN1Tree::SetCellText(int32_t, nsITreeColumn*, const nsAString&)
nsNSSASN1Tree::SetCellText(int32_t, nsTreeColumn*, const nsAString&)
{
return NS_OK;
}
@ -392,7 +392,7 @@ nsNSSASN1Tree::PerformActionOnRow(const char16_t*, int32_t)
}
NS_IMETHODIMP
nsNSSASN1Tree::PerformActionOnCell(const char16_t*, int32_t, nsITreeColumn*)
nsNSSASN1Tree::PerformActionOnCell(const char16_t*, int32_t, nsTreeColumn*)
{
return NS_OK;
}

View File

@ -881,14 +881,14 @@ nsCertTree::GetRowProperties(int32_t index, nsAString& aProps)
}
NS_IMETHODIMP
nsCertTree::GetCellProperties(int32_t row, nsITreeColumn* col,
nsCertTree::GetCellProperties(int32_t row, nsTreeColumn* col,
nsAString& aProps)
{
return NS_OK;
}
NS_IMETHODIMP
nsCertTree::GetColumnProperties(nsITreeColumn* col, nsAString& aProps)
nsCertTree::GetColumnProperties(nsTreeColumn* col, nsAString& aProps)
{
return NS_OK;
}
@ -989,7 +989,7 @@ nsCertTree::GetLevel(int32_t index, int32_t *_retval)
}
NS_IMETHODIMP
nsCertTree::GetImageSrc(int32_t row, nsITreeColumn* col,
nsCertTree::GetImageSrc(int32_t row, nsTreeColumn* col,
nsAString& _retval)
{
_retval.Truncate();
@ -997,7 +997,7 @@ nsCertTree::GetImageSrc(int32_t row, nsITreeColumn* col,
}
NS_IMETHODIMP
nsCertTree::GetCellValue(int32_t row, nsITreeColumn* col,
nsCertTree::GetCellValue(int32_t row, nsTreeColumn* col,
nsAString& _retval)
{
_retval.Truncate();
@ -1005,7 +1005,7 @@ nsCertTree::GetCellValue(int32_t row, nsITreeColumn* col,
}
NS_IMETHODIMP
nsCertTree::GetCellText(int32_t row, nsITreeColumn* col,
nsCertTree::GetCellText(int32_t row, nsTreeColumn* col,
nsAString& _retval)
{
if (!mTreeArray)
@ -1014,8 +1014,7 @@ nsCertTree::GetCellText(int32_t row, nsITreeColumn* col,
nsresult rv = NS_OK;
_retval.Truncate();
const char16_t* colID;
col->GetIdConst(&colID);
const nsAString& colID = col->GetId();
treeArrayEl *el = GetThreadDescAtIndex(row);
if (el) {
@ -1036,8 +1035,7 @@ nsCertTree::GetCellText(int32_t row, nsITreeColumn* col,
cert = certdi->mAddonInfo->mCert;
}
int32_t colIndex;
col->GetIndex(&colIndex);
int32_t colIndex = col->Index();
uint32_t arrayIndex=absoluteCertOffset+colIndex*(mNumRows-mNumOrgs);
uint32_t arrayLength=0;
if (mCellText) {
@ -1124,7 +1122,7 @@ nsCertTree::ToggleOpenState(int32_t index)
}
NS_IMETHODIMP
nsCertTree::CycleHeader(nsITreeColumn* col)
nsCertTree::CycleHeader(nsTreeColumn* col)
{
return NS_OK;
}
@ -1136,34 +1134,34 @@ nsCertTree::SelectionChanged()
}
NS_IMETHODIMP
nsCertTree::CycleCell(int32_t row, nsITreeColumn* col)
nsCertTree::CycleCell(int32_t row, nsTreeColumn* col)
{
return NS_OK;
}
NS_IMETHODIMP
nsCertTree::IsEditable(int32_t row, nsITreeColumn* col, bool *_retval)
nsCertTree::IsEditable(int32_t row, nsTreeColumn* col, bool *_retval)
{
*_retval = false;
return NS_OK;
}
NS_IMETHODIMP
nsCertTree::IsSelectable(int32_t row, nsITreeColumn* col, bool *_retval)
nsCertTree::IsSelectable(int32_t row, nsTreeColumn* col, bool *_retval)
{
*_retval = false;
return NS_OK;
}
NS_IMETHODIMP
nsCertTree::SetCellValue(int32_t row, nsITreeColumn* col,
nsCertTree::SetCellValue(int32_t row, nsTreeColumn* col,
const nsAString& value)
{
return NS_OK;
}
NS_IMETHODIMP
nsCertTree::SetCellText(int32_t row, nsITreeColumn* col,
nsCertTree::SetCellText(int32_t row, nsTreeColumn* col,
const nsAString& value)
{
return NS_OK;
@ -1183,7 +1181,7 @@ nsCertTree::PerformActionOnRow(const char16_t *action, int32_t row)
NS_IMETHODIMP
nsCertTree::PerformActionOnCell(const char16_t *action, int32_t row,
nsITreeColumn* col)
nsTreeColumn* col)
{
return NS_OK;
}

View File

@ -4,7 +4,8 @@
//! A rust helper to ease the use of Gecko's refcounted types.
use gecko_bindings::structs;
use Atom;
use gecko_bindings::{structs, bindings};
use gecko_bindings::sugar::ownership::HasArcFFI;
use servo_arc::Arc;
use std::{fmt, mem, ptr};
@ -255,13 +256,16 @@ unsafe impl<T: ThreadSafeRefCounted> Send for RefPtr<T> {}
unsafe impl<T: ThreadSafeRefCounted> Sync for RefPtr<T> {}
macro_rules! impl_refcount {
($t:ty, $addref:ident, $release:ident) => {
($t:ty, $addref:path, $release:path) => {
unsafe impl RefCounted for $t {
#[inline]
fn addref(&self) {
unsafe { ::gecko_bindings::bindings::$addref(self as *const _ as *mut _) }
unsafe { $addref(self as *const _ as *mut _) }
}
#[inline]
unsafe fn release(&self) {
::gecko_bindings::bindings::$release(self as *const _ as *mut _)
$release(self as *const _ as *mut _)
}
}
};
@ -271,50 +275,63 @@ macro_rules! impl_refcount {
//
// Gets you a free RefCounted impl implemented via FFI.
macro_rules! impl_threadsafe_refcount {
($t:ty, $addref:ident, $release:ident) => {
($t:ty, $addref:path, $release:path) => {
impl_refcount!($t, $addref, $release);
unsafe impl ThreadSafeRefCounted for $t {}
};
}
impl_threadsafe_refcount!(
::gecko_bindings::structs::RawGeckoURLExtraData,
Gecko_AddRefURLExtraDataArbitraryThread,
Gecko_ReleaseURLExtraDataArbitraryThread
structs::RawGeckoURLExtraData,
bindings::Gecko_AddRefURLExtraDataArbitraryThread,
bindings::Gecko_ReleaseURLExtraDataArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::nsStyleQuoteValues,
Gecko_AddRefQuoteValuesArbitraryThread,
Gecko_ReleaseQuoteValuesArbitraryThread
structs::nsStyleQuoteValues,
bindings::Gecko_AddRefQuoteValuesArbitraryThread,
bindings::Gecko_ReleaseQuoteValuesArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::nsCSSValueSharedList,
Gecko_AddRefCSSValueSharedListArbitraryThread,
Gecko_ReleaseCSSValueSharedListArbitraryThread
structs::nsCSSValueSharedList,
bindings::Gecko_AddRefCSSValueSharedListArbitraryThread,
bindings::Gecko_ReleaseCSSValueSharedListArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::mozilla::css::URLValue,
Gecko_AddRefCSSURLValueArbitraryThread,
Gecko_ReleaseCSSURLValueArbitraryThread
structs::mozilla::css::URLValue,
bindings::Gecko_AddRefCSSURLValueArbitraryThread,
bindings::Gecko_ReleaseCSSURLValueArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::mozilla::css::GridTemplateAreasValue,
Gecko_AddRefGridTemplateAreasValueArbitraryThread,
Gecko_ReleaseGridTemplateAreasValueArbitraryThread
structs::mozilla::css::GridTemplateAreasValue,
bindings::Gecko_AddRefGridTemplateAreasValueArbitraryThread,
bindings::Gecko_ReleaseGridTemplateAreasValueArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::ImageValue,
Gecko_AddRefImageValueArbitraryThread,
Gecko_ReleaseImageValueArbitraryThread
structs::ImageValue,
bindings::Gecko_AddRefImageValueArbitraryThread,
bindings::Gecko_ReleaseImageValueArbitraryThread
);
impl_threadsafe_refcount!(
::gecko_bindings::structs::SharedFontList,
Gecko_AddRefSharedFontListArbitraryThread,
Gecko_ReleaseSharedFontListArbitraryThread
structs::SharedFontList,
bindings::Gecko_AddRefSharedFontListArbitraryThread,
bindings::Gecko_ReleaseSharedFontListArbitraryThread
);
impl_threadsafe_refcount!(
structs::SheetLoadDataHolder,
bindings::Gecko_AddRefSheetLoadDataHolderArbitraryThread,
bindings::Gecko_ReleaseSheetLoadDataHolderArbitraryThread
);
#[inline]
unsafe fn addref_atom(atom: *mut structs::nsAtom) {
mem::forget(Atom::from_raw(atom));
}
#[inline]
unsafe fn release_atom(atom: *mut structs::nsAtom) {
let _ = Atom::from_addrefed(atom);
}
impl_threadsafe_refcount!(
::gecko_bindings::structs::SheetLoadDataHolder,
Gecko_AddRefSheetLoadDataHolderArbitraryThread,
Gecko_ReleaseSheetLoadDataHolderArbitraryThread
structs::nsAtom,
addref_atom,
release_atom
);

View File

@ -157,12 +157,12 @@ impl<'a> ParserContext<'a> {
///
/// The derive code understands the following attributes on each of the variants:
///
/// * `#[css(aliases = "foo,bar")]` can be used to alias a value with another
/// * `#[parse(aliases = "foo,bar")]` can be used to alias a value with another
/// at parse-time.
///
/// * `#[css(parse_condition = "function")]` can be used to make the parsing of
/// the value conditional on `function`, which will be invoked with a
/// `&ParserContext` reference.
/// * `#[parse(condition = "function")]` can be used to make the parsing of the
/// value conditional on `function`, which needs to fulfill
/// `fn(&ParserContext) -> bool`.
pub trait Parse: Sized {
/// Parse a value of this type.
///

View File

@ -1116,9 +1116,7 @@ where
let mut parser = Parser::new(&mut input);
let start_position = parser.position();
parser.parse_entirely(|parser| {
let name = id.name().into();
PropertyDeclaration::parse_into(declarations, id, name, &context, parser)
.map_err(|e| e.into())
PropertyDeclaration::parse_into(declarations, id, &context, parser)
}).map_err(|err| {
let location = err.location;
let error = ContextualParseError::UnsupportedPropertyDeclaration(
@ -1169,7 +1167,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
}
};
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(self.declarations, id, name, self.context, input)
PropertyDeclaration::parse_into(self.declarations, id, self.context, input)
})?;
let importance = match input.try(parse_important) {
Ok(()) => Importance::Important,

View File

@ -3274,10 +3274,7 @@ fn static_assert() {
self.gecko.mTransitions.ensure_len(v.len());
self.gecko.mTransitionPropertyCount = v.len() as u32;
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
if !gecko.mUnknownProperty.mRawPtr.is_null() {
unsafe { Atom::from_addrefed(gecko.mUnknownProperty.mRawPtr) };
gecko.mUnknownProperty.mRawPtr = ptr::null_mut();
}
unsafe { gecko.mUnknownProperty.clear() };
match servo {
TransitionProperty::Unsupported(ident) => {
@ -3355,10 +3352,7 @@ fn static_assert() {
for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) {
transition.mProperty = other.gecko.mTransitions[index].mProperty;
if !transition.mUnknownProperty.mRawPtr.is_null() {
unsafe { Atom::from_addrefed(transition.mUnknownProperty.mRawPtr) };
transition.mUnknownProperty.mRawPtr = ptr::null_mut();
}
unsafe { transition.mUnknownProperty.clear() };
if transition.mProperty == eCSSProperty_UNKNOWN ||
transition.mProperty == eCSSPropertyExtra_variable {
let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;

View File

@ -594,7 +594,7 @@
aliases.append(alias)
%>
% if aliases:
#[css(aliases = "${','.join(aliases)}")]
#[parse(aliases = "${','.join(aliases)}")]
% endif
% endif
${to_camel_case(variant)},

View File

@ -23,7 +23,7 @@ use std::fmt::{self, Write};
use std::mem::{self, ManuallyDrop};
#[cfg(feature = "servo")] use cssparser::RGBA;
use cssparser::{CowRcStr, Parser, TokenSerializationType, serialize_identifier};
use cssparser::{Parser, TokenSerializationType};
use cssparser::ParserInput;
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
use context::QuirksMode;
@ -49,6 +49,7 @@ use stylesheets::{CssRuleType, Origin, UrlExtraData};
use values::generics::text::LineHeight;
use values::computed;
use values::computed::NonNegativeLength;
use values::serialize_atom_name;
use rule_tree::{CascadeLevel, StrongRuleNode};
use self::computed_value_flags::*;
use str::{CssString, CssStringBorrow, CssStringWriter};
@ -427,6 +428,17 @@ impl NonCustomPropertyId {
MAP[self.0]
}
/// Get the property name.
#[inline]
fn name(self) -> &'static str {
static MAP: [&'static str; ${len(data.longhands) + len(data.shorthands) + len(data.all_aliases())}] = [
% for property in data.longhands + data.shorthands + data.all_aliases():
"${property.name}",
% endfor
];
MAP[self.0]
}
#[inline]
fn enabled_for_all_content(self) -> bool {
${static_non_custom_property_id_set(
@ -859,12 +871,9 @@ impl fmt::Debug for LonghandId {
impl LonghandId {
/// Get the name of this longhand property.
#[inline]
pub fn name(&self) -> &'static str {
match *self {
% for property in data.longhands:
LonghandId::${property.camel_case} => "${property.name}",
% endfor
}
NonCustomPropertyId::from(*self).name()
}
/// Returns whether the longhand property is inherited by default.
@ -1202,12 +1211,9 @@ impl ToCss for ShorthandId {
impl ShorthandId {
/// Get the name for this shorthand property.
#[inline]
pub fn name(&self) -> &'static str {
match *self {
% for property in data.shorthands:
ShorthandId::${property.camel_case} => "${property.name}",
% endfor
}
NonCustomPropertyId::from(*self).name()
}
/// Converts from a ShorthandId to an adequate nsCSSPropertyID.
@ -1506,8 +1512,9 @@ impl<'a> ToCss for PropertyDeclarationId<'a> {
{
match *self {
PropertyDeclarationId::Longhand(id) => dest.write_str(id.name()),
PropertyDeclarationId::Custom(_) => {
serialize_identifier(&self.name(), dest)
PropertyDeclarationId::Custom(ref name) => {
dest.write_str("--")?;
serialize_atom_name(name, dest)
}
}
}
@ -1587,8 +1594,9 @@ impl ToCss for PropertyId {
PropertyId::Shorthand(id) => dest.write_str(id.name()),
PropertyId::LonghandAlias(id, _) => dest.write_str(id.name()),
PropertyId::ShorthandAlias(id, _) => dest.write_str(id.name()),
PropertyId::Custom(_) => {
serialize_identifier(&self.name(), dest)
PropertyId::Custom(ref name) => {
dest.write_str("--")?;
serialize_atom_name(name, dest)
}
}
}
@ -1757,21 +1765,6 @@ impl PropertyId {
}
}
/// Returns the name of the property without CSS escaping.
pub fn name(&self) -> Cow<'static, str> {
match *self {
PropertyId::ShorthandAlias(id, _) |
PropertyId::Shorthand(id) => id.name().into(),
PropertyId::LonghandAlias(id, _) |
PropertyId::Longhand(id) => id.name().into(),
PropertyId::Custom(ref name) => {
let mut s = String::new();
write!(&mut s, "--{}", name).unwrap();
s.into()
}
}
}
fn non_custom_id(&self) -> Option<NonCustomPropertyId> {
Some(match *self {
PropertyId::Custom(_) => return None,
@ -2034,13 +2027,13 @@ impl PropertyDeclaration {
pub fn parse_into<'i, 't>(
declarations: &mut SourcePropertyDeclaration,
id: PropertyId,
name: CowRcStr<'i>,
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<(), ParseError<'i>> {
assert!(declarations.is_empty());
debug_assert!(id.allowed_in(context), "{:?}", id);
let non_custom_id = id.non_custom_id();
let start = input.state();
match id {
PropertyId::Custom(property_name) => {
@ -2051,7 +2044,10 @@ impl PropertyDeclaration {
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
Err(()) => match ::custom_properties::SpecifiedValue::parse(input) {
Ok(value) => DeclaredValueOwned::Value(value),
Err(e) => return Err(StyleParseErrorKind::new_invalid(name, e)),
Err(e) => return Err(StyleParseErrorKind::new_invalid(
format!("--{}", property_name),
e,
)),
}
};
declarations.push(PropertyDeclaration::Custom(CustomDeclaration {
@ -2076,7 +2072,10 @@ impl PropertyDeclaration {
input.reset(&start);
let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid(name, e)
StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
e,
)
})?;
Ok(PropertyDeclaration::WithVariables(VariableDeclaration {
id,
@ -2088,7 +2087,10 @@ impl PropertyDeclaration {
}),
}))
} else {
Err(StyleParseErrorKind::new_invalid(name, err))
Err(StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
err,
))
}
})
}).map(|declaration| {
@ -2122,7 +2124,10 @@ impl PropertyDeclaration {
input.reset(&start);
let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid(name, e)
StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
e,
)
})?;
let unparsed = Arc::new(UnparsedValue {
css: css.into_owned(),
@ -2144,7 +2149,10 @@ impl PropertyDeclaration {
}
Ok(())
} else {
Err(StyleParseErrorKind::new_invalid(name, err))
Err(StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
err,
))
}
})
}

View File

@ -623,12 +623,12 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> {
let id = match PropertyId::parse(&name, self.context) {
Ok(id) => id,
Err(()) => return Err(input.new_custom_error(
StyleParseErrorKind::UnknownProperty(name.clone())
StyleParseErrorKind::UnknownProperty(name)
)),
};
// TODO(emilio): Shouldn't this use parse_entirely?
PropertyDeclaration::parse_into(self.declarations, id, name, self.context, input)?;
PropertyDeclaration::parse_into(self.declarations, id, self.context, input)?;
// In case there is still unparsed text in the declaration, we should
// roll back.

View File

@ -316,20 +316,23 @@ impl Declaration {
let mut input = ParserInput::new(&self.0);
let mut input = Parser::new(&mut input);
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
let prop = input.expect_ident_cloned().unwrap();
input.expect_colon().unwrap();
let prop = input.expect_ident_cloned().unwrap();
input.expect_colon().unwrap();
let id = PropertyId::parse(&prop, context)
.map_err(|_| input.new_custom_error(()))?;
let id = PropertyId::parse(&prop, context)
.map_err(|_| input.new_custom_error(()))?;
let mut declarations = SourcePropertyDeclaration::new();
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(&mut declarations, id, prop, &context, input)
.map_err(|_| input.new_custom_error(()))
})?;
let _ = input.try(parse_important);
Ok(())
})
.is_ok()
let mut declarations = SourcePropertyDeclaration::new();
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(
&mut declarations,
id,
&context,
input,
).map_err(|_| input.new_custom_error(()))
})?;
let _ = input.try(parse_important);
Ok(())
}).is_ok()
}
}

View File

@ -9,7 +9,7 @@
#![deny(missing_docs)]
use Atom;
pub use cssparser::{serialize_identifier, CowRcStr, Parser, SourceLocation, Token, RGBA};
pub use cssparser::{serialize_identifier, serialize_name, CowRcStr, Parser, SourceLocation, Token, RGBA};
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use std::fmt::{self, Debug, Write};
@ -60,6 +60,28 @@ where
serialize_identifier(&ident, dest)
}
/// Serialize a name which is represented as an Atom.
#[cfg(feature = "gecko")]
pub fn serialize_atom_name<W>(ident: &Atom, dest: &mut W) -> fmt::Result
where
W: Write,
{
ident.with_str(|s| serialize_name(s, dest))
}
/// Serialize a name which is represented as an Atom.
#[cfg(feature = "servo")]
pub fn serialize_atom_name<Static, W>(
ident: &::string_cache::Atom<Static>,
dest: &mut W,
) -> fmt::Result
where
Static: ::string_cache::StaticAtomSet,
W: Write,
{
serialize_name(&ident, dest)
}
/// Serialize a normalized value into percentage.
pub fn serialize_percentage<W>(value: CSSFloat, dest: &mut CssWriter<W>) -> fmt::Result
where

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