diff --git a/CLOBBER b/CLOBBER index 5e796b3afa988..511582aa9a470 100644 --- a/CLOBBER +++ b/CLOBBER @@ -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. diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index a4b70c0757002..a5c153ab99d00 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -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 tcElm; @@ -519,7 +519,7 @@ nsCoreUtils::GetTreeBoxObject(nsIContent *aContent) return nullptr; } -already_AddRefed +already_AddRefed nsCoreUtils::GetFirstSensibleColumn(nsITreeBoxObject *aTree) { RefPtr cols; @@ -556,12 +556,12 @@ nsCoreUtils::GetSensibleColumnCount(nsITreeBoxObject *aTree) return count; } -already_AddRefed +already_AddRefed nsCoreUtils::GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex) { uint32_t idx = aIndex; - nsCOMPtr column = GetFirstSensibleColumn(aTree); + nsCOMPtr 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 -nsCoreUtils::GetNextSensibleColumn(nsITreeColumn *aColumn) +already_AddRefed +nsCoreUtils::GetNextSensibleColumn(nsTreeColumn* aColumn) { - nsCOMPtr nextColumn; - aColumn->GetNext(getter_AddRefs(nextColumn)); + RefPtr nextColumn = aColumn->GetNext(); while (nextColumn && IsColumnHidden(nextColumn)) { - nsCOMPtr tempColumn; - nextColumn->GetNext(getter_AddRefs(tempColumn)); - nextColumn.swap(tempColumn); + nextColumn = nextColumn->GetNext(); } return nextColumn.forget(); } -already_AddRefed -nsCoreUtils::GetPreviousSensibleColumn(nsITreeColumn *aColumn) +already_AddRefed +nsCoreUtils::GetPreviousSensibleColumn(nsTreeColumn* aColumn) { - nsCOMPtr prevColumn; - aColumn->GetPrevious(getter_AddRefs(prevColumn)); + RefPtr prevColumn = aColumn->GetPrevious(); while (prevColumn && IsColumnHidden(prevColumn)) { - nsCOMPtr 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; - aColumn->GetElement(getter_AddRefs(element)); + Element* element = aColumn->Element(); return element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden, nsGkAtoms::_true, eCaseMatters); } diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index 7fcc65b419f3e..868c5f0408cf9 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -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 @@ class nsCoreUtils * 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 @@ class nsCoreUtils /** * Return first sensible column for the given tree box object. */ - static already_AddRefed + static already_AddRefed GetFirstSensibleColumn(nsITreeBoxObject *aTree); /** @@ -260,25 +260,25 @@ class nsCoreUtils /** * Return sensible column at the given index for the given tree box object. */ - static already_AddRefed + static already_AddRefed GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex); /** * Return next sensible column for the given column. */ - static already_AddRefed - GetNextSensibleColumn(nsITreeColumn *aColumn); + static already_AddRefed + GetNextSensibleColumn(nsTreeColumn *aColumn); /** * Return previous sensible column for the given column. */ - static already_AddRefed - GetPreviousSensibleColumn(nsITreeColumn *aColumn); + static already_AddRefed + 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. diff --git a/accessible/tests/mochitest/jsat/a11y.ini b/accessible/tests/mochitest/jsat/a11y.ini index b26ce80f65836..a4c0179049e40 100644 --- a/accessible/tests/mochitest/jsat/a11y.ini +++ b/accessible/tests/mochitest/jsat/a11y.ini @@ -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] diff --git a/accessible/windows/msaa/XULTreeGridAccessibleWrap.h b/accessible/windows/msaa/XULTreeGridAccessibleWrap.h index 3c6c626998c16..d95e2844add80 100644 --- a/accessible/windows/msaa/XULTreeGridAccessibleWrap.h +++ b/accessible/windows/msaa/XULTreeGridAccessibleWrap.h @@ -52,7 +52,7 @@ class XULTreeGridCellAccessibleWrap : public XULTreeGridCellAccessible, 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) {} diff --git a/accessible/xul/XULTreeAccessible.cpp b/accessible/xul/XULTreeAccessible.cpp index 6167b4766ebde..261a5c3698b9a 100644 --- a/accessible/xul/XULTreeAccessible.cpp +++ b/accessible/xul/XULTreeAccessible.cpp @@ -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 column; + RefPtr column; nsAutoString childEltUnused; mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column), childEltUnused); @@ -724,7 +724,7 @@ XULTreeItemAccessibleBase::BoundsInCSSPixels() const return nsIntRect(); } - nsCOMPtr column = nsCoreUtils::GetFirstSensibleColumn(mTree); + RefPtr 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); diff --git a/accessible/xul/XULTreeAccessible.h b/accessible/xul/XULTreeAccessible.h index e24e6ae84223a..a2095f3621954 100644 --- a/accessible/xul/XULTreeAccessible.h +++ b/accessible/xul/XULTreeAccessible.h @@ -11,7 +11,7 @@ #include "XULListboxAccessible.h" class nsTreeBodyFrame; -class nsITreeColumn; +class nsTreeColumn; namespace mozilla { namespace a11y { @@ -177,7 +177,7 @@ class XULTreeItemAccessibleBase : public AccessibleWrap * 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 @@ class XULTreeItemAccessibleBase : public AccessibleWrap /** * Return name for cell at the given column. */ - void GetCellName(nsITreeColumn* aColumn, nsAString& aName) const; + void GetCellName(nsTreeColumn* aColumn, nsAString& aName) const; nsCOMPtr mTree; nsITreeView* mTreeView; @@ -244,7 +244,7 @@ class XULTreeItemAccessible : public XULTreeItemAccessibleBase virtual ~XULTreeItemAccessible(); // XULTreeItemAccessible - nsCOMPtr mColumn; + RefPtr mColumn; nsString mCachedName; }; diff --git a/accessible/xul/XULTreeGridAccessible.cpp b/accessible/xul/XULTreeGridAccessible.cpp index b5f5417689bd0..bdf570c9cb0d9 100644 --- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -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 column = + RefPtr 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 column = nsCoreUtils::GetFirstSensibleColumn(mTree); + RefPtr 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 column; + RefPtr 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 column = + RefPtr 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 column = mColumn; + RefPtr column = mColumn; while ((column = nsCoreUtils::GetPreviousSensibleColumn(column))) colIdx++; @@ -632,8 +621,7 @@ XULTreeGridCellAccessible::RowIdx() const void XULTreeGridCellAccessible::ColHeaderCells(nsTArray* aHeaderCells) { - RefPtr 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 columnAtOffset(mColumn), column; + RefPtr 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 columnElm; - mColumn->GetElement(getter_AddRefs(columnElm)); - if (!columnElm) - return false; + dom::Element* columnElm = mColumn->Element(); if (!columnElm->AttrValueIs(kNameSpaceID_None, nsGkAtoms::editable, diff --git a/accessible/xul/XULTreeGridAccessible.h b/accessible/xul/XULTreeGridAccessible.h index 81d210847d5ba..220aef1f47f96 100644 --- a/accessible/xul/XULTreeGridAccessible.h +++ b/accessible/xul/XULTreeGridAccessible.h @@ -90,7 +90,7 @@ class XULTreeGridRowAccessible final : public XULTreeItemAccessibleBase 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 @@ class XULTreeGridCellAccessible : public LeafAccessible, 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 @@ class XULTreeGridCellAccessible : public LeafAccessible, nsITreeView* mTreeView; int32_t mRow; - nsCOMPtr mColumn; + RefPtr mColumn; nsString mCachedTextEquiv; }; diff --git a/browser/components/sessionstore/test/browser_aboutSessionRestore.js b/browser/components/sessionstore/test/browser_aboutSessionRestore.js index 72289db6cd16a..207bfe539ee55 100644 --- a/browser/components/sessionstore/test/browser_aboutSessionRestore.js +++ b/browser/components/sessionstore/test/browser_aboutSessionRestore.js @@ -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); diff --git a/dom/base/WindowDestroyedEvent.cpp b/dom/base/WindowDestroyedEvent.cpp index ce2724d022446..d8a400a89eea6 100644 --- a/dom/base/WindowDestroyedEvent.cpp +++ b/dom/base/WindowDestroyedEvent.cpp @@ -110,7 +110,7 @@ WindowDestroyedEvent::Run() AutoSafeJSContext cx; JS::Rooted obj(cx, currentInner->FastGetGlobalJSObject()); - if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) { + if (obj && !js::IsSystemRealm(js::GetNonCCWObjectRealm(obj))) { JSCompartment* cpt = js::GetObjectCompartment(obj); nsCOMPtr pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(cpt)); diff --git a/dom/base/test/chrome/cpows_child.js b/dom/base/test/chrome/cpows_child.js index 5ef140abe3f9f..670b1349e8e24 100644 --- a/dom/base/test/chrome/cpows_child.js +++ b/dom/base/test/chrome/cpows_child.js @@ -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"); diff --git a/dom/base/test/chrome/cpows_parent.xul b/dom/base/test/chrome/cpows_parent.xul index ee33552004779..ec421d4d697f4 100644 --- a/dom/base/test/chrome/cpows_parent.xul +++ b/dom/base/test/chrome/cpows_parent.xul @@ -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); diff --git a/dom/bindings/DOMJSClass.h b/dom/bindings/DOMJSClass.h index 7bf3d0cdfc8ae..a2645964a6ffa 100644 --- a/dom/bindings/DOMJSClass.h +++ b/dom/bindings/DOMJSClass.h @@ -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 diff --git a/dom/webidl/TreeBoxObject.webidl b/dom/webidl/TreeBoxObject.webidl index 4b789fdd56643..397e2b8cb40b4 100644 --- a/dom/webidl/TreeBoxObject.webidl +++ b/dom/webidl/TreeBoxObject.webidl @@ -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. diff --git a/dom/webidl/TreeColumn.webidl b/dom/webidl/TreeColumn.webidl index 6d843a078a231..c65f73c949a71 100644 --- a/dom/webidl/TreeColumn.webidl +++ b/dom/webidl/TreeColumn.webidl @@ -4,8 +4,7 @@ [Func="IsChromeOrXBL"] interface TreeColumn { - [Throws] - readonly attribute Element? element; + readonly attribute Element element; readonly attribute TreeColumns? columns; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 99de26cb3aa40..f725e045fa43c 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1207,10 +1207,9 @@ class WorkerJSContextStats final : public JS::RuntimeStats 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 "?!"). diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index 3be74a0b70add..fc1e1d09e5888 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -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 ScopedGfxPref { public: @@ -332,6 +351,19 @@ class APZCTesterBase : public ::testing::Test { 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 void Tap(const RefPtr& aTarget, const ScreenIntPoint& aPoint, TimeDuration aTapLength, @@ -390,11 +422,38 @@ class APZCTesterBase : public ::testing::Test { const ScreenIntPoint& aPoint, uint64_t (*aOutInputBlockIds)[2] = nullptr); + template + void PinchWithTouchInput(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, const ScreenIntPoint& aSecondFocus, + float aScale, + int& inputId, + nsTArray* 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 + void PinchWithTouchInput(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, float aScale, + int& inputId, + nsTArray* aAllowedTouchBehaviors = nullptr, + nsEventStatus (*aOutEventStatuses)[4] = nullptr, + uint64_t* aOutInputBlockId = nullptr, + PinchOptions aOptions = PinchOptions::LiftBothFingers); + + template + void PinchWithTouchInputAndCheckStatus(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, float aScale, + int& inputId, bool aShouldTriggerPinch, + nsTArray* aAllowedTouchBehaviors); + protected: RefPtr mcc; }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(APZCTesterBase::PanOptions) +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(APZCTesterBase::PinchOptions) template void @@ -634,6 +693,119 @@ APZCTesterBase::DoubleTapAndCheckStatus(const RefPtr& aTarget, EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[3]); } +template +void +APZCTesterBase::PinchWithTouchInput(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, float aScale, + int& inputId, + nsTArray* 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 +void +APZCTesterBase::PinchWithTouchInput(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, const ScreenIntPoint& aSecondFocus, + float aScale, + int& inputId, + nsTArray* 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 +void +APZCTesterBase::PinchWithTouchInputAndCheckStatus(const RefPtr& aTarget, + const ScreenIntPoint& aFocus, float aScale, + int& inputId, bool aShouldTriggerPinch, + nsTArray* 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) diff --git a/gfx/layers/apz/test/gtest/InputUtils.h b/gfx/layers/apz/test/gtest/InputUtils.h index b4f23f4b82bf4..2111499fa796d 100644 --- a/gfx/layers/apz/test/gtest/InputUtils.h +++ b/gfx/layers/apz/test/gtest/InputUtils.h @@ -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& aTarget, EXPECT_EQ(expectedStatus, statuses[1]); } -template -void -PinchWithTouchInput(const RefPtr& aTarget, - const ScreenIntPoint& aFocus, float aScale, - int& inputId, - nsTArray* 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 -void -PinchWithTouchInputAndCheckStatus(const RefPtr& aTarget, - const ScreenIntPoint& aFocus, float aScale, - int& inputId, bool aShouldTriggerPinch, - nsTArray* 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 nsEventStatus Wheel(const RefPtr& aTarget, const ScreenIntPoint& aPoint, diff --git a/gfx/layers/apz/test/gtest/TestPinching.cpp b/gfx/layers/apz/test/gtest/TestPinching.cpp index a73b16bfa5d21..dc0139a4d40e7 100644 --- a/gfx/layers/apz/test/gtest/TestPinching.cpp +++ b/gfx/layers/apz/test/gtest/TestPinching.cpp @@ -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()); diff --git a/gfx/tests/reftest/reftest.list b/gfx/tests/reftest/reftest.list index 977f23765cae4..64a54af2f9ac0 100644 --- a/gfx/tests/reftest/reftest.list +++ b/gfx/tests/reftest/reftest.list @@ -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 diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index fbe3b1a2383ff..0fb08566648e6 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -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() diff --git a/js/public/Realm.h b/js/public/Realm.h index 7e88a2fdd87c6..b30987e7986f3 100644 --- a/js/public/Realm.h +++ b/js/public/Realm.h @@ -44,21 +44,33 @@ struct GCPolicy : public NonGCPointerPolicy 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(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(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(compartment); +GetCompartmentForRealm(Realm* realm) +{ + return shadow::Realm::get(realm)->compartment(); } // Return an object's realm. All objects except cross-compartment wrappers are diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 25826f668ea0b..00364115d13c6 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -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* diff --git a/js/public/Utility.h b/js/public/Utility.h index 835f2240bef42..bad92831652da 100644 --- a/js/public/Utility.h +++ b/js/public/Utility.h @@ -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. */ /* diff --git a/js/rust/build.rs b/js/rust/build.rs index ce610bce1a558..74113fa44eb56 100644 --- a/js/rust/build.rs +++ b/js/rust/build.rs @@ -236,6 +236,7 @@ const WHITELIST_TYPES: &'static [&'static str] = &[ "JS::TransferableOwnership", "JS::Value", "JS::WarningReporter", + "JS::shadow::Realm", "JS::shadow::Zone", "JS::Zone", ]; diff --git a/js/rust/src/rust.rs b/js/rust/src/rust.rs index 1c603d40a56ad..60e04856beb9c 100644 --- a/js/rust/src/rust.rs +++ b/js/rust/src/rust.rs @@ -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] diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 9a2381251ab8e..68adea24efb73 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -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; diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index 21de572bd631d..7be8998f4f27f 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -506,7 +506,7 @@ SimdTypeDescr::call(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); Rooted descr(cx, &args.callee().as()); - Rooted result(cx, TypedObject::createZeroed(cx, descr, 0)); + Rooted 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 result(cx, TypedObject::createZeroed(cx, typeDescr, 0)); + Rooted 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 result(cx, TypedObject::createZeroed(cx, typeDescr, 0)); + Rooted result(cx, TypedObject::createZeroed(cx, typeDescr)); if (!result) return false; diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 448b9f1afd3e0..6bc581098f0f0 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -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().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 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 obj(cx, OutlineTypedObject::createUnattached(cx, descr, length, heap)); + Rooted 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().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 obj(cx, createZeroed(cx, callee, length)); + Rooted 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 obj(cx, createZeroed(cx, callee, length)); + Rooted 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()); Rooted descr(cx, &args[0].toObject().as()); - int32_t length = TypedObjLengthFromType(*descr); Rooted 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; diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h index 3bd6281dcf38c..23a38fd72bcdc 100644 --- a/js/src/builtin/TypedObject.h +++ b/js/src/builtin/TypedObject.h @@ -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(); } diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index 7bdd688b484bb..8f6ef8ec2ea16 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -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 dontDelete = read == end && keepAtleastOne; - if ((realm->marked() || dontDelete) && !destroyingRuntime) { + bool keepAtleastOneRealm = read == end && keepAtleastOne; + comp->sweepRealms(fop, keepAtleastOneRealm, destroyingRuntime); + + if (!comp->realms().empty()) { *write++ = comp; keepAtleastOne = false; } else { - realm->destroy(fop); + 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++ = realm; + keepAtleastOne = false; + } else { + realm->destroy(fop); + } + } + 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 zoneHolder; + UniquePtr 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 = cx->make_unique(zone, options); + compHolder = cx->make_unique(zone); + if (!compHolder || !compHolder->init(cx)) + return nullptr; + + JSCompartment* comp = compHolder.get(); + UniquePtr realm(cx->new_(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(); } diff --git a/js/src/gc/PublicIterators.cpp b/js/src/gc/PublicIterators.cpp index 954aa8866b28b..5492f411f77be 100644 --- a/js/src/gc/PublicIterators.cpp +++ b/js/src/gc/PublicIterators.cpp @@ -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(cx); + for (RealmsInCompartmentIter r(compartment); !r.done(); r.next()) { + realm = r; + (*realmCallback)(cx, data, realm); + } +} diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index 1b0f32ec7e7cf..fcc5e57cb3173 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -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(); } diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index 6c245a6ac21e3..56d751353d3da 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -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. diff --git a/js/src/jit-test/lib/wasm-binary.js b/js/src/jit-test/lib/wasm-binary.js index 0eeb869499793..995245457fe32 100644 --- a/js/src/jit-test/lib/wasm-binary.js +++ b/js/src/jit-test/lib/wasm-binary.js @@ -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; diff --git a/js/src/jit-test/tests/modules/bug-1466487.js b/js/src/jit-test/tests/modules/bug-1466487.js new file mode 100644 index 0000000000000..1d5ce7bcf3d0c --- /dev/null +++ b/js/src/jit-test/tests/modules/bug-1466487.js @@ -0,0 +1,7 @@ +if (helperThreadCount() === 0) + quit(); +evalInWorker(` + let m = parseModule("import.meta;"); + m.declarationInstantiation(); + m.evaluation(); +`); diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index d19bbff22b627..0eaad9115cdab 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -1897,7 +1897,7 @@ GetTemplateObjectForClassHook(JSContext* cx, JSNative hook, CallArgs& args, { if (hook == TypedObject::construct) { Rooted descr(cx, &args.callee().as()); - templateObject.set(TypedObject::createZeroed(cx, descr, 1, gc::TenuredHeap)); + templateObject.set(TypedObject::createZeroed(cx, descr, gc::TenuredHeap)); return !!templateObject; } diff --git a/js/src/jit/JitRealm.h b/js/src/jit/JitRealm.h index a6962f55d1ac9..f57c43eab19f7 100644 --- a/js/src/jit/JitRealm.h +++ b/js/src/jit/JitRealm.h @@ -516,7 +516,7 @@ class JitRealm JSObject* getSimdTemplateObjectFor(JSContext* cx, Handle 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(); } diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index b0deb6e321e18..543e1c7e6b0db 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -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"); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index d212668a98609..ea7f4eedce3e2 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -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& diff --git a/js/src/jsapi.h b/js/src/jsapi.h index dbac59525d5e2..ec5b2c49a822e 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -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 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); diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 8ae60a52f80cd..4b56ab6dab440 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -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) diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 5108d997bf860..52b722a644300 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -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); diff --git a/js/src/proxy/Wrapper.cpp b/js/src/proxy/Wrapper.cpp index 97fadf425206c..cbdf3e23ad767 100644 --- a/js/src/proxy/Wrapper.cpp +++ b/js/src/proxy/Wrapper.cpp @@ -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()) { diff --git a/js/src/vm/CodeCoverage.cpp b/js/src/vm/CodeCoverage.cpp index 6e24c3d275e40..c8550b81fd3eb 100644 --- a/js/src/vm/CodeCoverage.cpp +++ b/js/src/vm/CodeCoverage.cpp @@ -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 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') || diff --git a/js/src/vm/JSCompartment.cpp b/js/src/vm/JSCompartment.cpp index 2cb05c8765a24..5f694a6844632 100644 --- a/js/src/vm/JSCompartment.cpp +++ b/js/src/vm/JSCompartment.cpp @@ -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); - } } } diff --git a/js/src/vm/JSCompartment.h b/js/src/vm/JSCompartment.h index 857ebc91f7d9c..2e2d5010b2abd 100644 --- a/js/src/vm/JSCompartment.h +++ b/js/src/vm/JSCompartment.h @@ -552,11 +552,10 @@ class WeakMapBase; struct JSCompartment { - protected: + private: JS::Zone* zone_; JSRuntime* runtime_; - private: js::WrapperMap crossCompartmentWrappers; using RealmVector = js::Vector; @@ -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_; } diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index e65d9a76f6e1d..aae936803c11d 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -145,7 +145,7 @@ struct JSContext : public JS::RootingContext, template 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(); } diff --git a/js/src/vm/MemoryMetrics.cpp b/js/src/vm/MemoryMetrics.cpp index 56c5fde2bfee2..d9554a26e3e3c 100644 --- a/js/src/vm/MemoryMetrics.cpp +++ b/js/src/vm/MemoryMetrics.cpp @@ -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) &realmStats.innerViewsTable, &realmStats.lazyArrayBuffersTable, &realmStats.objectMetadataTable, - &realmStats.crossCompartmentWrappersTable, &realmStats.savedStacksSet, &realmStats.varNamesSet, &realmStats.nonSyntacticLexicalScopesTable, &realmStats.jitRealm, - &realmStats.privateData, &realmStats.scriptCountsMap); } diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index fa9c0aacc9d6e..3f80ef7bc5c15 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -107,7 +107,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime) allowRelazificationForTesting(false), destroyCompartmentCallback(nullptr), sizeOfIncludingThisCompartmentCallback(nullptr), - compartmentNameCallback(nullptr), destroyRealmCallback(nullptr), realmNameCallback(nullptr), externalStringSizeofCallback(nullptr), diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index fec75795bc934..39438fd15b8ed 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -354,9 +354,6 @@ struct JSRuntime : public js::MallocProvider /* Compartment memory reporting callback. */ js::MainThreadData sizeOfIncludingThisCompartmentCallback; - /* Call this to get the name of a compartment. */ - js::MainThreadData compartmentNameCallback; - /* Realm destroy callback. */ js::MainThreadData destroyRealmCallback; diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index c3ebc086a3523..2cb025dd60002 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -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) diff --git a/js/xpconnect/idl/xpccomponents.idl b/js/xpconnect/idl/xpccomponents.idl index 6b95dba795807..38c26a5e1f3ae 100644 --- a/js/xpconnect/idl/xpccomponents.idl +++ b/js/xpconnect/idl/xpccomponents.idl @@ -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 diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 2ab8b65d3a728..3b27e847ef7db 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -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; } diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 2b0a62abf6b8f..479cad62f11a4 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -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) { + 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("", *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) { // silently ignore OOM errors - JSCompartment* c = JS::GetCompartmentForRealm(realm); Data* data = static_cast(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, 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, + 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, 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); diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 68c68f2f11983..70ea104489443 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -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 diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 110c874f5a14b..498f856901881 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2834,11 +2834,6 @@ class CompartmentPrivate CompartmentPrivate(const CompartmentPrivate&) = delete; public: - enum LocationHint { - LocationHintRegular, - LocationHintAddon - }; - explicit CompartmentPrivate(JSCompartment* c); ~CompartmentPrivate(); @@ -2911,48 +2906,6 @@ class CompartmentPrivate // by a security wrapper. See XrayWrapper.cpp. bool wrapperDenialWarnings[WrapperDenialTypeCount]; - const nsACString& GetLocation() { - if (location.IsEmpty() && locationURI) { - - nsCOMPtr 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(""); - } else if (NS_FAILED(locationURI->GetSpec(location))) { - location = NS_LITERAL_CSTRING(""); - } - } - return location; - } - bool GetLocationURI(nsIURI** aURI) { - return GetLocationURI(LocationHintRegular, aURI); - } - bool GetLocationURI(LocationHint aLocationHint, nsIURI** aURI) { - if (locationURI) { - nsCOMPtr 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 @@ class CompartmentPrivate size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); private: - nsCString location; - nsCOMPtr 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 @@ class RealmPrivate // 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 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(""); + } else if (NS_FAILED(locationURI->GetSpec(location))) { + location = NS_LITERAL_CSTRING(""); + } + } + return location; + } + bool GetLocationURI(LocationHint aLocationHint, nsIURI** aURI) { + if (locationURI) { + nsCOMPtr 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 locationURI; + + bool TryParseLocationURI(LocationHint aType, nsIURI** aURI); }; inline XPCWrappedNativeScope* diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index f5aa098bdc564..d233f50ce2455 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -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); diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 07ceb605f4841..6fff7dfb82be5 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -8369,13 +8369,10 @@ PresShell::GetCurrentItemAndPositionForElement(Element* aFocusedElement, if (cols) { nsTreeColumn* col = cols->GetFirstColumn(); if (col) { - RefPtr colElement; - col->GetElement(getter_AddRefs(colElement)); - if (colElement) { - nsIFrame* frame = colElement->GetPrimaryFrame(); - if (frame) { - extraTreeY += frame->GetSize().height; - } + RefPtr colElement = col->Element(); + nsIFrame* frame = colElement->GetPrimaryFrame(); + if (frame) { + extraTreeY += frame->GetSize().height; } } } diff --git a/layout/reftests/css-break/reftest.list b/layout/reftests/css-break/reftest.list index 00d019ee7e2a7..a6c9433bf1c71 100644 --- a/layout/reftests/css-break/reftest.list +++ b/layout/reftests/css-break/reftest.list @@ -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 diff --git a/layout/reftests/css-display/reftest.list b/layout/reftests/css-display/reftest.list index 00f83a6c0b72a..380479dea4af9 100644 --- a/layout/reftests/css-display/reftest.list +++ b/layout/reftests/css-display/reftest.list @@ -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 diff --git a/layout/reftests/font-features/reftest.list b/layout/reftests/font-features/reftest.list index 71c78557d8555..0bb8e7904b4c3 100644 --- a/layout/reftests/font-features/reftest.list +++ b/layout/reftests/font-features/reftest.list @@ -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 diff --git a/layout/reftests/font-matching/reftest.list b/layout/reftests/font-matching/reftest.list index d3595320f80b9..d83717f4b45e6 100644 --- a/layout/reftests/font-matching/reftest.list +++ b/layout/reftests/font-matching/reftest.list @@ -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 diff --git a/layout/reftests/forms/legend/reftest.list b/layout/reftests/forms/legend/reftest.list index 5f0444e002caf..245d18ab082d8 100644 --- a/layout/reftests/forms/legend/reftest.list +++ b/layout/reftests/forms/legend/reftest.list @@ -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 diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index 32c262c70b6da..828c8e25a7a77 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -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 diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index be240952851d4..e397d097e235d 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -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 diff --git a/layout/reftests/svg/smil/style/reftest.list b/layout/reftests/svg/smil/style/reftest.list index 819df0f585cc2..dcf0d2400608f 100644 --- a/layout/reftests/svg/smil/style/reftest.list +++ b/layout/reftests/svg/smil/style/reftest.list @@ -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) diff --git a/layout/reftests/w3c-css/failures.list b/layout/reftests/w3c-css/failures.list index dba7591adf2a0..d791c5e02a5dd 100644 --- a/layout/reftests/w3c-css/failures.list +++ b/layout/reftests/w3c-css/failures.list @@ -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 diff --git a/layout/reftests/w3c-css/received/reftest.list b/layout/reftests/w3c-css/received/reftest.list index 5170980644c77..476424625417d 100644 --- a/layout/reftests/w3c-css/received/reftest.list +++ b/layout/reftests/w3c-css/received/reftest.list @@ -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 diff --git a/layout/reftests/w3c-css/submitted/counter-styles-3/reftest.list b/layout/reftests/w3c-css/submitted/counter-styles-3/reftest.list index d85ef97bb2ac9..5409bba7ebe93 100644 --- a/layout/reftests/w3c-css/submitted/counter-styles-3/reftest.list +++ b/layout/reftests/w3c-css/submitted/counter-styles-3/reftest.list @@ -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 diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp index 78ce43bfc2c38..2e4c9ecb362a4 100644 --- a/layout/xul/nsXULTooltipListener.cpp +++ b/layout/xul/nsXULTooltipListener.cpp @@ -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 col; + RefPtr 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 view; aTreeBox->GetView(getter_AddRefs(view)); diff --git a/layout/xul/nsXULTooltipListener.h b/layout/xul/nsXULTooltipListener.h index 2254239ab1dc6..96d12c95a3bd9 100644 --- a/layout/xul/nsXULTooltipListener.h +++ b/layout/xul/nsXULTooltipListener.h @@ -18,7 +18,7 @@ #include "mozilla/Attributes.h" class nsIContent; -class nsITreeColumn; +class nsTreeColumn; namespace mozilla { namespace dom { @@ -99,7 +99,7 @@ class nsXULTooltipListener final : public nsIDOMEventListener bool mIsSourceTree; bool mNeedTitletip; int32_t mLastTreeRow; - nsCOMPtr mLastTreeCol; + RefPtr mLastTreeCol; #endif }; diff --git a/layout/xul/tree/TreeBoxObject.cpp b/layout/xul/tree/TreeBoxObject.cpp index f0c0fe4f31761..5c44ebea436ed 100644 --- a/layout/xul/tree/TreeBoxObject.cpp +++ b/layout/xul/tree/TreeBoxObject.cpp @@ -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 TreeBoxObject::SelectionRegion() { + nsTreeBodyFrame* body = GetTreeBodyFrame(); + if (!body) { + return nullptr; + } + nsCOMPtr 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 col; - GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(col), aRetVal.mChildElt); - aRetVal.mCol = col.forget().downcast(); + 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 col; nsAutoString childElt; - GetCellAt(x, y, &row, &col, childElt); + GetCellAt(x, y, &row, getter_AddRefs(col), childElt); JS::Rooted 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 diff --git a/layout/xul/tree/TreeBoxObject.h b/layout/xul/tree/TreeBoxObject.h index a1a76592d7820..e025f2074bcad 100644 --- a/layout/xul/tree/TreeBoxObject.h +++ b/layout/xul/tree/TreeBoxObject.h @@ -61,6 +61,14 @@ class TreeBoxObject final : public BoxObject, already_AddRefed 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 @@ class TreeBoxObject final : public BoxObject, 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 @@ class TreeBoxObject final : public BoxObject, // 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: diff --git a/layout/xul/tree/moz.build b/layout/xul/tree/moz.build index fd2553d56d2c1..cd7c400048627 100644 --- a/layout/xul/tree/moz.build +++ b/layout/xul/tree/moz.build @@ -9,7 +9,6 @@ with Files('**'): XPIDL_SOURCES += [ 'nsITreeBoxObject.idl', - 'nsITreeColumns.idl', 'nsITreeSelection.idl', 'nsITreeView.idl', ] diff --git a/layout/xul/tree/nsITreeBoxObject.idl b/layout/xul/tree/nsITreeBoxObject.idl index dd727d49e4370..47490712f79cf 100644 --- a/layout/xul/tree/nsITreeBoxObject.idl +++ b/layout/xul/tree/nsITreeBoxObject.idl @@ -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); }; diff --git a/layout/xul/tree/nsITreeColumns.idl b/layout/xul/tree/nsITreeColumns.idl deleted file mode 100644 index c2a20149873d7..0000000000000 --- a/layout/xul/tree/nsITreeColumns.idl +++ /dev/null @@ -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(); -}; diff --git a/layout/xul/tree/nsITreeSelection.idl b/layout/xul/tree/nsITreeSelection.idl index 6cc137f1ef66a..37e7f87fade8b 100644 --- a/layout/xul/tree/nsITreeSelection.idl +++ b/layout/xul/tree/nsITreeSelection.idl @@ -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 diff --git a/layout/xul/tree/nsITreeView.idl b/layout/xul/tree/nsITreeView.idl index d3c56c6488c0e..df05df2679aad 100644 --- a/layout/xul/tree/nsITreeView.idl +++ b/layout/xul/tree/nsITreeView.idl @@ -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); }; diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 3c56b995b2828..2b1c6917fe851 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -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 #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 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 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 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 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 col = GetColumnImpl(aCol); - if (!col) + if (!aCol) return NS_ERROR_INVALID_ARG; RefPtr 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 currentColumn; + RefPtr 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 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 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 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); } diff --git a/layout/xul/tree/nsTreeBodyFrame.h b/layout/xul/tree/nsTreeBodyFrame.h index 978ee14178323..ae6d75cd01a09 100644 --- a/layout/xul/tree/nsTreeBodyFrame.h +++ b/layout/xul/tree/nsTreeBodyFrame.h @@ -91,33 +91,28 @@ class nsTreeBodyFrame final 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 @@ class nsTreeBodyFrame final // 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 @@ class nsTreeBodyFrame final // 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 @@ class nsTreeBodyFrame final } public: - static - already_AddRefed GetColumnImpl(nsITreeColumn* aUnknownCol) { - if (!aUnknownCol) - return nullptr; - - nsCOMPtr 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 @@ class nsTreeBodyFrame final * been invalidated only */ void FireInvalidateEvent(int32_t aStartRow, int32_t aEndRow, - nsITreeColumn *aStartCol, nsITreeColumn *aEndCol); + nsTreeColumn *aStartCol, nsTreeColumn *aEndCol); #endif protected: // Data Members diff --git a/layout/xul/tree/nsTreeColumns.cpp b/layout/xul/tree/nsTreeColumns.cpp index faa0b3c201ebc..bdbd1c027befa 100644 --- a/layout/xul/tree/nsTreeColumns.cpp +++ b/layout/xul/tree/nsTreeColumns.cpp @@ -30,7 +30,7 @@ nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, dom::Element* aElement) kNameSpaceID_XUL), "nsTreeColumn's content must be a "); - 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 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 aGivenProto) return dom::TreeColumnBinding::Wrap(aCx, this, aGivenProto); } -mozilla::dom::Element* -nsTreeColumn::GetElement(mozilla::ErrorResult& aRv) +Element* +nsTreeColumn::Element() { - RefPtr 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) diff --git a/layout/xul/tree/nsTreeColumns.h b/layout/xul/tree/nsTreeColumns.h index 34846f3624856..333c337bb5fbf 100644 --- a/layout/xul/tree/nsTreeColumns.h +++ b/layout/xul/tree/nsTreeColumns.h @@ -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 @@ class nsTreeColumn final : public nsITreeColumn NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID) - static already_AddRefed From(nsITreeColumn* aColumn) - { - RefPtr 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 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 @@ class nsTreeColumn final : public nsITreeColumn 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; } diff --git a/layout/xul/tree/nsTreeContentView.cpp b/layout/xul/tree/nsTreeContentView.cpp index 15e17e7b273d5..cfad48643e6de 100644 --- a/layout/xul/tree/nsTreeContentView.cpp +++ b/layout/xul/tree/nsTreeContentView.cpp @@ -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 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 = aColumn.GetElement(IgnoreErrors()); + RefPtr 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 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 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 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 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 column; - aColumn.GetElement(getter_AddRefs(column)); - if (column) { - nsAutoString sort; - column->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, sort); - if (!sort.IsEmpty()) { - nsCOMPtr 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; - } + RefPtr column = aColumn.Element(); + nsAutoString sort; + column->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, sort); + if (!sort.IsEmpty()) { + nsCOMPtr 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; + nsAutoString hints; + column->GetAttr(kNameSpaceID_None, nsGkAtoms::sorthints, hints); + sortdirection.Append(' '); + sortdirection += hints; - xs->Sort(mRoot, sort, sortdirection); - } + xs->Sort(mRoot, sort, sortdirection); } } } NS_IMETHODIMP -nsTreeContentView::CycleHeader(nsITreeColumn* aCol) +nsTreeContentView::CycleHeader(nsTreeColumn* aCol) { - RefPtr 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 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 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 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 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; } diff --git a/layout/xul/tree/nsTreeImageListener.cpp b/layout/xul/tree/nsTreeImageListener.cpp index a0a93a029dc9b..ffe7ff3be562e 100644 --- a/layout/xul/tree/nsTreeImageListener.cpp +++ b/layout/xul/tree/nsTreeImageListener.cpp @@ -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), diff --git a/layout/xul/tree/nsTreeImageListener.h b/layout/xul/tree/nsTreeImageListener.h index 08379d3d644ec..ecf628434d5c9 100644 --- a/layout/xul/tree/nsTreeImageListener.h +++ b/layout/xul/tree/nsTreeImageListener.h @@ -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 @@ class nsTreeImageListener final : public imgINotificationObserver 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 @@ class nsTreeImageListener final : public imgINotificationObserver 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 mCol; + RefPtr mCol; int32_t mMin; int32_t mMax; InvalidationArea* mNext; diff --git a/layout/xul/tree/nsTreeSelection.cpp b/layout/xul/tree/nsTreeSelection.cpp index 89898e7e2a353..7b91502911ea2 100644 --- a/layout/xul/tree/nsTreeSelection.cpp +++ b/layout/xul/tree/nsTreeSelection.cpp @@ -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; diff --git a/layout/xul/tree/nsTreeSelection.h b/layout/xul/tree/nsTreeSelection.h index 9a42340ca335c..1346a3dc34a17 100644 --- a/layout/xul/tree/nsTreeSelection.h +++ b/layout/xul/tree/nsTreeSelection.h @@ -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 @@ class nsTreeSelection final : public nsINativeTreeSelection 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 mCurrentColumn; + RefPtr mCurrentColumn; int32_t mShiftSelectPivot; // Used when multiple SHIFT+selects are performed to pivot on. nsTreeRange* mFirstRange; // Our list of ranges. diff --git a/security/manager/pki/nsASN1Tree.cpp b/security/manager/pki/nsASN1Tree.cpp index 4d35e4b296b59..f72945a6426a9 100644 --- a/security/manager/pki/nsASN1Tree.cpp +++ b/security/manager/pki/nsASN1Tree.cpp @@ -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; } diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index dc635b70161fa..4c7e1102a6c8a 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -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; } diff --git a/servo/components/style/gecko_bindings/sugar/refptr.rs b/servo/components/style/gecko_bindings/sugar/refptr.rs index 76a7021ef5b06..10c9e627699c0 100644 --- a/servo/components/style/gecko_bindings/sugar/refptr.rs +++ b/servo/components/style/gecko_bindings/sugar/refptr.rs @@ -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 Send for RefPtr {} unsafe impl Sync for RefPtr {} 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!( + structs::nsStyleQuoteValues, + bindings::Gecko_AddRefQuoteValuesArbitraryThread, + bindings::Gecko_ReleaseQuoteValuesArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::nsStyleQuoteValues, - Gecko_AddRefQuoteValuesArbitraryThread, - Gecko_ReleaseQuoteValuesArbitraryThread + structs::nsCSSValueSharedList, + bindings::Gecko_AddRefCSSValueSharedListArbitraryThread, + bindings::Gecko_ReleaseCSSValueSharedListArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::nsCSSValueSharedList, - Gecko_AddRefCSSValueSharedListArbitraryThread, - Gecko_ReleaseCSSValueSharedListArbitraryThread + structs::mozilla::css::URLValue, + bindings::Gecko_AddRefCSSURLValueArbitraryThread, + bindings::Gecko_ReleaseCSSURLValueArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::mozilla::css::URLValue, - Gecko_AddRefCSSURLValueArbitraryThread, - Gecko_ReleaseCSSURLValueArbitraryThread + structs::mozilla::css::GridTemplateAreasValue, + bindings::Gecko_AddRefGridTemplateAreasValueArbitraryThread, + bindings::Gecko_ReleaseGridTemplateAreasValueArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::mozilla::css::GridTemplateAreasValue, - Gecko_AddRefGridTemplateAreasValueArbitraryThread, - Gecko_ReleaseGridTemplateAreasValueArbitraryThread + structs::ImageValue, + bindings::Gecko_AddRefImageValueArbitraryThread, + bindings::Gecko_ReleaseImageValueArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::ImageValue, - Gecko_AddRefImageValueArbitraryThread, - Gecko_ReleaseImageValueArbitraryThread + structs::SharedFontList, + bindings::Gecko_AddRefSharedFontListArbitraryThread, + bindings::Gecko_ReleaseSharedFontListArbitraryThread ); impl_threadsafe_refcount!( - ::gecko_bindings::structs::SharedFontList, - Gecko_AddRefSharedFontListArbitraryThread, - Gecko_ReleaseSharedFontListArbitraryThread + 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 ); diff --git a/servo/components/style/parser.rs b/servo/components/style/parser.rs index 1b7c65e255931..6dbfe1cfa015c 100644 --- a/servo/components/style/parser.rs +++ b/servo/components/style/parser.rs @@ -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. /// diff --git a/servo/components/style/properties/declaration_block.rs b/servo/components/style/properties/declaration_block.rs index a66058caf1efc..3cdbf61de66d7 100644 --- a/servo/components/style/properties/declaration_block.rs +++ b/servo/components/style/properties/declaration_block.rs @@ -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, diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index b4411e1ea8ba5..13d93b0a144bc 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -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; diff --git a/servo/components/style/properties/helpers.mako.rs b/servo/components/style/properties/helpers.mako.rs index d266d3e27ace1..11a1283f1cc05 100644 --- a/servo/components/style/properties/helpers.mako.rs +++ b/servo/components/style/properties/helpers.mako.rs @@ -594,7 +594,7 @@ aliases.append(alias) %> % if aliases: - #[css(aliases = "${','.join(aliases)}")] + #[parse(aliases = "${','.join(aliases)}")] % endif % endif ${to_camel_case(variant)}, diff --git a/servo/components/style/properties/properties.mako.rs b/servo/components/style/properties/properties.mako.rs index 38245b707f6cc..5133cd6ae2d76 100644 --- a/servo/components/style/properties/properties.mako.rs +++ b/servo/components/style/properties/properties.mako.rs @@ -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 { 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, + )) } }) } diff --git a/servo/components/style/stylesheets/keyframes_rule.rs b/servo/components/style/stylesheets/keyframes_rule.rs index afe797c12ff90..5f39267ac7b1c 100644 --- a/servo/components/style/stylesheets/keyframes_rule.rs +++ b/servo/components/style/stylesheets/keyframes_rule.rs @@ -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. diff --git a/servo/components/style/stylesheets/supports_rule.rs b/servo/components/style/stylesheets/supports_rule.rs index 5e2739d153dd2..f8c3235f2952f 100644 --- a/servo/components/style/stylesheets/supports_rule.rs +++ b/servo/components/style/stylesheets/supports_rule.rs @@ -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() } } diff --git a/servo/components/style/values/mod.rs b/servo/components/style/values/mod.rs index f02242e78d119..a5f8d0abd32e3 100644 --- a/servo/components/style/values/mod.rs +++ b/servo/components/style/values/mod.rs @@ -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(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( + ident: &::string_cache::Atom, + 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(value: CSSFloat, dest: &mut CssWriter) -> fmt::Result where diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 020c8112ad178..7980fb2b2e70b 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -53,9 +53,9 @@ pub enum Display { TableCaption, ListItem, None, - #[css(aliases = "-webkit-flex")] + #[parse(aliases = "-webkit-flex")] Flex, - #[css(aliases = "-webkit-inline-flex")] + #[parse(aliases = "-webkit-inline-flex")] InlineFlex, #[cfg(feature = "gecko")] Grid, @@ -84,31 +84,31 @@ pub enum Display { #[cfg(feature = "gecko")] MozInlineBox, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozGrid, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozInlineGrid, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozGridGroup, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozGridLine, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozStack, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozInlineStack, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozDeck, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozPopup, #[cfg(feature = "gecko")] - #[css(parse_condition = "moz_display_values_enabled")] + #[parse(condition = "moz_display_values_enabled")] MozGroupbox, } @@ -756,13 +756,13 @@ impl ToCss for TransitionProperty { where W: Write, { - use values::serialize_atom_identifier; + use values::serialize_atom_name; match *self { TransitionProperty::Shorthand(ref s) => s.to_css(dest), TransitionProperty::Longhand(ref l) => l.to_css(dest), TransitionProperty::Custom(ref name) => { dest.write_str("--")?; - serialize_atom_identifier(name, dest) + serialize_atom_name(name, dest) } TransitionProperty::Unsupported(ref i) => i.to_css(dest), } diff --git a/servo/components/style_derive/lib.rs b/servo/components/style_derive/lib.rs index 88f0bbadfb1e4..8c8c0705e8fd1 100644 --- a/servo/components/style_derive/lib.rs +++ b/servo/components/style_derive/lib.rs @@ -40,7 +40,7 @@ pub fn derive_to_animated_value(stream: TokenStream) -> TokenStream { to_animated_value::derive(input).into() } -#[proc_macro_derive(Parse, attributes(css))] +#[proc_macro_derive(Parse, attributes(css, parse))] pub fn derive_parse(stream: TokenStream) -> TokenStream { let input = syn::parse(stream).unwrap(); parse::derive(input).into() @@ -64,7 +64,7 @@ pub fn derive_to_css(stream: TokenStream) -> TokenStream { to_css::derive(input).into() } -#[proc_macro_derive(SpecifiedValueInfo, attributes(css, value_info))] +#[proc_macro_derive(SpecifiedValueInfo, attributes(css, parse, value_info))] pub fn derive_specified_value_info(stream: TokenStream) -> TokenStream { let input = syn::parse(stream).unwrap(); specified_value_info::derive(input).into() diff --git a/servo/components/style_derive/parse.rs b/servo/components/style_derive/parse.rs index 8b9044fb495ae..13d8aa6f48b95 100644 --- a/servo/components/style_derive/parse.rs +++ b/servo/components/style_derive/parse.rs @@ -4,10 +4,17 @@ use cg; use quote::Tokens; -use syn::DeriveInput; +use syn::{DeriveInput, Path}; use synstructure; use to_css::CssVariantAttrs; +#[darling(attributes(parse), default)] +#[derive(Default, FromVariant)] +pub struct ParseVariantAttrs { + pub aliases: Option, + pub condition: Option, +} + pub fn derive(input: DeriveInput) -> Tokens { let name = &input.ident; let s = synstructure::Structure::new(&input); @@ -20,18 +27,21 @@ pub fn derive(input: DeriveInput) -> Tokens { "Parse is only supported for single-variant enums for now" ); - let variant_attrs = cg::parse_variant_attrs_from_ast::(&variant.ast()); - if variant_attrs.skip { + let css_variant_attrs = + cg::parse_variant_attrs_from_ast::(&variant.ast()); + let parse_attrs = + cg::parse_variant_attrs_from_ast::(&variant.ast()); + if css_variant_attrs.skip { return match_body; } let identifier = cg::to_css_identifier( - &variant_attrs.keyword.unwrap_or(variant.ast().ident.as_ref().into()), + &css_variant_attrs.keyword.unwrap_or(variant.ast().ident.as_ref().into()), ); let ident = &variant.ast().ident; - saw_condition |= variant_attrs.parse_condition.is_some(); - let condition = match variant_attrs.parse_condition { + saw_condition |= parse_attrs.condition.is_some(); + let condition = match parse_attrs.condition { Some(ref p) => quote! { if #p(context) }, None => quote! { }, }; @@ -41,7 +51,7 @@ pub fn derive(input: DeriveInput) -> Tokens { #identifier #condition => Ok(#name::#ident), }; - let aliases = match variant_attrs.aliases { + let aliases = match parse_attrs.aliases { Some(aliases) => aliases, None => return body, }; diff --git a/servo/components/style_derive/specified_value_info.rs b/servo/components/style_derive/specified_value_info.rs index 7aae081641dd7..37471b041a8ca 100644 --- a/servo/components/style_derive/specified_value_info.rs +++ b/servo/components/style_derive/specified_value_info.rs @@ -6,6 +6,7 @@ use cg; use quote::Tokens; use syn::{Data, DeriveInput, Fields, Ident, Type}; use to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs}; +use parse::ParseVariantAttrs; pub fn derive(mut input: DeriveInput) -> Tokens { let css_attrs = cg::parse_input_attrs::(&input); @@ -33,10 +34,11 @@ pub fn derive(mut input: DeriveInput) -> Tokens { for v in e.variants.iter() { let css_attrs = cg::parse_variant_attrs::(&v); let info_attrs = cg::parse_variant_attrs::(&v); + let parse_attrs = cg::parse_variant_attrs::(&v); if css_attrs.skip { continue; } - if let Some(aliases) = css_attrs.aliases { + if let Some(aliases) = parse_attrs.aliases { for alias in aliases.split(",") { values.push(alias.to_string()); } diff --git a/servo/components/style_derive/to_css.rs b/servo/components/style_derive/to_css.rs index 4853f41ee5314..471cf37b6deb9 100644 --- a/servo/components/style_derive/to_css.rs +++ b/servo/components/style_derive/to_css.rs @@ -234,8 +234,6 @@ pub struct CssVariantAttrs { pub comma: bool, pub dimension: bool, pub keyword: Option, - pub aliases: Option, - pub parse_condition: Option, pub skip: bool, } diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs index f232b157cf93e..b1eaf4e086fe7 100644 --- a/servo/components/style_traits/lib.rs +++ b/servo/components/style_traits/lib.rs @@ -177,7 +177,11 @@ pub enum ValueParseErrorKind<'i> { impl<'i> StyleParseErrorKind<'i> { /// Create an InvalidValue parse error - pub fn new_invalid(name: CowRcStr<'i>, value_error: ParseError<'i>) -> ParseError<'i> { + pub fn new_invalid(name: S, value_error: ParseError<'i>) -> ParseError<'i> + where + S: Into>, + { + let name = name.into(); let variant = match value_error.kind { cssparser::ParseErrorKind::Custom(StyleParseErrorKind::ValueError(e)) => { match e { diff --git a/servo/components/style_traits/specified_value_info.rs b/servo/components/style_traits/specified_value_info.rs index d9f4578b1a8c7..e0dd5544d0a31 100644 --- a/servo/components/style_traits/specified_value_info.rs +++ b/servo/components/style_traits/specified_value_info.rs @@ -43,7 +43,7 @@ pub type KeywordsCollectFn<'a> = &'a mut FnMut(&[&'static str]); /// name is listed in `collect_completion_keywords`. /// * If `#[css(skip)]` is found, the content inside the variant or /// field is ignored. -/// * Values listed in `#[css(if_empty)]`, `#[css(aliases)]`, and +/// * Values listed in `#[css(if_empty)]`, `#[parse(aliases)]`, and /// `#[css(keyword)]` are added into `collect_completion_keywords`. /// /// In addition to `css` attributes, it also has `value_info` helper diff --git a/testing/web-platform/tests/content-security-policy/generic/policy-inherited-correctly-by-plznavigate.html b/testing/web-platform/tests/content-security-policy/generic/policy-inherited-correctly-by-plznavigate.html index e83cbaf1f35f2..e21bede418c3f 100644 --- a/testing/web-platform/tests/content-security-policy/generic/policy-inherited-correctly-by-plznavigate.html +++ b/testing/web-platform/tests/content-security-policy/generic/policy-inherited-correctly-by-plznavigate.html @@ -12,17 +12,13 @@ - - - - + diff --git a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp index 4c3b2f1b85c08..e1a727072ba39 100644 --- a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp +++ b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp @@ -110,7 +110,7 @@ URLForGlobal(JSContext* cx, JS::Handle global, nsAString& url) { * Extract a somewhat human-readable name from the current context. */ void -CompartmentName(JSContext* cx, JS::Handle global, nsAString& name) { +RealmName(JSContext* cx, JS::Handle global, nsAString& name) { // Attempt to use the URL as name. if (URLForGlobal(cx, global, name)) { return; @@ -119,7 +119,7 @@ CompartmentName(JSContext* cx, JS::Handle global, nsAString& name) { // Otherwise, fallback to XPConnect's less readable but more // complete naming scheme. nsAutoCString cname; - xpc::GetCurrentCompartmentName(cx, cname); + xpc::GetCurrentRealmName(cx, cname); name.Assign(NS_ConvertUTF8toUTF16(cname)); } @@ -1035,7 +1035,7 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, } nsAutoString name; - CompartmentName(cx, global, name); + RealmName(cx, global, name); bool isSystem = nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(global)); // Find out if the compartment is executed by a window. If so, its diff --git a/toolkit/content/widgets/tree.xml b/toolkit/content/widgets/tree.xml index f23c39805ab1e..eccede1eb3af4 100644 --- a/toolkit/content/widgets/tree.xml +++ b/toolkit/content/widgets/tree.xml @@ -336,8 +336,8 @@ return false; if (row < 0 || row >= this.view.rowCount || !column) return false; - if (column.type != Ci.nsITreeColumn.TYPE_TEXT && - column.type != Ci.nsITreeColumn.TYPE_PASSWORD) + if (column.type != window.TreeColumn.TYPE_TEXT && + column.type != window.TreeColumn.TYPE_PASSWORD) return false; if (column.cycler || !this.view.isEditable(row, column)) return false; @@ -1128,7 +1128,7 @@ if (cell.col.cycler) { view.cycleCell(cell.row, cell.col); return; - } else if (cell.col.type == Ci.nsITreeColumn.TYPE_CHECKBOX) { + } else if (cell.col.type == window.TreeColumn.TYPE_CHECKBOX) { if (this.parentNode.editable && cell.col.editable && view.isEditable(cell.row, cell.col)) { var value = view.getCellValue(cell.row, cell.col); @@ -1222,7 +1222,7 @@ // mousedown and the time we click, don't fire the select handler. // see bug #92366 if (!cell.col.cycler && this._lastSelectedRow == cell.row && - cell.col.type != Ci.nsITreeColumn.TYPE_CHECKBOX) { + cell.col.type != window.TreeColumn.TYPE_CHECKBOX) { var cellSelType = this.parentNode._cellSelType; if (cellSelType == "text" && cell.childElt != "text" && cell.childElt != "image") diff --git a/tools/profiler/core/ProfileBuffer.cpp b/tools/profiler/core/ProfileBuffer.cpp index cab34892d7958..0ebcd11ba6e16 100644 --- a/tools/profiler/core/ProfileBuffer.cpp +++ b/tools/profiler/core/ProfileBuffer.cpp @@ -130,8 +130,8 @@ static bool IsChromeJSScript(JSScript* aScript) { // WARNING: this function runs within the profiler's "critical section". - auto compartment = js::GetScriptCompartment(aScript); - return js::IsSystemCompartment(compartment); + auto realm = js::GetScriptRealm(aScript); + return js::IsSystemRealm(realm); } void