author | Narcis Beleuzu <nbeleuzu@mozilla.com> |
Tue, 15 May 2018 00:36:35 +0300 | |
changeset 472424 | a382f8feaba41f1cb1cee718f8815cd672c10f3c |
parent 472399 | 237b7b5faa03ae808f71a5cfb8f7f6920d64941f (current diff) |
parent 472423 | a5e82df2064191211edf514520e8f9aa37fe9d3d (diff) |
child 472438 | 73c2c4c8ce60283ddf16f38f91812b3ac23d506f |
child 472490 | 0c40ef091a721e32b0feb1cb3617d5286ef31a78 |
push id | 9374 |
push user | jlund@mozilla.com |
push date | Mon, 18 Jun 2018 21:43:20 +0000 |
treeherder | mozilla-beta@160e085dfb0b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | merge |
milestone | 62.0a1 |
first release with | nightly linux32
a382f8feaba4
/
62.0a1
/
20180514220126
/
files
nightly linux64
a382f8feaba4
/
62.0a1
/
20180514220126
/
files
nightly mac
a382f8feaba4
/
62.0a1
/
20180514220126
/
files
nightly win32
a382f8feaba4
/
62.0a1
/
20180514220126
/
files
nightly win64
a382f8feaba4
/
62.0a1
/
20180514220126
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
62.0a1
/
20180514220126
/
pushlog to previous
nightly linux64
62.0a1
/
20180514220126
/
pushlog to previous
nightly mac
62.0a1
/
20180514220126
/
pushlog to previous
nightly win32
62.0a1
/
20180514220126
/
pushlog to previous
nightly win64
62.0a1
/
20180514220126
/
pushlog to previous
|
--- a/accessible/generic/ARIAGridAccessible.cpp +++ b/accessible/generic/ARIAGridAccessible.cpp @@ -29,17 +29,17 @@ using namespace mozilla::a11y; ARIAGridAccessible:: ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { mGenericTypes |= eTable; } role -ARIAGridAccessible::NativeRole() +ARIAGridAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); return r != roles::NOTHING ? r : roles::TABLE; } //////////////////////////////////////////////////////////////////////////////// // Table @@ -545,17 +545,17 @@ ARIAGridAccessible::SetARIASelected(Acce ARIARowAccessible:: ARIARowAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { mGenericTypes |= eTableRow; } role -ARIARowAccessible::NativeRole() +ARIARowAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); return r != roles::NOTHING ? r : roles::ROW; } GroupPos ARIARowAccessible::GroupPosition() { @@ -582,17 +582,17 @@ ARIARowAccessible::GroupPosition() ARIAGridCellAccessible:: ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { mGenericTypes |= eTableCell; } role -ARIAGridCellAccessible::NativeRole() +ARIAGridCellAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); return r != roles::NOTHING ? r : roles::CELL; } //////////////////////////////////////////////////////////////////////////////// // TableCell
--- a/accessible/generic/ARIAGridAccessible.h +++ b/accessible/generic/ARIAGridAccessible.h @@ -20,17 +20,17 @@ class ARIAGridAccessible : public Access public TableAccessible { public: ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(ARIAGridAccessible, AccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual TableAccessible* AsTable() override { return this; } // TableAccessible virtual uint32_t ColCount() const override; virtual uint32_t RowCount() override; virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex) override; virtual bool IsColSelected(uint32_t aColIdx) override; virtual bool IsRowSelected(uint32_t aRowIdx) override; @@ -80,17 +80,17 @@ protected: class ARIARowAccessible : public AccessibleWrap { public: ARIARowAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(ARIARowAccessible, AccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual mozilla::a11y::GroupPos GroupPosition() override; protected: virtual ~ARIARowAccessible() {} }; /** @@ -101,17 +101,17 @@ class ARIAGridCellAccessible : public Hy { public: ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(ARIAGridCellAccessible, HyperTextAccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual TableCellAccessible* AsTableCell() override { return this; } virtual void ApplyARIAState(uint64_t* aState) const override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; virtual mozilla::a11y::GroupPos GroupPosition() override; protected: virtual ~ARIAGridCellAccessible() {}
--- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -316,17 +316,17 @@ Accessible::TranslateString(const nsStri nsAutoString xsValue; nsresult rv = stringBundle->GetStringFromName(NS_ConvertUTF16toUTF8(aKey).get(), xsValue); if (NS_SUCCEEDED(rv)) aStringOut.Assign(xsValue); } uint64_t -Accessible::VisibilityState() +Accessible::VisibilityState() const { nsIFrame* frame = GetFrame(); if (!frame) return states::INVISIBLE; // Walk the parent frame chain to see if there's invisible parent or the frame // is in background tab. if (!frame->StyleVisibility()->IsVisible()) @@ -1509,17 +1509,17 @@ nsAtom* Accessible::LandmarkRole() const { const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); return roleMapEntry && roleMapEntry->IsOfType(eLandmark) ? *(roleMapEntry->roleAtom) : nullptr; } role -Accessible::NativeRole() +Accessible::NativeRole() const { return roles::NOTHING; } uint8_t Accessible::ActionCount() { return GetActionRule() == eNoAction ? 0 : 1;
--- a/accessible/generic/Accessible.h +++ b/accessible/generic/Accessible.h @@ -246,17 +246,17 @@ public: * Return a landmark role if applied. */ virtual nsAtom* LandmarkRole() const; /** * Returns enumerated accessible role from native markup (see constants in * Role.h). Doesn't take into account ARIA roles. */ - virtual mozilla::a11y::role NativeRole(); + virtual mozilla::a11y::role NativeRole() const; /** * Return all states of accessible (including ARIA states). */ virtual uint64_t State(); /** * Return interactive states present on the accessible @@ -303,17 +303,17 @@ public: /** * Return native link states present on the accessible. */ virtual uint64_t NativeLinkState() const; /** * Return bit set of invisible and offscreen states. */ - uint64_t VisibilityState(); + uint64_t VisibilityState() const; /** * Return true if native unavailable state present. */ virtual bool NativelyUnavailable() const; /** * Return object attributes for the accessible.
--- a/accessible/generic/ApplicationAccessible.cpp +++ b/accessible/generic/ApplicationAccessible.cpp @@ -137,17 +137,17 @@ ApplicationAccessible::Shutdown() } void ApplicationAccessible::ApplyARIAState(uint64_t* aState) const { } role -ApplicationAccessible::NativeRole() +ApplicationAccessible::NativeRole() const { return roles::APP_ROOT; } uint64_t ApplicationAccessible::NativeState() { return 0;
--- a/accessible/generic/ApplicationAccessible.h +++ b/accessible/generic/ApplicationAccessible.h @@ -39,17 +39,17 @@ public: virtual nsIntRect Bounds() const override; virtual nsRect BoundsInAppUnits() const override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; virtual GroupPos GroupPosition() override; virtual ENameValueFlag Name(nsString& aName) override; virtual void ApplyARIAState(uint64_t* aState) const override; virtual void Description(nsString& aDescription) override; virtual void Value(nsString& aValue) override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t State() override; virtual uint64_t NativeState() override; virtual Relation RelationByType(RelationType aType) override; virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) override; virtual Accessible* FocusedChild() override;
--- a/accessible/generic/BaseAccessibles.h +++ b/accessible/generic/BaseAccessibles.h @@ -94,17 +94,17 @@ class EnumRoleAccessible : public Access public: EnumRoleAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } NS_IMETHOD QueryInterface(REFNSIID aIID, void** aPtr) override { return Accessible::QueryInterface(aIID, aPtr); } // Accessible - virtual a11y::role NativeRole() override { return R; } + virtual a11y::role NativeRole() const override { return R; } protected: virtual ~EnumRoleAccessible() { } }; /** * A wrapper accessible around native accessible to connect it with
--- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -188,17 +188,17 @@ DocAccessible::Name(nsString& aName) URL(aName); } return eNameOK; } // Accessible public method role -DocAccessible::NativeRole() +DocAccessible::NativeRole() const { nsCOMPtr<nsIDocShell> docShell = nsCoreUtils::GetDocShellFor(mDocumentNode); if (docShell) { nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot; docShell->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); int32_t itemType = docShell->ItemType(); if (sameTypeRoot == docShell) { // Root of content or chrome tree
--- a/accessible/generic/DocAccessible.h +++ b/accessible/generic/DocAccessible.h @@ -67,17 +67,17 @@ public: virtual void Shutdown() override; virtual nsIFrame* GetFrame() const override; virtual nsINode* GetNode() const override { return mDocumentNode; } nsIDocument* DocumentNode() const { return mDocumentNode; } virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) override; virtual void Description(nsString& aDescription) override; virtual Accessible* FocusedChild() override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; virtual bool NativelyUnavailable() const override; virtual void ApplyARIAState(uint64_t* aState) const override; virtual already_AddRefed<nsIPersistentProperties> Attributes() override; virtual void TakeFocus() override;
--- a/accessible/generic/FormControlAccessible.cpp +++ b/accessible/generic/FormControlAccessible.cpp @@ -20,17 +20,17 @@ using namespace mozilla::a11y; template class mozilla::a11y::ProgressMeterAccessible<1>; template class mozilla::a11y::ProgressMeterAccessible<100>; //////////////////////////////////////////////////////////////////////////////// // Accessible template<int Max> role -ProgressMeterAccessible<Max>::NativeRole() +ProgressMeterAccessible<Max>::NativeRole() const { return roles::PROGRESSBAR; } template<int Max> uint64_t ProgressMeterAccessible<Max>::NativeState() { @@ -171,17 +171,17 @@ RadioButtonAccessible::DoAction(uint8_t if (aIndex != eAction_Click) return false; DoCommand(); return true; } role -RadioButtonAccessible::NativeRole() +RadioButtonAccessible::NativeRole() const { return roles::RADIOBUTTON; } //////////////////////////////////////////////////////////////////////////////// // RadioButtonAccessible: Widgets bool
--- a/accessible/generic/FormControlAccessible.h +++ b/accessible/generic/FormControlAccessible.h @@ -24,17 +24,17 @@ public: // Ignore 'ValueChange' DOM event in lieu of @value attribute change // notifications. mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent; mType = eProgressType; } // Accessible virtual void Value(nsString& aValue) override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // Value virtual double MaxValue() const override; virtual double MinValue() const override; virtual double CurValue() const override; virtual double Step() const override; virtual bool SetCurValue(double aValue) override; @@ -51,17 +51,17 @@ protected: */ class RadioButtonAccessible : public LeafAccessible { public: RadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; enum { eAction_Click = 0 };
--- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -52,17 +52,17 @@ HyperTextAccessible:: HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) : AccessibleWrap(aNode, aDoc) { mType = eHyperTextType; mGenericTypes |= eHyperText; } role -HyperTextAccessible::NativeRole() +HyperTextAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); if (r != roles::NOTHING) return r; nsIFrame* frame = GetFrame(); if (frame && frame->IsInlineFrame()) return roles::TEXT;
--- a/accessible/generic/HyperTextAccessible.h +++ b/accessible/generic/HyperTextAccessible.h @@ -52,17 +52,17 @@ public: HyperTextAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(HyperTextAccessible, AccessibleWrap) // Accessible virtual nsAtom* LandmarkRole() const override; virtual int32_t GetLevelInternal() override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual void Shutdown() override; virtual bool RemoveChild(Accessible* aAccessible) override; virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override; virtual Relation RelationByType(RelationType aType) override; // HyperTextAccessible (static helper method)
--- a/accessible/generic/ImageAccessible.cpp +++ b/accessible/generic/ImageAccessible.cpp @@ -85,17 +85,17 @@ ImageAccessible::NativeName(nsString& aN // No accessible name but empty 'alt' attribute is present. If further name // computation algorithm doesn't provide non empty name then it means // an empty 'alt' attribute was used to indicate a decorative image (see // Accessible::Name() method for details). return hasAltAttrib ? eNoNameOnPurpose : eNameOK; } role -ImageAccessible::NativeRole() +ImageAccessible::NativeRole() const { return roles::GRAPHIC; } //////////////////////////////////////////////////////////////////////////////// // Accessible uint8_t
--- a/accessible/generic/ImageAccessible.h +++ b/accessible/generic/ImageAccessible.h @@ -17,17 +17,17 @@ namespace a11y { * - support basic state */ class ImageAccessible : public LinkableAccessible { public: ImageAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override;
--- a/accessible/generic/OuterDocAccessible.cpp +++ b/accessible/generic/OuterDocAccessible.cpp @@ -49,17 +49,17 @@ OuterDocAccessible:: OuterDocAccessible::~OuterDocAccessible() { } //////////////////////////////////////////////////////////////////////////////// // Accessible public (DON'T add methods here) role -OuterDocAccessible::NativeRole() +OuterDocAccessible::NativeRole() const { return roles::INTERNAL_FRAME; } Accessible* OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) {
--- a/accessible/generic/OuterDocAccessible.h +++ b/accessible/generic/OuterDocAccessible.h @@ -27,17 +27,17 @@ public: OuterDocAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(OuterDocAccessible, AccessibleWrap) DocAccessibleParent* RemoteChildDoc() const; // Accessible virtual void Shutdown() override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) override; virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) override; virtual bool RemoveChild(Accessible* aAccessible) override; virtual bool IsAcceptableChild(nsIContent* aEl) const override; #if defined(XP_WIN)
--- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -83,17 +83,17 @@ RootAccessible::Name(nsString& aName) return eNameOK; } mDocumentNode->GetTitle(aName); return eNameOK; } role -RootAccessible::NativeRole() +RootAccessible::NativeRole() const { // If it's a <dialog> or <wizard>, use roles::DIALOG instead dom::Element* rootElm = mDocumentNode->GetRootElement(); if (rootElm && rootElm->IsAnyOfXULElements(nsGkAtoms::dialog, nsGkAtoms::wizard)) return roles::DIALOG; return DocAccessibleWrap::NativeRole();
--- a/accessible/generic/RootAccessible.h +++ b/accessible/generic/RootAccessible.h @@ -26,17 +26,17 @@ public: // nsIDOMEventListener NS_DECL_NSIDOMEVENTLISTENER // Accessible virtual void Shutdown() override; virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) override; virtual Relation RelationByType(RelationType aType) override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // RootAccessible /** * Notify that the sub document presshell was activated. */ virtual void DocumentActivated(DocAccessible* aDocument);
--- a/accessible/generic/TextLeafAccessible.cpp +++ b/accessible/generic/TextLeafAccessible.cpp @@ -24,17 +24,17 @@ TextLeafAccessible:: mStateFlags |= eNoKidsFromDOM; } TextLeafAccessible::~TextLeafAccessible() { } role -TextLeafAccessible::NativeRole() +TextLeafAccessible::NativeRole() const { nsIFrame* frame = GetFrame(); if (frame && frame->IsGeneratedContentFrame()) return roles::STATICTEXT; return roles::TEXT_LEAF; }
--- a/accessible/generic/TextLeafAccessible.h +++ b/accessible/generic/TextLeafAccessible.h @@ -16,17 +16,17 @@ namespace a11y { */ class TextLeafAccessible : public LinkableAccessible { public: TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc); virtual ~TextLeafAccessible(); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0, uint32_t aLength = UINT32_MAX) override; virtual ENameValueFlag Name(nsString& aName) override; // TextLeafAccessible void SetText(const nsAString& aText) { mText = aText; } const nsString& Text() const { return mText; }
--- a/accessible/html/HTMLCanvasAccessible.cpp +++ b/accessible/html/HTMLCanvasAccessible.cpp @@ -11,12 +11,12 @@ using namespace mozilla::a11y; HTMLCanvasAccessible:: HTMLCanvasAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { } role -HTMLCanvasAccessible::NativeRole() +HTMLCanvasAccessible::NativeRole() const { return roles::CANVAS; }
--- a/accessible/html/HTMLCanvasAccessible.h +++ b/accessible/html/HTMLCanvasAccessible.h @@ -19,17 +19,17 @@ class HTMLCanvasAccessible : public Hype public: HTMLCanvasAccessible(nsIContent* aContent, DocAccessible* aDoc); // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLCanvasAccessible, HyperTextAccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; protected: virtual ~HTMLCanvasAccessible() { } }; } // namespace a11y } // namespace mozilla
--- a/accessible/html/HTMLElementAccessibles.cpp +++ b/accessible/html/HTMLElementAccessibles.cpp @@ -19,27 +19,27 @@ using namespace mozilla::a11y; //////////////////////////////////////////////////////////////////////////////// // HTMLHRAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLHRAccessible::NativeRole() +HTMLHRAccessible::NativeRole() const { return roles::SEPARATOR; } //////////////////////////////////////////////////////////////////////////////// // HTMLBRAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLBRAccessible::NativeRole() +HTMLBRAccessible::NativeRole() const { return roles::WHITESPACE; } uint64_t HTMLBRAccessible::NativeState() { return states::READONLY; @@ -200,17 +200,17 @@ HTMLSummaryAccessible::IsWidget() const } //////////////////////////////////////////////////////////////////////////////// // HTMLHeaderOrFooterAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLHeaderOrFooterAccessible::NativeRole() +HTMLHeaderOrFooterAccessible::NativeRole() const { // Only map header and footer if they are direct descendants of the body tag. // If other sectioning or sectioning root elements, they become sections. nsIContent* parent = mContent->GetParent(); while (parent) { if (parent->IsAnyOfHTMLElements(nsGkAtoms::article, nsGkAtoms::aside, nsGkAtoms::nav, nsGkAtoms::section, nsGkAtoms::blockquote, nsGkAtoms::details,
--- a/accessible/html/HTMLElementAccessibles.h +++ b/accessible/html/HTMLElementAccessibles.h @@ -17,34 +17,34 @@ namespace a11y { class HTMLHRAccessible : public LeafAccessible { public: HTMLHRAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) {} // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; }; /** * Used for HTML br element. */ class HTMLBRAccessible : public LeafAccessible { public: HTMLBRAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { mType = eHTMLBRType; mGenericTypes |= eText; } // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; }; /** @@ -126,17 +126,17 @@ public: HTMLHeaderOrFooterAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) {} NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLHeaderOrFooterAccessible, HyperTextAccessibleWrap) // Accessible virtual nsAtom* LandmarkRole() const override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; protected: virtual ~HTMLHeaderOrFooterAccessible() {} }; } // namespace a11y } // namespace mozilla
--- a/accessible/html/HTMLFormControlAccessible.cpp +++ b/accessible/html/HTMLFormControlAccessible.cpp @@ -35,17 +35,17 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::a11y; //////////////////////////////////////////////////////////////////////////////// // HTMLCheckboxAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLCheckboxAccessible::NativeRole() +HTMLCheckboxAccessible::NativeRole() const { return roles::CHECKBUTTON; } uint8_t HTMLCheckboxAccessible::ActionCount() { return 1; @@ -229,17 +229,17 @@ HTMLButtonAccessible::NativeState() EventStates elmState = mContent->AsElement()->State(); if (elmState.HasState(NS_EVENT_STATE_DEFAULT)) state |= states::DEFAULT; return state; } role -HTMLButtonAccessible::NativeRole() +HTMLButtonAccessible::NativeRole() const { return roles::PUSHBUTTON; } ENameValueFlag HTMLButtonAccessible::NativeName(nsString& aName) { // No need to check @value attribute for buttons since this attribute results @@ -284,17 +284,17 @@ HTMLTextFieldAccessible:: { mType = mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, nsGkAtoms::password, eIgnoreCase) ? eHTMLTextPasswordFieldType : eHTMLTextFieldType; } role -HTMLTextFieldAccessible::NativeRole() +HTMLTextFieldAccessible::NativeRole() const { if (mType == eHTMLTextPasswordFieldType) { return roles::PASSWORD_TEXT; } return roles::ENTRY; } @@ -498,17 +498,17 @@ HTMLTextFieldAccessible::ContainerWidget HTMLFileInputAccessible:: HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { mType = eHTMLFileInputType; } role -HTMLFileInputAccessible::NativeRole() +HTMLFileInputAccessible::NativeRole() const { // JAWS wants a text container, others don't mind. No specific role in // AT APIs. return roles::TEXT_CONTAINER; } nsresult HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent) @@ -538,17 +538,17 @@ HTMLFileInputAccessible::HandleAccEvent( } //////////////////////////////////////////////////////////////////////////////// // HTMLSpinnerAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLSpinnerAccessible::NativeRole() +HTMLSpinnerAccessible::NativeRole() const { return roles::SPINBUTTON; } void HTMLSpinnerAccessible::Value(nsString& aValue) { AccessibleWrap::Value(aValue); @@ -610,17 +610,17 @@ HTMLSpinnerAccessible::SetCurValue(doubl } //////////////////////////////////////////////////////////////////////////////// // HTMLRangeAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLRangeAccessible::NativeRole() +HTMLRangeAccessible::NativeRole() const { return roles::SLIDER; } bool HTMLRangeAccessible::IsWidget() const { return true; @@ -694,17 +694,17 @@ HTMLRangeAccessible::SetCurValue(double HTMLGroupboxAccessible:: HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { } role -HTMLGroupboxAccessible::NativeRole() +HTMLGroupboxAccessible::NativeRole() const { return roles::GROUPING; } nsIContent* HTMLGroupboxAccessible::GetLegend() const { for (nsIContent* legendContent = mContent->GetFirstChild(); legendContent;
--- a/accessible/html/HTMLFormControlAccessible.h +++ b/accessible/html/HTMLFormControlAccessible.h @@ -31,17 +31,17 @@ public: LeafAccessible(aContent, aDoc) { // Ignore "CheckboxStateChange" DOM event in lieu of document observer // state change notification. mStateFlags |= eIgnoreDOMUIEvent; } // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; // Widgets @@ -79,17 +79,17 @@ class HTMLButtonAccessible : public Hype { public: enum { eAction_Click = 0 }; HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t State() override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; @@ -118,17 +118,17 @@ public: HyperTextAccessibleWrap) // HyperTextAccessible virtual already_AddRefed<TextEditor> GetEditor() const override; // Accessible virtual void Value(nsString& aValue) override; virtual void ApplyARIAState(uint64_t* aState) const override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; @@ -153,17 +153,17 @@ protected: * Accessible for input@type="file" element. */ class HTMLFileInputAccessible : public HyperTextAccessibleWrap { public: HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual nsresult HandleAccEvent(AccEvent* aAccEvent) override; }; /** * Used for HTML input@type="number". */ class HTMLSpinnerAccessible : public AccessibleWrap @@ -171,17 +171,17 @@ class HTMLSpinnerAccessible : public Acc public: HTMLSpinnerAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { mStateFlags |= eHasNumericValue; } // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual void Value(nsString& aValue) override; virtual double MaxValue() const override; virtual double MinValue() const override; virtual double CurValue() const override; virtual double Step() const override; virtual bool SetCurValue(double aValue) override; }; @@ -196,17 +196,17 @@ public: HTMLRangeAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { mStateFlags |= eHasNumericValue; } // Accessible virtual void Value(nsString& aValue) override; - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; // Value virtual double MaxValue() const override; virtual double MinValue() const override; virtual double CurValue() const override; virtual double Step() const override; virtual bool SetCurValue(double aValue) override; @@ -219,17 +219,17 @@ public: * Accessible for HTML fieldset element. */ class HTMLGroupboxAccessible : public HyperTextAccessibleWrap { public: HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual Relation RelationByType(RelationType aType) override; protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; // HTMLGroupboxAccessible nsIContent* GetLegend() const;
--- a/accessible/html/HTMLImageMapAccessible.cpp +++ b/accessible/html/HTMLImageMapAccessible.cpp @@ -31,17 +31,17 @@ HTMLImageMapAccessible:: UpdateChildAreas(false); } //////////////////////////////////////////////////////////////////////////////// // HTMLImageMapAccessible: Accessible public role -HTMLImageMapAccessible::NativeRole() +HTMLImageMapAccessible::NativeRole() const { return roles::IMAGE_MAP; } //////////////////////////////////////////////////////////////////////////////// // HTMLImageMapAccessible: HyperLinkAccessible uint32_t
--- a/accessible/html/HTMLImageMapAccessible.h +++ b/accessible/html/HTMLImageMapAccessible.h @@ -20,17 +20,17 @@ class HTMLImageMapAccessible final : pub public: HTMLImageMapAccessible(nsIContent* aContent, DocAccessible* aDoc); // nsISupports and cycle collector NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLImageMapAccessible, ImageAccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; // HyperLinkAccessible virtual uint32_t AnchorCount() override; virtual Accessible* AnchorAt(uint32_t aAnchorIndex) override; virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override; /** * Update area children of the image map.
--- a/accessible/html/HTMLLinkAccessible.cpp +++ b/accessible/html/HTMLLinkAccessible.cpp @@ -26,17 +26,17 @@ HTMLLinkAccessible:: HyperTextAccessibleWrap(aContent, aDoc) { } //////////////////////////////////////////////////////////////////////////////// // nsIAccessible role -HTMLLinkAccessible::NativeRole() +HTMLLinkAccessible::NativeRole() const { return roles::LINK; } uint64_t HTMLLinkAccessible::NativeState() { return HyperTextAccessibleWrap::NativeState() & ~states::READONLY;
--- a/accessible/html/HTMLLinkAccessible.h +++ b/accessible/html/HTMLLinkAccessible.h @@ -16,17 +16,17 @@ class HTMLLinkAccessible : public HyperT public: HTMLLinkAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLinkAccessible, HyperTextAccessibleWrap) // Accessible virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeLinkState() const override; virtual uint64_t NativeInteractiveState() const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override;
--- a/accessible/html/HTMLListAccessible.cpp +++ b/accessible/html/HTMLListAccessible.cpp @@ -17,17 +17,17 @@ using namespace mozilla; using namespace mozilla::a11y; //////////////////////////////////////////////////////////////////////////////// // HTMLListAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLListAccessible::NativeRole() +HTMLListAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); return r != roles::NOTHING ? r : roles::LIST; } uint64_t HTMLListAccessible::NativeState() { @@ -57,17 +57,17 @@ void HTMLLIAccessible::Shutdown() { mBullet = nullptr; HyperTextAccessibleWrap::Shutdown(); } role -HTMLLIAccessible::NativeRole() +HTMLLIAccessible::NativeRole() const { a11y::role r = GetAccService()->MarkupRole(mContent); return r != roles::NOTHING ? r : roles::LISTITEM; } uint64_t HTMLLIAccessible::NativeState() { @@ -156,17 +156,17 @@ HTMLListBulletAccessible::Name(nsString if (blockFrame) { blockFrame->GetSpokenBulletText(aName); } return eNameOK; } role -HTMLListBulletAccessible::NativeRole() +HTMLListBulletAccessible::NativeRole() const { return roles::STATICTEXT; } uint64_t HTMLListBulletAccessible::NativeState() { return LeafAccessible::NativeState() | states::READONLY;
--- a/accessible/html/HTMLListAccessible.h +++ b/accessible/html/HTMLListAccessible.h @@ -24,17 +24,17 @@ public: HTMLListAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { mGenericTypes |= eList; } // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLListAccessible, HyperTextAccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; protected: virtual ~HTMLListAccessible() { } }; /** @@ -47,17 +47,17 @@ public: // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLIAccessible, HyperTextAccessibleWrap) // Accessible virtual void Shutdown() override; virtual nsRect BoundsInAppUnits() const override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override; // HTMLLIAccessible HTMLListBulletAccessible* Bullet() const { return mBullet; } void UpdateBullet(bool aHasBullet); @@ -76,17 +76,17 @@ class HTMLListBulletAccessible : public { public: HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc); virtual ~HTMLListBulletAccessible() { } // Accessible virtual nsIFrame* GetFrame() const override; virtual ENameValueFlag Name(nsString& aName) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0, uint32_t aLength = UINT32_MAX) override; // HTMLListBulletAccessible /** * Return true if the bullet is inside of list item element boundaries.
--- a/accessible/html/HTMLSelectAccessible.cpp +++ b/accessible/html/HTMLSelectAccessible.cpp @@ -44,17 +44,17 @@ HTMLSelectListAccessible::NativeState() uint64_t state = AccessibleWrap::NativeState(); if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) state |= states::MULTISELECTABLE | states::EXTSELECTABLE; return state; } role -HTMLSelectListAccessible::NativeRole() +HTMLSelectListAccessible::NativeRole() const { return roles::LISTBOX; } //////////////////////////////////////////////////////////////////////////////// // HTMLSelectListAccessible: SelectAccessible bool @@ -134,17 +134,17 @@ HTMLSelectOptionAccessible:: HyperTextAccessibleWrap(aContent, aDoc) { } //////////////////////////////////////////////////////////////////////////////// // HTMLSelectOptionAccessible: Accessible public role -HTMLSelectOptionAccessible::NativeRole() +HTMLSelectOptionAccessible::NativeRole() const { if (GetCombobox()) return roles::COMBOBOX_OPTION; return roles::OPTION; } ENameValueFlag @@ -301,17 +301,17 @@ HTMLSelectOptionAccessible::ContainerWid return parent && parent->IsListControl() ? parent : nullptr; } //////////////////////////////////////////////////////////////////////////////// // HTMLSelectOptGroupAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLSelectOptGroupAccessible::NativeRole() +HTMLSelectOptGroupAccessible::NativeRole() const { return roles::GROUPING; } uint64_t HTMLSelectOptGroupAccessible::NativeInteractiveState() const { return NativelyUnavailable() ? states::UNAVAILABLE : 0; @@ -363,17 +363,17 @@ HTMLComboboxAccessible:: } } } //////////////////////////////////////////////////////////////////////////////// // HTMLComboboxAccessible: Accessible role -HTMLComboboxAccessible::NativeRole() +HTMLComboboxAccessible::NativeRole() const { return roles::COMBOBOX; } bool HTMLComboboxAccessible::RemoveChild(Accessible* aChild) { MOZ_ASSERT(aChild == mListAccessible); @@ -557,17 +557,17 @@ HTMLComboboxListAccessible::GetFrame() c if (comboBox) { return comboBox->GetDropDown(); } return nullptr; } role -HTMLComboboxListAccessible::NativeRole() +HTMLComboboxListAccessible::NativeRole() const { return roles::COMBOBOX_LIST; } uint64_t HTMLComboboxListAccessible::NativeState() { // As a HTMLComboboxListAccessible we can have the following states:
--- a/accessible/html/HTMLSelectAccessible.h +++ b/accessible/html/HTMLSelectAccessible.h @@ -32,17 +32,17 @@ namespace a11y { class HTMLSelectListAccessible : public AccessibleWrap { public: HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc); virtual ~HTMLSelectListAccessible() {} // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual bool IsAcceptableChild(nsIContent* aEl) const override; // SelectAccessible virtual bool SelectAll() override; virtual bool UnselectAll() override; // Widgets @@ -60,17 +60,17 @@ class HTMLSelectOptionAccessible : publi { public: enum { eAction_Select = 0 }; HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc); virtual ~HTMLSelectOptionAccessible() {} // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; virtual int32_t GetLevelInternal() override; virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override; virtual void SetSelected(bool aSelect) override; // ActionAccessible @@ -130,17 +130,17 @@ class HTMLSelectOptGroupAccessible : pub public: HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) : HTMLSelectOptionAccessible(aContent, aDoc) { mType = eHTMLOptGroupType; } virtual ~HTMLSelectOptGroupAccessible() {} // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeInteractiveState() const override; virtual bool IsAcceptableChild(nsIContent* aEl) const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; }; @@ -161,17 +161,17 @@ public: HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc); virtual ~HTMLComboboxAccessible() {} // Accessible virtual void Shutdown() override; virtual void Description(nsString& aDescription) override; virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual bool RemoveChild(Accessible* aChild) override; virtual bool IsAcceptableChild(nsIContent* aEl) const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; @@ -203,17 +203,17 @@ class HTMLComboboxListAccessible : publi public: HTMLComboboxListAccessible(Accessible* aParent, nsIContent* aContent, DocAccessible* aDoc); virtual ~HTMLComboboxListAccessible() {} // Accessible virtual nsIFrame* GetFrame() const override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override; virtual bool IsAcceptableChild(nsIContent* aEl) const override; // Widgets virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; };
--- a/accessible/html/HTMLTableAccessible.cpp +++ b/accessible/html/HTMLTableAccessible.cpp @@ -48,17 +48,17 @@ HTMLTableCellAccessible:: mType = eHTMLTableCellType; mGenericTypes |= eTableCell; } //////////////////////////////////////////////////////////////////////////////// // HTMLTableCellAccessible: Accessible implementation role -HTMLTableCellAccessible::NativeRole() +HTMLTableCellAccessible::NativeRole() const { if (mContent->IsMathMLElement(nsGkAtoms::mtd_)) { return roles::MATHML_CELL; } return roles::CELL; } uint64_t @@ -299,17 +299,17 @@ HTMLTableHeaderCellAccessible:: HTMLTableCellAccessible(aContent, aDoc) { } //////////////////////////////////////////////////////////////////////////////// // HTMLTableHeaderCellAccessible: Accessible implementation role -HTMLTableHeaderCellAccessible::NativeRole() +HTMLTableHeaderCellAccessible::NativeRole() const { // Check value of @scope attribute. static Element::AttrValuesArray scopeValues[] = { &nsGkAtoms::col, &nsGkAtoms::colgroup, &nsGkAtoms::row, &nsGkAtoms::rowgroup, nullptr }; int32_t valueIdx = mContent->AsElement()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::scope, scopeValues, eCaseMatters); @@ -348,17 +348,17 @@ HTMLTableHeaderCellAccessible::NativeRol } //////////////////////////////////////////////////////////////////////////////// // HTMLTableRowAccessible //////////////////////////////////////////////////////////////////////////////// role -HTMLTableRowAccessible::NativeRole() +HTMLTableRowAccessible::NativeRole() const { if (mContent->IsMathMLElement(nsGkAtoms::mtr_)) { return roles::MATHML_TABLE_ROW; } else if (mContent->IsMathMLElement(nsGkAtoms::mlabeledtr_)) { return roles::MATHML_LABELED_ROW; } return roles::ROW; } @@ -390,17 +390,17 @@ HTMLTableAccessible::InsertChildAt(uint3 // Move caption accessible so that it's the first child. Check for the first // caption only, because nsAccessibilityService ensures we don't create // accessibles for the other captions, since only the first is actually // visible. return Accessible::InsertChildAt(aChild->IsHTMLCaption() ? 0 : aIndex, aChild); } role -HTMLTableAccessible::NativeRole() +HTMLTableAccessible::NativeRole() const { if (mContent->IsMathMLElement(nsGkAtoms::mtable_)) { return roles::MATHML_TABLE; } return roles::TABLE; } uint64_t @@ -1109,12 +1109,12 @@ HTMLCaptionAccessible::RelationByType(Re Relation rel = HyperTextAccessible::RelationByType(aType); if (aType == RelationType::LABEL_FOR) rel.AppendTarget(Parent()); return rel; } role -HTMLCaptionAccessible::NativeRole() +HTMLCaptionAccessible::NativeRole() const { return roles::CAPTION; }
--- a/accessible/html/HTMLTableAccessible.h +++ b/accessible/html/HTMLTableAccessible.h @@ -29,17 +29,17 @@ public: HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc); // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableCellAccessible, HyperTextAccessibleWrap) // Accessible virtual TableCellAccessible* AsTableCell() override { return this; } - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; virtual mozilla::a11y::GroupPos GroupPosition() override; // TableCellAccessible virtual TableAccessible* Table() const override; virtual uint32_t ColIdx() const override; @@ -74,17 +74,17 @@ protected: * HTML table row/column header accessible (html:th or html:td@scope). */ class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible { public: HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; }; /** * HTML table row accessible (html:tr). */ class HTMLTableRowAccessible : public AccessibleWrap { @@ -94,17 +94,17 @@ public: { mType = eHTMLTableRowType; mGenericTypes |= eTableRow; } NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableRowAccessible, AccessibleWrap) // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual mozilla::a11y::GroupPos GroupPosition() override; protected: virtual ~HTMLTableRowAccessible() { } }; /** @@ -157,17 +157,17 @@ public: virtual void UnselectCol(uint32_t aColIdx) override; virtual void UnselectRow(uint32_t aRowIdx) override; virtual bool IsProbablyLayoutTable() override; virtual Accessible* AsAccessible() override { return this; } // Accessible virtual TableAccessible* AsTable() override { return this; } virtual void Description(nsString& aDescription) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; virtual Relation RelationByType(RelationType aRelationType) override; virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override; protected: virtual ~HTMLTableAccessible() {} @@ -218,17 +218,17 @@ protected: */ class HTMLCaptionAccessible : public HyperTextAccessibleWrap { public: HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) : HyperTextAccessibleWrap(aContent, aDoc) { mType = eHTMLCaptionType; } // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual Relation RelationByType(RelationType aRelationType) override; protected: virtual ~HTMLCaptionAccessible() { } }; } // namespace a11y } // namespace mozilla
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp +++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp @@ -34,17 +34,17 @@ HTMLWin32ObjectOwnerAccessible:: void HTMLWin32ObjectOwnerAccessible::Shutdown() { AccessibleWrap::Shutdown(); mNativeAccessible = nullptr; } role -HTMLWin32ObjectOwnerAccessible::NativeRole() +HTMLWin32ObjectOwnerAccessible::NativeRole() const { return roles::EMBEDDED_OBJECT; } bool HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const { // XXX: No HWND means this is windowless plugin which is not accessible in
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.h +++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.h @@ -27,17 +27,17 @@ public: // Mozilla tree, and returns null for previous and next sibling. This would // have the effect of cutting off all content after the plugin. HTMLWin32ObjectOwnerAccessible(nsIContent* aContent, DocAccessible* aDoc, void* aHwnd); virtual ~HTMLWin32ObjectOwnerAccessible() {} // Accessible virtual void Shutdown(); - virtual mozilla::a11y::role NativeRole(); + virtual mozilla::a11y::role NativeRole() const override; virtual bool NativelyUnavailable() const; protected: void* mHwnd; RefPtr<Accessible> mNativeAccessible; }; /**
--- a/accessible/xul/XULAlertAccessible.cpp +++ b/accessible/xul/XULAlertAccessible.cpp @@ -22,17 +22,17 @@ XULAlertAccessible:: mGenericTypes |= eAlert; } XULAlertAccessible::~XULAlertAccessible() { } role -XULAlertAccessible::NativeRole() +XULAlertAccessible::NativeRole() const { return roles::ALERT; } uint64_t XULAlertAccessible::NativeState() { return Accessible::NativeState() | states::ALERT;
--- a/accessible/xul/XULAlertAccessible.h +++ b/accessible/xul/XULAlertAccessible.h @@ -19,17 +19,17 @@ class XULAlertAccessible : public Access { public: XULAlertAccessible(nsIContent* aContent, DocAccessible* aDoc); NS_INLINE_DECL_REFCOUNTING_INHERITED(XULAlertAccessible, AccessibleWrap) // Accessible virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // Widgets virtual bool IsWidget() const override; virtual Accessible* ContainerWidget() const override; protected: ~XULAlertAccessible();
--- a/accessible/xul/XULColorPickerAccessible.cpp +++ b/accessible/xul/XULColorPickerAccessible.cpp @@ -32,17 +32,17 @@ void XULColorPickerTileAccessible::Value(nsString& aValue) { aValue.Truncate(); mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue); } role -XULColorPickerTileAccessible::NativeRole() +XULColorPickerTileAccessible::NativeRole() const { return roles::PUSHBUTTON; } uint64_t XULColorPickerTileAccessible::NativeState() { uint64_t state = AccessibleWrap::NativeState(); @@ -91,17 +91,17 @@ XULColorPickerAccessible:: uint64_t XULColorPickerAccessible::NativeState() { uint64_t state = AccessibleWrap::NativeState(); return state | states::HASPOPUP; } role -XULColorPickerAccessible::NativeRole() +XULColorPickerAccessible::NativeRole() const { return roles::BUTTONDROPDOWNGRID; } //////////////////////////////////////////////////////////////////////////////// // XULColorPickerAccessible: Widgets bool
--- a/accessible/xul/XULColorPickerAccessible.h +++ b/accessible/xul/XULColorPickerAccessible.h @@ -17,17 +17,17 @@ namespace a11y { class XULColorPickerTileAccessible : public AccessibleWrap { public: XULColorPickerTileAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; // Widgets virtual Accessible* ContainerWidget() const override; }; @@ -35,17 +35,17 @@ public: * Used for colorpicker button (xul:colorpicker@type="button"). */ class XULColorPickerAccessible : public XULColorPickerTileAccessible { public: XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // Widgets virtual bool IsWidget() const override; virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; virtual bool IsAcceptableChild(nsIContent* aEl) const override;
--- a/accessible/xul/XULComboboxAccessible.cpp +++ b/accessible/xul/XULComboboxAccessible.cpp @@ -39,17 +39,17 @@ XULComboboxAccessible:: !mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::editable, nsGkAtoms::_true, eIgnoreCase)) { mStateFlags |= eNoXBLKids; } } role -XULComboboxAccessible::NativeRole() +XULComboboxAccessible::NativeRole() const { return IsAutoComplete() ? roles::AUTOCOMPLETE : roles::COMBOBOX; } uint64_t XULComboboxAccessible::NativeState() { // As a nsComboboxAccessible we can have the following states:
--- a/accessible/xul/XULComboboxAccessible.h +++ b/accessible/xul/XULComboboxAccessible.h @@ -19,17 +19,17 @@ class XULComboboxAccessible : public Acc public: enum { eAction_Click = 0 }; XULComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Description(nsString& aDescription) override; virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; // Widgets
--- a/accessible/xul/XULElementAccessibles.cpp +++ b/accessible/xul/XULElementAccessibles.cpp @@ -68,17 +68,17 @@ XULLabelAccessible::NativeName(nsString& // from the accessible text interface or from the children if (mValueTextLeaf) return mValueTextLeaf->Name(aName); return Accessible::NativeName(aName); } role -XULLabelAccessible::NativeRole() +XULLabelAccessible::NativeRole() const { return roles::LABEL; } uint64_t XULLabelAccessible::NativeState() { // Labels and description have read only state @@ -122,17 +122,17 @@ XULLabelAccessible::UpdateLabelValue(con } //////////////////////////////////////////////////////////////////////////////// // XULLabelTextLeafAccessible //////////////////////////////////////////////////////////////////////////////// role -XULLabelTextLeafAccessible::NativeRole() +XULLabelTextLeafAccessible::NativeRole() const { return roles::TEXT_LEAF; } uint64_t XULLabelTextLeafAccessible::NativeState() { return TextLeafAccessibleWrap::NativeState() | states::READONLY; @@ -151,17 +151,17 @@ XULTooltipAccessible:: uint64_t XULTooltipAccessible::NativeState() { return LeafAccessible::NativeState() | states::READONLY; } role -XULTooltipAccessible::NativeRole() +XULTooltipAccessible::NativeRole() const { return roles::TOOLTIP; } //////////////////////////////////////////////////////////////////////////////// // XULLinkAccessible //////////////////////////////////////////////////////////////////////////////// @@ -194,17 +194,17 @@ XULLinkAccessible::NativeName(nsString& if (!aName.IsEmpty()) return eNameOK; nsTextEquivUtils::GetNameFromSubtree(this, aName); return aName.IsEmpty() ? eNameOK : eNameFromSubtree; } role -XULLinkAccessible::NativeRole() +XULLinkAccessible::NativeRole() const { return roles::LINK; } uint64_t XULLinkAccessible::NativeLinkState() const {
--- a/accessible/xul/XULElementAccessibles.h +++ b/accessible/xul/XULElementAccessibles.h @@ -19,17 +19,17 @@ class XULLabelTextLeafAccessible; */ class XULLabelAccessible : public HyperTextAccessibleWrap { public: XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Shutdown() override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual Relation RelationByType(RelationType aType) override; void UpdateLabelValue(const nsString& aValue); protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; @@ -54,44 +54,44 @@ class XULLabelTextLeafAccessible final : public: XULLabelTextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc) : TextLeafAccessibleWrap(aContent, aDoc) { mStateFlags |= eSharedNode; } virtual ~XULLabelTextLeafAccessible() { } // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; }; /** * Used for XUL tooltip element. */ class XULTooltipAccessible : public LeafAccessible { public: XULTooltipAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; }; class XULLinkAccessible : public XULLabelAccessible { public: XULLinkAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeLinkState() const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; // HyperLinkAccessible
--- a/accessible/xul/XULFormControlAccessible.cpp +++ b/accessible/xul/XULFormControlAccessible.cpp @@ -77,17 +77,17 @@ XULButtonAccessible::DoAction(uint8_t aI DoCommand(); return true; } //////////////////////////////////////////////////////////////////////////////// // XULButtonAccessible: Accessible role -XULButtonAccessible::NativeRole() +XULButtonAccessible::NativeRole() const { return roles::PUSHBUTTON; } uint64_t XULButtonAccessible::NativeState() { // Possible states: focused, focusable, unavailable(disabled). @@ -259,17 +259,17 @@ XULDropmarkerAccessible::DoAction(uint8_ if (index == eAction_Click) { DropmarkerOpen(true); // Reverse the open attribute return true; } return false; } role -XULDropmarkerAccessible::NativeRole() +XULDropmarkerAccessible::NativeRole() const { return roles::PUSHBUTTON; } uint64_t XULDropmarkerAccessible::NativeState() { return DropmarkerOpen(false) ? states::PRESSED : 0; @@ -281,17 +281,17 @@ XULDropmarkerAccessible::NativeState() XULCheckboxAccessible:: XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { } role -XULCheckboxAccessible::NativeRole() +XULCheckboxAccessible::NativeRole() const { return roles::CHECKBUTTON; } uint8_t XULCheckboxAccessible::ActionCount() { return 1; @@ -347,17 +347,17 @@ XULCheckboxAccessible::NativeState() XULGroupboxAccessible:: XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } role -XULGroupboxAccessible::NativeRole() +XULGroupboxAccessible::NativeRole() const { return roles::GROUPING; } ENameValueFlag XULGroupboxAccessible::NativeName(nsString& aName) { // XXX: we use the first related accessible only. @@ -457,17 +457,17 @@ XULRadioButtonAccessible::ContainerWidge XULRadioGroupAccessible:: XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) : XULSelectControlAccessible(aContent, aDoc) { } role -XULRadioGroupAccessible::NativeRole() +XULRadioGroupAccessible::NativeRole() const { return roles::RADIO_GROUP; } uint64_t XULRadioGroupAccessible::NativeInteractiveState() const { // The radio group is not focusable. Sometimes the focus controller will @@ -504,17 +504,17 @@ XULRadioGroupAccessible::AreItemsOperabl XULStatusBarAccessible:: XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } role -XULStatusBarAccessible::NativeRole() +XULStatusBarAccessible::NativeRole() const { return roles::STATUSBAR; } //////////////////////////////////////////////////////////////////////////////// // XULToolbarButtonAccessible //////////////////////////////////////////////////////////////////////////////// @@ -573,17 +573,17 @@ XULToolbarButtonAccessible::IsSeparator( XULToolbarAccessible:: XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } role -XULToolbarAccessible::NativeRole() +XULToolbarAccessible::NativeRole() const { return roles::TOOLBAR; } ENameValueFlag XULToolbarAccessible::NativeName(nsString& aName) { if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, aName)) @@ -599,17 +599,17 @@ XULToolbarAccessible::NativeName(nsStrin XULToolbarSeparatorAccessible:: XULToolbarSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { } role -XULToolbarSeparatorAccessible::NativeRole() +XULToolbarSeparatorAccessible::NativeRole() const { return roles::SEPARATOR; } uint64_t XULToolbarSeparatorAccessible::NativeState() { return 0;
--- a/accessible/xul/XULFormControlAccessible.h +++ b/accessible/xul/XULFormControlAccessible.h @@ -31,17 +31,17 @@ class XULButtonAccessible : public Acces public: enum { eAction_Click = 0 }; XULButtonAccessible(nsIContent* aContent, DocAccessible* aDoc); // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(XULButtonAccessible, AccessibleWrap) // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; // Widgets @@ -65,17 +65,17 @@ protected: */ class XULCheckboxAccessible : public LeafAccessible { public: enum { eAction_Click = 0 }; XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; }; @@ -84,17 +84,17 @@ public: */ class XULDropmarkerAccessible : public LeafAccessible { public: enum { eAction_Click = 0 }; XULDropmarkerAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; private: @@ -105,17 +105,17 @@ private: * Used for XUL groupbox element. */ class XULGroupboxAccessible final : public AccessibleWrap { public: XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual Relation RelationByType(RelationType aType) override; protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; }; /** @@ -139,17 +139,17 @@ public: * Used for XUL radiogroup element. */ class XULRadioGroupAccessible : public XULSelectControlAccessible { public: XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeInteractiveState() const override; // Widgets virtual bool IsWidget() const override; virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; }; @@ -157,17 +157,17 @@ public: * Used for XUL statusbar element. */ class XULStatusBarAccessible : public AccessibleWrap { public: XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; }; /** * Used for XUL toolbarbutton element. */ class XULToolbarButtonAccessible : public XULButtonAccessible { public: @@ -185,34 +185,34 @@ public: * Used for XUL toolbar element. */ class XULToolbarAccessible : public AccessibleWrap { public: XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; }; /** * Used for XUL toolbarseparator element. */ class XULToolbarSeparatorAccessible : public LeafAccessible { public: XULToolbarSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual mozilla::a11y::role NativeRole() override; + virtual mozilla::a11y::role NativeRole() const override; virtual uint64_t NativeState() override; }; } // namespace a11y } // namespace mozilla #endif
--- a/accessible/xul/XULListboxAccessible.cpp +++ b/accessible/xul/XULListboxAccessible.cpp @@ -30,17 +30,17 @@ using namespace mozilla::a11y; XULColumAccessible:: XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } role -XULColumAccessible::NativeRole() +XULColumAccessible::NativeRole() const { return roles::LIST; } uint64_t XULColumAccessible::NativeState() { return states::READONLY; @@ -53,17 +53,17 @@ XULColumAccessible::NativeState() XULColumnItemAccessible:: XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { } role -XULColumnItemAccessible::NativeRole() +XULColumnItemAccessible::NativeRole() const { return roles::COLUMNHEADER; } uint64_t XULColumnItemAccessible::NativeState() { return states::READONLY; @@ -147,17 +147,17 @@ XULListboxAccessible::Value(nsString& aV nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem; select->GetSelectedItem(getter_AddRefs(selectedItem)); if (selectedItem) selectedItem->GetLabel(aValue); } } role -XULListboxAccessible::NativeRole() +XULListboxAccessible::NativeRole() const { // A richlistbox is used with the new autocomplete URL bar, and has a parent // popup <panel>. if (mContent->GetParent() && mContent->GetParent()->IsXULElement(nsGkAtoms::panel)) return roles::COMBOBOX_LIST; return IsMulticolumn() ? roles::TABLE : roles::LISTBOX; } @@ -587,17 +587,17 @@ XULListitemAccessible::NativeName(nsStri return eNameOK; } } return Accessible::NativeName(aName); } role -XULListitemAccessible::NativeRole() +XULListitemAccessible::NativeRole() const { Accessible* list = GetListAccessible(); if (!list) { NS_ERROR("No list accessible for listitem accessible!"); return roles::NOTHING; } if (list->Role() == roles::TABLE) @@ -779,17 +779,17 @@ XULListCellAccessible::Selected() return table->IsRowSelected(RowIdx()); } //////////////////////////////////////////////////////////////////////////////// // XULListCellAccessible. Accessible implementation role -XULListCellAccessible::NativeRole() +XULListCellAccessible::NativeRole() const { return roles::CELL; } already_AddRefed<nsIPersistentProperties> XULListCellAccessible::NativeAttributes() { nsCOMPtr<nsIPersistentProperties> attributes =
--- a/accessible/xul/XULListboxAccessible.h +++ b/accessible/xul/XULListboxAccessible.h @@ -22,31 +22,31 @@ namespace a11y { * (xul:treecols and xul:listcols). */ class XULColumAccessible : public AccessibleWrap { public: XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; }; /** * XULColumnItemAccessible are accessibles for list and tree column elements * (xul:listcol and xul:treecol). */ class XULColumnItemAccessible : public LeafAccessible { public: XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; enum { eAction_Click = 0 }; @@ -77,17 +77,17 @@ public: virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override; virtual void SelectRow(uint32_t aRowIdx) override; virtual void UnselectRow(uint32_t aRowIdx) override; virtual Accessible* AsAccessible() override { return this; } // Accessible virtual void Value(nsString& aValue) override; virtual TableAccessible* AsTable() override { return this; } - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // Widgets virtual bool IsWidget() const override; virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; virtual Accessible* ContainerWidget() const override; @@ -108,17 +108,17 @@ public: NS_INLINE_DECL_REFCOUNTING_INHERITED(XULListitemAccessible, XULMenuitemAccessible) XULListitemAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Description(nsString& aDesc) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; // Actions virtual void ActionNameAt(uint8_t index, nsAString& aName) override; // Widgets virtual Accessible* ContainerWidget() const override; @@ -151,17 +151,17 @@ public: // nsISupports NS_INLINE_DECL_REFCOUNTING_INHERITED(XULListCellAccessible, HyperTextAccessibleWrap) // Accessible virtual TableCellAccessible* AsTableCell() override { return this; } virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; // TableCellAccessible virtual TableAccessible* Table() const override; virtual uint32_t ColIdx() const override; virtual uint32_t RowIdx() const override; virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) override; virtual bool Selected() override;
--- a/accessible/xul/XULMenuAccessible.cpp +++ b/accessible/xul/XULMenuAccessible.cpp @@ -237,17 +237,17 @@ XULMenuitemAccessible::KeyboardShortcut( if (modifiersStr.Find("accel") != -1) { modifierMask |= KeyBinding::AccelModifier(); } return KeyBinding(key, modifierMask); } role -XULMenuitemAccessible::NativeRole() +XULMenuitemAccessible::NativeRole() const { nsCOMPtr<nsIDOMXULContainerElement> xulContainer(do_QueryInterface(mContent)); if (xulContainer) return roles::PARENT_MENUITEM; if (mParent && mParent->Role() == roles::COMBOBOX_LIST) return roles::COMBOBOX_OPTION; @@ -363,17 +363,17 @@ XULMenuSeparatorAccessible::NativeState( ENameValueFlag XULMenuSeparatorAccessible::NativeName(nsString& aName) { return eNameOK; } role -XULMenuSeparatorAccessible::NativeRole() +XULMenuSeparatorAccessible::NativeRole() const { return roles::SEPARATOR; } bool XULMenuSeparatorAccessible::DoAction(uint8_t index) { return false; @@ -449,17 +449,17 @@ XULMenupopupAccessible::NativeName(nsStr } content = content->GetFlattenedTreeParent(); } return eNameOK; } role -XULMenupopupAccessible::NativeRole() +XULMenupopupAccessible::NativeRole() const { // If accessible is not bound to the tree (this happens while children are // cached) return general role. if (mParent) { if (mParent->IsCombobox() || mParent->IsAutoComplete()) return roles::COMBOBOX_LIST; if (mParent->Role() == roles::PUSHBUTTON) { @@ -546,17 +546,17 @@ XULMenubarAccessible:: ENameValueFlag XULMenubarAccessible::NativeName(nsString& aName) { aName.AssignLiteral("Application"); return eNameOK; } role -XULMenubarAccessible::NativeRole() +XULMenubarAccessible::NativeRole() const { return roles::MENUBAR; } //////////////////////////////////////////////////////////////////////////////// // XULMenubarAccessible: Widgets bool
--- a/accessible/xul/XULMenuAccessible.h +++ b/accessible/xul/XULMenuAccessible.h @@ -20,17 +20,17 @@ class XULMenuitemAccessible : public Acc { public: enum { eAction_Click = 0 }; XULMenuitemAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Description(nsString& aDescription) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; virtual int32_t GetLevelInternal() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; @@ -51,17 +51,17 @@ protected: * Used for XUL menuseparator element. */ class XULMenuSeparatorAccessible : public XULMenuitemAccessible { public: XULMenuSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; protected: @@ -74,17 +74,17 @@ protected: * Used for XUL menupopup and panel. */ class XULMenupopupAccessible : public XULSelectControlAccessible { public: XULMenupopupAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; // Widgets virtual bool IsWidget() const override; virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; virtual Accessible* ContainerWidget() const override; @@ -98,17 +98,17 @@ protected: * Used for XUL menubar element. */ class XULMenubarAccessible : public AccessibleWrap { public: XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; // Widget virtual bool IsActiveWidget() const override; virtual bool AreItemsOperable() const override; virtual Accessible* CurrentItem() override; virtual void SetCurrentItem(Accessible* aItem) override; protected:
--- a/accessible/xul/XULSliderAccessible.cpp +++ b/accessible/xul/XULSliderAccessible.cpp @@ -25,17 +25,17 @@ XULSliderAccessible:: AccessibleWrap(aContent, aDoc) { mStateFlags |= eHasNumericValue | eNoXBLKids; } // Accessible role -XULSliderAccessible::NativeRole() +XULSliderAccessible::NativeRole() const { return roles::SLIDER; } uint64_t XULSliderAccessible::NativeInteractiveState() const { if (NativelyUnavailable()) @@ -202,15 +202,15 @@ XULThumbAccessible:: AccessibleWrap(aContent, aDoc) { } //////////////////////////////////////////////////////////////////////////////// // XULThumbAccessible: Accessible role -XULThumbAccessible::NativeRole() +XULThumbAccessible::NativeRole() const { return roles::INDICATOR; } } }
--- a/accessible/xul/XULSliderAccessible.h +++ b/accessible/xul/XULSliderAccessible.h @@ -16,17 +16,17 @@ namespace a11y { */ class XULSliderAccessible : public AccessibleWrap { public: XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeInteractiveState() const override; virtual bool NativelyUnavailable() const override; // Value virtual double MaxValue() const override; virtual double MinValue() const override; virtual double CurValue() const override; virtual double Step() const override; @@ -58,16 +58,16 @@ private: * Used for slider's thumb element. */ class XULThumbAccessible : public AccessibleWrap { public: XULThumbAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; }; } // namespace a11y } // namespace mozilla #endif
--- a/accessible/xul/XULTabAccessible.cpp +++ b/accessible/xul/XULTabAccessible.cpp @@ -60,17 +60,17 @@ XULTabAccessible::DoAction(uint8_t index } return false; } //////////////////////////////////////////////////////////////////////////////// // XULTabAccessible: Accessible role -XULTabAccessible::NativeRole() +XULTabAccessible::NativeRole() const { return roles::PAGETAB; } uint64_t XULTabAccessible::NativeState() { // Possible states: focused, focusable, unavailable(disabled), offscreen. @@ -132,17 +132,17 @@ XULTabAccessible::RelationByType(Relatio XULTabsAccessible:: XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc) : XULSelectControlAccessible(aContent, aDoc) { } role -XULTabsAccessible::NativeRole() +XULTabsAccessible::NativeRole() const { return roles::PAGETABLIST; } uint8_t XULTabsAccessible::ActionCount() { return 0; @@ -162,33 +162,33 @@ XULTabsAccessible::NativeName(nsString& } //////////////////////////////////////////////////////////////////////////////// // XULTabpanelsAccessible //////////////////////////////////////////////////////////////////////////////// role -XULTabpanelsAccessible::NativeRole() +XULTabpanelsAccessible::NativeRole() const { return roles::PANE; } //////////////////////////////////////////////////////////////////////////////// // XULTabpanelAccessible //////////////////////////////////////////////////////////////////////////////// XULTabpanelAccessible:: XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { } role -XULTabpanelAccessible::NativeRole() +XULTabpanelAccessible::NativeRole() const { return roles::PROPERTYPAGE; } Relation XULTabpanelAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType);
--- a/accessible/xul/XULTabAccessible.h +++ b/accessible/xul/XULTabAccessible.h @@ -20,17 +20,17 @@ namespace a11y { class XULTabAccessible : public HyperTextAccessibleWrap { public: enum { eAction_Switch = 0 }; XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; virtual Relation RelationByType(RelationType aType) override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override; @@ -42,17 +42,17 @@ public: */ class XULTabsAccessible : public XULSelectControlAccessible { public: XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; // ActionAccessible virtual uint8_t ActionCount() override; protected: // Accessible virtual ENameValueFlag NativeName(nsString& aName) override; }; @@ -64,34 +64,34 @@ protected: class XULTabpanelsAccessible : public AccessibleWrap { public: XULTabpanelsAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { mType = eXULTabpanelsType; } // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; }; /** * A tabpanel object, child elements of xul:tabpanels element. * * XXX: we need to move the class logic into generic class since * for example we do not create instance of this class for XUL textbox used as * a tabpanel. */ class XULTabpanelAccessible : public AccessibleWrap { public: XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc); // Accessible - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual Relation RelationByType(RelationType aType) override; }; } // namespace a11y } // namespace mozilla #endif
--- a/accessible/xul/XULTreeAccessible.cpp +++ b/accessible/xul/XULTreeAccessible.cpp @@ -148,17 +148,17 @@ XULTreeAccessible::Shutdown() mTree = nullptr; mTreeView = nullptr; AccessibleWrap::Shutdown(); } role -XULTreeAccessible::NativeRole() +XULTreeAccessible::NativeRole() const { // No primary column means we're in a list. In fact, history and mail turn off // the primary flag when switching to a flat view. nsIContent* child = nsTreeUtils::GetDescendantChild(mContent, nsGkAtoms::treechildren); NS_ASSERTION(child, "tree without treechildren!"); nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame()); NS_ASSERTION(treeFrame, "xul tree accessible for tree without a frame!"); @@ -1113,17 +1113,17 @@ XULTreeItemAccessible::Name(nsString& aN void XULTreeItemAccessible::Shutdown() { mColumn = nullptr; XULTreeItemAccessibleBase::Shutdown(); } role -XULTreeItemAccessible::NativeRole() +XULTreeItemAccessible::NativeRole() const { nsCOMPtr<nsITreeColumns> columns; mTree->GetColumns(getter_AddRefs(columns)); if (!columns) { NS_ERROR("No tree columns object in the tree!"); return roles::NOTHING; }
--- a/accessible/xul/XULTreeAccessible.h +++ b/accessible/xul/XULTreeAccessible.h @@ -36,17 +36,17 @@ public: // nsISupports and cycle collection NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeAccessible, Accessible) // Accessible virtual void Shutdown() override; virtual void Value(nsString& aValue) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) override; virtual Accessible* GetChildAt(uint32_t aIndex) const override; virtual uint32_t ChildCount() const override; virtual Relation RelationByType(RelationType aType) override; @@ -230,17 +230,17 @@ public: // nsISupports and cycle collection NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessible, XULTreeItemAccessibleBase) // Accessible virtual void Shutdown() override; virtual ENameValueFlag Name(nsString& aName) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; // XULTreeItemAccessibleBase virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) override; protected: virtual ~XULTreeItemAccessible(); // XULTreeItemAccessible
--- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -204,17 +204,17 @@ XULTreeGridAccessible::UnselectRow(uint3 if (selection) selection->ClearRange(aRowIdx, aRowIdx); } //////////////////////////////////////////////////////////////////////////////// // XULTreeGridAccessible: Accessible implementation role -XULTreeGridAccessible::NativeRole() +XULTreeGridAccessible::NativeRole() const { nsCOMPtr<nsITreeColumns> treeColumns; mTree->GetColumns(getter_AddRefs(treeColumns)); if (!treeColumns) { NS_ERROR("No treecolumns object for tree!"); return roles::NOTHING; } @@ -282,17 +282,17 @@ XULTreeGridRowAccessible::Shutdown() if (mDoc && !mDoc->IsDefunct()) { UnbindCacheEntriesFromDocument(mAccessibleCache); } XULTreeItemAccessibleBase::Shutdown(); } role -XULTreeGridRowAccessible::NativeRole() +XULTreeGridRowAccessible::NativeRole() const { return roles::ROW; } ENameValueFlag XULTreeGridRowAccessible::Name(nsString& aName) { aName.Truncate(); @@ -677,17 +677,17 @@ XULTreeGridCellAccessible::NativeAttribu if (NS_SUCCEEDED(rv) && isCycler) nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles, NS_LITERAL_STRING("true")); return attributes.forget(); } role -XULTreeGridCellAccessible::NativeRole() +XULTreeGridCellAccessible::NativeRole() const { return roles::GRID_CELL; } uint64_t XULTreeGridCellAccessible::NativeState() { if (!mTreeView)
--- a/accessible/xul/XULTreeGridAccessible.h +++ b/accessible/xul/XULTreeGridAccessible.h @@ -45,17 +45,17 @@ public: virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override; virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override; virtual void SelectRow(uint32_t aRowIdx) override; virtual void UnselectRow(uint32_t aRowIdx) override; virtual Accessible* AsAccessible() override { return this; } // Accessible virtual TableAccessible* AsTable() override { return this; } - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; protected: virtual ~XULTreeGridAccessible(); // XULTreeAccessible virtual already_AddRefed<Accessible> CreateTreeItemAccessible(int32_t aRow) const override; }; @@ -76,17 +76,17 @@ public: // nsISupports and cycle collection NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridRowAccessible, XULTreeItemAccessibleBase) // Accessible virtual void Shutdown() override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual ENameValueFlag Name(nsString& aName) override; virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) override; virtual Accessible* GetChildAt(uint32_t aIndex) const override; virtual uint32_t ChildCount() const override; // XULTreeItemAccessibleBase @@ -128,17 +128,17 @@ public: virtual TableCellAccessible* AsTableCell() override { return this; } virtual nsRect BoundsInAppUnits() const override; virtual nsIntRect BoundsInCSSPixels() const override; virtual ENameValueFlag Name(nsString& aName) override; virtual Accessible* FocusedChild() override; virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; virtual int32_t IndexInParent() const override; virtual Relation RelationByType(RelationType aType) override; - virtual a11y::role NativeRole() override; + virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() override; virtual uint64_t NativeInteractiveState() const override; // ActionAccessible virtual uint8_t ActionCount() override; virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; virtual bool DoAction(uint8_t aIndex) override;
--- a/devtools/client/debugger/new/README.mozilla +++ b/devtools/client/debugger/new/README.mozilla @@ -1,13 +1,13 @@ This is the debugger.html project output. See https://github.com/devtools-html/debugger.html -Version 50 +Version 52 -Comparison: https://github.com/devtools-html/debugger.html/compare/release-49...release-50 +Comparison: https://github.com/devtools-html/debugger.html/compare/release-51...release-52 Packages: - babel-plugin-transform-es2015-modules-commonjs @6.26.2 - babel-preset-react @6.24.1 - react @16.2.0 - react-dom @16.2.0 - webpack @3.11.0
--- a/devtools/client/debugger/new/dist/debugger.css +++ b/devtools/client/debugger/new/dist/debugger.css @@ -968,106 +968,103 @@ img.close::before { } .search-shadow.focused { box-shadow: var(--theme-focus-box-shadow-textbox); } .search-field { position: relative; - + height: 27px; width: calc(100% - 1px); background-color: var(--theme-toolbar-background); border-bottom: 1px solid var(--theme-splitter-color); - padding: 5px 10px; + padding-right: 10px; display: flex; flex-shrink: 0; } .search-field.big { + padding: 5px 10px; height: 40px; } .search-field i { display: block; padding: 0; width: 16px; } .search-field i svg { + width: 16px; +} + +.search-field.big i svg { width: 22px; } -.search-field.big input { - line-height: 40px; -} - .search-field input { - position: relative; - margin-left: 30px; border: none; line-height: 30px; background-color: var(--theme-toolbar-background); color: var(--theme-body-color-active); width: calc(100% - 38px); flex: 1; +} + +.search-field.big input { + position: relative; + margin-left: 30px; font-size: 14px; + line-height: 40px; } .search-field input:focus { outline: none; } .theme-dark .search-field input { color: var(--theme-body-color-inactive); } .search-field i.magnifying-glass, .search-field i.sad-face { - position: absolute; - top: 50%; - padding: 2px 0; + padding: 6px; width: 24px; - margin-top: -12px; -} - -.search-field i.sad-face { - padding-top: 1px; } .search-field.big i.magnifying-glass, .search-field.big i.sad-face { - padding: 14px; + position: absolute; width: 40px; - margin-top: -20px; } .search-field .magnifying-glass path, .search-field .magnifying-glass ellipse { stroke: var(--theme-comment); } .search-field input::placeholder { color: var(--theme-toolbar-color); } .search-field input.empty { color: var(--theme-highlight-orange); } -.search-field.big .summary { - line-height: 40px; -} - .search-field .summary { line-height: 27px; padding-right: 10px; color: var(--theme-body-color-inactive); } +.search-field.big .summary { + line-height: 40px; +} + .search-field .search-nav-buttons { display: flex; user-select: none; } .search-field .search-nav-buttons .nav-btn { display: flex; height: 100%; @@ -1864,17 +1861,17 @@ html .toggle-button.end.vertical svg { } .search-bar .search-field { padding-left: 7px; height: var(--editor-searchbar-height); } .search-field .close-btn { - margin-top: 12px; + align-self: center; } .search-bottom-bar * { -moz-user-select: none; user-select: none; } .search-bottom-bar { @@ -2913,16 +2910,17 @@ debug-expression-error { } .breakpoints-list .breakpoint-heading, .breakpoints-list .breakpoint { font-size: 12px; color: var(--theme-content-color1); position: relative; transition: all 0.25s ease; + cursor: pointer; } .breakpoints-list .breakpoint-heading, .breakpoints-list .breakpoint, .breakpoints-exceptions { padding: 0.25em 1em; } @@ -3082,17 +3080,17 @@ html[dir="rtl"] .breakpoints-list .break visibility: hidden; } .breakpoint:hover .close { visibility: visible; } .CodeMirror.cm-s-mozilla-breakpoint { - cursor: default; + cursor: pointer; } .CodeMirror.cm-s-mozilla-breakpoint .CodeMirror-lines { padding: 0; } .CodeMirror.cm-s-mozilla-breakpoint .CodeMirror-sizer { min-width: initial !important;
--- a/devtools/client/debugger/new/dist/parser-worker.js +++ b/devtools/client/debugger/new/dist/parser-worker.js @@ -24740,16 +24740,20 @@ const isReturn = node => t.isReturnState const isCall = node => t.isCallExpression(node) || t.isJSXElement(node); const inStepExpression = parent => t.isArrayExpression(parent) || t.isObjectProperty(parent) || t.isCallExpression(parent) || t.isJSXElement(parent); const inExpression = (parent, grandParent) => inStepExpression(parent) || t.isJSXAttribute(grandParent) || t.isTemplateLiteral(parent); const isExport = node => t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node); +function getStartLine(node) { + return node.loc.start.line; +} + function getPausePoints(sourceId) { const state = {}; (0, _ast.traverseAst)(sourceId, { enter: onEnter }, state); return state; } /* eslint-disable complexity */ function onEnter(node, ancestors, state) { @@ -24776,20 +24780,22 @@ function onEnter(node, ancestors, state) return; } if (t.isBlockStatement(node)) { return addEmptyPoint(state, startLocation); } if (isReturn(node)) { - // We do not want to pause at the return and the call e.g. return foo() - if (isCall(node.argument)) { + // We do not want to pause at the return if the + // argument is a call on the same line e.g. return foo() + if (isCall(node.argument) && getStartLine(node) == getStartLine(node.argument)) { return addEmptyPoint(state, startLocation); } + return addStopPoint(state, startLocation); } if (isAssignment(node)) { // We only want to pause at literal assignments `var a = foo()` const value = node.right || node.init; if (isCall(value) || t.isFunction(parentNode)) {
--- a/devtools/client/debugger/new/src/actions/ast.js +++ b/devtools/client/debugger/new/src/actions/ast.js @@ -107,21 +107,22 @@ function setPausePoints(sourceId) { client }) => { const source = (0, _selectors.getSource)(getState(), sourceId); if (!_prefs.features.pausePoints || !source || !source.text || source.isWasm) { return; } - const pausePoints = await (0, _parser.getPausePoints)(source.id); + const pausePoints = await (0, _parser.getPausePoints)(sourceId); - if ((0, _devtoolsSourceMap.isGeneratedId)(source.id)) { - await client.setPausePoints(source.id, pausePoints); + if ((0, _devtoolsSourceMap.isGeneratedId)(sourceId)) { + await client.setPausePoints(sourceId, pausePoints); } dispatch({ type: "SET_PAUSE_POINTS", - source: source.toJS(), + sourceText: source.text, + sourceId, pausePoints }); }; } \ No newline at end of file
--- a/devtools/client/debugger/new/src/actions/pause/breakOnNext.js +++ b/devtools/client/debugger/new/src/actions/pause/breakOnNext.js @@ -13,19 +13,18 @@ exports.breakOnNext = breakOnNext; * Debugger breakOnNext command. * It's different from the comand action because we also want to * highlight the pause icon. * * @memberof actions/pause * @static */ function breakOnNext() { - return ({ + return async ({ dispatch, client }) => { - client.breakOnNext(); + await client.breakOnNext(); return dispatch({ - type: "BREAK_ON_NEXT", - value: true + type: "BREAK_ON_NEXT" }); }; } \ No newline at end of file
--- a/devtools/client/debugger/new/src/actions/pause/index.js +++ b/devtools/client/debugger/new/src/actions/pause/index.js @@ -137,16 +137,25 @@ var _pauseOnExceptions = require("./paus Object.defineProperty(exports, "pauseOnExceptions", { enumerable: true, get: function () { return _pauseOnExceptions.pauseOnExceptions; } }); +var _selectComponent = require("./selectComponent"); + +Object.defineProperty(exports, "selectComponent", { + enumerable: true, + get: function () { + return _selectComponent.selectComponent; + } +}); + var _selectFrame = require("./selectFrame"); Object.defineProperty(exports, "selectFrame", { enumerable: true, get: function () { return _selectFrame.selectFrame; } });
--- a/devtools/client/debugger/new/src/actions/pause/moz.build +++ b/devtools/client/debugger/new/src/actions/pause/moz.build @@ -14,12 +14,13 @@ DevToolsModules( 'extra.js', 'fetchScopes.js', 'index.js', 'mapFrames.js', 'mapScopes.js', 'paused.js', 'pauseOnExceptions.js', 'resumed.js', + 'selectComponent.js', 'selectFrame.js', 'setPopupObjectProperties.js', 'skipPausing.js', )
new file mode 100644 --- /dev/null +++ b/devtools/client/debugger/new/src/actions/pause/selectComponent.js @@ -0,0 +1,20 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.selectComponent = selectComponent; + +/* 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/>. */ +function selectComponent(componentIndex) { + return async ({ + dispatch + }) => { + dispatch({ + type: "SELECT_COMPONENT", + componentIndex + }); + }; +} \ No newline at end of file
--- a/devtools/client/debugger/new/src/actions/sources/select.js +++ b/devtools/client/debugger/new/src/actions/sources/select.js @@ -113,17 +113,17 @@ function selectLocation(location) { const activeSearch = (0, _selectors.getActiveSearch)(getState()); if (activeSearch !== "file") { dispatch((0, _ui.closeActiveSearch)()); } const source = sourceRecord.toJS(); - dispatch((0, _tabs.addTab)(source, 0)); + dispatch((0, _tabs.addTab)(source.url, 0)); dispatch({ type: "SELECT_SOURCE", source, location }); await dispatch((0, _loadSourceText.loadSourceText)(sourceRecord)); const selectedSource = (0, _selectors.getSelectedSource)(getState());
--- a/devtools/client/debugger/new/src/actions/sources/tabs.js +++ b/devtools/client/debugger/new/src/actions/sources/tabs.js @@ -17,20 +17,20 @@ var _selectors = require("../../selector /* 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/>. */ /** * Redux actions for the sources state * @module actions/sources */ -function addTab(source, tabIndex) { +function addTab(url, tabIndex) { return { type: "ADD_TAB", - source, + url, tabIndex }; } function moveTab(url, tabIndex) { return { type: "MOVE_TAB", url,
--- a/devtools/client/debugger/new/src/components/QuickOpenModal.js +++ b/devtools/client/debugger/new/src/components/QuickOpenModal.js @@ -431,29 +431,32 @@ class QuickOpenModal extends _react.Comp } const newResults = results && results.slice(0, 100); const items = this.highlightMatching(query, newResults || []); const expanded = !!items && items.length > 0; return _react2.default.createElement(_Modal2.default, { "in": enabled, handleClose: this.closeModal - }, _react2.default.createElement(_SearchInput2.default, { + }, _react2.default.createElement(_SearchInput2.default, _extends({ query: query, hasPrefix: true, count: this.getResultCount(), placeholder: L10N.getStr("sourceSearch.search"), summaryMsg: "", showErrorEmoji: this.shouldShowErrorEmoji(), onChange: this.onChange, onKeyDown: this.onKeyDown, handleClose: this.closeModal, expanded: expanded, + showClose: false, selectedItemId: expanded && items[selectedIndex] ? items[selectedIndex].id : "" - }), this.renderLoading(), newResults && _react2.default.createElement(_ResultList2.default, _extends({ + }, this.isSourceSearch() ? { + size: "big" + } : {})), this.renderLoading(), newResults && _react2.default.createElement(_ResultList2.default, _extends({ key: "results", items: items, selected: selectedIndex, selectItem: this.selectResultItem, ref: "resultList", expanded: expanded }, this.isSourceSearch() ? { size: "big"
--- a/devtools/client/debugger/new/src/components/SecondaryPanes/ReactComponentStack.js +++ b/devtools/client/debugger/new/src/components/SecondaryPanes/ReactComponentStack.js @@ -9,34 +9,51 @@ var _react = require("devtools/client/sh var _react2 = _interopRequireDefault(_react); var _reactRedux = require("devtools/client/shared/vendor/react-redux"); var _actions = require("../../actions/index"); var _actions2 = _interopRequireDefault(_actions); +var _classnames = require("devtools/client/debugger/new/dist/vendors").vendored["classnames"]; + +var _classnames2 = _interopRequireDefault(_classnames); + var _selectors = require("../../selectors/index"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* 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/>. */ class ReactComponentStack extends _react.PureComponent { + onMouseDown(e, componentIndex) { + if (e.nativeEvent.which == 3) { + return; + } + + this.props.selectComponent(componentIndex); + } + render() { const { componentStack } = this.props.extra.react; return _react2.default.createElement("div", { className: "pane frames" }, _react2.default.createElement("ul", null, componentStack.slice().reverse().map((component, index) => _react2.default.createElement("li", { - key: index + className: (0, _classnames2.default)("frame", { + selected: this.props.selectedComponentIndex === index + }), + key: index, + onMouseDown: e => this.onMouseDown(e, index) }, component)))); } } const mapStateToProps = state => ({ - extra: (0, _selectors.getExtra)(state) + extra: (0, _selectors.getExtra)(state), + selectedComponentIndex: (0, _selectors.getSelectedComponentIndex)(state) }); exports.default = (0, _reactRedux.connect)(mapStateToProps, _actions2.default)(ReactComponentStack); \ No newline at end of file
--- a/devtools/client/debugger/new/src/components/moz.build +++ b/devtools/client/debugger/new/src/components/moz.build @@ -3,17 +3,16 @@ # 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/. DIRS += [ 'Editor', 'PrimaryPanes', 'SecondaryPanes', 'shared', - 'test', ] DevToolsModules( 'App.js', 'ProjectSearch.js', 'QuickOpenModal.js', 'ShortcutsModal.js', 'WelcomeBox.js',
--- a/devtools/client/debugger/new/src/components/shared/SearchInput.js +++ b/devtools/client/debugger/new/src/components/shared/SearchInput.js @@ -136,17 +136,18 @@ class SearchInput extends _react.Compone onChange, onKeyDown, onKeyUp, placeholder, query, selectedItemId, showErrorEmoji, size, - summaryMsg + summaryMsg, + showClose } = this.props; const inputProps = { className: (0, _classnames2.default)({ empty: showErrorEmoji }), onChange, onKeyDown, onKeyUp, @@ -167,23 +168,24 @@ class SearchInput extends _react.Compone }, _react2.default.createElement("div", { className: (0, _classnames2.default)("search-field", size), role: "combobox", "aria-haspopup": "listbox", "aria-owns": "result-list", "aria-expanded": expanded }, this.renderSvg(), _react2.default.createElement("input", inputProps), summaryMsg && _react2.default.createElement("div", { className: "summary" - }, summaryMsg), this.renderNav(), _react2.default.createElement(_Close2.default, { + }, summaryMsg), this.renderNav(), showClose && _react2.default.createElement(_Close2.default, { handleClick: handleClose, buttonClass: size }))); } } SearchInput.defaultProps = { expanded: false, hasPrefix: false, selectedItemId: "", - size: "" + size: "", + showClose: true }; exports.default = SearchInput; \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/Outline.spec.js +++ /dev/null @@ -1,316 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _Outline = require("../../components/PrimaryPanes/Outline"); - -var _Outline2 = _interopRequireDefault(_Outline); - -var _testHead = require("../../utils/test-head"); - -var _devtoolsContextmenu = require("devtools/client/debugger/new/dist/vendors").vendored["devtools-contextmenu"]; - -var _clipboard = require("../../utils/clipboard"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -jest.mock("devtools-contextmenu", () => ({ - showMenu: jest.fn() -})); -jest.mock("../../utils/clipboard", () => ({ - copyToTheClipboard: jest.fn() -})); -const sourceId = "id"; -const mockFunctionText = "mock function text"; - -function generateDefaults(overrides) { - return _objectSpread({ - selectLocation: jest.genMockFunction(), - selectedSource: { - get: () => sourceId - }, - getFunctionText: jest.fn().mockReturnValue(mockFunctionText), - flashLineRange: jest.fn(), - isHidden: false, - symbols: {}, - selectedLocation: { - sourceId: sourceId - }, - onAlphabetizeClick: jest.fn() - }, overrides); -} - -function render(overrides = {}) { - const props = generateDefaults(overrides); - const component = (0, _enzyme.shallow)(_react2.default.createElement(_Outline2.default.WrappedComponent, props)); - const instance = component.instance(); - return { - component, - props, - instance - }; -} - -describe("Outline", () => { - afterEach(() => { - _clipboard.copyToTheClipboard.mockClear(); - - _devtoolsContextmenu.showMenu.mockClear(); - }); - it("renders a list of functions when properties change", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("my_example_function1", 21), (0, _testHead.makeSymbolDeclaration)("my_example_function2", 22)] - }; - const { - component - } = render({ - symbols - }); - expect(component).toMatchSnapshot(); - }); - it("selects a line of code in the current file on click", async () => { - const startLine = 12; - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("my_example_function", startLine)] - }; - const { - component, - props - } = render({ - symbols - }); - const { - selectLocation - } = props; - const listItem = component.find("li").first(); - listItem.simulate("click"); - expect(selectLocation).toHaveBeenCalledWith({ - line: startLine, - sourceId - }); - }); - describe("renders outline", () => { - describe("renders loading", () => { - it("if symbols is not defined", () => { - const { - component - } = render({ - symbols: null - }); - expect(component).toMatchSnapshot(); - }); - it("if symbols are loading", () => { - const { - component - } = render({ - symbols: { - loading: true - } - }); - expect(component).toMatchSnapshot(); - }); - }); - it("renders ignore anonymous functions", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("my_example_function1", 21), (0, _testHead.makeSymbolDeclaration)("anonymous", 25)] - }; - const { - component - } = render({ - symbols - }); - expect(component).toMatchSnapshot(); - }); - describe("renders placeholder", () => { - it("`No File Selected` if selectedSource is not defined", async () => { - const { - component - } = render({ - selectedSource: null - }); - expect(component).toMatchSnapshot(); - }); - it("`No functions` if all func are anonymous", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("anonymous", 25), (0, _testHead.makeSymbolDeclaration)("anonymous", 30)] - }; - const { - component - } = render({ - symbols - }); - expect(component).toMatchSnapshot(); - }); - it("`No functions` if symbols has no func", async () => { - const symbols = { - functions: [] - }; - const { - component - } = render({ - symbols - }); - expect(component).toMatchSnapshot(); - }); - }); - it("sorts functions alphabetically by function name", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("c_function", 25), (0, _testHead.makeSymbolDeclaration)("x_function", 30), (0, _testHead.makeSymbolDeclaration)("a_function", 70)] - }; - const { - component - } = render({ - symbols: symbols, - alphabetizeOutline: true - }); - expect(component).toMatchSnapshot(); - }); - it("calls onAlphabetizeClick when sort button is clicked", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("example_function", 25)] - }; - const { - component, - props - } = render({ - symbols - }); - await component.find(".outline-footer").find("button").simulate("click", {}); - expect(props.onAlphabetizeClick).toHaveBeenCalled(); - }); - it("renders functions by function class", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("x_function", 25, 26, "x_klass"), (0, _testHead.makeSymbolDeclaration)("a2_function", 30, 31, "a_klass"), (0, _testHead.makeSymbolDeclaration)("a1_function", 70, 71, "a_klass")], - classes: [(0, _testHead.makeSymbolDeclaration)("x_klass", 24, 27), (0, _testHead.makeSymbolDeclaration)("a_klass", 29, 72)] - }; - const { - component - } = render({ - symbols: symbols - }); - expect(component).toMatchSnapshot(); - }); - it("renders functions by function class, alphabetically", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("x_function", 25, 26, "x_klass"), (0, _testHead.makeSymbolDeclaration)("a2_function", 30, 31, "a_klass"), (0, _testHead.makeSymbolDeclaration)("a1_function", 70, 71, "a_klass")], - classes: [(0, _testHead.makeSymbolDeclaration)("x_klass", 24, 27), (0, _testHead.makeSymbolDeclaration)("a_klass", 29, 72)] - }; - const { - component - } = render({ - symbols: symbols, - alphabetizeOutline: true - }); - expect(component).toMatchSnapshot(); - }); - it("selects class on click on class headline", async () => { - const symbols = { - functions: [(0, _testHead.makeSymbolDeclaration)("x_function", 25, 26, "x_klass")], - classes: [(0, _testHead.makeSymbolDeclaration)("x_klass", 24, 27)] - }; - const { - component, - props - } = render({ - symbols: symbols - }); - await component.find("h2").simulate("click", {}); - expect(props.selectLocation).toHaveBeenCalledWith({ - line: 24, - sourceId: sourceId - }); - }); - it("does not select an item if selectedSource is not defined", async () => { - const { - instance, - props - } = render({ - selectedSource: null - }); - await instance.selectItem({}); - expect(props.selectLocation).not.toHaveBeenCalled(); - }); - }); - describe("onContextMenu of Outline", () => { - it("is called onContextMenu for each item", async () => { - const event = { - event: "oncontextmenu" - }; - const fn = (0, _testHead.makeSymbolDeclaration)("exmple_function", 2); - const symbols = { - functions: [fn] - }; - const { - component, - instance - } = render({ - symbols - }); - instance.onContextMenu = jest.fn(() => {}); - await component.find(".outline-list__element").simulate("contextmenu", event); - expect(instance.onContextMenu).toHaveBeenCalledWith(event, fn); - }); - it("does not show menu with no selected source", async () => { - const mockEvent = { - preventDefault: jest.fn(), - stopPropagation: jest.fn() - }; - const { - instance - } = render({ - selectedSource: null - }); - await instance.onContextMenu(mockEvent, {}); - expect(mockEvent.preventDefault).toHaveBeenCalled(); - expect(mockEvent.stopPropagation).toHaveBeenCalled(); - expect(_devtoolsContextmenu.showMenu).not.toHaveBeenCalled(); - }); - it("shows menu to copy func, copies to clipboard on click", async () => { - const startLine = 12; - const endLine = 21; - const func = (0, _testHead.makeSymbolDeclaration)("my_example_function", startLine, endLine); - const symbols = { - functions: [func] - }; - const mockEvent = { - preventDefault: jest.fn(), - stopPropagation: jest.fn() - }; - const { - instance, - props - } = render({ - symbols - }); - await instance.onContextMenu(mockEvent, func); - expect(mockEvent.preventDefault).toHaveBeenCalled(); - expect(mockEvent.stopPropagation).toHaveBeenCalled(); - const expectedMenuOptions = [{ - accesskey: "F", - click: expect.any(Function), - disabled: false, - id: "node-menu-copy-function", - label: "Copy function" - }]; - expect(props.getFunctionText).toHaveBeenCalledWith(12); - expect(_devtoolsContextmenu.showMenu).toHaveBeenCalledWith(mockEvent, expectedMenuOptions); - - _devtoolsContextmenu.showMenu.mock.calls[0][1][0].click(); - - expect(_clipboard.copyToTheClipboard).toHaveBeenCalledWith(mockFunctionText); - expect(props.flashLineRange).toHaveBeenCalledWith({ - end: endLine, - sourceId: sourceId, - start: startLine - }); - }); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/ProjectSearch.spec.js +++ /dev/null @@ -1,248 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _immutable = require("devtools/client/shared/vendor/immutable"); - -var _ProjectSearch = require("../ProjectSearch"); - -var _projectTextSearch = require("../../reducers/project-text-search"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -const hooks = { - on: [], - off: [] -}; -const shortcuts = { - dispatch(eventName) { - hooks.on.forEach(hook => { - if (hook.event === eventName) { - hook.cb(); - } - }); - hooks.off.forEach(hook => { - if (hook.event === eventName) { - hook.cb(); - } - }); - }, - - on: jest.fn((event, cb) => hooks.on.push({ - event, - cb - })), - off: jest.fn((event, cb) => hooks.off.push({ - event, - cb - })) -}; -const context = { - shortcuts -}; -const testResults = (0, _immutable.List)([{ - filepath: "testFilePath1", - matches: [{ - match: "match1", - value: "some thing match1", - column: 30 - }, { - match: "match2", - value: "some thing match2", - column: 60 - }, { - match: "match3", - value: "some thing match3", - column: 90 - }] -}, { - filepath: "testFilePath2", - matches: [{ - match: "match4", - value: "some thing match4", - column: 80 - }, { - match: "match5", - value: "some thing match5", - column: 40 - }] -}]); -const testMatch = { - match: "match1", - value: "some thing match1", - column: 30 -}; - -function render(overrides = {}, mounted = false) { - const props = _objectSpread({ - status: "DONE", - sources: {}, - results: (0, _immutable.List)([]), - query: "foo", - activeSearch: "project", - closeProjectSearch: jest.fn(), - searchSources: jest.fn(), - clearSearch: jest.fn(), - updateSearchStatus: jest.fn(), - selectLocation: jest.fn(), - doSearchForHighlight: jest.fn() - }, overrides); - - return mounted ? (0, _enzyme.mount)(_react2.default.createElement(_ProjectSearch.ProjectSearch, props), { - context - }) : (0, _enzyme.shallow)(_react2.default.createElement(_ProjectSearch.ProjectSearch, props), { - context - }); -} - -describe("ProjectSearch", () => { - beforeEach(() => { - context.shortcuts.on.mockClear(); - context.shortcuts.off.mockClear(); - }); - it("renders nothing when disabled", () => { - const component = render({ - activeSearch: null - }); - expect(component).toMatchSnapshot(); - }); - it("where <Enter> has not been pressed", () => { - const component = render({ - query: "" - }); - expect(component).toMatchSnapshot(); - }); - it("found no search results", () => { - const component = render(); - expect(component).toMatchSnapshot(); - }); - it("should display loading message while search is in progress", () => { - const component = render({ - query: "match", - status: _projectTextSearch.statusType.fetching - }); - expect(component).toMatchSnapshot(); - }); - it("found search results", () => { - const component = render({ - query: "match", - results: testResults - }, true); - expect(component).toMatchSnapshot(); - }); - it("turns off shortcuts on unmount", () => { - const component = render({ - query: "" - }); - expect(component).toMatchSnapshot(); - component.unmount(); - expect(context.shortcuts.off).toHaveBeenCalled(); - }); - it("calls inputOnChange", () => { - const component = render({ - results: testResults - }, true); - component.find("SearchInput input").simulate("change", { - target: { - value: "bar" - } - }); - expect(component.state().inputValue).toEqual("bar"); - }); - it("onKeyDown Escape/Other", () => { - const searchSources = jest.fn(); - const component = render({ - results: testResults, - searchSources - }, true); - component.find("SearchInput input").simulate("keydown", { - key: "Escape" - }); - expect(searchSources).not.toHaveBeenCalled(); - searchSources.mockClear(); - component.find("SearchInput input").simulate("keydown", { - key: "Other", - stopPropagation: jest.fn() - }); - expect(searchSources).not.toHaveBeenCalled(); - }); - it("onKeyDown Enter", () => { - const searchSources = jest.fn(); - const component = render({ - results: testResults, - searchSources - }, true); - component.find("SearchInput input").simulate("keydown", { - key: "Enter", - stopPropagation: jest.fn() - }); - expect(searchSources).toHaveBeenCalledWith("foo"); - }); - it("onEnterPress shortcut no match or setExpanded", () => { - const selectLocation = jest.fn(); - const component = render({ - results: testResults, - selectLocation - }, true); - component.instance().focusedItem = {}; - shortcuts.dispatch("Enter"); - expect(selectLocation).not.toHaveBeenCalled(); - }); - it("onEnterPress shortcut match", () => { - const selectLocation = jest.fn(); - const component = render({ - results: testResults, - selectLocation - }, true); - component.instance().focusedItem = { - match: testMatch - }; - shortcuts.dispatch("Enter"); - expect(selectLocation).toHaveBeenCalledWith(testMatch); - }); - it("onEnterPress shortcut setExpanded", () => { - const selectLocation = jest.fn(); - const component = render({ - results: testResults, - selectLocation - }, true); - const setExpanded = jest.fn(); - const testFile = { - filepath: "testFilePath1", - matches: [testMatch] - }; - component.instance().focusedItem = { - setExpanded, - file: testFile, - expanded: true - }; - shortcuts.dispatch("Enter"); - expect(setExpanded).toHaveBeenCalledWith(testFile, false); - }); - describe("showErrorEmoji", () => { - it("false if not done & results", () => { - const component = render({ - status: _projectTextSearch.statusType.fetching, - results: testResults - }); - expect(component).toMatchSnapshot(); - }); - it("false if not done & no results", () => { - const component = render({ - status: _projectTextSearch.statusType.fetching - }); - expect(component).toMatchSnapshot(); - }); // "false if done & has results" - // is the same test as "found search results" - // "true if done & has no results" - // is the same test as "found no search results" - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/QuickOpenModal.spec.js +++ /dev/null @@ -1,277 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _QuickOpenModal = require("../QuickOpenModal"); - -var _fuzzaldrinPlus = require("devtools/client/debugger/new/dist/vendors").vendored["fuzzaldrin-plus"]; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -jest.mock("fuzzaldrin-plus"); - -function generateModal(propOverrides, renderType = "shallow") { - const props = _objectSpread({ - enabled: false, - query: "", - searchType: "sources", - sources: [], - tabs: [], - selectLocation: jest.fn(), - setQuickOpenQuery: jest.fn(), - highlightLineRange: jest.fn(), - clearHighlightLineRange: jest.fn(), - closeQuickOpen: jest.fn() - }, propOverrides); - - return { - wrapper: renderType === "shallow" ? (0, _enzyme.shallow)(_react2.default.createElement(_QuickOpenModal.QuickOpenModal, props)) : (0, _enzyme.mount)(_react2.default.createElement(_QuickOpenModal.QuickOpenModal, props)), - props - }; -} - -describe("QuickOpenModal", () => { - beforeEach(() => { - _fuzzaldrinPlus.filter.mockClear(); - }); - test("Doesn't render when disabled", () => { - const { - wrapper - } = generateModal(); - expect(wrapper).toMatchSnapshot(); - }); - test("Renders when enabled", () => { - const { - wrapper - } = generateModal({ - enabled: true - }); - expect(wrapper).toMatchSnapshot(); - }); - test("Basic render with mount", () => { - const { - wrapper - } = generateModal({ - enabled: true - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - test("Basic render with mount & searchType = functions", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "@", - searchType: "functions", - symbols: { - functions: [], - variables: [] - } - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - test("Ensure anonymous functions do not render in QuickOpenModal", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "@", - searchType: "functions", - symbols: { - functions: [{ - title: "anonymous" - }, { - title: "c" - }, { - title: "anonymous" - }], - variables: [] - } - }, "mount"); - expect(wrapper.find("ResultList")).toHaveLength(1); - expect(wrapper.find("li")).toHaveLength(1); - }); - test("Basic render with mount & searchType = variables", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "#", - searchType: "variables", - symbols: { - functions: [], - variables: [] - } - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - test("Basic render with mount & searchType = shortcuts", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "?", - searchType: "shortcuts", - symbols: { - functions: [], - variables: [] - } - }, "mount"); - expect(wrapper.find("ResultList")).toHaveLength(1); - expect(wrapper.find("li")).toHaveLength(3); - }); - test("updateResults on enable", () => { - const { - wrapper - } = generateModal({}, "mount"); - expect(wrapper).toMatchSnapshot(); - wrapper.setProps({ - enabled: true - }); - expect(wrapper).toMatchSnapshot(); - }); - test("basic source search", () => { - const { - wrapper - } = generateModal({ - enabled: true, - symbols: { - functions: [], - variables: [] - } - }, "mount"); - wrapper.find("input").simulate("change", { - target: { - value: "somefil" - } - }); - expect(_fuzzaldrinPlus.filter).toHaveBeenCalledWith([], "somefil", { - key: "value", - maxResults: 1000 - }); - }); - test("basic gotoSource search", () => { - const { - wrapper - } = generateModal({ - enabled: true, - searchType: "gotoSource", - symbols: { - functions: [], - variables: [] - } - }, "mount"); - wrapper.find("input").simulate("change", { - target: { - value: "somefil:33" - } - }); - expect(_fuzzaldrinPlus.filter).toHaveBeenCalledWith([], "somefil", { - key: "value", - maxResults: 1000 - }); - }); - test("basic symbol seach", () => { - const { - wrapper - } = generateModal({ - enabled: true, - searchType: "functions", - symbols: { - functions: [], - variables: [] - }, - // symbol searching relies on a source being selected. - // So we dummy out the source and the API. - selectedSource: { - get: jest.fn(() => true) - } - }, "mount"); - wrapper.find("input").simulate("change", { - target: { - value: "@someFunc" - } - }); - expect(_fuzzaldrinPlus.filter).toHaveBeenCalledWith([], "someFunc", { - key: "value", - maxResults: 1000 - }); - }); - test("Simple goto search query = :abc & searchType = goto", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: ":abc", - searchType: "goto", - symbols: { - functions: [], - variables: [] - } - }, "mount"); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.state().results).toEqual(null); - }); - describe("showErrorEmoji", () => { - it("true when no count + query", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "test", - searchType: "" - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - it("false when count + query", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "dasdasdas" - }, "mount"); - wrapper.setState(() => ({ - results: [1, 2] - })); - expect(wrapper).toMatchSnapshot(); - }); - it("false when no query", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: "", - searchType: "" - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - it("false when goto numeric ':2222'", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: ":2222", - searchType: "goto" - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - it("true when goto not numeric ':22k22'", () => { - const { - wrapper - } = generateModal({ - enabled: true, - query: ":22k22", - searchType: "goto" - }, "mount"); - expect(wrapper).toMatchSnapshot(); - }); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/ShortcutsModal.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _ShortcutsModal = require("../ShortcutsModal"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* 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/>. */ -describe("ShortcutsModal", () => { - it("renders when enabled", () => { - const enabled = true; - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ShortcutsModal.ShortcutsModal, { - enabled: enabled - })); - expect(wrapper).toMatchSnapshot(); - }); - it("renders nothing when not enabled", () => { - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ShortcutsModal.ShortcutsModal, null)); - expect(wrapper.text()).toBe(""); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/SourcesTree.spec.js +++ /dev/null @@ -1,639 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _SourcesTree = require("../../components/PrimaryPanes/SourcesTree"); - -var _SourcesTree2 = _interopRequireDefault(_SourcesTree); - -var _immutable = require("devtools/client/shared/vendor/immutable"); - -var I = _interopRequireWildcard(_immutable); - -var _devtoolsContextmenu = require("devtools/client/debugger/new/dist/vendors").vendored["devtools-contextmenu"]; - -var _clipboard = require("../../utils/clipboard"); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -jest.mock("devtools-contextmenu", () => ({ - showMenu: jest.fn() -})); -jest.mock("../../utils/clipboard", () => ({ - copyToTheClipboard: jest.fn() -})); -describe("SourcesTree", () => { - afterEach(() => { - _clipboard.copyToTheClipboard.mockClear(); - - _devtoolsContextmenu.showMenu.mockClear(); - }); - it("Should show the tree with nothing expanded", async () => { - const { - component - } = render(); - expect(component).toMatchSnapshot(); - }); - describe("When loading initial source", () => { - it("Shows the tree with one.js, two.js and three.js expanded", async () => { - const { - component, - props - } = render(); - await component.setProps(_objectSpread({}, props, { - expanded: ["one.js", "two.js", "three.js"] - })); - expect(component).toMatchSnapshot(); - }); - }); - describe("After changing expanded nodes", () => { - it("Shows the tree with four.js, five.js and six.js expanded", async () => { - const { - component, - props - } = render(); - await component.setProps(_objectSpread({}, props, { - expanded: ["four.js", "five.js", "six.js"] - })); - expect(component).toMatchSnapshot(); - }); - }); - describe("on receiving new props", () => { - describe("recreates tree", () => { - it("does not recreate tree if no new source is added", async () => { - const { - component, - props, - defaultState - } = render(); - const mockSource = I.Map({ - "server1.conn13.child1/41": createMockSource("server1.conn13.child1/41", "http://mdn.com/three.js") - }); - await component.setProps(_objectSpread({}, props, { - sources: mockSource - })); - expect(component.state("uncollapsedTree")).toEqual(defaultState.uncollapsedTree); - }); - it("updates tree with a new item", async () => { - const { - component, - props - } = render(); - const sources = props.sources.merge({ - "server1.conn13.child1/42": createMockSource("server1.conn13.child1/42", "http://mdn.com/four.js") - }); - await component.setProps(_objectSpread({}, props, { - sources: sources - })); - expect(component.state("uncollapsedTree").contents[0].contents).toHaveLength(4); - }); - it("updates sources if sources are emptied", async () => { - const { - component, - props, - defaultState - } = render(); - expect(defaultState.uncollapsedTree.contents).toHaveLength(1); - await component.setProps(_objectSpread({}, props, { - sources: I.Map({}) - })); - expect(component.state("uncollapsedTree").contents).toHaveLength(0); - }); - it("recreates tree if projectRoot is changed", async () => { - const { - component, - props, - defaultState - } = render(); - const sources = I.Map({ - "server1.conn13.child1/41": createMockSource("server1.conn13.child1/41", "http://mozilla.com/three.js") - }); - expect(defaultState.uncollapsedTree.contents[0].contents).toHaveLength(3); - await component.setProps(_objectSpread({}, props, { - sources: sources, - projectRoot: "mozilla" - })); - expect(component.state("uncollapsedTree").contents[0].contents).toHaveLength(1); - }); - it("recreates tree if debugeeUrl is changed", async () => { - const { - component, - props, - defaultState - } = render(); - const mockSource = I.Map({ - "server1.conn13.child1/41": createMockSource("server1.conn13.child1/41", "http://mdn.com/three.js") - }); - expect(defaultState.uncollapsedTree.contents[0].contents).toHaveLength(3); - await component.setProps(_objectSpread({}, props, { - debuggeeUrl: "mozilla", - sources: mockSource - })); - expect(component.state("uncollapsedTree").contents[0].contents).toHaveLength(1); - }); - }); - describe("updates list items", () => { - it("updates list items if shownSource changes", async () => { - const { - component, - props - } = render(); - await component.setProps(_objectSpread({}, props, { - shownSource: "http://mdn.com/three.js" - })); - expect(component).toMatchSnapshot(); - expect(props.selectLocation).toHaveBeenCalledWith({ - sourceId: "server1.conn13.child1/41" - }); - }); - }); - describe("updates highlighted items", () => { - it("updates highlightItems if selectedSource changes", async () => { - const { - component, - props - } = render(); - const mockSource = I.Map({ - "server1.conn13.child1/41": createMockSource("server1.conn13.child1/41", "http://mdn.com/three.js") - }); - await component.setProps(_objectSpread({}, props, { - selectedSource: mockSource - })); - expect(component).toMatchSnapshot(); - }); - }); - }); - describe("focusItem", () => { - it("update the focused item", async () => { - const { - component, - instance, - props - } = render(); - const item = createMockItem(); - await instance.focusItem(item); - await component.update(); - await component.find(".sources-list").simulate("keydown", { - keyCode: 13 - }); - expect(props.selectLocation).toHaveBeenCalledWith({ - sourceId: item.contents.get("id") - }); - }); - }); - describe("with custom root", () => { - it("renders custom root source list", async () => { - const { - component - } = render({ - projectRoot: "mdn.com" - }); - expect(component).toMatchSnapshot(); - }); - it("calls clearProjectDirectoryRoot on click", async () => { - const { - component, - props - } = render({ - projectRoot: "mdn" - }); - component.find(".sources-clear-root").simulate("click"); - expect(props.clearProjectDirectoryRoot).toHaveBeenCalled(); - }); - it("renders empty custom root source list", async () => { - const { - component - } = render({ - projectRoot: "custom", - sources: I.Map() - }); - expect(component).toMatchSnapshot(); - }); - }); - describe("onContextMenu of the tree", () => { - it("shows context menu on directory to set as root", async () => { - const menuOptions = [{ - accesskey: "r", - click: expect.any(Function), - disabled: false, - id: "node-set-directory-root", - label: "Set directory root" - }]; - const mockEvent = { - preventDefault: jest.fn(), - stopPropagation: jest.fn() - }; - const { - props, - instance - } = render({ - projectRoot: "root/" - }); - await instance.onContextMenu(mockEvent, createMockDirectory()); - expect(_devtoolsContextmenu.showMenu).toHaveBeenCalledWith(mockEvent, menuOptions); - expect(mockEvent.preventDefault).toHaveBeenCalled(); - expect(mockEvent.stopPropagation).toHaveBeenCalled(); - - _devtoolsContextmenu.showMenu.mock.calls[0][1][0].click(); - - expect(props.setProjectDirectoryRoot).toHaveBeenCalled(); - expect(props.clearProjectDirectoryRoot).not.toHaveBeenCalled(); - expect(_clipboard.copyToTheClipboard).not.toHaveBeenCalled(); - }); - it("shows context menu on file to copy source uri", async () => { - const menuOptions = [{ - accesskey: "u", - click: expect.any(Function), - disabled: false, - id: "node-menu-copy-source", - label: "Copy source URI" - }]; - const mockEvent = { - preventDefault: jest.fn(), - stopPropagation: jest.fn() - }; - const { - props, - instance - } = render({ - projectRoot: "root/" - }); - await instance.onContextMenu(mockEvent, createMockItem()); - expect(_devtoolsContextmenu.showMenu).toHaveBeenCalledWith(mockEvent, menuOptions); - expect(mockEvent.preventDefault).toHaveBeenCalled(); - expect(mockEvent.stopPropagation).toHaveBeenCalled(); - - _devtoolsContextmenu.showMenu.mock.calls[0][1][0].click(); - - expect(props.setProjectDirectoryRoot).not.toHaveBeenCalled(); - expect(props.clearProjectDirectoryRoot).not.toHaveBeenCalled(); - expect(_clipboard.copyToTheClipboard).toHaveBeenCalled(); - }); - it("shows context menu on root to remove directory root", async () => { - const menuOptions = [{ - click: expect.any(Function), - disabled: false, - id: "node-remove-directory-root", - label: "Remove directory root" - }]; - const { - props, - instance - } = render({ - projectRoot: "root/" - }); - const mockEvent = { - preventDefault: jest.fn(), - stopPropagation: jest.fn() - }; - await instance.onContextMenu(mockEvent, createMockDirectory("root/", "root")); - expect(_devtoolsContextmenu.showMenu).toHaveBeenCalledWith(mockEvent, menuOptions); - expect(mockEvent.preventDefault).toHaveBeenCalled(); - expect(mockEvent.stopPropagation).toHaveBeenCalled(); - - _devtoolsContextmenu.showMenu.mock.calls[0][1][0].click(); - - expect(props.setProjectDirectoryRoot).not.toHaveBeenCalled(); - expect(props.clearProjectDirectoryRoot).toHaveBeenCalled(); - expect(_clipboard.copyToTheClipboard).not.toHaveBeenCalled(); - }); - }); - describe("renderItem", () => { - it("should show icon for webpack item", async () => { - const { - instance - } = render(); - const item = createMockDirectory("webpack://", "webpack://"); - const node = renderItem(instance, item); - expect(node).toMatchSnapshot(); - }); - it("should show icon for angular item", async () => { - const { - instance - } = render(); - const item = createMockDirectory("ng://", "ng://"); - const node = renderItem(instance, item); - expect(node).toMatchSnapshot(); - }); - it("should show icon for moz-extension item", async () => { - const { - instance - } = render(); - const item = createMockDirectory("moz-extension://", "moz-extension://"); - const node = renderItem(instance, item); - expect(node).toMatchSnapshot(); - }); - it("should show icon for folder with arrow", async () => { - const { - instance - } = render(); - const node = renderItem(instance, createMockDirectory()); - expect(node).toMatchSnapshot(); - }); - it("should show icon for folder with expanded arrow", async () => { - const { - instance - } = render(); - const node = renderItem(instance, createMockDirectory(), 1, false, true); - expect(node).toMatchSnapshot(); - }); - it("should show focused item for folder with expanded arrow", async () => { - const { - instance - } = render(); - const node = renderItem(instance, createMockDirectory(), 1, true, true); - expect(node).toMatchSnapshot(); - }); - it("should show source item with source icon", async () => { - const { - instance - } = render(); - const node = renderItem(instance, createMockItem()); - expect(node).toMatchSnapshot(); - }); - it("should show source item with source icon with focus", async () => { - const { - instance - } = render(); - const node = renderItem(instance, createMockItem(), 1, true, false); - expect(node).toMatchSnapshot(); - }); - it("should show domain item", async () => { - const { - instance - } = render(); - const item = createMockItem("root", "root"); - const node = renderItem(instance, item, 0); - expect(node).toMatchSnapshot(); - }); - it("should show domain item as debuggee", async () => { - const { - instance - } = render(); - const item = createMockItem("root", "http://mdn.com"); - const node = renderItem(instance, item, 0); - expect(node).toMatchSnapshot(); - }); - it("should show domain item as debuggee with focus and arrow", async () => { - const { - instance - } = render(); - const item = createMockDirectory("root", "http://mdn.com"); - const node = renderItem(instance, item, 0, true); - expect(node).toMatchSnapshot(); - }); - it("should not show domain item when the projectRoot exists", async () => { - const { - instance - } = render({ - projectRoot: "root/" - }); - const node = renderItem(instance, createMockItem(), 0); - expect(node).toMatchSnapshot(); - }); - it("should show menu on contextmenu of an item", async () => { - const { - instance - } = render(); - const item = createMockItem(); - instance.onContextMenu = jest.fn(() => {}); - const event = { - event: "contextmenu" - }; - const node = (0, _enzyme.shallow)(renderItem(instance, item, 1, true)); - node.simulate("contextmenu", event); - expect(instance.onContextMenu).toHaveBeenCalledWith(event, item); - }); - it("should focus on and select item on click", async () => { - const { - component, - instance, - props - } = render(); - const item = createMockItem(); - const event = { - event: "click" - }; - const setExpanded = jest.fn(); - const node = (0, _enzyme.shallow)(renderItem(instance, item, 1, true, false, setExpanded)); - node.simulate("click", event); - await component.find(".sources-list").simulate("keydown", { - keyCode: 13 - }); - expect(props.selectLocation).toHaveBeenCalledWith({ - sourceId: item.contents.get("id") - }); - expect(setExpanded).not.toHaveBeenCalled(); - }); - it("should focus on and expand directory on click", async () => { - const { - component, - instance, - props - } = render(); - const event = { - event: "click" - }; - const setExpanded = jest.fn(); - const mockDirectory = createMockDirectory(); - const node = (0, _enzyme.shallow)(renderItem(instance, mockDirectory, 1, true, false, setExpanded)); - node.simulate("click", event); - expect(component.state("focusedItem")).toEqual(mockDirectory); - expect(setExpanded).toHaveBeenCalled(); - expect(props.selectLocation).not.toHaveBeenCalledWith(); - }); - }); - describe("selectItem", () => { - it("should select item with no children", async () => { - const { - instance, - props - } = render(); - instance.selectItem(createMockItem()); - expect(props.selectLocation).toHaveBeenCalledWith({ - sourceId: "server1.conn13.child1/39" - }); - }); - it("should not select item with children", async () => { - const { - props, - instance - } = render(); - instance.selectItem(createMockDirectory()); - expect(props.selectLocation).not.toHaveBeenCalled(); - }); - it("should select item on enter onKeyDown event", async () => { - const { - component, - props, - instance - } = render(); - await instance.focusItem(createMockItem()); - await component.update(); - await component.find(".sources-list").simulate("keydown", { - keyCode: 13 - }); - expect(props.selectLocation).toHaveBeenCalledWith({ - sourceId: "server1.conn13.child1/39" - }); - }); - it("does not select if no item is focused on", async () => { - const { - component, - props - } = render(); - await component.find(".sources-list").simulate("keydown", { - keyCode: 13 - }); - expect(props.selectLocation).not.toHaveBeenCalled(); - }); - }); - describe("handles items", () => { - it("getChildren from directory", async () => { - const { - component - } = render(); - const item = createMockDirectory("http://mdn.com/views", "views", ["a", "b"]); - const children = component.find("ManagedTree").props().getChildren(item); - expect(children).toEqual(["a", "b"]); - }); - it("getChildren from non directory", async () => { - const { - component - } = render(); - const children = component.find("ManagedTree").props().getChildren(createMockItem()); - expect(children).toEqual([]); - }); - it("onExpand", async () => { - const { - component, - props - } = render(); - const expandedState = ["x", "y"]; - await component.find("ManagedTree").props().onExpand({}, expandedState); - expect(props.setExpandedState).toHaveBeenCalledWith(expandedState); - }); - it("onCollapse", async () => { - const { - component, - props - } = render(); - const expandedState = ["y", "z"]; - await component.find("ManagedTree").props().onCollapse({}, expandedState); - expect(props.setExpandedState).toHaveBeenCalledWith(expandedState); - }); - it("getParent", async () => { - const { - component - } = render(); - const item = component.state("sourceTree").contents[0].contents[0]; - const parent = component.find("ManagedTree").props().getParent(item); - expect(parent.path).toEqual("mdn.com"); - expect(parent.contents).toHaveLength(3); - }); - }); - describe("getPath", () => { - it("should return path for item", async () => { - const { - instance - } = render(); - const path = instance.getPath(createMockItem()); - expect(path).toEqual("http://mdn.com/one.js/one.js/"); - }); - it("should return path for blackboxedboxed item", async () => { - const item = createMockItem("http://mdn.com/blackboxed.js", "blackboxed.js", I.Map({ - id: "server1.conn13.child1/59" - })); - const source = I.Map({ - "server1.conn13.child1/59": createMockSource("server1.conn13.child1/59", "http://mdn.com/blackboxed.js", true) - }); - const { - instance - } = render({ - sources: source - }); - const path = instance.getPath(item); - expect(path).toEqual("http://mdn.com/blackboxed.js/blackboxed.js/update"); - }); - }); -}); - -function generateDefaults(overrides) { - const defaultSources = I.Map({ - "server1.conn13.child1/39": createMockSource("server1.conn13.child1/39", "http://mdn.com/one.js"), - "server1.conn13.child1/40": createMockSource("server1.conn13.child1/40", "http://mdn.com/two.js"), - "server1.conn13.child1/41": createMockSource("server1.conn13.child1/41", "http://mdn.com/three.js") - }); - return _objectSpread({ - autoExpandAll: true, - selectLocation: jest.fn(), - setExpandedState: jest.fn(), - sources: defaultSources, - debuggeeUrl: "http://mdn.com", - clearProjectDirectoryRoot: jest.fn(), - setProjectDirectoryRoot: jest.fn(), - projectRoot: "" - }, overrides); -} - -function renderItem(instance, item = createMockItem(), depth = 1, focused = false, expanded = false, setExpanded = jest.fn()) { - return instance.renderItem(item, depth, focused, null, expanded, { - setExpanded: setExpanded - }); -} - -function render(overrides = {}) { - const props = generateDefaults(overrides); - const component = (0, _enzyme.shallow)(_react2.default.createElement(_SourcesTree2.default.WrappedComponent, props)); - const defaultState = component.state(); - const instance = component.instance(); - - instance.shouldComponentUpdate = () => true; - - return { - component, - props, - defaultState, - instance - }; -} - -function createMockSource(id, url, isBlackBoxed = false) { - return I.Map({ - id: id, - url: url, - isPrettyPrinted: false, - isWasm: false, - sourceMapURL: null, - isBlackBoxed: isBlackBoxed, - loadedState: "unloaded" - }); -} - -function createMockDirectory(path = "folder/", name = "folder", contents = []) { - return { - name, - path, - contents - }; -} - -function createMockItem(path = "http://mdn.com/one.js", name = "one.js", contents = I.Map({ - id: "server1.conn13.child1/39" -})) { - return { - name, - path, - contents - }; -} \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/WelcomeBox.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -var _react = require("devtools/client/shared/vendor/react"); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require("enzyme/index"); - -var _WelcomeBox = require("../WelcomeBox"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* 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/>. */ -describe("WelomeBox", () => { - const setActiveSearch = () => null; - - it("renders with default values", () => { - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_WelcomeBox.WelcomeBox, { - setActiveSearch: setActiveSearch - })); - expect(wrapper).toMatchSnapshot(); - }); - it("doesn't render toggle button in horizontal mode", () => { - const horizontal = true; - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_WelcomeBox.WelcomeBox, { - horizontal: horizontal, - setActiveSearch: setActiveSearch - })); - expect(wrapper.find("PaneToggleButton")).toHaveLength(0); - }); - it("calls correct function on searchSources click", () => { - const openQuickOpen = jest.fn(); - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_WelcomeBox.WelcomeBox, { - setActiveSearch: setActiveSearch, - openQuickOpen: openQuickOpen - })); - wrapper.find(".welcomebox__searchSources").simulate("click"); - expect(openQuickOpen).toBeCalled(); - }); - it("calls correct function on searchProject click", () => { - const setActiveSearchSpy = jest.fn(); - const wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_WelcomeBox.WelcomeBox, { - setActiveSearch: setActiveSearchSpy - })); - wrapper.find(".welcomebox__searchProject").simulate("click"); - expect(setActiveSearchSpy).toBeCalled(); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/WhyPaused.spec.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; - -var _enzyme = require("enzyme/index"); - -var _WhyPaused = require("../SecondaryPanes/Frames/WhyPaused.js/index"); - -var _WhyPaused2 = _interopRequireDefault(_WhyPaused); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* 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/>. */ -describe("WhyPaused", () => { - it("should pause reason with message", () => { - const why = { - type: "breakpoint", - message: "bla is hit" - }; - const component = (0, _enzyme.shallow)((0, _WhyPaused2.default)(why)); - expect(component).toMatchSnapshot(); - }); - it("should show pause reason with exception details", () => { - const why = { - type: "exception", - exception: { - class: "Error", - preview: { - name: "ReferenceError", - message: "o is not defined" - } - } - }; - const component = (0, _enzyme.shallow)((0, _WhyPaused2.default)(why)); - expect(component).toMatchSnapshot(); - }); - it("should show pause reason with exception string", () => { - const why = { - type: "exception", - exception: "Not Available" - }; - const component = (0, _enzyme.shallow)((0, _WhyPaused2.default)(why)); - expect(component).toMatchSnapshot(); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/components/test/moz.build +++ /dev/null @@ -1,18 +0,0 @@ -# vim: set filetype=python: -# 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/. - -DIRS += [ - -] - -DevToolsModules( - 'Outline.spec.js', - 'ProjectSearch.spec.js', - 'QuickOpenModal.spec.js', - 'ShortcutsModal.spec.js', - 'SourcesTree.spec.js', - 'WelcomeBox.spec.js', - 'WhyPaused.spec.js', -)
--- a/devtools/client/debugger/new/src/reducers/ast.js +++ b/devtools/client/debugger/new/src/reducers/ast.js @@ -65,21 +65,22 @@ function update(state = initialASTState( const value = action.value; return state.setIn(["symbols", sourceId], value); } case "SET_PAUSE_POINTS": { const { - source, + sourceText, + sourceId, pausePoints } = action; - const emptyLines = (0, _ast.findEmptyLines)(source, pausePoints); - return state.setIn(["pausePoints", source.id], pausePoints).setIn(["emptyLines", source.id], emptyLines); + const emptyLines = (0, _ast.findEmptyLines)(sourceText, pausePoints); + return state.setIn(["pausePoints", sourceId], pausePoints).setIn(["emptyLines", sourceId], emptyLines); } case "OUT_OF_SCOPE_LOCATIONS": { return state.set("outOfScopeLocations", action.locations); } case "IN_SCOPE_LINES":
--- a/devtools/client/debugger/new/src/reducers/pause.js +++ b/devtools/client/debugger/new/src/reducers/pause.js @@ -19,16 +19,17 @@ exports.getExtra = getExtra; exports.getFrames = getFrames; exports.getGeneratedFrameScope = getGeneratedFrameScope; exports.getOriginalFrameScope = getOriginalFrameScope; exports.getFrameScopes = getFrameScopes; exports.getFrameScope = getFrameScope; exports.getSelectedScope = getSelectedScope; exports.getSelectedScopeMappings = getSelectedScopeMappings; exports.getSelectedFrameId = getSelectedFrameId; +exports.getSelectedComponentIndex = getSelectedComponentIndex; exports.getTopFrame = getTopFrame; exports.getDebuggeeUrl = getDebuggeeUrl; exports.getSkipPausing = getSkipPausing; exports.getChromeScopes = getChromeScopes; var _reselect = require("devtools/client/debugger/new/dist/vendors").vendored["reselect"]; var _devtoolsSourceMap = require("devtools/client/shared/source-map/index.js"); @@ -42,16 +43,17 @@ function _objectSpread(target) { for (va function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const createPauseState = exports.createPauseState = () => ({ extra: {}, why: null, isWaitingOnBreak: false, frames: undefined, selectedFrameId: undefined, + selectedComponentIndex: undefined, frameScopes: { generated: {}, original: {}, mappings: {} }, loadedObjects: {}, shouldPauseOnExceptions: _prefs.prefs.pauseOnExceptions, shouldPauseOnCaughtExceptions: _prefs.prefs.pauseOnCaughtExceptions, @@ -172,16 +174,21 @@ function update(state = createPauseState isWaitingOnBreak: true }); case "SELECT_FRAME": return _objectSpread({}, state, { selectedFrameId: action.frame.id }); + case "SELECT_COMPONENT": + return _objectSpread({}, state, { + selectedComponentIndex: action.componentIndex + }); + case "SET_POPUP_OBJECT_PROPERTIES": if (!action.properties) { return _objectSpread({}, state); } return _objectSpread({}, state, { loadedObjects: _objectSpread({}, state.loadedObjects, { [action.objectId]: action.properties @@ -381,16 +388,20 @@ function getSelectedScopeMappings(state) return getFrameScopes(state).mappings[frameId]; } function getSelectedFrameId(state) { return state.pause.selectedFrameId; } +function getSelectedComponentIndex(state) { + return state.pause.selectedComponentIndex; +} + function getTopFrame(state) { const frames = getFrames(state); return frames && frames[0]; } const getSelectedFrame = exports.getSelectedFrame = (0, _reselect.createSelector)(getSelectedFrameId, getFrames, (selectedFrameId, frames) => { if (!frames) { return null;
--- a/devtools/client/debugger/new/src/reducers/sources.js +++ b/devtools/client/debugger/new/src/reducers/sources.js @@ -110,17 +110,17 @@ function update(state = initialSourcesSt }; _prefs.prefs.pendingSelectedLocation = location; return state.set("pendingSelectedLocation", location); case "ADD_TAB": return state.merge({ tabs: updateTabList({ sources: state - }, action.source.url) + }, action.url) }); case "MOVE_TAB": return state.merge({ tabs: updateTabList({ sources: state }, action.url, action.tabIndex) });
--- a/devtools/client/debugger/new/src/selectors/moz.build +++ b/devtools/client/debugger/new/src/selectors/moz.build @@ -1,15 +1,15 @@ # vim: set filetype=python: # 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/. DIRS += [ - 'test', + ] DevToolsModules( 'breakpointAtLocation.js', 'getCallStackFrames.js', 'getRelativeSources.js', 'index.js', 'isSelectedFrameVisible.js',
deleted file mode 100644 --- a/devtools/client/debugger/new/src/selectors/test/getCallStackFrames.spec.js +++ /dev/null @@ -1,189 +0,0 @@ -"use strict"; - -var _getCallStackFrames = require("../getCallStackFrames"); - -var _immutable = require("devtools/client/shared/vendor/immutable"); - -var _lodash = require("devtools/client/shared/vendor/lodash"); - -/* 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/>. */ -describe("getCallStackFrames selector", () => { - describe("library annotation", () => { - it("annotates React frames", () => { - const state = { - frames: [{ - location: { - sourceId: "source1" - } - }, { - location: { - sourceId: "source2" - } - }, { - location: { - sourceId: "source2" - } - }], - sources: (0, _immutable.fromJS)({ - source1: { - id: "source1", - url: "webpack:///src/App.js" - }, - source2: { - id: "source2", - url: "webpack:///~/react-dom/lib/ReactCompositeComponent.js" - } - }), - selectedSource: (0, _immutable.fromJS)({ - id: "sourceId-originalSource" - }) - }; - - const frames = _getCallStackFrames.getCallStackFrames.resultFunc(state.frames, state.sources, state.selectedSource, true); - - expect(frames[0]).not.toHaveProperty("library"); - expect(frames[1]).toHaveProperty("library", "React"); - expect(frames[2]).toHaveProperty("library", "React"); - }); // Multiple Babel async frame groups occur when you have an async function - // calling another async function (a common case). - // - // There are two possible frame groups that can occur depending on whether - // one sets a breakpoint before or after an await - - it("annotates frames related to Babel async transforms", () => { - const preAwaitGroup = [{ - displayName: "asyncAppFunction", - location: { - sourceId: "bundle" - } - }, { - displayName: "tryCatch", - location: { - sourceId: "regenerator" - } - }, { - displayName: "invoke", - location: { - sourceId: "regenerator" - } - }, { - displayName: "defineIteratorMethods/</prototype[method]", - location: { - sourceId: "regenerator" - } - }, { - displayName: "step", - location: { - sourceId: "bundle" - } - }, { - displayName: "_asyncToGenerator/</<", - location: { - sourceId: "bundle" - } - }, { - displayName: "Promise", - location: { - sourceId: "promise" - } - }, { - displayName: "_asyncToGenerator/<", - location: { - sourceId: "bundle" - } - }, { - displayName: "asyncAppFunction", - location: { - sourceId: "app" - } - }]; - const postAwaitGroup = [{ - displayName: "asyncAppFunction", - location: { - sourceId: "bundle" - } - }, { - displayName: "tryCatch", - location: { - sourceId: "regenerator" - } - }, { - displayName: "invoke", - location: { - sourceId: "regenerator" - } - }, { - displayName: "defineIteratorMethods/</prototype[method]", - location: { - sourceId: "regenerator" - } - }, { - displayName: "step", - location: { - sourceId: "bundle" - } - }, { - displayName: "step/<", - location: { - sourceId: "bundle" - } - }, { - displayName: "run", - location: { - sourceId: "bundle" - } - }, { - displayName: "notify/<", - location: { - sourceId: "bundle" - } - }, { - displayName: "flush", - location: { - sourceId: "microtask" - } - }]; - const state = { - frames: [...preAwaitGroup, ...postAwaitGroup], - sources: (0, _immutable.fromJS)({ - app: { - id: "app", - url: "webpack///app.js" - }, - bundle: { - id: "bundle", - url: "https://foo.com/bundle.js" - }, - regenerator: { - id: "regenerator", - url: "webpack:///foo/node_modules/regenerator-runtime/runtime.js" - }, - microtask: { - id: "microtask", - url: "webpack:///foo/node_modules/core-js/modules/_microtask.js" - }, - promise: { - id: "promise", - url: "webpack///foo/node_modules/core-js/modules/es6.promise.js" - } - }), - selectedSource: (0, _immutable.fromJS)({ - id: "sourceId-originalSource" - }) - }; - - const frames = _getCallStackFrames.getCallStackFrames.resultFunc(state.frames, state.sources, state.selectedSource); - - const babelFrames = (0, _lodash.pullAt)(frames, [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17]); - const otherFrames = frames; - expect(babelFrames).toEqual(Array(babelFrames.length).fill(expect.objectContaining({ - library: "Babel" - }))); - expect(otherFrames).not.toEqual(Array(babelFrames.length).fill(expect.objectContaining({ - library: "Babel" - }))); - }); - }); -}); \ No newline at end of file
deleted file mode 100644 --- a/devtools/client/debugger/new/src/selectors/test/moz.build +++ /dev/null @@ -1,12 +0,0 @@ -# vim: set filetype=python: -# 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/. - -DIRS += [ - -] - -DevToolsModules( - 'getCallStackFrames.spec.js', -)
--- a/devtools/client/debugger/new/src/utils/ast.js +++ b/devtools/client/debugger/new/src/utils/ast.js @@ -39,30 +39,30 @@ function findBestMatchExpression(symbols if (overlaps) { return expression; } return found; }, null); } -function findEmptyLines(selectedSource, pausePoints) { - if (!pausePoints || !selectedSource) { +function findEmptyLines(sourceText, pausePoints) { + if (!pausePoints || !sourceText) { return []; } const pausePointsList = (0, _pausePoints.convertToList)(pausePoints); const breakpoints = pausePointsList.filter(point => point.types.break); const breakpointLines = breakpoints.map(point => point.location.line); - if (!selectedSource.text || breakpointLines.length == 0) { + if (!sourceText || breakpointLines.length == 0) { return []; } - const lineCount = selectedSource.text.split("\n").length; + const lineCount = sourceText.split("\n").length; const sourceLines = (0, _lodash.range)(1, lineCount + 1); return (0, _lodash.xor)(sourceLines, breakpointLines); } function containsPosition(a, b) { const startsBefore = a.start.line < b.line || a.start.line === b.line && a.start.column <= b.column; const endsAfter = a.end.line > b.line || a.end.line === b.line && a.end.column >= b.column; return startsBefore && endsAfter;
--- a/devtools/client/debugger/new/src/utils/moz.build +++ b/devtools/client/debugger/new/src/utils/moz.build @@ -32,16 +32,15 @@ DevToolsModules( 'project-search.js', 'quick-open.js', 'result-list.js', 'source-maps.js', 'source-queue.js', 'source.js', 'tabs.js', 'task.js', - 'test-head.js', 'text.js', 'timings.js', 'ui.js', 'utils.js', 'wasm.js', 'worker.js', )
--- a/devtools/client/debugger/new/src/workers/parser/pausePoints.js +++ b/devtools/client/debugger/new/src/workers/parser/pausePoints.js @@ -35,16 +35,20 @@ const isReturn = node => t.isReturnState const isCall = node => t.isCallExpression(node) || t.isJSXElement(node); const inStepExpression = parent => t.isArrayExpression(parent) || t.isObjectProperty(parent) || t.isCallExpression(parent) || t.isJSXElement(parent); const inExpression = (parent, grandParent) => inStepExpression(parent) || t.isJSXAttribute(grandParent) || t.isTemplateLiteral(parent); const isExport = node => t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node); +function getStartLine(node) { + return node.loc.start.line; +} + function getPausePoints(sourceId) { const state = {}; (0, _ast.traverseAst)(sourceId, { enter: onEnter }, state); return state; } /* eslint-disable complexity */ @@ -76,18 +80,19 @@ function onEnter(node, ancestors, state) return; } if (t.isBlockStatement(node)) { return addEmptyPoint(state, startLocation); } if (isReturn(node)) { - // We do not want to pause at the return and the call e.g. return foo() - if (isCall(node.argument)) { + // We do not want to pause at the return if the + // argument is a call on the same line e.g. return foo() + if (isCall(node.argument) && getStartLine(node) == getStartLine(node.argument)) { return addEmptyPoint(state, startLocation); } return addStopPoint(state, startLocation); } if (isAssignment(node)) { // We only want to pause at literal assignments `var a = foo()`
--- a/devtools/client/debugger/new/test/mochitest/browser.ini +++ b/devtools/client/debugger/new/test/mochitest/browser.ini @@ -181,16 +181,17 @@ skip-if = (os == "win" && ccov) # Bug 14 [browser_dbg-inline-cache.js] [browser_dbg-keyboard-navigation.js] [browser_dbg-keyboard-shortcuts.js] skip-if = os == "linux" # bug 1351952 [browser_dbg-layout-changes.js] [browser_dbg-outline.js] [browser_dbg-pause-exceptions.js] skip-if = !debug && (os == "win" && os_version == "6.1") # Bug 1456441 +[browser_dbg-pause-on-next.js] [browser_dbg-pause-ux.js] skip-if = os == "win" [browser_dbg-navigation.js] [browser_dbg-minified.js] [browser_dbg-pretty-print.js] [browser_dbg-pretty-print-console.js] [browser_dbg-pretty-print-paused.js] [browser_dbg-preview.js]
new file mode 100644 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-pause-on-next.js @@ -0,0 +1,15 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that when pause on next is selected, we pause on the next execution + +add_task(async function() { + const dbg = await initDebugger("doc-scripts.html"); + + clickElement(dbg, "pause"); + await waitForState(dbg, state => dbg.selectors.getIsWaitingOnBreak(state)) + invokeInTab("simple"); + + await waitForPaused(dbg, "simple3"); + assertPaused(dbg); +});
--- a/devtools/client/debugger/new/test/mochitest/helpers.js +++ b/devtools/client/debugger/new/test/mochitest/helpers.js @@ -244,16 +244,25 @@ function waitForSelectedSource(dbg, url) * Assert that the debugger is not currently paused. * @memberof mochitest/asserts * @static */ function assertNotPaused(dbg) { ok(!isPaused(dbg), "client is not paused"); } +/** + * Assert that the debugger is currently paused. + * @memberof mochitest/asserts + * @static + */ +function assertPaused(dbg) { + ok(isPaused(dbg), "client is paused"); +} + function getVisibleSelectedFrameLine(dbg) { const { selectors: { getVisibleSelectedFrame }, getState } = dbg; const frame = getVisibleSelectedFrame(getState()); return frame && frame.location.line; } /** * Assert that the debugger is paused at the correct location. @@ -1009,16 +1018,17 @@ const selectors = { menuitem: i => `menupopup menuitem:nth-child(${i})`, pauseOnExceptions: ".pause-exceptions", breakpoint: ".CodeMirror-code > .new-breakpoint", highlightLine: ".CodeMirror-code > .highlight-line", debugLine: ".new-debug-line", debugErrorLine: ".new-debug-line-error", codeMirror: ".CodeMirror", resume: ".resume.active", + pause: ".pause.active", sourceTabs: ".source-tabs", stepOver: ".stepOver.active", stepOut: ".stepOut.active", stepIn: ".stepIn.active", replayPrevious: ".replay-previous.active", replayNext: ".replay-next.active", toggleBreakpoints: ".breakpoints-toggle", prettyPrintButton: ".source-footer .prettyPrint",
--- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -1225,17 +1225,17 @@ CustomElementReactionsStack::InvokeReact // Note: It's possible to re-enter this method. for (uint32_t i = 0; i < aElementQueue->Length(); ++i) { Element* element = aElementQueue->ElementAt(i); // ElementQueue hold a element's strong reference, it should not be a nullptr. MOZ_ASSERT(element); RefPtr<CustomElementData> elementData = element->GetCustomElementData(); - if (!elementData) { + if (!elementData || !element->GetOwnerGlobal()) { // This happens when the document is destroyed and the element is already // unlinked, no need to fire the callbacks in this case. continue; } auto& reactions = elementData->mReactionQueue; for (uint32_t j = 0; j < reactions.Length(); ++j) { // Transfer the ownership of the entry due to reentrant invocation of
--- a/dom/indexedDB/test/browser.ini +++ b/dom/indexedDB/test/browser.ini @@ -18,9 +18,10 @@ support-files = [browser_forgetThisSite.js] [browser_permissionsPromptAllow.js] [browser_permissionsPromptDeny.js] [browser_permissionsPromptWorker.js] [browser_perwindow_privateBrowsing.js] skip-if = os == 'linux' && debug # bug 1394671 [browser_private_idb.js] +skip-if = (os == 'osx' && debug) || (os == 'win' && debug) # Bug 1456325 [browser_bug839193.js]
--- a/dom/u2f/U2F.cpp +++ b/dom/u2f/U2F.cpp @@ -59,17 +59,17 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(U2 static ErrorCode ConvertNSResultToErrorCode(const nsresult& aError) { if (aError == NS_ERROR_DOM_TIMEOUT_ERR) { return ErrorCode::TIMEOUT; } /* Emitted by U2F{Soft,HID}TokenManager when we really mean ineligible */ - if (aError == NS_ERROR_DOM_NOT_ALLOWED_ERR) { + if (aError == NS_ERROR_DOM_INVALID_STATE_ERR) { return ErrorCode::DEVICE_INELIGIBLE; } return ErrorCode::OTHER_ERROR; } static uint32_t AdjustedTimeoutMillis(const Optional<Nullable<int32_t>>& opt_aSeconds) {
--- a/dom/webauthn/U2FSoftTokenManager.cpp +++ b/dom/webauthn/U2FSoftTokenManager.cpp @@ -605,17 +605,17 @@ U2FSoftTokenManager::Register(const WebA // Optional exclusion list. for (const WebAuthnScopedCredential& cred: aInfo.ExcludeList()) { bool isRegistered = false; nsresult rv = IsRegistered(cred.id(), aInfo.RpIdHash(), isRegistered); if (NS_FAILED(rv)) { return U2FRegisterPromise::CreateAndReject(rv, __func__); } if (isRegistered) { - return U2FRegisterPromise::CreateAndReject(NS_ERROR_DOM_NOT_ALLOWED_ERR, __func__); + return U2FRegisterPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__); } } // We should already have a wrapping key MOZ_ASSERT(mWrappingKey); UniquePK11SlotInfo slot(PK11_GetInternalSlot()); MOZ_ASSERT(slot.get()); @@ -757,17 +757,17 @@ U2FSoftTokenManager::Sign(const WebAuthn } } nsTArray<uint8_t> chosenAppId; nsTArray<uint8_t> keyHandle; // Fail if we can't find a valid key handle. if (!FindRegisteredKeyHandle(appIds, aInfo.AllowList(), keyHandle, chosenAppId)) { - return U2FSignPromise::CreateAndReject(NS_ERROR_DOM_NOT_ALLOWED_ERR, __func__); + return U2FSignPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__); } MOZ_ASSERT(mWrappingKey); UniquePK11SlotInfo slot(PK11_GetInternalSlot()); MOZ_ASSERT(slot.get()); if (NS_WARN_IF((aInfo.ClientDataHash().Length() != kParamLen) ||
--- a/dom/webauthn/tests/browser/browser_fido_appid_extension.js +++ b/dom/webauthn/tests/browser/browser_fido_appid_extension.js @@ -13,17 +13,17 @@ function arrivingHereIsBad(aResult) { function expectError(aType) { let expected = `${aType}Error`; return function (aResult) { is(aResult.slice(0, expected.length), expected, `Expecting a ${aType}Error`); }; } let expectNotSupportedError = expectError("NotSupported"); -let expectNotAllowedError = expectError("NotAllowed"); +let expectInvalidStateError = expectError("InvalidState"); let expectSecurityError = expectError("Security"); function promiseU2FRegister(tab, app_id) { let challenge = crypto.getRandomValues(new Uint8Array(16)); challenge = bytesToBase64UrlSafe(challenge); return ContentTask.spawn(tab.linkedBrowser, [app_id, challenge], function ([app_id, challenge]) { return new Promise(resolve => { @@ -106,29 +106,32 @@ add_task(async function test_appid() { let keyHandle = await promiseU2FRegister(tab, appid); // The FIDO AppId extension can't be used for MakeCredential. await promiseWebAuthnRegister(tab, appid) .then(arrivingHereIsBad) .catch(expectNotSupportedError); // Using the keyHandle shouldn't work without the FIDO AppId extension. + // This will be an invalid state, because the softtoken will consent without + // having the correct "RP ID" via the FIDO extension. await promiseWebAuthnSign(tab, keyHandle) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); // Invalid app IDs (for the current origin) must be rejected. await promiseWebAuthnSign(tab, keyHandle, {appid: "https://bogus.com/appId"}) .then(arrivingHereIsBad) .catch(expectSecurityError); - // Non-matching app IDs must be rejected. + // Non-matching app IDs must be rejected. Even when the user/softtoken + // consents, leading to an invalid state. await promiseWebAuthnSign(tab, keyHandle, {appid: appid + "2"}) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); let rpId = new TextEncoder("utf-8").encode(appid); let rpIdHash = await crypto.subtle.digest("SHA-256", rpId); // Succeed with the right fallback rpId. await promiseWebAuthnSign(tab, keyHandle, {appid}) .then(({authenticatorData, clientDataJSON, extensions}) => { is(extensions.appid, true, "appid extension was acted upon");
--- a/dom/webauthn/tests/test_webauthn_authenticator_transports.html +++ b/dom/webauthn/tests/test_webauthn_authenticator_transports.html @@ -22,16 +22,20 @@ function arrivingHereIsBad(aResult) { ok(false, "Bad result! Received a: " + aResult); } function expectNotAllowedError(aResult) { ok(aResult.toString().startsWith("NotAllowedError"), "Expecting a NotAllowedError, got " + aResult); } + function expectInvalidStateError(aResult) { + ok(aResult.toString().startsWith("InvalidStateError"), "Expecting a InvalidStateError, got " + aResult); + } + // Store the credential of the first successful make credential // operation so we can use it to get assertions later. let gCredential; add_task(() => { // Enable the softtoken. return SpecialPowers.pushPrefEnv({"set": [ ["security.webauth.webauthn", true], @@ -79,58 +83,64 @@ await requestMakeCredential([{ type: "public-key", id: crypto.getRandomValues(new Uint8Array(16)), transports: ["usb"], }]).then(arrivingHereIsGood) .catch(arrivingHereIsBad); // Pass gCredential with transport=usb. + // The credential already exists, and the softoken consents to create, + // so the error is InvalidState and not NotAllowed. await requestMakeCredential([{ type: "public-key", id: gCredential, transports: ["usb"], }]).then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); // Pass gCredential with transport=nfc. // The softoken pretends to support all transports. + // Also, as above, the credential exists and the token indicates consent. await requestMakeCredential([{ type: "public-key", id: gCredential, transports: ["nfc"], }]).then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); // Pass gCredential with an empty transports list. + // As above, the token indicates consent, so expect InvalidStateError. await requestMakeCredential([{ type: "public-key", id: gCredential, transports: [], }]).then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); }); // Test get assertion behavior. add_task(async () => { // Request an assertion for gCredential. await requestGetAssertion([{ type: "public-key", id: gCredential, transports: ["usb"], }]).then(arrivingHereIsGood) .catch(arrivingHereIsBad); - // Request an assertion for a random credential. + // Request an assertion for a random credential. The token indicates + // consent even though this credential doesn't exist, so expect an + // InvalidStateError. await requestGetAssertion([{ type: "public-key", id: crypto.getRandomValues(new Uint8Array(16)), transports: ["usb"], }]).then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); // Request an assertion for gCredential with transport=nfc. // The softoken pretends to support all transports. await requestGetAssertion([{ type: "public-key", id: gCredential, transports: ["nfc"], }]).then(arrivingHereIsGood)
--- a/dom/webauthn/tests/test_webauthn_get_assertion.html +++ b/dom/webauthn/tests/test_webauthn_get_assertion.html @@ -24,68 +24,117 @@ isnot(navigator.credentials.create, undefined, "CredentialManagement create API endpoint must exist"); isnot(navigator.credentials.get, undefined, "CredentialManagement get API endpoint must exist"); let gAssertionChallenge = new Uint8Array(16); window.crypto.getRandomValues(gAssertionChallenge); let invalidCred = {type: "Magic", id: base64ToBytes("AAA=")}; let unknownCred = {type: "public-key", id: base64ToBytes("AAA=")}; + let validCred = null; function requestGetAssertion(params) { return navigator.credentials.get(params); } + function arrivingHereIsGood(aResult) { + ok(true, "Good result! Received a: " + aResult); + } + function arrivingHereIsBad(aResult) { ok(false, "Bad result! Received a: " + aResult); } function expectNotAllowedError(aResult) { - ok(aResult.toString().startsWith("NotAllowedError"), "Expecting a NotAllowedError"); + ok(aResult.toString().startsWith("NotAllowedError"), "Expecting a NotAllowedError, got " + aResult); + } + + function expectInvalidStateError(aResult) { + ok(aResult.toString().startsWith("InvalidStateError"), "Expecting a InvalidStateError, got " + aResult); } function expectTypeError(aResult) { - ok(aResult.toString().startsWith("TypeError"), "Expecting a TypeError"); + ok(aResult.toString().startsWith("TypeError"), "Expecting a TypeError, got " + aResult); } function expectAbortError(aResult) { is(aResult.code, DOMException.ABORT_ERR, "Expecting an AbortError"); } add_task(() => { return SpecialPowers.pushPrefEnv({"set": [ ["security.webauth.webauthn", true], ["security.webauth.webauthn_enable_softtoken", true], ["security.webauth.webauthn_enable_usbtoken", false] ]}); }); + // Set up a valid credential + add_task(async () => { + let publicKey = { + rp: {id: document.domain, name: "none", icon: "none"}, + user: {id: new Uint8Array(), name: "none", icon: "none", displayName: "none"}, + challenge: crypto.getRandomValues(new Uint8Array(16)), + pubKeyCredParams: [{type: "public-key", alg: cose_alg_ECDSA_w_SHA256}], + }; + + return navigator.credentials.create({publicKey}) + .then(res => validCred = {type: "public-key", id: res.rawId} ); + }); + // Test basic good call, but without giving a credential so expect failures // this is OK by the standard, but not supported by U2F-backed authenticators // like the soft token in use here. add_task(async () => { let publicKey = { challenge: gAssertionChallenge }; await requestGetAssertion({publicKey}) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); }); - // Test with an unexpected option + // Test with a valid credential + add_task(async () => { + let publicKey = { + challenge: gAssertionChallenge, + allowCredentials: [validCred] + }; + + await requestGetAssertion({publicKey}) + .then(arrivingHereIsGood) + .catch(arrivingHereIsBad); + }); + + // Test with an unexpected option. That won't stop anything, and we'll + // fail with InvalidState just as if we had no valid credentials -- which + // we don't. add_task(async () => { let publicKey = { challenge: gAssertionChallenge, unknownValue: "hi" }; await requestGetAssertion({publicKey}) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); + }); + + // Test with an unexpected option but a valid credential + add_task(async () => { + let publicKey = { + challenge: gAssertionChallenge, + unknownValue: "hi", + allowCredentials: [validCred] + }; + + await requestGetAssertion({publicKey}) + .then(arrivingHereIsGood) + .catch(arrivingHereIsBad); }); // Test with an invalid credential add_task(async () => { let publicKey = { challenge: gAssertionChallenge, allowCredentials: [invalidCred] }; @@ -99,42 +148,44 @@ add_task(async () => { let publicKey = { challenge: gAssertionChallenge, allowCredentials: [unknownCred] }; await requestGetAssertion({publicKey}) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); }); // Test with an unexpected option and an invalid credential add_task(async () => { let publicKey = { challenge: gAssertionChallenge, unknownValue: "hi", allowCredentials: [invalidCred] }; await requestGetAssertion({publicKey}) .then(arrivingHereIsBad) .catch(expectTypeError); }); // Test with an empty credential list + // This will return InvalidStateError since the softotken consents, but + // there are no valid credentials. add_task(async () => { let publicKey = { challenge: gAssertionChallenge, allowCredentials: [] }; await requestGetAssertion({publicKey}) .then(arrivingHereIsBad) - .catch(expectNotAllowedError); + .catch(expectInvalidStateError); }); add_task(() => { // Enable USB tokens. return SpecialPowers.pushPrefEnv({"set": [ ["security.webauth.webauthn", true], ["security.webauth.webauthn_enable_softtoken", false], ["security.webauth.webauthn_enable_usbtoken", true]
--- a/dom/webauthn/tests/test_webauthn_loopback.html +++ b/dom/webauthn/tests/test_webauthn_loopback.html @@ -180,17 +180,17 @@ function() { }; credm.create({publicKey: makeCredentialOptions}) .then(function() { // We should have errored here! ok(false, "The excludeList didn't stop a duplicate being created!"); SimpleTest.finish(); }) .catch(function(aReason) { - ok(aReason.toString().startsWith("NotAllowedError"), "Expect NotAllowedError, got " + aReason); + ok(aReason.toString().startsWith("InvalidStateError"), "Expect InvalidStateError, got " + aReason); testAssertion(aCredInfo); }); } function testAssertion(aCredInfo) { let newCredential = { type: "public-key", id: new Uint8Array(aCredInfo.rawId),
--- a/dom/webauthn/u2f-hid-rs/src/u2fprotocol.rs +++ b/dom/webauthn/u2f-hid-rs/src/u2fprotocol.rs @@ -16,30 +16,21 @@ use util::io_err; //////////////////////////////////////////////////////////////////////// // Device Commands //////////////////////////////////////////////////////////////////////// pub fn u2f_init_device<T>(dev: &mut T) -> bool where T: U2FDevice + Read + Write, { - // Do a few U2F device checks. let mut nonce = [0u8; 8]; thread_rng().fill_bytes(&mut nonce); - if init_device(dev, &nonce).is_err() { - return false; - } - let mut random = [0u8; 8]; - thread_rng().fill_bytes(&mut random); - if ping_device(dev, &random).is_err() { - return false; - } - - is_v2_device(dev).unwrap_or(false) + // Initialize the device and check its version. + init_device(dev, &nonce).is_ok() && is_v2_device(dev).unwrap_or(false) } pub fn u2f_register<T>(dev: &mut T, challenge: &[u8], application: &[u8]) -> io::Result<Vec<u8>> where T: U2FDevice + Read + Write, { if challenge.len() != PARAMETER_SIZE || application.len() != PARAMETER_SIZE { return Err(io::Error::new( @@ -135,28 +126,16 @@ where { assert_eq!(nonce.len(), INIT_NONCE_SIZE); let raw = sendrecv(dev, U2FHID_INIT, nonce)?; dev.set_cid(U2FHIDInitResp::read(&raw, nonce)?); Ok(()) } -fn ping_device<T>(dev: &mut T, random: &[u8]) -> io::Result<()> -where - T: U2FDevice + Read + Write, -{ - assert_eq!(random.len(), 8); - if sendrecv(dev, U2FHID_PING, random)? != random { - return Err(io_err("Ping was corrupted!")); - } - - Ok(()) -} - fn is_v2_device<T>(dev: &mut T) -> io::Result<bool> where T: U2FDevice + Read + Write, { let (data, status) = send_apdu(dev, U2F_VERSION, 0x00, &[])?; let actual = CString::new(data)?; let expected = CString::new("U2F_V2")?; status_word_to_result(status, actual == expected) @@ -230,17 +209,17 @@ where //////////////////////////////////////////////////////////////////////// // Tests //////////////////////////////////////////////////////////////////////// #[cfg(test)] mod tests { use rand::{thread_rng, Rng}; - use super::{init_device, ping_device, send_apdu, sendrecv, U2FDevice}; + use super::{init_device, send_apdu, sendrecv, U2FDevice}; use consts::{U2FHID_INIT, U2FHID_MSG, U2FHID_PING, CID_BROADCAST, SW_NO_ERROR}; mod platform { use std::io; use std::io::{Read, Write}; use consts::{CID_BROADCAST, HID_RPT_SIZE}; use u2ftypes::U2FDevice; @@ -412,30 +391,9 @@ mod tests { msg.extend_from_slice(&data); msg.extend_from_slice(&SW_NO_ERROR); device.add_read(&msg, 0); let (result, status) = send_apdu(&mut device, U2FHID_PING, 0xaa, &data).unwrap(); assert_eq!(result, &data); assert_eq!(status, SW_NO_ERROR); } - - #[test] - fn test_ping_device() { - let mut device = platform::TestDevice::new(); - device.set_cid([0x01, 0x02, 0x03, 0x04]); - - // ping nonce - let random = vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]; - - // APDU header - let mut msg = vec![0x01, 0x02, 0x03, 0x04, U2FHID_PING, 0x00, 0x08]; - msg.extend_from_slice(&random); - device.add_write(&msg, 0); - - // Only expect data from APDU back - let mut msg = vec![0x01, 0x02, 0x03, 0x04, U2FHID_MSG, 0x00, 0x08]; - msg.extend_from_slice(&random); - device.add_read(&msg, 0); - - ping_device(&mut device, &random).unwrap(); - } }
--- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -112,16 +112,17 @@ public: protected: friend class GLContextProviderEGL; friend class GLContextEGLFactory; public: const EGLConfig mConfig; protected: EGLSurface mSurface; + const EGLSurface mFallbackSurface; public: const EGLContext mContext; protected: EGLSurface mSurfaceOverride; RefPtr<gfxASurface> mThebesSurface; bool mBound; bool mIsPBuffer;
--- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -126,20 +126,45 @@ DestroySurface(EGLSurface oldSurface) { sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); sEGLLibrary.fDestroySurface(EGL_DISPLAY(), oldSurface); } } static EGLSurface -CreateSurfaceFromNativeWindow(EGLNativeWindowType window, const EGLConfig& config) { - EGLSurface newSurface = nullptr; +CreateFallbackSurface(const EGLConfig& config) +{ + if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_surfaceless_context)) { + // We don't need a PBuffer surface in this case + return EGL_NO_SURFACE; + } + + std::vector<EGLint> pbattrs; + pbattrs.push_back(LOCAL_EGL_WIDTH); pbattrs.push_back(1); + pbattrs.push_back(LOCAL_EGL_HEIGHT); pbattrs.push_back(1); + + for (const auto& cur : kTerminationAttribs) { + pbattrs.push_back(cur); + } + EGLSurface surface = sEGLLibrary.fCreatePbufferSurface(EGL_DISPLAY(), config, pbattrs.data()); + if (!surface) { + MOZ_CRASH("Failed to create fallback EGLSurface"); + } + + return surface; +} + +static EGLSurface +CreateSurfaceFromNativeWindow(EGLNativeWindowType window, const EGLConfig& config) +{ MOZ_ASSERT(window); + EGLSurface newSurface = EGL_NO_SURFACE; + #ifdef MOZ_WIDGET_ANDROID JNIEnv* const env = jni::GetEnvForThread(); ANativeWindow* const nativeWindow = ANativeWindow_fromSurface( env, reinterpret_cast<jobject>(window)); newSurface = sEGLLibrary.fCreateWindowSurface( sEGLLibrary.fGetDisplay(EGL_DEFAULT_DISPLAY), config, nativeWindow, 0); ANativeWindow_release(nativeWindow); @@ -163,17 +188,16 @@ private: GLContextEGLFactory(){} ~GLContextEGLFactory(){} }; already_AddRefed<GLContext> GLContextEGLFactory::Create(EGLNativeWindowType aWindow, bool aWebRender) { - MOZ_ASSERT(aWindow); nsCString discardFailureId; if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) { gfxCriticalNote << "Failed to load EGL library 3!"; return nullptr; } bool doubleBuffered = true; @@ -188,21 +212,19 @@ GLContextEGLFactory::Create(EGLNativeWin } } else { if (!CreateConfig(&config, aWebRender)) { gfxCriticalNote << "Failed to create EGLConfig!"; return nullptr; } } - EGLSurface surface = mozilla::gl::CreateSurfaceFromNativeWindow(aWindow, config); - - if (!surface) { - gfxCriticalNote << "Failed to create EGLSurface!"; - return nullptr; + EGLSurface surface = EGL_NO_SURFACE; + if (aWindow) { + surface = mozilla::gl::CreateSurfaceFromNativeWindow(aWindow, config); } CreateContextFlags flags = CreateContextFlags::NONE; if (aWebRender) { flags |= CreateContextFlags::PREFER_ES3; } SurfaceCaps caps = SurfaceCaps::Any(); RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, caps, false, config, @@ -223,16 +245,17 @@ GLContextEGLFactory::Create(EGLNativeWin } GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps, bool isOffscreen, EGLConfig config, EGLSurface surface, EGLContext context) : GLContext(flags, caps, nullptr, isOffscreen, false) , mConfig(config) , mSurface(surface) + , mFallbackSurface(CreateFallbackSurface(config)) , mContext(context) , mSurfaceOverride(EGL_NO_SURFACE) , mThebesSurface(nullptr) , mBound(false) , mIsPBuffer(false) , mIsDoubleBuffered(false) , mCanBindToTexture(false) , mShareWithEGLImage(false) @@ -254,16 +277,17 @@ GLContextEGL::~GLContextEGL() #ifdef DEBUG printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY()); #endif sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext); mozilla::gl::DestroySurface(mSurface); + mozilla::gl::DestroySurface(mFallbackSurface); } bool GLContextEGL::Init() { #if defined(ANDROID) // We can't use LoadApitraceLibrary here because the GLContext // expects its own handle to the GL library @@ -351,18 +375,22 @@ GLContextEGL::SetEGLSurfaceOverride(EGLS mSurfaceOverride = surf; DebugOnly<bool> ok = MakeCurrent(true); MOZ_ASSERT(ok); } bool GLContextEGL::MakeCurrentImpl() const { - const EGLSurface surface = (mSurfaceOverride != EGL_NO_SURFACE) ? mSurfaceOverride - : mSurface; + EGLSurface surface = (mSurfaceOverride != EGL_NO_SURFACE) ? mSurfaceOverride + : mSurface; + if (!surface) { + surface = mFallbackSurface; + } + const bool succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), surface, surface, mContext); if (!succeeded) { const auto eglError = sEGLLibrary.fGetError(); if (eglError == LOCAL_EGL_CONTEXT_LOST) { mContextLost = true; NS_WARNING("EGL context has been lost."); } else { @@ -386,20 +414,26 @@ bool GLContextEGL::RenewSurface(CompositorWidget* aWidget) { if (!mOwnsContext) { return false; } // unconditionally release the surface and create a new one. Don't try to optimize this away. // If we get here, then by definition we know that we want to get a new surface. ReleaseSurface(); MOZ_ASSERT(aWidget); - mSurface = mozilla::gl::CreateSurfaceFromNativeWindow(GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget), mConfig); - if (!mSurface) { - return false; + + EGLNativeWindowType nativeWindow = GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget); + if (nativeWindow) { + mSurface = mozilla::gl::CreateSurfaceFromNativeWindow(nativeWindow, mConfig); + if (!mSurface) { + NS_WARNING("Failed to create EGLSurface from native window"); + return false; + } } + return MakeCurrent(true); } void GLContextEGL::ReleaseSurface() { if (mOwnsContext) { mozilla::gl::DestroySurface(mSurface); }
--- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -56,16 +56,17 @@ static const char* sEGLExtensionNames[] "EGL_KHR_create_context", "EGL_KHR_stream", "EGL_KHR_stream_consumer_gltexture", "EGL_EXT_device_query", "EGL_NV_stream_consumer_gltexture_yuv", "EGL_ANGLE_stream_producer_d3d_texture", "EGL_ANGLE_device_creation", "EGL_ANGLE_device_creation_d3d11", + "EGL_KHR_surfaceless_context" }; #if defined(ANDROID) static PRLibrary* LoadApitraceLibrary() { // Initialization of gfx prefs here is only needed during the unit tests... gfxPrefs::GetSingleton();
--- a/gfx/gl/GLLibraryEGL.h +++ b/gfx/gl/GLLibraryEGL.h @@ -70,17 +70,17 @@ public: void InitClientExtensions(); void InitDisplayExtensions(); /** * Known GL extensions that can be queried by * IsExtensionSupported. The results of this are cached, and as * such it's safe to use this even in performance critical code. * If you add to this array, remember to add to the string names - * in GLContext.cpp. + * in GLLibraryEGL.cpp. */ enum EGLExtensions { KHR_image_base, KHR_image_pixmap, KHR_gl_texture_2D_image, KHR_lock_surface, ANGLE_surface_d3d_texture_2d_share_handle, EXT_create_context_robustness, @@ -94,16 +94,17 @@ public: KHR_create_context, KHR_stream, KHR_stream_consumer_gltexture, EXT_device_query, NV_stream_consumer_gltexture_yuv, ANGLE_stream_producer_d3d_texture, ANGLE_device_creation, ANGLE_device_creation_d3d11, + KHR_surfaceless_context, Extensions_Max }; bool IsExtensionSupported(EGLExtensions aKnownExtension) const { return mAvailableExtensions[aKnownExtension]; } void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
--- a/gfx/ipc/CompositorOptions.h +++ b/gfx/ipc/CompositorOptions.h @@ -28,47 +28,56 @@ namespace layers { class CompositorOptions { public: // This constructor needed for IPDL purposes, don't use it anywhere else. CompositorOptions() : mUseAPZ(false) , mUseWebRender(false) , mUseAdvancedLayers(false) + , mInitiallyPaused(false) { } explicit CompositorOptions(bool aUseAPZ, bool aUseWebRender) : mUseAPZ(aUseAPZ) , mUseWebRender(aUseWebRender) , mUseAdvancedLayers(false) + , mInitiallyPaused(false) { } bool UseAPZ() const { return mUseAPZ; } bool UseWebRender() const { return mUseWebRender; } bool UseAdvancedLayers() const { return mUseAdvancedLayers; } + bool InitiallyPaused() const { return mInitiallyPaused; } void SetUseAdvancedLayers(bool aUseAdvancedLayers) { mUseAdvancedLayers = aUseAdvancedLayers; } + void SetInitiallyPaused(bool aPauseAtStartup) { + mInitiallyPaused = aPauseAtStartup; + } + bool operator==(const CompositorOptions& aOther) const { return mUseAPZ == aOther.mUseAPZ && mUseWebRender == aOther.mUseWebRender && mUseAdvancedLayers == aOther.mUseAdvancedLayers; } friend struct IPC::ParamTraits<CompositorOptions>; private: bool mUseAPZ; bool mUseWebRender; bool mUseAdvancedLayers; + bool mInitiallyPaused; // Make sure to add new fields to the ParamTraits implementation + // in LayersMessageUtils.h }; } // namespace layers } // namespace mozilla #endif // _include_mozilla_gfx_ipc_CompositorOptions_h_
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -406,16 +406,18 @@ CompositorBridgeParent::Initialize() MOZ_ASSERT(!mApzcTreeManager); MOZ_ASSERT(!mApzSampler); MOZ_ASSERT(!mApzUpdater); mApzcTreeManager = new APZCTreeManager(mRootLayerTreeID); mApzSampler = new APZSampler(mApzcTreeManager, mOptions.UseWebRender()); mApzUpdater = new APZUpdater(mApzcTreeManager, mOptions.UseWebRender()); } + mPaused = mOptions.InitiallyPaused(); + mCompositorBridgeID = 0; // FIXME: This holds on the the fact that right now the only thing that // can destroy this instance is initialized on the compositor thread after // this task has been processed. MOZ_ASSERT(CompositorLoop()); CompositorLoop()->PostTask(NewRunnableFunction("AddCompositorRunnable", &AddCompositor, this, &mCompositorBridgeID));
--- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -630,22 +630,24 @@ template <> struct ParamTraits<mozilla::layers::CompositorOptions> { typedef mozilla::layers::CompositorOptions paramType; static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.mUseAPZ); WriteParam(aMsg, aParam.mUseWebRender); WriteParam(aMsg, aParam.mUseAdvancedLayers); + WriteParam(aMsg, aParam.mInitiallyPaused); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mUseAPZ) && ReadParam(aMsg, aIter, &aResult->mUseWebRender) - && ReadParam(aMsg, aIter, &aResult->mUseAdvancedLayers); + && ReadParam(aMsg, aIter, &aResult->mUseAdvancedLayers) + && ReadParam(aMsg, aIter, &aResult->mInitiallyPaused); } }; template <> struct ParamTraits<mozilla::layers::SimpleLayerAttributes> : public PlainOldDataSerializer<mozilla::layers::SimpleLayerAttributes> { };
--- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -351,28 +351,28 @@ namespace JS { D(INCREMENTAL_TOO_SLOW) \ D(ABORT_GC) \ D(FULL_WHOLE_CELL_BUFFER) \ D(FULL_GENERIC_BUFFER) \ D(FULL_VALUE_BUFFER) \ D(FULL_CELL_PTR_BUFFER) \ D(FULL_SLOT_BUFFER) \ D(FULL_SHAPE_BUFFER) \ + D(TOO_MUCH_WASM_MEMORY) \ \ /* These are reserved for future use. */ \ D(RESERVED0) \ D(RESERVED1) \ D(RESERVED2) \ D(RESERVED3) \ D(RESERVED4) \ D(RESERVED5) \ D(RESERVED6) \ D(RESERVED7) \ D(RESERVED8) \ - D(RESERVED9) \ \ /* Reasons from Firefox */ \ D(DOM_WINDOW_UTILS) \ D(COMPONENT_UTILS) \ D(MEM_PRESSURE) \ D(CC_WAITING) \ D(CC_FORCED) \ D(LOAD_END) \
--- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -7491,16 +7491,17 @@ GCRuntime::gcCycle(bool nonincrementalBy static bool IsDeterministicGCReason(JS::gcreason::Reason reason) { switch (reason) { case JS::gcreason::API: case JS::gcreason::DESTROY_RUNTIME: case JS::gcreason::LAST_DITCH: case JS::gcreason::TOO_MUCH_MALLOC: + case JS::gcreason::TOO_MUCH_WASM_MEMORY: case JS::gcreason::ALLOC_TRIGGER: case JS::gcreason::DEBUG_GC: case JS::gcreason::CC_FORCED: case JS::gcreason::SHUTDOWN_CC: case JS::gcreason::ABORT_GC: return true; default: @@ -7807,16 +7808,18 @@ GCRuntime::onOutOfMallocMemory(const Aut decommitAllWithoutUnlocking(lock); } void GCRuntime::minorGC(JS::gcreason::Reason reason, gcstats::PhaseKind phase) { MOZ_ASSERT(!JS::CurrentThreadIsHeapBusy()); + MOZ_ASSERT_IF(reason == JS::gcreason::EVICT_NURSERY, + !rt->mainContextFromOwnThread()->suppressGC); if (rt->mainContextFromOwnThread()->suppressGC) return; gcstats::AutoPhase ap(rt->gc.stats(), phase); nursery().clearMinorGCRequest(); TraceLoggerThread* logger = TraceLoggerForCurrentThread(); AutoTraceLog logMinorGC(logger, TraceLogger_MinorGC);
new file mode 100644 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/block-addmarkobservers.js @@ -0,0 +1,23 @@ +grayRoot().x = Object.create(null); + +try { + wasmEvalText(` + (module + (import "global" "func" (result i32)) + (func (export "func_0") (result i32) + call 0 ;; calls the import, which is func #0 + ) + ) + `, { + global: { + func: function() { + addMarkObservers([grayRoot().x]); + getMarks(); + } + } + }).exports.func_0(); +} catch(e) { + // If there's an error, it must be that the addMarkObservers API is + // temporarily disabled because of wasm gc. + assertEq(/temporarily unavailable/.test(e.message), true); +}
--- a/js/src/jit/BaselineCacheIRCompiler.cpp +++ b/js/src/jit/BaselineCacheIRCompiler.cpp @@ -539,68 +539,16 @@ BaselineCacheIRCompiler::emitLoadDynamic masm.load32(stubAddress(reader.stubOffset()), scratch); masm.loadPtr(Address(obj, NativeObject::offsetOfSlots()), scratch2); masm.loadValue(BaseIndex(scratch2, scratch, TimesOne), output.valueReg()); return true; } bool -BaselineCacheIRCompiler::emitMegamorphicLoadSlotResult() -{ - AutoOutputRegister output(*this); - - Register obj = allocator.useRegister(masm, reader.objOperandId()); - Address nameAddr = stubAddress(reader.stubOffset()); - bool handleMissing = reader.readBool(); - - AutoScratchRegisterMaybeOutput scratch1(allocator, masm, output); - AutoScratchRegister scratch2(allocator, masm); - AutoScratchRegister scratch3(allocator, masm); - - FailurePath* failure; - if (!addFailurePath(&failure)) - return false; - - // The object must be Native. - masm.branchIfNonNativeObj(obj, scratch3, failure->label()); - - masm.Push(UndefinedValue()); - masm.moveStackPtrTo(scratch3.get()); - - LiveRegisterSet volatileRegs(GeneralRegisterSet::Volatile(), liveVolatileFloatRegs()); - volatileRegs.takeUnchecked(scratch1); - volatileRegs.takeUnchecked(scratch2); - volatileRegs.takeUnchecked(scratch3); - masm.PushRegsInMask(volatileRegs); - - masm.setupUnalignedABICall(scratch1); - masm.loadJSContext(scratch1); - masm.passABIArg(scratch1); - masm.passABIArg(obj); - masm.loadPtr(nameAddr, scratch2); - masm.passABIArg(scratch2); - masm.passABIArg(scratch3); - if (handleMissing) - masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<true>))); - else - masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<false>))); - masm.mov(ReturnReg, scratch2); - masm.PopRegsInMask(volatileRegs); - - masm.loadTypedOrValue(Address(masm.getStackPointer(), 0), output); - masm.adjustStack(sizeof(Value)); - - masm.branchIfFalseBool(scratch2, failure->label()); - if (JitOptions.spectreJitToCxxCalls) - masm.speculationBarrier(); - return true; -} - -bool BaselineCacheIRCompiler::emitMegamorphicStoreSlot() { Register obj = allocator.useRegister(masm, reader.objOperandId()); Address nameAddr = stubAddress(reader.stubOffset()); ValueOperand val = allocator.useValueRegister(masm, reader.valOperandId()); bool needsTypeBarrier = reader.readBool(); AutoScratchRegister scratch1(allocator, masm);
--- a/js/src/jit/CacheIRCompiler.cpp +++ b/js/src/jit/CacheIRCompiler.cpp @@ -2932,17 +2932,17 @@ CacheIRCompiler::emitCallObjectHasSparse masm.loadTypedOrValue(Address(masm.getStackPointer(), 0), output); masm.adjustStack(sizeof(Value)); return true; } /* * Move a constant value into register dest. */ -void CacheIRCompiler::EmitLoadStubFieldConstant(StubFieldOffset val, Register dest) { +void CacheIRCompiler::emitLoadStubFieldConstant(StubFieldOffset val, Register dest) { MOZ_ASSERT(mode_ == Mode::Ion); switch (val.getStubFieldType()) { case StubField::Type::Shape: masm.movePtr(ImmGCPtr(shapeStubField(val.getOffset())),dest); break; case StubField::Type::String: masm.movePtr(ImmGCPtr(stringStubField(val.getOffset())), dest); break; @@ -2954,19 +2954,19 @@ void CacheIRCompiler::EmitLoadStubFieldC /* * After this is done executing, dest contains the value; either through a constant load * or through the load from the stub data. * * The current policy is that Baseline will use loads from the stub data (to allow IC * sharing), where as Ion doesn't share ICs, and so we can safely use constants in the * IC. */ -void CacheIRCompiler::EmitLoadStubField(StubFieldOffset val, Register dest) { +void CacheIRCompiler::emitLoadStubField(StubFieldOffset val, Register dest) { if (stubFieldPolicy_ == StubFieldPolicy::Constant) { - EmitLoadStubFieldConstant(val, dest); + emitLoadStubFieldConstant(val, dest); } else { Address load(ICStubReg, stubDataOffset_ + val.getOffset()); masm.loadPtr(load, dest); } } bool CacheIRCompiler::emitLoadInstanceOfObjectResult() @@ -3009,8 +3009,61 @@ CacheIRCompiler::emitLoadInstanceOfObjec masm.jump(&done); masm.bind(&returnTrue); EmitStoreBoolean(masm, true, output); //fallthrough masm.bind(&done); return true; } + +bool +CacheIRCompiler::emitMegamorphicLoadSlotResult() +{ + AutoOutputRegister output(*this); + + Register obj = allocator.useRegister(masm, reader.objOperandId()); + StubFieldOffset name(reader.stubOffset(), StubField::Type::String); + bool handleMissing = reader.readBool(); + + AutoScratchRegisterMaybeOutput scratch1(allocator, masm, output); + AutoScratchRegister scratch2(allocator, masm); + AutoScratchRegister scratch3(allocator, masm); + + FailurePath* failure; + if (!addFailurePath(&failure)) + return false; + + // The object must be Native. + masm.branchIfNonNativeObj(obj, scratch3, failure->label()); + + masm.Push(UndefinedValue()); + masm.moveStackPtrTo(scratch3.get()); + + LiveRegisterSet volatileRegs(GeneralRegisterSet::Volatile(), liveVolatileFloatRegs()); + volatileRegs.takeUnchecked(scratch1); + volatileRegs.takeUnchecked(scratch2); + volatileRegs.takeUnchecked(scratch3); + masm.PushRegsInMask(volatileRegs); + + masm.setupUnalignedABICall(scratch1); + masm.loadJSContext(scratch1); + masm.passABIArg(scratch1); + masm.passABIArg(obj); + emitLoadStubField(name, scratch2); + masm.passABIArg(scratch2); + masm.passABIArg(scratch3); + if (handleMissing) + masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<true>))); + else + masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<false>))); + masm.mov(ReturnReg, scratch2); + masm.PopRegsInMask(volatileRegs); + + masm.loadTypedOrValue(Address(masm.getStackPointer(), 0), output); + masm.adjustStack(sizeof(Value)); + + masm.branchIfFalseBool(scratch2, failure->label()); + if (JitOptions.spectreJitToCxxCalls) + masm.speculationBarrier(); + + return true; +} \ No newline at end of file
--- a/js/src/jit/CacheIRCompiler.h +++ b/js/src/jit/CacheIRCompiler.h @@ -72,16 +72,17 @@ namespace jit { _(LoadStringTruthyResult) \ _(LoadObjectTruthyResult) \ _(CompareStringResult) \ _(CompareObjectResult) \ _(CompareSymbolResult) \ _(ArrayJoinResult) \ _(CallPrintString) \ _(Breakpoint) \ + _(MegamorphicLoadSlotResult) \ _(MegamorphicLoadSlotByValueResult) \ _(MegamorphicHasPropResult) \ _(CallObjectHasSparseElementResult) \ _(WrapResult) // Represents a Value on the Baseline frame's expression stack. Slot 0 is the // value on top of the stack (the most recently pushed value), slot 1 is the // value pushed before that, etc. @@ -654,18 +655,18 @@ class MOZ_RAII CacheIRCompiler } bool emitComparePointerResultShared(bool symbol); #define DEFINE_SHARED_OP(op) MOZ_MUST_USE bool emit##op(); CACHE_IR_SHARED_OPS(DEFINE_SHARED_OP) #undef DEFINE_SHARED_OP - void EmitLoadStubField(StubFieldOffset val, Register dest); - void EmitLoadStubFieldConstant(StubFieldOffset val, Register dest); + void emitLoadStubField(StubFieldOffset val, Register dest); + void emitLoadStubFieldConstant(StubFieldOffset val, Register dest); uintptr_t readStubWord(uint32_t offset, StubField::Type type) { MOZ_ASSERT(stubFieldPolicy_ == StubFieldPolicy::Constant); MOZ_ASSERT((offset % sizeof(uintptr_t)) == 0); // We use nextStubField_ to access the data as it's stored in an as-of-yet // unpacked vector, and so using the offset can be incorrect where the index // would change as a result of packing. return writer_.readStubFieldForIon(nextStubField_++, type).asWord();
--- a/js/src/jit/IonCacheIRCompiler.cpp +++ b/js/src/jit/IonCacheIRCompiler.cpp @@ -926,68 +926,16 @@ IonCacheIRCompiler::emitLoadDynamicSlotR AutoScratchRegisterMaybeOutput scratch(allocator, masm, output); masm.loadPtr(Address(obj, NativeObject::offsetOfSlots()), scratch); masm.loadTypedOrValue(Address(scratch, offset), output); return true; } bool -IonCacheIRCompiler::emitMegamorphicLoadSlotResult() -{ - AutoOutputRegister output(*this); - - Register obj = allocator.useRegister(masm, reader.objOperandId()); - PropertyName* name = stringStubField(reader.stubOffset())->asAtom().asPropertyName(); - bool handleMissing = reader.readBool(); - - AutoScratchRegisterMaybeOutput scratch1(allocator, masm, output); - AutoScratchRegister scratch2(allocator, masm); - AutoScratchRegister scratch3(allocator, masm); - - FailurePath* failure; - if (!addFailurePath(&failure)) - return false; - - // The object must be Native. - masm.branchIfNonNativeObj(obj, scratch3, failure->label()); - - masm.Push(UndefinedValue()); - masm.moveStackPtrTo(scratch3.get()); - - LiveRegisterSet volatileRegs(GeneralRegisterSet::Volatile(), liveVolatileFloatRegs()); - volatileRegs.takeUnchecked(scratch1); - volatileRegs.takeUnchecked(scratch2); - volatileRegs.takeUnchecked(scratch3); - masm.PushRegsInMask(volatileRegs); - - masm.setupUnalignedABICall(scratch1); - masm.loadJSContext(scratch1); - masm.passABIArg(scratch1); - masm.passABIArg(obj); - masm.movePtr(ImmGCPtr(name), scratch2); - masm.passABIArg(scratch2); - masm.passABIArg(scratch3); - if (handleMissing) - masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<true>))); - else - masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, (GetNativeDataProperty<false>))); - masm.mov(ReturnReg, scratch2); - masm.PopRegsInMask(volatileRegs); - - masm.loadTypedOrValue(Address(masm.getStackPointer(), 0), output); - masm.adjustStack(sizeof(Value)); - - masm.branchIfFalseBool(scratch2, failure->label()); - if (JitOptions.spectreJitToCxxCalls) - masm.speculationBarrier(); - return true; -} - -bool IonCacheIRCompiler::emitMegamorphicStoreSlot() { Register obj = allocator.useRegister(masm, reader.objOperandId()); PropertyName* name = stringStubField(reader.stubOffset())->asAtom().asPropertyName(); ValueOperand val = allocator.useValueRegister(masm, reader.valOperandId()); bool needsTypeBarrier = reader.readBool(); AutoScratchRegister scratch1(allocator, masm);
--- a/js/src/jsapi-tests/testArrayBuffer.cpp +++ b/js/src/jsapi-tests/testArrayBuffer.cpp @@ -221,122 +221,90 @@ hasExpectedLength(JSContext* cx, JS::Han if (!JS_GetProperty(cx, obj, "byteLength", &v)) return false; *len = v.toInt32(); return true; } END_TEST(testArrayBuffer_externalize) -BEGIN_TEST(testArrayBuffer_refcountedContents) -{ - RefCountedData data("One two three four"); - JS::RootedObject buffer(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), - &RefCountedData::incCallback, &RefCountedData::decCallback, &data)); - CHECK(buffer); - CHECK_EQUAL(data.refcount(), size_t(2)); - - uint32_t len; - bool isShared; - uint8_t* bufferData; - js::GetArrayBufferLengthAndData(buffer, &len, &isShared, &bufferData); - CHECK_EQUAL(len, data.len()); - CHECK(bufferData == data.contents()); - CHECK(strcmp(reinterpret_cast<char*>(bufferData), data.asString()) == 0); - - buffer = nullptr; - JS_GC(cx); - JS_GC(cx); - CHECK_EQUAL(data.refcount(), size_t(1)); - - data.decref(); - CHECK_NULL(data.contents()); - CHECK_EQUAL(data.refcount(), size_t(0)); - - return true; -} -END_TEST(testArrayBuffer_refcountedContents) - BEGIN_TEST(testArrayBuffer_customFreeFunc) { - RefCountedData data("One two three four"); - // Without passing a ref function, the buffer takes over the one existing - // reference to the data. + ExternalData data("One two three four"); + + // The buffer takes ownership of the data. JS::RootedObject buffer(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), - nullptr, &RefCountedData::decCallback, &data)); + &ExternalData::freeCallback, &data)); CHECK(buffer); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); uint32_t len; bool isShared; uint8_t* bufferData; js::GetArrayBufferLengthAndData(buffer, &len, &isShared, &bufferData); CHECK_EQUAL(len, data.len()); CHECK(bufferData == data.contents()); CHECK(strcmp(reinterpret_cast<char*>(bufferData), data.asString()) == 0); buffer = nullptr; JS_GC(cx); JS_GC(cx); - CHECK_NULL(data.contents()); - CHECK_EQUAL(data.refcount(), size_t(0)); + CHECK(data.wasFreed()); return true; } END_TEST(testArrayBuffer_customFreeFunc) BEGIN_TEST(testArrayBuffer_staticContents) { - RefCountedData data("One two three four"); - // When passing neither a ref nor unref function, the buffer doesn't own - // any reference. + ExternalData data("One two three four"); + + // When not passing a free function, the buffer doesn't own the data. JS::RootedObject buffer(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), - nullptr, nullptr)); + nullptr)); CHECK(buffer); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); uint32_t len; bool isShared; uint8_t* bufferData; js::GetArrayBufferLengthAndData(buffer, &len, &isShared, &bufferData); CHECK_EQUAL(len, data.len()); CHECK(bufferData == data.contents()); CHECK(strcmp(reinterpret_cast<char*>(bufferData), data.asString()) == 0); buffer = nullptr; JS_GC(cx); JS_GC(cx); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); - data.decref(); + data.free(); return true; } END_TEST(testArrayBuffer_staticContents) BEGIN_TEST(testArrayBuffer_stealDetachExternal) { - RefCountedData data("One two three four"); + ExternalData data("One two three four"); JS::RootedObject buffer(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), - &RefCountedData::incCallback, &RefCountedData::decCallback, &data)); + &ExternalData::freeCallback, &data)); CHECK(buffer); - data.decref(); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); void* stolenContents = JS_StealArrayBufferContents(cx, buffer); // External buffers are currently not stealable, since stealing only // gives you a pointer with no indication how to free it. So this should // copy the data. CHECK(stolenContents != data.contents()); CHECK(strcmp(reinterpret_cast<char*>(stolenContents), data.asString()) == 0); // External buffers are currently not stealable, so this should keep the // reference to the data and just mark the buffer as detached. CHECK(JS_IsDetachedArrayBufferObject(buffer)); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); buffer = nullptr; JS_GC(cx); JS_GC(cx); - CHECK_NULL(data.contents()); - CHECK_EQUAL(data.refcount(), size_t(0)); + CHECK(data.wasFreed()); return true; } END_TEST(testArrayBuffer_stealDetachExternal) \ No newline at end of file
--- a/js/src/jsapi-tests/testStructuredClone.cpp +++ b/js/src/jsapi-tests/testStructuredClone.cpp @@ -79,31 +79,30 @@ BEGIN_TEST(testStructuredClone_string) } return true; } END_TEST(testStructuredClone_string) BEGIN_TEST(testStructuredClone_externalArrayBuffer) { - RefCountedData data("One two three four"); + ExternalData data("One two three four"); JS::RootedObject g1(cx, createGlobal()); JS::RootedObject g2(cx, createGlobal()); CHECK(g1); CHECK(g2); JS::RootedValue v1(cx); { JSAutoCompartment ac(cx, g1); JS::RootedObject obj(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), - &RefCountedData::incCallback, &RefCountedData::decCallback, &data)); - data.decref(); - CHECK_EQUAL(data.refcount(), size_t(1)); + &ExternalData::freeCallback, &data)); + CHECK(!data.wasFreed()); v1 = JS::ObjectOrNullValue(obj); CHECK(v1.isObject()); } { JSAutoCompartment ac(cx, g2); JS::RootedValue v2(cx); @@ -115,34 +114,89 @@ BEGIN_TEST(testStructuredClone_externalA CHECK(&v1.toObject() != obj); uint32_t len; bool isShared; uint8_t* clonedData; js::GetArrayBufferLengthAndData(obj, &len, &isShared, &clonedData); // The contents of the two array buffers should be equal, but not the - // same pointer, and an extra reference should not be taken. + // same pointer. CHECK_EQUAL(len, data.len()); CHECK(clonedData != data.contents()); CHECK(strcmp(reinterpret_cast<char*>(clonedData), data.asString()) == 0); - CHECK_EQUAL(data.refcount(), size_t(1)); + CHECK(!data.wasFreed()); } // GC the array buffer before data goes out of scope v1.setNull(); JS_GC(cx); JS_GC(cx); // Trigger another to wait for background finalization to end - CHECK_EQUAL(data.refcount(), size_t(0)); + CHECK(data.wasFreed()); return true; } END_TEST(testStructuredClone_externalArrayBuffer) +BEGIN_TEST(testStructuredClone_externalArrayBufferDifferentThreadOrProcess) +{ + // SameProcessSameThread is tested above. + CHECK(testStructuredCloneCopy(JS::StructuredCloneScope::SameProcessDifferentThread)); + CHECK(testStructuredCloneCopy(JS::StructuredCloneScope::DifferentProcess)); + return true; +} + +bool testStructuredCloneCopy(JS::StructuredCloneScope scope) +{ + ExternalData data("One two three four"); + JS::RootedObject buffer(cx, JS_NewExternalArrayBuffer(cx, data.len(), data.contents(), + &ExternalData::freeCallback, &data)); + CHECK(buffer); + CHECK(!data.wasFreed()); + + JS::RootedValue v1(cx, JS::ObjectValue(*buffer)); + JS::RootedValue v2(cx); + CHECK(clone(scope, v1, &v2)); + JS::RootedObject bufferOut(cx, v2.toObjectOrNull()); + CHECK(bufferOut); + CHECK(JS_IsArrayBufferObject(bufferOut)); + + uint32_t len; + bool isShared; + uint8_t* clonedData; + js::GetArrayBufferLengthAndData(bufferOut, &len, &isShared, &clonedData); + + // Cloning should copy the data, so the contents of the two array buffers + // should be equal, but not the same pointer. + CHECK_EQUAL(len, data.len()); + CHECK(clonedData != data.contents()); + CHECK(strcmp(reinterpret_cast<char*>(clonedData), data.asString()) == 0); + CHECK(!data.wasFreed()); + + buffer = nullptr; + bufferOut = nullptr; + v1.setNull(); + v2.setNull(); + JS_GC(cx); + JS_GC(cx); + CHECK(data.wasFreed()); + + return true; +} + +bool clone(JS::StructuredCloneScope scope, JS::HandleValue v1, JS::MutableHandleValue v2) +{ + JSAutoStructuredCloneBuffer clonedBuffer(scope, nullptr, nullptr); + CHECK(clonedBuffer.write(cx, v1)); + CHECK(clonedBuffer.read(cx, v2)); + return true; +} +END_TEST(testStructuredClone_externalArrayBufferDifferentThreadOrProcess) + struct StructuredCloneTestPrincipals final : public JSPrincipals { uint32_t rank; explicit StructuredCloneTestPrincipals(uint32_t rank, int32_t rc = 1) : rank(rank) { this->refcount = rc; } bool write(JSContext* cx, JSStructuredCloneWriter* writer) override {
--- a/js/src/jsapi-tests/tests.h +++ b/js/src/jsapi-tests/tests.h @@ -436,50 +436,40 @@ class TestJSPrincipals : public JSPrinci } bool write(JSContext* cx, JSStructuredCloneWriter* writer) override { MOZ_ASSERT(false, "not implemented"); return false; } }; -// A class that simulates refcounted data, for testing with array buffers. -class RefCountedData { +// A class that simulates externally memory-managed data, for testing with +// array buffers. +class ExternalData { char* contents_; size_t len_; - size_t refcount_; public: - explicit RefCountedData(const char* str) : contents_(strdup(str)), - len_(strlen(str) + 1), refcount_(1) { } + explicit ExternalData(const char* str) : contents_(strdup(str)), len_(strlen(str) + 1) { } size_t len() const { return len_; } void* contents() const { return contents_; } char* asString() const { return contents_; } - size_t refcount() const { return refcount_; } + bool wasFreed() const { return !contents_; } - void incref() { refcount_++; } - void decref() { - refcount_--; - if (refcount_ == 0) { - free(contents_); - contents_ = nullptr; - } + void free() { + MOZ_ASSERT(!wasFreed()); + ::free(contents_); + contents_ = nullptr; } - static void incCallback(void* contents, void* userData) { - auto self = static_cast<RefCountedData*>(userData); + static void freeCallback(void* contents, void* userData) { + auto self = static_cast<ExternalData*>(userData); MOZ_ASSERT(self->contents() == contents); - self->incref(); - } - - static void decCallback(void* contents, void* userData) { - auto self = static_cast<RefCountedData*>(userData); - MOZ_ASSERT(self->contents() == contents); - self->decref(); + self->free(); } }; #ifdef JS_GC_ZEAL /* * Temporarily disable the GC zeal setting. This is only useful in tests that * need very explicit GC behavior and should not be used elsewhere. */
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3220,49 +3220,49 @@ JS_SetAllNonReservedSlotsToUndefined(JSC * these contents to free(). On success, the ownership is transferred to the * new array buffer. */ extern JS_PUBLIC_API(JSObject*) JS_NewArrayBufferWithContents(JSContext* cx, size_t nbytes, void* contents); namespace JS { -using BufferContentsRefFunc = void (*)(void* contents, void* userData); +using BufferContentsFreeFunc = void (*)(void* contents, void* userData); } /* namespace JS */ /** - * Create a new array buffer with the given contents. The ref and unref - * functions should increment or decrement the reference count of the contents. - * These functions allow array buffers to be used with embedder objects that - * use reference counting, for example. The contents must not be modified by - * any reference holders, internal or external. - * - * On success, the new array buffer takes a reference, and |ref(contents, - * refUserData)| will be called. When the array buffer is ready to be disposed - * of, |unref(contents, refUserData)| will be called to release the array - * buffer's reference on the contents. - * - * The ref and unref functions must not call any JSAPI functions that could - * cause a garbage collection. - * - * The ref function is optional. If it is nullptr, the caller is responsible + * Create a new array buffer with the given contents. The contents must not be + * modified by any other code, internal or external. + * + * When the array buffer is ready to be disposed of, `freeFunc(contents, + * freeUserData)` will be called to release the array buffer's reference on the + * contents. + * + * `freeFunc()` must not call any JSAPI functions that could cause a garbage + * collection. + * + * The caller must keep the buffer alive until `freeFunc()` is called, or, if + * `freeFunc` is null, until the JSRuntime is destroyed. + * + * The caller must not access the buffer on other threads. The JS engine will + * not allow the buffer to be transferred to other threads. If you try to + * transfer an external ArrayBuffer to another thread, the data is copied to a + * new malloc buffer. `freeFunc()` must be threadsafe, and may be called from + * any thread. + * + * This allows array buffers to be used with embedder objects that use reference + * counting, for example. In that case the caller is responsible * for incrementing the reference count before passing the contents to this * function. This also allows using non-reference-counted contents that must be * freed with some function other than free(). - * - * The ref function may also be called in case the buffer is cloned in some - * way. Currently this is not used, but it may be in the future. If the ref - * function is nullptr, any operation where an extra reference would otherwise - * be taken, will either copy the data, or throw an exception. */ extern JS_PUBLIC_API(JSObject*) JS_NewExternalArrayBuffer(JSContext* cx, size_t nbytes, void* contents, - JS::BufferContentsRefFunc ref, JS::BufferContentsRefFunc unref, - void* refUserData = nullptr); + JS::BufferContentsFreeFunc freeFunc, void* freeUserData = nullptr); /** * Create a new array buffer with the given contents. The array buffer does not take ownership of * contents, and JS_DetachArrayBuffer must be called before the contents are disposed of. */ extern JS_PUBLIC_API(JSObject*) JS_NewArrayBufferWithExternalContents(JSContext* cx, size_t nbytes, void* contents);
--- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -6309,16 +6309,23 @@ AddMarkObservers(JSContext* cx, unsigned if (!markObservers) return false; if (!args.get(0).isObject()) { JS_ReportErrorASCII(cx, "argument must be an Array of objects"); return false; } +#ifdef ENABLE_WASM_GC + if (gc::GCRuntime::temporaryAbortIfWasmGc(cx)) { + JS_ReportErrorASCII(cx, "API temporarily unavailable under wasm gc"); + return false; + } +#endif + // WeakCaches are not swept during a minor GC. To prevent nursery-allocated // contents from having the mark bits be deceptively black until the second // GC, they would need to be marked weakly (cf NurseryAwareHashMap). It is // simpler to evict the nursery to prevent nursery objects from being // observed. cx->runtime()->gc.evictNursery(); RootedObject observersArg(cx, &args[0].toObject());
--- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -49,20 +49,22 @@ #include "gc/Marking-inl.h" #include "gc/Nursery-inl.h" #include "vm/JSAtom-inl.h" #include "vm/NativeObject-inl.h" #include "vm/Shape-inl.h" using JS::ToInt32; +using mozilla::Atomic; using mozilla::CheckedInt; using mozilla::Some; using mozilla::Maybe; using mozilla::Nothing; +using mozilla::Unused; using namespace js; using namespace js::gc; /* * Convert |v| to an array index for an array of length |length| per * the Typed Array Specification section 7.0, |subarray|. If successful, * the output value is in the range [0, length]. @@ -86,19 +88,29 @@ js::ToClampedIndex(JSContext* cx, Handle // If there are too many 4GB buffers live we run up against system resource // exhaustion (address space or number of memory map descriptors), see // bug 1068684, bug 1073934 for details. The limiting case seems to be // Windows Vista Home 64-bit, where the per-process address space is limited // to 8TB. Thus we track the number of live objects, and set a limit of // 1000 live objects per process; we run synchronous GC if necessary; and // we throw an OOM error if the per-process limit is exceeded. -static mozilla::Atomic<int32_t, mozilla::ReleaseAcquire> liveBufferCount(0); +// +// Since the MaximumLiveMappedBuffers limit is not generally accounted for by +// any existing GC-trigger heuristics, we need an extra heuristic for triggering +// GCs when the caller is allocating memories rapidly without other garbage. +// Thus, once the live buffer count crosses a certain threshold, we start +// triggering GCs every N allocations. static const int32_t MaximumLiveMappedBuffers = 1000; +static const int32_t StartTriggeringAtLiveBufferCount = 200; +static const int32_t AllocatedBuffersPerTrigger = 100; + +static Atomic<int32_t, mozilla::ReleaseAcquire> liveBufferCount(0); +static Atomic<int32_t, mozilla::ReleaseAcquire> allocatedSinceLastTrigger(0); int32_t js::LiveMappedBufferCount() { return liveBufferCount; } void* @@ -667,20 +679,16 @@ class js::WasmArrayRawBuffer size_t mappedSize() const { return mappedSize_; } Maybe<uint32_t> maxSize() const { return maxSize_; } - size_t allocatedBytes() const { - return mappedSize_ + gc::SystemPageSize(); - } - #ifndef WASM_HUGE_MEMORY uint32_t boundsCheckLimit() const { MOZ_ASSERT(mappedSize_ <= UINT32_MAX); MOZ_ASSERT(mappedSize_ >= wasm::GuardSize); MOZ_ASSERT(wasm::IsValidBoundsCheckImmediate(mappedSize_ - wasm::GuardSize)); return mappedSize_ - wasm::GuardSize; } #endif @@ -824,16 +832,28 @@ CreateBuffer(JSContext* cx, uint32_t ini // ObjT::createFromNewRawBuffer assumes ownership of |buffer| even in case // of failure. ObjT* object = ObjT::createFromNewRawBuffer(cx, buffer, initialSize); if (!object) return false; maybeSharedObject.set(object); + + // See StartTriggeringAtLiveBufferCount comment above. + if (liveBufferCount > StartTriggeringAtLiveBufferCount) { + allocatedSinceLastTrigger++; + if (allocatedSinceLastTrigger > AllocatedBuffersPerTrigger) { + Unused << cx->runtime()->gc.triggerGC(JS::gcreason::TOO_MUCH_WASM_MEMORY); + allocatedSinceLastTrigger = 0; + } + } else { + allocatedSinceLastTrigger = 0; + } + return true; } bool js::CreateWasmBuffer(JSContext* cx, const wasm::Limits& memory, MutableHandleArrayBufferObjectMaybeShared buffer) { MOZ_ASSERT(memory.initial % wasm::PageSize == 0); @@ -959,21 +979,21 @@ ArrayBufferObject::dataPointer() const } SharedMem<uint8_t*> ArrayBufferObject::dataPointerShared() const { return SharedMem<uint8_t*>::unshared(getFixedSlot(DATA_SLOT).toPrivate()); } -ArrayBufferObject::RefcountInfo* -ArrayBufferObject::refcountInfo() const +ArrayBufferObject::FreeInfo* +ArrayBufferObject::freeInfo() const { MOZ_ASSERT(isExternal()); - return reinterpret_cast<RefcountInfo*>(inlineDataPointer()); + return reinterpret_cast<FreeInfo*>(inlineDataPointer()); } void ArrayBufferObject::releaseData(FreeOp* fop) { MOZ_ASSERT(ownsData()); switch (bufferKind()) { @@ -982,45 +1002,39 @@ ArrayBufferObject::releaseData(FreeOp* f break; case MAPPED: DeallocateMappedContent(dataPointer(), byteLength()); break; case WASM: WasmArrayRawBuffer::Release(dataPointer()); break; case EXTERNAL: - if (refcountInfo()->unref) { + if (freeInfo()->freeFunc) { // The analyzer can't know for sure whether the embedder-supplied - // unref function will GC. We give the analyzer a hint here. - // (Doing a GC in the unref function is considered a programmer + // free function will GC. We give the analyzer a hint here. + // (Doing a GC in the free function is considered a programmer // error.) JS::AutoSuppressGCAnalysis nogc; - refcountInfo()->unref(dataPointer(), refcountInfo()->refUserData); + freeInfo()->freeFunc(dataPointer(), freeInfo()->freeUserData); } break; } } void ArrayBufferObject::setDataPointer(BufferContents contents, OwnsState ownsData) { setFixedSlot(DATA_SLOT, PrivateValue(contents.data())); setOwnsData(ownsData); setFlags((flags() & ~KIND_MASK) | contents.kind()); if (isExternal()) { - auto info = refcountInfo(); - info->ref = contents.refFunc(); - info->unref = contents.unrefFunc(); - info->refUserData = contents.refUserData(); - if (info->ref) { - // See comment in releaseData() for the explanation for this. - JS::AutoSuppressGCAnalysis nogc; - info->ref(dataPointer(), info->refUserData); - } + auto info = freeInfo(); + info->freeFunc = contents.freeFunc(); + info->freeUserData = contents.freeUserData(); } } uint32_t ArrayBufferObject::byteLength() const { return getFixedSlot(BYTE_LENGTH_SLOT).toInt32(); } @@ -1181,30 +1195,28 @@ ArrayBufferObject::create(JSContext* cx, // available for the buffer's data, see NewObject(). size_t reservedSlots = JSCLASS_RESERVED_SLOTS(&class_); size_t nslots = reservedSlots; bool allocated = false; if (contents) { if (ownsState == OwnsData) { if (contents.kind() == EXTERNAL) { - // Store the RefcountInfo in the inline data slots so that we + // Store the FreeInfo in the inline data slots so that we // don't use up slots for it in non-refcounted array buffers. - size_t refcountInfoSlots = JS_HOWMANY(sizeof(RefcountInfo), sizeof(Value)); - MOZ_ASSERT(reservedSlots + refcountInfoSlots <= NativeObject::MAX_FIXED_SLOTS, - "RefcountInfo must fit in inline slots"); - nslots += refcountInfoSlots; + size_t freeInfoSlots = JS_HOWMANY(sizeof(FreeInfo), sizeof(Value)); + MOZ_ASSERT(reservedSlots + freeInfoSlots <= NativeObject::MAX_FIXED_SLOTS, + "FreeInfo must fit in inline slots"); + nslots += freeInfoSlots; } else { // The ABO is taking ownership, so account the bytes against // the zone. size_t nAllocated = nbytes; if (contents.kind() == MAPPED) nAllocated = JS_ROUNDUP(nbytes, js::gc::SystemPageSize()); - else if (contents.kind() == WASM) - nAllocated = contents.wasmBuffer()->allocatedBytes(); cx->updateMallocCounter(nAllocated); } } } else { MOZ_ASSERT(ownsState == OwnsData); size_t usableSlots = NativeObject::MAX_FIXED_SLOTS - reservedSlots; if (nbytes <= usableSlots * sizeof(Value)) { int newSlots = JS_HOWMANY(nbytes, sizeof(Value)); @@ -1282,17 +1294,17 @@ ArrayBufferObject::createFromNewRawBuffe obj->setByteLength(initialSize); obj->setFlags(0); obj->setFirstView(nullptr); auto contents = BufferContents::create<WASM>(buffer->dataPointer()); obj->setDataPointer(contents, OwnsData); - cx->updateMallocCounter(buffer->mappedSize()); + cx->updateMallocCounter(initialSize); return obj; } /* static */ ArrayBufferObject::BufferContents ArrayBufferObject::externalizeContents(JSContext* cx, Handle<ArrayBufferObject*> buffer, bool hasStealableContents) { @@ -1847,27 +1859,26 @@ JS_NewArrayBufferWithContents(JSContext* ArrayBufferObject::BufferContents contents = ArrayBufferObject::BufferContents::create<ArrayBufferObject::PLAIN>(data); return ArrayBufferObject::create(cx, nbytes, contents, ArrayBufferObject::OwnsData, /* proto = */ nullptr, TenuredObject); } JS_PUBLIC_API(JSObject*) JS_NewExternalArrayBuffer(JSContext* cx, size_t nbytes, void* data, - JS::BufferContentsRefFunc ref, JS::BufferContentsRefFunc unref, - void* refUserData) + JS::BufferContentsFreeFunc freeFunc, void* freeUserData) { AssertHeapIsIdle(); CHECK_REQUEST(cx); MOZ_ASSERT(data); MOZ_ASSERT(nbytes > 0); ArrayBufferObject::BufferContents contents = - ArrayBufferObject::BufferContents::createExternal(data, ref, unref, refUserData); + ArrayBufferObject::BufferContents::createExternal(data, freeFunc, freeUserData); return ArrayBufferObject::create(cx, nbytes, contents, ArrayBufferObject::OwnsData, /* proto = */ nullptr, TenuredObject); } JS_PUBLIC_API(JSObject*) JS_NewArrayBufferWithExternalContents(JSContext* cx, size_t nbytes, void* data) { AssertHeapIsIdle();
--- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -188,18 +188,18 @@ class ArrayBufferObject : public ArrayBu enum ArrayBufferFlags { // The flags also store the BufferKind BUFFER_KIND_MASK = BufferKind::KIND_MASK, DETACHED = 0x4, // The dataPointer() is owned by this buffer and should be released // when no longer in use. Releasing the pointer may be done by freeing, - // invoking a dereference callback function, or unmapping, as - // determined by the buffer's other flags. + // invoking a free callback function, or unmapping, as determined by the + // buffer's other flags. // // Array buffers which do not own their data include buffers that // allocate their data inline, and buffers that are created lazily for // typed objects with inline storage, in which case the buffer points // directly to the typed object's storage. OWNS_DATA = 0x8, // This array buffer was created lazily for a typed object with inline @@ -219,59 +219,56 @@ class ArrayBufferObject : public ArrayBu static_assert(JS_ARRAYBUFFER_DETACHED_FLAG == DETACHED, "self-hosted code with burned-in constants must use the " "correct DETACHED bit value"); public: class BufferContents { uint8_t* data_; BufferKind kind_; - JS::BufferContentsRefFunc ref_; - JS::BufferContentsRefFunc unref_; - void* refUserData_; + JS::BufferContentsFreeFunc free_; + void* freeUserData_; friend class ArrayBufferObject; - BufferContents(uint8_t* data, BufferKind kind, JS::BufferContentsRefFunc ref = nullptr, - JS::BufferContentsRefFunc unref = nullptr, void* refUserData = nullptr) - : data_(data), kind_(kind), ref_(ref), unref_(unref), refUserData_(refUserData) + BufferContents(uint8_t* data, BufferKind kind, + JS::BufferContentsFreeFunc freeFunc = nullptr, + void* freeUserData = nullptr) + : data_(data), kind_(kind), free_(freeFunc), freeUserData_(freeUserData) { MOZ_ASSERT((kind_ & ~KIND_MASK) == 0); - MOZ_ASSERT_IF(ref_ || unref_ || refUserData_, kind_ == EXTERNAL); + MOZ_ASSERT_IF(free_ || freeUserData_, kind_ == EXTERNAL); - // BufferContents does not ref or unref the data since it is - // internal and short-lived. It is the caller's responsibility to - // ensure that the BufferContents does not outlive the data. + // It is the caller's responsibility to ensure that the + // BufferContents does not outlive the data. } public: template<BufferKind Kind> static BufferContents create(void* data) { return BufferContents(static_cast<uint8_t*>(data), Kind); } static BufferContents createPlain(void* data) { return BufferContents(static_cast<uint8_t*>(data), PLAIN); } - static BufferContents createExternal(void *data, JS::BufferContentsRefFunc ref, - JS::BufferContentsRefFunc unref, - void* refUserData = nullptr) + static BufferContents createExternal(void* data, JS::BufferContentsFreeFunc freeFunc, + void* freeUserData = nullptr) { - return BufferContents(static_cast<uint8_t*>(data), EXTERNAL, ref, unref, refUserData); + return BufferContents(static_cast<uint8_t*>(data), EXTERNAL, freeFunc, freeUserData); } uint8_t* data() const { return data_; } BufferKind kind() const { return kind_; } - JS::BufferContentsRefFunc refFunc() const { return ref_; } - JS::BufferContentsRefFunc unrefFunc() const { return unref_; } - void* refUserData() const { return refUserData_; } + JS::BufferContentsFreeFunc freeFunc() const { return free_; } + void* freeUserData() const { return freeUserData_; } explicit operator bool() const { return data_ != nullptr; } WasmArrayRawBuffer* wasmBuffer() const; }; static const Class class_; static const Class protoClass_; @@ -344,32 +341,31 @@ class ArrayBufferObject : public ArrayBu private: void changeViewContents(JSContext* cx, ArrayBufferViewObject* view, uint8_t* oldDataPointer, BufferContents newContents); void setFirstView(ArrayBufferViewObject* view); uint8_t* inlineDataPointer() const; - struct RefcountInfo { - JS::BufferContentsRefFunc ref; - JS::BufferContentsRefFunc unref; - void* refUserData; + struct FreeInfo { + JS::BufferContentsFreeFunc freeFunc; + void* freeUserData; }; - RefcountInfo* refcountInfo() const; + FreeInfo* freeInfo() const; public: uint8_t* dataPointer() const; SharedMem<uint8_t*> dataPointerShared() const; uint32_t byteLength() const; BufferContents contents() const { if (isExternal()) { - return BufferContents(dataPointer(), EXTERNAL, refcountInfo()->ref, - refcountInfo()->unref, refcountInfo()->refUserData); + return BufferContents(dataPointer(), EXTERNAL, freeInfo()->freeFunc, + freeInfo()->freeUserData); } return BufferContents(dataPointer(), bufferKind()); } bool hasInlineData() const { return dataPointer() == inlineDataPointer(); } void releaseData(FreeOp* fop);
--- a/js/src/vm/NativeObject-inl.h +++ b/js/src/vm/NativeObject-inl.h @@ -97,23 +97,23 @@ NativeObject::initDenseElementWithType(J inline void NativeObject::setDenseElementHole(JSContext* cx, uint32_t index) { MarkObjectGroupFlags(cx, this, OBJECT_FLAG_NON_PACKED); setDenseElement(index, MagicValue(JS_ELEMENTS_HOLE)); } -/* static */ inline void -NativeObject::removeDenseElementForSparseIndex(JSContext* cx, - HandleNativeObject obj, uint32_t index) +inline void +NativeObject::removeDenseElementForSparseIndex(JSContext* cx, uint32_t index) { - MarkObjectGroupFlags(cx, obj, OBJECT_FLAG_NON_PACKED | OBJECT_FLAG_SPARSE_INDEXES); - if (obj->containsDenseElement(index)) - obj->setDenseElementUnchecked(index, MagicValue(JS_ELEMENTS_HOLE)); + MOZ_ASSERT(containsPure(INT_TO_JSID(index))); + MarkObjectGroupFlags(cx, this, OBJECT_FLAG_NON_PACKED | OBJECT_FLAG_SPARSE_INDEXES); + if (containsDenseElement(index)) + setDenseElement(index, MagicValue(JS_ELEMENTS_HOLE)); } inline bool NativeObject::writeToIndexWouldMarkNotPacked(uint32_t index) { return getElementsHeader()->initializedLength < index; }
--- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -499,55 +499,16 @@ NativeObject::shrinkSlots(JSContext* cx, if (!newslots) { cx->recoverFromOutOfMemory(); return; /* Leave slots at its old size. */ } slots_ = newslots; } -/* static */ bool -NativeObject::sparsifyDenseElement(JSContext* cx, HandleNativeObject obj, uint32_t index) -{ - if (!obj->maybeCopyElementsForWrite(cx)) - return false; - - RootedValue value(cx, obj->getDenseElement(index)); - MOZ_ASSERT(!value.isMagic(JS_ELEMENTS_HOLE)); - - removeDenseElementForSparseIndex(cx, obj, index); - - RootedId id(cx, INT_TO_JSID(index)); - - AutoKeepShapeTables keep(cx); - ShapeTable* table = nullptr; - ShapeTable::Entry* entry = nullptr; - if (obj->inDictionaryMode()) { - table = obj->lastProperty()->ensureTableForDictionary(cx, keep); - if (!table) - return false; - entry = &table->search<MaybeAdding::Adding>(id, keep); - } - - // NOTE: We don't use addDataProperty because we don't want the - // extensibility check if we're, for example, sparsifying an element of a - // non-extensible object. - Shape* shape = addDataPropertyInternal(cx, obj, id, SHAPE_INVALID_SLOT, - obj->getElementsHeader()->elementAttributes(), - table, entry, keep); - if (!shape) { - obj->setDenseElementUnchecked(index, value); - return false; - } - - obj->initSlot(shape->slot(), value); - - return true; -} - bool NativeObject::willBeSparseElements(uint32_t requiredCapacity, uint32_t newElementsHint) { MOZ_ASSERT(isNative()); MOZ_ASSERT(requiredCapacity > MIN_SPARSE_INDEX); uint32_t cap = getDenseCapacity(); MOZ_ASSERT(requiredCapacity >= cap); @@ -1459,17 +1420,17 @@ AddOrChangeProperty(JSContext* cx, Handl // Clear any existing dense index after adding a sparse indexed property, // and investigate converting the object to dense indexes. if (JSID_IS_INT(id)) { if (!obj->maybeCopyElementsForWrite(cx)) return false; uint32_t index = JSID_TO_INT(id); - NativeObject::removeDenseElementForSparseIndex(cx, obj, index); + obj->removeDenseElementForSparseIndex(cx, index); DenseElementResult edResult = NativeObject::maybeDensifySparseElements(cx, obj); if (edResult == DenseElementResult::Failure) return false; if (edResult == DenseElementResult::Success) { MOZ_ASSERT(!desc.setter()); return CallAddPropertyHookDense(cx, obj, index, desc.value()); } @@ -1782,41 +1743,27 @@ js::NativeDefineProperty(JSContext* cx, desc.setGetterObject(prop.shape()->getterObject()); desc.setSetterObject(prop.shape()->setterObject()); } } else if (desc.isDataDescriptor() != IsDataDescriptor(shapeAttrs)) { // Step 6. if (!IsConfigurable(shapeAttrs) && !skipRedefineChecks) return result.fail(JSMSG_CANT_REDEFINE_PROP); - if (prop.isDenseOrTypedArrayElement()) { - MOZ_ASSERT(!obj->is<TypedArrayObject>()); - if (!NativeObject::sparsifyDenseElement(cx, obj, JSID_TO_INT(id))) - return false; - prop.setNativeProperty(obj->lookup(cx, id)); - } - // Fill in desc fields with default values (steps 6.b.i and 6.c.i). CompletePropertyDescriptor(&desc); } else if (desc.isDataDescriptor()) { // Step 7. bool frozen = !IsConfigurable(shapeAttrs) && !IsWritable(shapeAttrs); // Step 7.a.i.1. if (frozen && desc.hasWritable() && desc.writable() && !skipRedefineChecks) return result.fail(JSMSG_CANT_REDEFINE_PROP); if (frozen || !desc.hasValue()) { - if (prop.isDenseOrTypedArrayElement()) { - MOZ_ASSERT(!obj->is<TypedArrayObject>()); - if (!NativeObject::sparsifyDenseElement(cx, obj, JSID_TO_INT(id))) - return false; - prop.setNativeProperty(obj->lookup(cx, id)); - } - RootedValue currentValue(cx); if (!GetExistingPropertyValue(cx, obj, id, prop, ¤tValue)) return false; if (!desc.hasValue()) { // Fill in desc.[[Value]]. desc.setValue(currentValue); } else { @@ -1829,16 +1776,17 @@ js::NativeDefineProperty(JSContext* cx, return result.fail(JSMSG_CANT_REDEFINE_PROP); } } // Step 7.a.i.3. if (frozen && !skipRedefineChecks) return result.succeed(); + // Fill in desc.[[Writable]]. if (!desc.hasWritable()) desc.setWritable(IsWritable(shapeAttrs)); } else { // Step 8. MOZ_ASSERT(prop.shape()->isAccessorDescriptor()); MOZ_ASSERT(desc.isAccessorDescriptor()); // The spec says to use SameValue, but since the values in
--- a/js/src/vm/NativeObject.h +++ b/js/src/vm/NativeObject.h @@ -1211,34 +1211,16 @@ class NativeObject : public ShapedObject private: inline void ensureDenseInitializedLengthNoPackedCheck(uint32_t index, uint32_t extra); // Run a post write barrier that encompasses multiple contiguous elements in a // single step. inline void elementsRangeWriteBarrierPost(uint32_t start, uint32_t count); - // See the comment over setDenseElementUnchecked, this applies in the same way. - void setDenseInitializedLengthUnchecked(uint32_t length) { - MOZ_ASSERT(length <= getDenseCapacity()); - MOZ_ASSERT(!denseElementsAreCopyOnWrite()); - prepareElementRangeForOverwrite(length, getElementsHeader()->initializedLength); - getElementsHeader()->initializedLength = length; - } - - // Use this function with care. This is done to allow sparsifying frozen - // objects, but should only be called in a few places, and should be - // audited carefully! - void setDenseElementUnchecked(uint32_t index, const Value& val) { - MOZ_ASSERT(index < getDenseInitializedLength()); - MOZ_ASSERT(!denseElementsAreCopyOnWrite()); - checkStoredValue(val); - elements_[index].set(this, HeapSlot::Element, unshiftedIndex(index), val); - } - public: // When an array's length becomes non-writable, writes to indexes greater // greater than or equal to the length don't change the array. We handle // this with a check for non-writable length in most places. But in JIT code // every check counts -- so we piggyback the check on the already-required // range check for |index < capacity| by making capacity of arrays with // non-writable length never exceed the length. This mechanism is also used // when an object becomes non-extensible. @@ -1251,26 +1233,32 @@ class NativeObject : public ShapedObject if (header->capacity > len) { shrinkElements(cx, len); header = getElementsHeader(); header->capacity = len; } } void setDenseInitializedLength(uint32_t length) { + MOZ_ASSERT(length <= getDenseCapacity()); + MOZ_ASSERT(!denseElementsAreCopyOnWrite()); MOZ_ASSERT(!denseElementsAreFrozen()); - setDenseInitializedLengthUnchecked(length); + prepareElementRangeForOverwrite(length, getElementsHeader()->initializedLength); + getElementsHeader()->initializedLength = length; } inline void ensureDenseInitializedLength(JSContext* cx, uint32_t index, uint32_t extra); void setDenseElement(uint32_t index, const Value& val) { + MOZ_ASSERT(index < getDenseInitializedLength()); + MOZ_ASSERT(!denseElementsAreCopyOnWrite()); MOZ_ASSERT(!denseElementsAreFrozen()); - setDenseElementUnchecked(index, val); + checkStoredValue(val); + elements_[index].set(this, HeapSlot::Element, unshiftedIndex(index), val); } void initDenseElement(uint32_t index, const Value& val) { MOZ_ASSERT(index < getDenseInitializedLength()); MOZ_ASSERT(!denseElementsAreCopyOnWrite()); MOZ_ASSERT(isExtensible()); checkStoredValue(val); elements_[index].init(this, HeapSlot::Element, unshiftedIndex(index), val); @@ -1283,18 +1271,17 @@ class NativeObject : public ShapedObject setDenseElement(index, val); } inline void setDenseElementWithType(JSContext* cx, uint32_t index, const Value& val); inline void initDenseElementWithType(JSContext* cx, uint32_t index, const Value& val); inline void setDenseElementHole(JSContext* cx, uint32_t index); - static inline void removeDenseElementForSparseIndex(JSContext* cx, - HandleNativeObject obj, uint32_t index); + inline void removeDenseElementForSparseIndex(JSContext* cx, uint32_t index); inline Value getDenseOrTypedArrayElement(uint32_t idx); inline void copyDenseElements(uint32_t dstStart, const Value* src, uint32_t count); inline void initDenseElements(const Value* src, uint32_t count); inline void initDenseElements(NativeObject* src, uint32_t srcStart, uint32_t count); inline void moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count); inline void moveDenseElementsNoPreBarrier(uint32_t dstStart, uint32_t srcStart, uint32_t count); @@ -1332,20 +1319,16 @@ class NativeObject : public ShapedObject // sparse to grow (this includes the case of index + extra overflow). In // the last two cases the object is kept intact. inline DenseElementResult ensureDenseElements(JSContext* cx, uint32_t index, uint32_t extra); inline DenseElementResult extendDenseElements(JSContext* cx, uint32_t requiredCapacity, uint32_t extra); - /* Convert a single dense element to a sparse property. */ - static bool sparsifyDenseElement(JSContext* cx, - HandleNativeObject obj, uint32_t index); - /* Small objects are dense, no matter what. */ static const uint32_t MIN_SPARSE_INDEX = 1000; /* * Element storage for an object will be sparse if fewer than 1/8 indexes * are filled in. */ static const unsigned SPARSE_DENSITY_RATIO = 8;
--- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -3983,17 +3983,17 @@ nsTextPaintStyle::GetSelectionUnderlineF float* aRelativeSize, uint8_t* aStyle) { NS_ASSERTION(aLineColor, "aLineColor is null"); NS_ASSERTION(aRelativeSize, "aRelativeSize is null"); NS_ASSERTION(aIndex >= 0 && aIndex < 5, "Index out of range"); nsSelectionStyle* selectionStyle = GetSelectionStyle(aIndex); - if (selectionStyle->mUnderlineStyle == NS_STYLE_BORDER_STYLE_NONE || + if (selectionStyle->mUnderlineStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE || selectionStyle->mUnderlineColor == NS_TRANSPARENT || selectionStyle->mUnderlineRelativeSize <= 0.0f) return false; *aLineColor = selectionStyle->mUnderlineColor; *aRelativeSize = selectionStyle->mUnderlineRelativeSize; *aStyle = selectionStyle->mUnderlineStyle; return true;
--- a/layout/style/ServoCSSParser.h +++ b/layout/style/ServoCSSParser.h @@ -35,17 +35,17 @@ namespace mozilla { class ServoStyleSet; class SharedFontList; struct URLExtraData; class ServoCSSParser { public: - using ParsingEnvironment = nsDOMCSSDeclaration::ServoCSSParsingEnvironment; + using ParsingEnvironment = nsDOMCSSDeclaration::ParsingEnvironment; /** * Returns whether the specified string can be parsed as a valid CSS * <color> value. * * This includes Mozilla-specific keywords such as -moz-default-color. */ static bool IsValidCSSColor(const nsAString& aValue);
--- a/layout/style/ServoKeyframeRule.cpp +++ b/layout/style/ServoKeyframeRule.cpp @@ -52,20 +52,20 @@ public: mDecls->SetOwningRule(nullptr); mDecls = aDecls->AsServo(); mDecls->SetOwningRule(mRule); Servo_Keyframe_SetStyle(mRule->Raw(), mDecls->Raw()); } }); return NS_OK; } - ServoCSSParsingEnvironment GetServoCSSParsingEnvironment( + ParsingEnvironment GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const final { - return GetServoCSSParsingEnvironmentForRule(mRule); + return GetParsingEnvironmentForRule(mRule); } nsIDocument* DocToUpdate() final { return nullptr; } nsINode* GetParentObject() final { return mRule ? mRule->GetDocument() : nullptr; }
--- a/layout/style/ServoPageRule.cpp +++ b/layout/style/ServoPageRule.cpp @@ -82,21 +82,21 @@ ServoPageRuleDeclaration::SetCSSDeclarat } nsIDocument* ServoPageRuleDeclaration::DocToUpdate() { return nullptr; } -nsDOMCSSDeclaration::ServoCSSParsingEnvironment -ServoPageRuleDeclaration::GetServoCSSParsingEnvironment( +nsDOMCSSDeclaration::ParsingEnvironment +ServoPageRuleDeclaration::GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const { - return GetServoCSSParsingEnvironmentForRule(Rule()); + return GetParsingEnvironmentForRule(Rule()); } // -- ServoPageRule -------------------------------------------------- ServoPageRule::ServoPageRule(RefPtr<RawServoPageRule> aRawRule, uint32_t aLine, uint32_t aColumn) : CSSPageRule(aLine, aColumn) , mRawRule(Move(aRawRule))
--- a/layout/style/ServoPageRule.h +++ b/layout/style/ServoPageRule.h @@ -30,18 +30,18 @@ public: css::Rule* GetParentRule() final; nsINode* GetParentObject() final; protected: DeclarationBlock* GetCSSDeclaration(Operation aOperation) final; nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final; nsIDocument* DocToUpdate() final; - nsDOMCSSDeclaration::ServoCSSParsingEnvironment - GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; + nsDOMCSSDeclaration::ParsingEnvironment + GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; private: // For accessing the constructor. friend class ServoPageRule; explicit ServoPageRuleDeclaration( already_AddRefed<RawServoDeclarationBlock> aDecls); ~ServoPageRuleDeclaration();
--- a/layout/style/ServoStyleRule.cpp +++ b/layout/style/ServoStyleRule.cpp @@ -87,21 +87,21 @@ ServoStyleRuleDeclaration::SetCSSDeclara } nsIDocument* ServoStyleRuleDeclaration::DocToUpdate() { return nullptr; } -nsDOMCSSDeclaration::ServoCSSParsingEnvironment -ServoStyleRuleDeclaration::GetServoCSSParsingEnvironment( +nsDOMCSSDeclaration::ParsingEnvironment +ServoStyleRuleDeclaration::GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const { - return GetServoCSSParsingEnvironmentForRule(Rule()); + return GetParsingEnvironmentForRule(Rule()); } // -- ServoStyleRule -------------------------------------------------- ServoStyleRule::ServoStyleRule(already_AddRefed<RawServoStyleRule> aRawRule, uint32_t aLine, uint32_t aColumn) : BindingStyleRule(aLine, aColumn) , mRawRule(aRawRule)
--- a/layout/style/ServoStyleRule.h +++ b/layout/style/ServoStyleRule.h @@ -31,18 +31,18 @@ public: css::Rule* GetParentRule() final; nsINode* GetParentObject() final; protected: DeclarationBlock* GetCSSDeclaration(Operation aOperation) final; nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final; nsIDocument* DocToUpdate() final; - ServoCSSParsingEnvironment - GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; + ParsingEnvironment + GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; private: // For accessing the constructor. friend class ServoStyleRule; explicit ServoStyleRuleDeclaration( already_AddRefed<RawServoDeclarationBlock> aDecls); ~ServoStyleRuleDeclaration();
--- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -753,21 +753,21 @@ nsComputedDOMStyle::SetCSSDeclaration(De } nsIDocument* nsComputedDOMStyle::DocToUpdate() { MOZ_CRASH("called nsComputedDOMStyle::DocToUpdate"); } -nsDOMCSSDeclaration::ServoCSSParsingEnvironment -nsComputedDOMStyle::GetServoCSSParsingEnvironment( +nsDOMCSSDeclaration::ParsingEnvironment +nsComputedDOMStyle::GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const { - MOZ_CRASH("called nsComputedDOMStyle::GetServoCSSParsingEnvironment"); + MOZ_CRASH("called nsComputedDOMStyle::GetParsingEnvironment"); } void nsComputedDOMStyle::ClearComputedStyle() { if (mResolvedComputedStyle) { mResolvedComputedStyle = false; mContent->RemoveMutationObserver(this);
--- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -123,18 +123,18 @@ public: // nsDOMCSSDeclaration abstract methods which should never be called // on a nsComputedDOMStyle object, but must be defined to avoid // compile errors. virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation) override; virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*) override; virtual nsIDocument* DocToUpdate() override; - nsDOMCSSDeclaration::ServoCSSParsingEnvironment - GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; + nsDOMCSSDeclaration::ParsingEnvironment + GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; static already_AddRefed<nsROCSSPrimitiveValue> MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix); static void RegisterPrefChangeCallbacks(); static void UnregisterPrefChangeCallbacks(); // nsIMutationObserver
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -152,18 +152,18 @@ nsDOMCSSAttributeDeclaration::GetCSSDecl if (NS_FAILED(rv)) { return nullptr; // the decl will be destroyed along with the style rule } return decl; } -nsDOMCSSDeclaration::ServoCSSParsingEnvironment -nsDOMCSSAttributeDeclaration::GetServoCSSParsingEnvironment( +nsDOMCSSDeclaration::ParsingEnvironment +nsDOMCSSAttributeDeclaration::GetParsingEnvironment( nsIPrincipal* aSubjectPrincipal) const { return { mElement->GetURLDataForStyleAttr(aSubjectPrincipal), mElement->OwnerDoc()->GetCompatibilityMode(), mElement->OwnerDoc()->CSSLoader(), }; }
--- a/layout/style/nsDOMCSSAttrDeclaration.h +++ b/layout/style/nsDOMCSSAttrDeclaration.h @@ -31,18 +31,18 @@ public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCSSAttributeDeclaration, nsICSSDeclaration) // If GetCSSDeclaration returns non-null, then the decl it returns // is owned by our current style rule. mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) final; - nsDOMCSSDeclaration::ServoCSSParsingEnvironment - GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; + nsDOMCSSDeclaration::ParsingEnvironment + GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; mozilla::css::Rule* GetParentRule() override { return nullptr; } nsINode* GetParentObject() override {
--- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -113,18 +113,18 @@ nsDOMCSSDeclaration::SetCssText(const ns // For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to // Attribute setting code, which leads in turn to BeginUpdate. We // need to start the update now so that the old rule doesn't get used // between when we mutate the declaration and when we set the new // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - ServoCSSParsingEnvironment servoEnv = - GetServoCSSParsingEnvironment(aSubjectPrincipal); + ParsingEnvironment servoEnv = + GetParsingEnvironment(aSubjectPrincipal); if (!servoEnv.mUrlExtraData) { aRv.Throw(NS_ERROR_NOT_AVAILABLE); return; } RefPtr<DeclarationBlock> newdecl = ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData, servoEnv.mCompatMode, servoEnv.mLoader); @@ -215,18 +215,18 @@ NS_IMETHODIMP nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName, nsAString& aReturn) { nsresult rv = GetPropertyValue(aPropertyName, aReturn); NS_ENSURE_SUCCESS(rv, rv); return RemovePropertyInternal(aPropertyName); } -/* static */ nsDOMCSSDeclaration::ServoCSSParsingEnvironment -nsDOMCSSDeclaration::GetServoCSSParsingEnvironmentForRule(const css::Rule* aRule) +/* static */ nsDOMCSSDeclaration::ParsingEnvironment +nsDOMCSSDeclaration::GetParsingEnvironmentForRule(const css::Rule* aRule) { StyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr; if (!sheet) { return { nullptr, eCompatibility_FullStandards, nullptr }; } if (nsIDocument* document = aRule->GetDocument()) { return { @@ -257,18 +257,18 @@ nsDOMCSSDeclaration::ModifyDeclaration(n // Attribute setting code, which leads in turn to BeginUpdate. We // need to start the update now so that the old rule doesn't get used // between when we mutate the declaration and when we set the new // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable(); bool changed; - ServoCSSParsingEnvironment servoEnv = - GetServoCSSParsingEnvironment(aSubjectPrincipal); + ParsingEnvironment servoEnv = + GetParsingEnvironment(aSubjectPrincipal); if (!servoEnv.mUrlExtraData) { return NS_ERROR_NOT_AVAILABLE; } changed = aFunc(decl->AsServo(), servoEnv); if (!changed) { // Parsing failed -- but we don't throw an exception for that. @@ -281,34 +281,34 @@ nsDOMCSSDeclaration::ModifyDeclaration(n nsresult nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID, const nsAString& aPropValue, bool aIsImportant, nsIPrincipal* aSubjectPrincipal) { return ModifyDeclaration( aSubjectPrincipal, - [&](ServoDeclarationBlock* decl, ServoCSSParsingEnvironment& env) { + [&](ServoDeclarationBlock* decl, ParsingEnvironment& env) { NS_ConvertUTF16toUTF8 value(aPropValue); return Servo_DeclarationBlock_SetPropertyById( decl->Raw(), aPropID, &value, aIsImportant, env.mUrlExtraData, ParsingMode::Default, env.mCompatMode, env.mLoader); }); } nsresult nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName, const nsAString& aPropValue, bool aIsImportant, nsIPrincipal* aSubjectPrincipal) { MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName)); return ModifyDeclaration( aSubjectPrincipal, - [&](ServoDeclarationBlock* decl, ServoCSSParsingEnvironment& env) { + [&](ServoDeclarationBlock* decl, ParsingEnvironment& env) { NS_ConvertUTF16toUTF8 property(aPropertyName); NS_ConvertUTF16toUTF8 value(aPropValue); return Servo_DeclarationBlock_SetProperty( decl->Raw(), &property, &value, aIsImportant, env.mUrlExtraData, ParsingMode::Default, env.mCompatMode, env.mLoader); }); }
--- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -106,31 +106,31 @@ public: #undef CSS_PROP_PUBLIC_OR_PRIVATE virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; // Information needed to parse a declaration for Servo side. // Put this in public so other Servo parsing functions can reuse this. - struct MOZ_STACK_CLASS ServoCSSParsingEnvironment + struct MOZ_STACK_CLASS ParsingEnvironment { RefPtr<mozilla::URLExtraData> mUrlExtraData; nsCompatibility mCompatMode; mozilla::css::Loader* mLoader; - ServoCSSParsingEnvironment(mozilla::URLExtraData* aUrlData, + ParsingEnvironment(mozilla::URLExtraData* aUrlData, nsCompatibility aCompatMode, mozilla::css::Loader* aLoader) : mUrlExtraData(aUrlData) , mCompatMode(aCompatMode) , mLoader(aLoader) {} - ServoCSSParsingEnvironment(already_AddRefed<mozilla::URLExtraData> aUrlData, + ParsingEnvironment(already_AddRefed<mozilla::URLExtraData> aUrlData, nsCompatibility aCompatMode, mozilla::css::Loader* aLoader) : mUrlExtraData(aUrlData) , mCompatMode(aCompatMode) , mLoader(aLoader) {} }; @@ -161,23 +161,23 @@ protected: // to it. virtual nsIDocument* DocToUpdate() = 0; // mUrlExtraData returns URL data for parsing url values in // CSS. Returns nullptr on failure. If mUrlExtraData is nullptr, // mCompatMode may not be set to anything meaningful. // If aSubjectPrincipal is passed, it should be the subject principal of the // scripted caller that initiated the parser. - virtual ServoCSSParsingEnvironment - GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal = nullptr) const = 0; + virtual ParsingEnvironment + GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal = nullptr) const = 0; - // An implementation for GetServoCSSParsingEnvironment for callers wrapping a + // An implementation for GetParsingEnvironment for callers wrapping a // css::Rule. - static ServoCSSParsingEnvironment - GetServoCSSParsingEnvironmentForRule(const mozilla::css::Rule* aRule); + static ParsingEnvironment + GetParsingEnvironmentForRule(const mozilla::css::Rule* aRule); nsresult ParsePropertyValue(const nsCSSPropertyID aPropID, const nsAString& aPropValue, bool aIsImportant, nsIPrincipal* aSubjectPrincipal); nsresult ParseCustomPropertyValue(const nsAString& aPropertyName, const nsAString& aPropValue,
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java +++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java @@ -220,23 +220,23 @@ public class WebAppManifest { return scope; } public boolean isInScope(final Uri uri) { if (mScope == null) { return true; } - if (!uri.getScheme().equals(mScope.getScheme())) { + if (!mScope.getScheme().equals(uri.getScheme())) { return false; } - if (!uri.getHost().equals(mScope.getHost())) { + if (!mScope.getHost().equals(uri.getHost())) { return false; } - if (!uri.getPath().startsWith(mScope.getPath())) { + if (uri.getPath() != null && !uri.getPath().startsWith(mScope.getPath())) { return false; } return true; } }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerSession.java @@ -77,20 +77,16 @@ public class LayerSession { @Override protected native void disposeNative(); @WrapForJNI(calledFrom = "any", dispatchTo = "gecko") public native void attachNPZC(PanZoomController npzc); @WrapForJNI(calledFrom = "ui", dispatchTo = "gecko") public native void onBoundsChanged(int left, int top, int width, int height); - // Gecko thread creates compositor; blocks UI thread. - @WrapForJNI(calledFrom = "ui", dispatchTo = "proxy") - public native void createCompositor(int width, int height, Object surface); - // Gecko thread pauses compositor; blocks UI thread. @WrapForJNI(calledFrom = "ui", dispatchTo = "current") public native void syncPauseCompositor(); // UI thread resumes compositor and notifies Gecko thread; does not block UI thread. @WrapForJNI(calledFrom = "ui", dispatchTo = "current") public native void syncResumeResizeCompositor(int width, int height, Object surface); @@ -158,17 +154,16 @@ public class LayerSession { // All fields are accessed on UI thread only. private final GeckoDisplay mDisplay = new GeckoDisplay(this); private PanZoomController mNPZC; private OverscrollEdgeEffect mOverscroll; private DynamicToolbarAnimator mToolbar; private CompositorController mController; private boolean mAttachedCompositor; - private boolean mCalledCreateCompositor; private boolean mCompositorReady; private Surface mSurface; // All fields of coordinates are in screen units. private int mLeft; private int mTop; // Top of the surface (including toolbar); private int mClientTop; // Top of the client area (i.e. excluding toolbar); private int mWidth; @@ -356,29 +351,30 @@ public class LayerSession { mCompositor.attachNPZC(mNPZC); } if (mSurface != null) { // If we have a valid surface, create the compositor now that we're attached. // Leave mSurface alone because we'll need it later for onCompositorReady. onSurfaceChanged(mSurface, mWidth, mHeight); } + + mCompositor.sendToolbarAnimatorMessage(IS_COMPOSITOR_CONTROLLER_OPEN); } /* package */ void onCompositorDetached() { if (DEBUG) { ThreadUtils.assertOnUiThread(); } if (mController != null) { mController.onCompositorDetached(); } mAttachedCompositor = false; - mCalledCreateCompositor = false; mCompositorReady = false; } /* package */ void handleCompositorMessage(final int message) { if (DEBUG) { ThreadUtils.assertOnUiThread(); } @@ -547,22 +543,16 @@ public class LayerSession { mHeight = height; if (mCompositorReady) { mCompositor.syncResumeResizeCompositor(width, height, surface); onWindowBoundsChanged(); return; } - if (mAttachedCompositor && !mCalledCreateCompositor) { - mCompositor.createCompositor(width, height, surface); - mCompositor.sendToolbarAnimatorMessage(IS_COMPOSITOR_CONTROLLER_OPEN); - mCalledCreateCompositor = true; - } - // We have a valid surface but we're not attached or the compositor // is not ready; save the surface for later when we're ready. mSurface = surface; // Adjust bounds as the last step. onWindowBoundsChanged(); }
--- a/security/manager/ssl/security-prefs.js +++ b/security/manager/ssl/security-prefs.js @@ -87,17 +87,17 @@ pref("security.signed_app_signatures.pol // 1: fall back to the subject common name for certificates valid before 23 // August 2016 if necessary // 2: fall back to the subject common name for certificates valid before 23 // August 2015 if necessary // 3: only use name information from the subject alternative name extension #ifdef RELEASE_OR_BETA pref("security.pki.name_matching_mode", 1); #else -pref("security.pki.name_matching_mode", 2); +pref("security.pki.name_matching_mode", 3); #endif // security.pki.netscape_step_up_policy controls how the platform handles the // id-Netscape-stepUp OID in extended key usage extensions of CA certificates. // 0: id-Netscape-stepUp is always considered equivalent to id-kp-serverAuth // 1: it is considered equivalent when the notBefore is before 23 August 2016 // 2: similarly, but for 23 August 2015 // 3: it is never considered equivalent
--- a/testing/mozharness/configs/unittests/mac_unittest.py +++ b/testing/mozharness/configs/unittests/mac_unittest.py @@ -4,16 +4,17 @@ import os INSTALLER_PATH = os.path.join(os.getcwd(), "installer.dmg") XPCSHELL_NAME = 'xpcshell' EXE_SUFFIX = '' DISABLE_SCREEN_SAVER = False ADJUST_MOUSE_AND_SCREEN = False ##### config = { "buildbot_json_path": "buildprops.json", + "virtualenv_modules": ['six==1.10.0', 'vcversioner==2.16.0.0'], ### "installer_path": INSTALLER_PATH, "xpcshell_name": XPCSHELL_NAME, "exe_suffix": EXE_SUFFIX, "run_file_names": { "mochitest": "runtests.py", "reftest": "runreftest.py", "xpcshell": "runxpcshelltests.py",
--- a/widget/GfxDriverInfo.cpp +++ b/widget/GfxDriverInfo.cpp @@ -9,18 +9,18 @@ #include "nsTArray.h" using namespace mozilla::widget; int32_t GfxDriverInfo::allFeatures = 0; uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0)); GfxDeviceFamily* const GfxDriverInfo::allDevices = nullptr; -GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax]; -nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax]; +GfxDeviceFamily* GfxDriverInfo::sDeviceFamilies[DeviceFamilyMax]; +nsAString* GfxDriverInfo::sDeviceVendors[DeviceVendorMax]; GfxDriverInfo::GfxDriverInfo() : mOperatingSystem(OperatingSystem::Unknown), mOperatingSystemVersion(0), mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)), mDevices(allDevices), mDeleteDevices(false), mFeature(allFeatures), @@ -94,21 +94,21 @@ GfxDriverInfo::~GfxDriverInfo() const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) { // The code here is too sensitive to fall through to the default case if the // code is invalid. NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range"); // If it already exists, we must have processed it once, so return it now. - if (mDeviceFamilies[id]) - return mDeviceFamilies[id]; + if (sDeviceFamilies[id]) + return sDeviceFamilies[id]; - mDeviceFamilies[id] = new GfxDeviceFamily; - GfxDeviceFamily* deviceFamily = mDeviceFamilies[id]; + sDeviceFamilies[id] = new GfxDeviceFamily; + GfxDeviceFamily* deviceFamily = sDeviceFamilies[id]; switch (id) { case IntelGMA500: APPEND_DEVICE(0x8108); /* IntelGMA500_1 */ APPEND_DEVICE(0x8109); /* IntelGMA500_2 */ break; case IntelGMA900: APPEND_DEVICE(0x2582); /* IntelGMA900_1 */ @@ -327,37 +327,37 @@ const GfxDeviceFamily* GfxDriverInfo::Ge } return deviceFamily; } // Macro for assigning a device vendor id to a string. #define DECLARE_VENDOR_ID(name, deviceId) \ case name: \ - mDeviceVendors[id]->AssignLiteral(deviceId); \ + sDeviceVendors[id]->AssignLiteral(deviceId); \ break; const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id) { NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range"); - if (mDeviceVendors[id]) - return *mDeviceVendors[id]; + if (sDeviceVendors[id]) + return *sDeviceVendors[id]; - mDeviceVendors[id] = new nsString(); + sDeviceVendors[id] = new nsString(); switch (id) { DECLARE_VENDOR_ID(VendorAll, ""); DECLARE_VENDOR_ID(VendorIntel, "0x8086"); DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de"); DECLARE_VENDOR_ID(VendorAMD, "0x1022"); DECLARE_VENDOR_ID(VendorATI, "0x1002"); DECLARE_VENDOR_ID(VendorMicrosoft, "0x1414"); DECLARE_VENDOR_ID(VendorParallels, "0x1ab8"); // Choose an arbitrary Qualcomm PCI VENdor ID for now. // TODO: This should be "QCOM" when Windows device ID parsing is reworked. DECLARE_VENDOR_ID(VendorQualcomm, "0x5143"); // Suppress a warning. DECLARE_VENDOR_ID(DeviceVendorMax, ""); } - return *mDeviceVendors[id]; + return *sDeviceVendors[id]; }
--- a/widget/GfxDriverInfo.h +++ b/widget/GfxDriverInfo.h @@ -5,38 +5,38 @@ #ifndef __mozilla_widget_GfxDriverInfo_h__ #define __mozilla_widget_GfxDriverInfo_h__ #include "nsString.h" // Macros for adding a blocklist item to the static list. #define APPEND_TO_DRIVER_BLOCKLIST(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion) \ - mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion)) + sDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion)) #define APPEND_TO_DRIVER_BLOCKLIST2(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId) \ - mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId)) + sDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId)) #define APPEND_TO_DRIVER_BLOCKLIST_RANGE(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, driverVersionMax, ruleId, suggestedVersion) \ do { \ MOZ_ASSERT(driverComparator == DRIVER_BETWEEN_EXCLUSIVE || \ driverComparator == DRIVER_BETWEEN_INCLUSIVE || \ driverComparator == DRIVER_BETWEEN_INCLUSIVE_START); \ GfxDriverInfo info(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion); \ info.mDriverVersionMax = driverVersionMax; \ - mDriverInfo->AppendElement(info); \ + sDriverInfo->AppendElement(info); \ } while (false) #define APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, driverVersionMax, ruleId, suggestedVersion) \ do { \ MOZ_ASSERT(driverComparator == DRIVER_BETWEEN_EXCLUSIVE || \ driverComparator == DRIVER_BETWEEN_INCLUSIVE || \ driverComparator == DRIVER_BETWEEN_INCLUSIVE_START); \ GfxDriverInfo info(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion, false, true); \ info.mDriverVersionMax = driverVersionMax; \ - mDriverInfo->AppendElement(info); \ + sDriverInfo->AppendElement(info); \ } while (false) namespace mozilla { namespace widget { enum class OperatingSystem { Unknown, @@ -156,20 +156,20 @@ struct GfxDriverInfo uint64_t mDriverVersion; uint64_t mDriverVersionMax; static uint64_t allDriverVersions; const char *mSuggestedVersion; nsCString mRuleId; static const GfxDeviceFamily* GetDeviceFamily(DeviceFamily id); - static GfxDeviceFamily* mDeviceFamilies[DeviceFamilyMax]; + static GfxDeviceFamily* sDeviceFamilies[DeviceFamilyMax]; static const nsAString& GetDeviceVendor(DeviceVendor id); - static nsAString* mDeviceVendors[DeviceVendorMax]; + static nsAString* sDeviceVendors[DeviceVendorMax]; nsString mModel, mHardware, mProduct, mManufacturer; bool mGpu2; }; #define GFX_DRIVER_VERSION(a,b,c,d) \ ((uint64_t(a)<<48) | (uint64_t(b)<<32) | (uint64_t(c)<<16) | uint64_t(d))
--- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -34,66 +34,66 @@ #include "gfxPlatform.h" #include "gfxConfig.h" #include "DriverCrashGuard.h" using namespace mozilla::widget; using namespace mozilla; using mozilla::MutexAutoLock; -nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo; -nsTArray<dom::GfxInfoFeatureStatus>* GfxInfoBase::mFeatureStatus; -bool GfxInfoBase::mDriverInfoObserverInitialized; -bool GfxInfoBase::mShutdownOccurred; +nsTArray<GfxDriverInfo>* GfxInfoBase::sDriverInfo; +nsTArray<dom::GfxInfoFeatureStatus>* GfxInfoBase::sFeatureStatus; +bool GfxInfoBase::sDriverInfoObserverInitialized; +bool GfxInfoBase::sShutdownOccurred; // Observes for shutdown so that the child GfxDriverInfo list is freed. class ShutdownObserver : public nsIObserver { virtual ~ShutdownObserver() {} public: ShutdownObserver() {} NS_DECL_ISUPPORTS NS_IMETHOD Observe(nsISupports *subject, const char *aTopic, const char16_t *aData) override { MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0); - delete GfxInfoBase::mDriverInfo; - GfxInfoBase::mDriverInfo = nullptr; + delete GfxInfoBase::sDriverInfo; + GfxInfoBase::sDriverInfo = nullptr; - delete GfxInfoBase::mFeatureStatus; - GfxInfoBase::mFeatureStatus = nullptr; + delete GfxInfoBase::sFeatureStatus; + GfxInfoBase::sFeatureStatus = nullptr; for (uint32_t i = 0; i < DeviceFamilyMax; i++) { - delete GfxDriverInfo::mDeviceFamilies[i]; - GfxDriverInfo::mDeviceFamilies[i] = nullptr; + delete GfxDriverInfo::sDeviceFamilies[i]; + GfxDriverInfo::sDeviceFamilies[i] = nullptr; } for (uint32_t i = 0; i < DeviceVendorMax; i++) { - delete GfxDriverInfo::mDeviceVendors[i]; - GfxDriverInfo::mDeviceVendors[i] = nullptr; + delete GfxDriverInfo::sDeviceVendors[i]; + GfxDriverInfo::sDeviceVendors[i] = nullptr; } - GfxInfoBase::mShutdownOccurred = true; + GfxInfoBase::sShutdownOccurred = true; return NS_OK; } }; NS_IMPL_ISUPPORTS(ShutdownObserver, nsIObserver) void InitGfxDriverInfoShutdownObserver() { - if (GfxInfoBase::mDriverInfoObserverInitialized) + if (GfxInfoBase::sDriverInfoObserverInitialized) return; - GfxInfoBase::mDriverInfoObserverInitialized = true; + GfxInfoBase::sDriverInfoObserverInitialized = true; nsCOMPtr<nsIObserverService> observerService = services::GetObserverService(); if (!observerService) { NS_WARNING("Could not get observer service!"); return; } ShutdownObserver *obs = new ShutdownObserver(); @@ -629,19 +629,19 @@ GfxInfoBase::GetFeatureStatus(int32_t aF } if (GetPrefValueForFeature(aFeature, *aStatus, aFailureId)) { return NS_OK; } if (XRE_IsContentProcess()) { // Use the cached data received from the parent process. - MOZ_ASSERT(mFeatureStatus); + MOZ_ASSERT(sFeatureStatus); bool success = false; - for (const auto& fs : *mFeatureStatus) { + for (const auto& fs : *sFeatureStatus) { if (fs.feature() == aFeature) { aFailureId = fs.failureId(); *aStatus = fs.status(); success = true; break; } } return success ? NS_OK : NS_ERROR_FAILURE; @@ -884,18 +884,18 @@ GfxInfoBase::FindBlocklistedDeviceInList #endif return status; } void GfxInfoBase::SetFeatureStatus(const nsTArray<dom::GfxInfoFeatureStatus>& aFS) { - MOZ_ASSERT(!mFeatureStatus); - mFeatureStatus = new nsTArray<dom::GfxInfoFeatureStatus>(aFS); + MOZ_ASSERT(!sFeatureStatus); + sFeatureStatus = new nsTArray<dom::GfxInfoFeatureStatus>(aFS); } nsresult GfxInfoBase::GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId, @@ -907,17 +907,17 @@ GfxInfoBase::GetFeatureStatusImpl(int32_ } if (*aStatus != nsIGfxInfo::FEATURE_STATUS_UNKNOWN) { // Terminate now with the status determined by the derived type (OS-specific // code). return NS_OK; } - if (mShutdownOccurred) { + if (sShutdownOccurred) { // This is futile; we've already commenced shutdown and our blocklists have // been deleted. We may want to look into resurrecting the blocklist instead // but for now, just don't even go there. return NS_OK; } // If an operating system was provided by the derived GetFeatureStatusImpl, // grab it here. Otherwise, the OS is unknown. @@ -938,18 +938,18 @@ GfxInfoBase::GetFeatureStatusImpl(int32_ // Check if the device is blocked from the downloaded blocklist. If not, check // the static list after that. This order is used so that we can later escape // out of static blocks (i.e. if we were wrong or something was patched, we // can back out our static block without doing a release). int32_t status; if (aDriverInfo.Length()) { status = FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion, aFeature, aFailureId, os); } else { - if (!mDriverInfo) { - mDriverInfo = new nsTArray<GfxDriverInfo>(); + if (!sDriverInfo) { + sDriverInfo = new nsTArray<GfxDriverInfo>(); } status = FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion, aFeature, aFailureId, os); } // It's now done being processed. It's safe to set the status to STATUS_OK. if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) { *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; } else {
--- a/widget/GfxInfoBase.h +++ b/widget/GfxInfoBase.h @@ -76,20 +76,20 @@ public: virtual nsresult Init(); // only useful on X11 NS_IMETHOD_(void) GetData() override { } static void AddCollector(GfxInfoCollectorBase* collector); static void RemoveCollector(GfxInfoCollectorBase* collector); - static nsTArray<GfxDriverInfo>* mDriverInfo; - static nsTArray<mozilla::dom::GfxInfoFeatureStatus>* mFeatureStatus; - static bool mDriverInfoObserverInitialized; - static bool mShutdownOccurred; + static nsTArray<GfxDriverInfo>* sDriverInfo; + static nsTArray<mozilla::dom::GfxInfoFeatureStatus>* sFeatureStatus; + static bool sDriverInfoObserverInitialized; + static bool sShutdownOccurred; virtual nsString Model() { return EmptyString(); } virtual nsString Hardware() { return EmptyString(); } virtual nsString Product() { return EmptyString(); } virtual nsString Manufacturer() { return EmptyString(); } virtual uint32_t OperatingSystemVersion() { return 0; } // Convenience to get the application version
--- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -255,20 +255,20 @@ static inline uint64_t version(uint32_t { return (uint64_t(major) << 32) + (uint64_t(minor) << 16) + uint64_t(revision); } const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { // Nothing here yet. - //if (!mDriverInfo->Length()) { + //if (!sDriverInfo->Length()) { // //} - return *mDriverInfo; + return *sDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(int32_t aFeature, int32_t *aStatus, nsAString & aSuggestedDriverVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId, @@ -277,17 +277,17 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF { NS_ENSURE_ARG_POINTER(aStatus); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; aSuggestedDriverVersion.SetIsVoid(true); OperatingSystem os = OperatingSystem::Linux; if (aOS) *aOS = os; - if (mShutdownOccurred) { + if (sShutdownOccurred) { return NS_OK; } GetData(); if (mGLMajorVersion == 1) { // We're on OpenGL 1. In most cases that indicates really old hardware. // We better block them, rather than rely on them to fail gracefully, because they don't!
--- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -361,25 +361,25 @@ GfxInfo::AddCrashReportAnnotations() note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); CrashReporter::AppendAppNotesToCrashReport(note); } const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { - if (mDriverInfo->IsEmpty()) { + if (sDriverInfo->IsEmpty()) { APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK, DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions, "FEATURE_OK_FORCE_OPENGL" ); } - return *mDriverInfo; + return *sDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(int32_t aFeature, int32_t *aStatus, nsAString &aSuggestedDriverVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString &aFailureId, @@ -387,17 +387,17 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF { NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; OperatingSystem os = mOS; if (aOS) *aOS = os; - if (mShutdownOccurred) { + if (sShutdownOccurred) { return NS_OK; } // OpenGL layers are never blacklisted on Android. // This early return is so we avoid potentially slow // GLStrings initialization on startup when we initialize GL layers. if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
--- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -818,29 +818,16 @@ class nsWindow::LayerViewSupport final queue.insertBack(this); } } }; public: typedef LayerSession::Compositor::Natives<LayerViewSupport> Base; - template<class Functor> - static void OnNativeCall(Functor&& aCall) - { - if (aCall.IsTarget(&LayerViewSupport::CreateCompositor)) { - // This call is blocking. - nsAppShell::SyncRunEvent(nsAppShell::LambdaEvent<Functor>( - mozilla::Move(aCall)), &LayerViewEvent::MakeEvent); - return; - } - - MOZ_CRASH("Unexpected call"); - } - static LayerViewSupport* FromNative(const LayerSession::Compositor::LocalRef& instance) { return GetNative(instance); } LayerViewSupport(NativePtr<LayerViewSupport>* aPtr, nsWindow* aWindow, const LayerSession::Compositor::LocalRef& aInstance) @@ -925,30 +912,16 @@ public: MOZ_ASSERT(NS_IsMainThread()); if (!mWindow) { return; // Already shut down. } mWindow->Resize(aLeft, aTop, aWidth, aHeight, /* repaint */ false); } - void CreateCompositor(int32_t aWidth, int32_t aHeight, - jni::Object::Param aSurface) - { - MOZ_ASSERT(NS_IsMainThread()); - if (!mWindow) { - return; // Already shut down. - } - - mSurface = aSurface; - mWindow->CreateLayerManager(aWidth, aHeight); - - mCompositorPaused = false; - } - void SyncPauseCompositor() { MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); if (RefPtr<UiCompositorControllerChild> child = GetUiCompositorControllerChild()) { mCompositorPaused = true; child->Pause(); } @@ -1418,16 +1391,24 @@ nsWindow::Create(nsIWidget* aParent, if (IsTopLevel()) { gTopLevelWindows.AppendElement(this); } else if (parent) { parent->mChildren.AppendElement(this); mParent = parent; } + // A default size of 1x1 confuses MobileViewportManager, so + // use 0x0 instead. This is also a little more fitting since + // we don't yet have a surface yet (and therefore a valid size) + // and 0x0 is usually recognized as invalid. + Resize(0, 0, false); + + CreateLayerManager(); + #ifdef DEBUG_ANDROID_WIDGET DumpWindows(); #endif return NS_OK; } void @@ -1854,33 +1835,34 @@ nsWindow::GetLayerManager(PLayerTransact { if (mLayerManager) { return mLayerManager; } return nullptr; } void -nsWindow::CreateLayerManager(int aCompositorWidth, int aCompositorHeight) +nsWindow::CreateLayerManager() { if (mLayerManager) { return; } nsWindow *topLevelWindow = FindTopLevel(); if (!topLevelWindow || topLevelWindow->mWindowType == eWindowType_invisible) { // don't create a layer manager for an invisible top-level window return; } // Ensure that gfxPlatform is initialized first. gfxPlatform::GetPlatform(); if (ShouldUseOffMainThreadCompositing()) { - CreateCompositor(aCompositorWidth, aCompositorHeight); + LayoutDeviceIntRect rect = GetBounds(); + CreateCompositor(rect.Width(), rect.Height()); if (mLayerManager) { return; } // If we get here, then off main thread compositing failed to initialize. sFailedToCreateGLContext = true; }
--- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -336,17 +336,17 @@ protected: return true; } static void DumpWindows(); static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0); static void LogWindow(nsWindow *win, int index, int indent); private: - void CreateLayerManager(int aCompositorWidth, int aCompositorHeight); + void CreateLayerManager(); void RedrawAll(); mozilla::layers::LayersId GetRootLayerId() const; RefPtr<mozilla::layers::UiCompositorControllerChild> GetUiCompositorControllerChild(); }; // Explicit template declarations to make clang be quiet. template<> const char nsWindow::NativePtr<nsWindow::LayerViewSupport>::sName[];
--- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -304,28 +304,28 @@ GfxInfo::AddCrashReportAnnotations() #define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, ruleId) \ APPEND_TO_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, \ DRIVER_COMPARISON_IGNORED, V(0,0,0,0), ruleId, "") const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { - if (!mDriverInfo->Length()) { + if (!sDriverInfo->Length()) { IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION, "FEATURE_FAILURE_MAC_ATI_NO_MSAA"); IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(RadeonX1000), nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, "FEATURE_FAILURE_MAC_RADEONX1000_NO_TEXTURE2D"); IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(Geforce7300GT), nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, "FEATURE_FAILURE_MAC_7300_NO_WEBGL"); } - return *mDriverInfo; + return *sDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId, @@ -333,17 +333,17 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF { NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; OperatingSystem os = OSXVersionToOperatingSystem(mOSXVersion); if (aOS) *aOS = os; - if (mShutdownOccurred) { + if (sShutdownOccurred) { return NS_OK; } // Don't evaluate special cases when we're evaluating the downloaded blocklist. if (!aDriverInfo.Length()) { if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { // Blacklist all ATI cards on OSX, except for // 0x6760 and 0x9488
--- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1318,16 +1318,22 @@ nsBaseWidget::CreateCompositorSession(in bool enableWR = gfx::gfxVars::UseWebRender() && WidgetTypeSupportsAcceleration() && AllowWebRenderForThisWindow(); bool enableAPZ = UseAPZ(); CompositorOptions options(enableAPZ, enableWR); bool enableAL = gfx::gfxConfig::IsEnabled(gfx::Feature::ADVANCED_LAYERS); options.SetUseAdvancedLayers(enableAL); +#ifdef MOZ_WIDGET_ANDROID + if (!GetNativeData(NS_JAVA_SURFACE)) { + options.SetInitiallyPaused(true); + } +#endif + RefPtr<LayerManager> lm; if (options.UseWebRender()) { lm = new WebRenderLayerManager(this); } else { lm = new ClientLayerManager(this); } bool retry = false;
--- a/widget/tests/chrome.ini +++ b/widget/tests/chrome.ini @@ -31,17 +31,17 @@ support-files = window_imestate_iframes. [test_plugin_scroll_consistency.html] [test_composition_text_querycontent.xul] support-files = window_composition_text_querycontent.xul [test_input_events_on_deactive_window.xul] support-files = file_input_events_on_deactive_window.html [test_position_on_resize.xul] [test_sizemode_events.xul] [test_taskbar_progress.xul] -skip-if = toolkit != "cocoa" && toolkit != "windows" +skip-if = toolkit != "cocoa" && toolkit != "windows" || (os == "win" && os_version == "10.0" && !ccov) # Bug 1456811 [test_bug760802.xul] [test_clipboard.xul] subsuite = clipboard [test_panel_mouse_coords.xul] skip-if = toolkit == "windows" # bug 1009955 # Cocoa [test_native_menus.xul]
--- a/widget/tests/unit/xpcshell.ini +++ b/widget/tests/unit/xpcshell.ini @@ -1,8 +1,9 @@ [DEFAULT] head = [test_taskbar_jumplistitems.js] +skip-if = os == "win" && os_version == "10.0" # Bug 1457329 [test_macsharingservice.js] skip-if = os != "mac" [test_macwebapputils.js] skip-if = os != "mac"
--- a/widget/uikit/GfxInfo.cpp +++ b/widget/uikit/GfxInfo.cpp @@ -147,40 +147,40 @@ NS_IMETHODIMP GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { return NS_ERROR_FAILURE; } const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { - if (mDriverInfo->IsEmpty()) { + if (sDriverInfo->IsEmpty()) { APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Ios, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK, DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions ); } - return *mDriverInfo; + return *sDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(int32_t aFeature, int32_t *aStatus, nsAString & aSuggestedDriverVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, OperatingSystem* aOS /* = nullptr */) { NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; if (aOS) *aOS = OperatingSystem::Ios; - if (mShutdownOccurred) { + if (sShutdownOccurred) { return NS_OK; } // OpenGL layers are never blacklisted on iOS. // This early return is so we avoid potentially slow // GLStrings initialization on startup when we initialize GL layers. if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS || aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL ||
--- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -1005,17 +1005,17 @@ DetectBrokenAVX() const unsigned AVX_CTRL_BITS = (1 << 1) | (1 << 2); return (_xgetbv(0) & AVX_CTRL_BITS) != AVX_CTRL_BITS; } #endif const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { - if (!mDriverInfo->Length()) { + if (!sDriverInfo->Length()) { /* * It should be noted here that more specialized rules on certain features * should be inserted -before- more generalized restriction. As the first * match for feature/OS/device found in the list will be used for the final * blacklisting call. */ /* @@ -1430,17 +1430,17 @@ GfxInfo::GetGfxDriverInfo() (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "FEATURE_UNQUALIFIED_WEBRENDER_NVIDIA_8"); APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows8_1, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "FEATURE_UNQUALIFIED_WEBRENDER_NVIDIA_8_1"); } - return *mDriverInfo; + return *sDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(int32_t aFeature, int32_t *aStatus, nsAString & aSuggestedDriverVersion, const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId, @@ -1448,17 +1448,17 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF { NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; if (aOS) *aOS = os; - if (mShutdownOccurred) { + if (sShutdownOccurred) { return NS_OK; } // Don't evaluate special cases if we're checking the downloaded blocklist. if (!aDriverInfo.Length()) { nsAutoString adapterVendorID; nsAutoString adapterDeviceID; nsAutoString adapterDriverVersionString;