diff --git a/CLOBBER b/CLOBBER index 585b368dd31..a7852c5964b 100644 --- a/CLOBBER +++ b/CLOBBER @@ -18,4 +18,4 @@ # Modifying this file will now automatically clobber the buildbot machines \o/ # -Bug 895047 - Clobber needed for touching js/src/js-confdefs.h.in +Bug 924992 - WebIDL headers changes not correctly picked up by the build system somehow diff --git a/accessible/src/atk/AccessibleWrap.cpp b/accessible/src/atk/AccessibleWrap.cpp index 57801ff3cf1..f5d99f06459 100644 --- a/accessible/src/atk/AccessibleWrap.cpp +++ b/accessible/src/atk/AccessibleWrap.cpp @@ -882,23 +882,23 @@ refRelationSetCB(AtkObject *aAtkObj) return relation_set; // Keep in sync with AtkRelationType enum. - static const uint32_t relationTypes[] = { - nsIAccessibleRelation::RELATION_CONTROLLED_BY, - nsIAccessibleRelation::RELATION_CONTROLLER_FOR, - nsIAccessibleRelation::RELATION_LABEL_FOR, - nsIAccessibleRelation::RELATION_LABELLED_BY, - nsIAccessibleRelation::RELATION_MEMBER_OF, - nsIAccessibleRelation::RELATION_NODE_CHILD_OF, - nsIAccessibleRelation::RELATION_FLOWS_TO, - nsIAccessibleRelation::RELATION_FLOWS_FROM, - nsIAccessibleRelation::RELATION_SUBWINDOW_OF, - nsIAccessibleRelation::RELATION_EMBEDS, - nsIAccessibleRelation::RELATION_EMBEDDED_BY, - nsIAccessibleRelation::RELATION_POPUP_FOR, - nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF, - nsIAccessibleRelation::RELATION_DESCRIBED_BY, - nsIAccessibleRelation::RELATION_DESCRIPTION_FOR, - nsIAccessibleRelation::RELATION_NODE_PARENT_OF + static const RelationType relationTypes[] = { + RelationType::CONTROLLED_BY, + RelationType::CONTROLLER_FOR, + RelationType::LABEL_FOR, + RelationType::LABELLED_BY, + RelationType::MEMBER_OF, + RelationType::NODE_CHILD_OF, + RelationType::FLOWS_TO, + RelationType::FLOWS_FROM, + RelationType::SUBWINDOW_OF, + RelationType::EMBEDS, + RelationType::EMBEDDED_BY, + RelationType::POPUP_FOR, + RelationType::PARENT_WINDOW_OF, + RelationType::DESCRIBED_BY, + RelationType::DESCRIPTION_FOR, + RelationType::NODE_PARENT_OF }; for (uint32_t i = 0; i < ArrayLength(relationTypes); i++) { diff --git a/accessible/src/base/Relation.h b/accessible/src/base/Relation.h index 6a9c9308e5a..f76750dd108 100644 --- a/accessible/src/base/Relation.h +++ b/accessible/src/base/Relation.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef RELATION_H_ -#define RELATION_H_ +#ifndef mozilla_a11y_relation_h_ +#define mozilla_a11y_relation_h_ #include "AccIterator.h" diff --git a/accessible/src/base/RelationType.h b/accessible/src/base/RelationType.h new file mode 100644 index 00000000000..6ddd8fa8c40 --- /dev/null +++ b/accessible/src/base/RelationType.h @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_a11y_relationtype_h_ +#define mozilla_a11y_relationtype_h_ + +#include "mozilla/TypedEnum.h" + +namespace mozilla { +namespace a11y { + +MOZ_BEGIN_ENUM_CLASS(RelationType) + + /** + * This object is labelled by a target object. + */ + LABELLED_BY = 0x00, + + /** + * This object is label for a target object. + */ + LABEL_FOR = 0x01, + + /** + * This object is described by the target object. + */ + DESCRIBED_BY = 0x02, + + /** + * This object is describes the target object. + */ + DESCRIPTION_FOR = 0x3, + + /** + * This object is a child of a target object. + */ + NODE_CHILD_OF = 0x4, + + /** + * This object is a parent of a target object. A dual relation to + * NODE_CHILD_OF. + */ + NODE_PARENT_OF = 0x5, + + /** + * Some attribute of this object is affected by a target object. + */ + CONTROLLED_BY = 0x06, + + /** + * This object is interactive and controls some attribute of a target object. + */ + CONTROLLER_FOR = 0x07, + + /** + * Content flows from this object to a target object, i.e. has content that + * flows logically to another object in a sequential way, e.g. text flow. + */ + FLOWS_TO = 0x08, + + /** + * Content flows to this object from a target object, i.e. has content that + * flows logically from another object in a sequential way, e.g. text flow. + */ + FLOWS_FROM = 0x09, + + /** + * This object is a member of a group of one or more objects. When there is + * more than one object in the group each member may have one and the same + * target, e.g. a grouping object. It is also possible that each member has + * multiple additional targets, e.g. one for every other member in the group. + */ + MEMBER_OF = 0x0a, + + /** + * This object is a sub window of a target object. + */ + SUBWINDOW_OF = 0x0b, + + /** + * This object embeds a target object. This relation can be used on the + * OBJID_CLIENT accessible for a top level window to show where the content + * areas are. + */ + EMBEDS = 0x0c, + + /** + * This object is embedded by a target object. + */ + EMBEDDED_BY = 0x0d, + + /** + * This object is a transient component related to the target object. When + * this object is activated the target object doesn't lose focus. + */ + POPUP_FOR = 0x0e, + + /** + * This object is a parent window of the target object. + */ + PARENT_WINDOW_OF = 0x0f, + + /** + * Part of a form/dialog with a related default button. It is used for + * MSAA/XPCOM, it isn't for IA2 or ATK. + */ + DEFAULT_BUTTON = 0x10, + + LAST = DEFAULT_BUTTON + +MOZ_END_ENUM_CLASS(RelationType) + +} // namespace a11y +} // namespace mozilla + +#endif diff --git a/accessible/src/base/moz.build b/accessible/src/base/moz.build index cbf498a6106..109bd4617ab 100644 --- a/accessible/src/base/moz.build +++ b/accessible/src/base/moz.build @@ -19,6 +19,7 @@ EXPORTS.mozilla.a11y += [ 'DocManager.h', 'FocusManager.h', 'Platform.h', + 'RelationType.h', 'Role.h', 'SelectionManager.h', 'States.h', diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index 16b54b32e41..1adb688479a 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -1519,7 +1519,7 @@ Accessible::State() state |= states::SELECTED; } else { // If focus is in a child of the tab panel surely the tab is selected! - Relation rel = RelationByType(nsIAccessibleRelation::RELATION_LABEL_FOR); + Relation rel = RelationByType(RelationType::LABEL_FOR); Accessible* relTarget = nullptr; while ((relTarget = rel.Next())) { if (relTarget->Role() == roles::PROPERTYPAGE && @@ -1814,7 +1814,7 @@ Accessible::ARIATransformRole(role aRole) if (mParent && mParent->Role() == roles::COMBOBOX) { return roles::COMBOBOX_LIST; - Relation rel = RelationByType(nsIAccessibleRelation::RELATION_NODE_CHILD_OF); + Relation rel = RelationByType(RelationType::NODE_CHILD_OF); Accessible* targetAcc = nullptr; while ((targetAcc = rel.Next())) if (targetAcc->Role() == roles::COMBOBOX) @@ -1984,21 +1984,23 @@ Accessible::GetAtomicRegion() const // nsIAccessible getRelationByType() NS_IMETHODIMP -Accessible::GetRelationByType(uint32_t aType, - nsIAccessibleRelation** aRelation) +Accessible::GetRelationByType(uint32_t aType, nsIAccessibleRelation** aRelation) { NS_ENSURE_ARG_POINTER(aRelation); *aRelation = nullptr; + + NS_ENSURE_ARG(aType <= static_cast(RelationType::LAST)); + if (IsDefunct()) return NS_ERROR_FAILURE; - Relation rel = RelationByType(aType); + Relation rel = RelationByType(static_cast(aType)); NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel)); return *aRelation ? NS_OK : NS_ERROR_FAILURE; } Relation -Accessible::RelationByType(uint32_t aType) +Accessible::RelationByType(RelationType aType) { if (!HasOwnContent()) return Relation(); @@ -2006,7 +2008,7 @@ Accessible::RelationByType(uint32_t aType) // Relationships are defined on the same content node that the role would be // defined on. switch (aType) { - case nsIAccessibleRelation::RELATION_LABELLED_BY: { + case RelationType::LABELLED_BY: { Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_labelledby)); if (mContent->IsHTML()) { @@ -2018,7 +2020,7 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_LABEL_FOR: { + case RelationType::LABEL_FOR: { Relation rel(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_labelledby)); if (mContent->Tag() == nsGkAtoms::label && mContent->IsXUL()) @@ -2027,7 +2029,7 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_DESCRIBED_BY: { + case RelationType::DESCRIBED_BY: { Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_describedby)); if (mContent->IsXUL()) @@ -2036,7 +2038,7 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_DESCRIPTION_FOR: { + case RelationType::DESCRIPTION_FOR: { Relation rel(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_describedby)); @@ -2051,7 +2053,7 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_NODE_CHILD_OF: { + case RelationType::NODE_CHILD_OF: { Relation rel(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_owns)); @@ -2082,7 +2084,7 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_NODE_PARENT_OF: { + case RelationType::NODE_PARENT_OF: { Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_owns)); // ARIA tree or treegrid can do the hierarchy by @aria-level, ARIA trees @@ -2100,36 +2102,36 @@ Accessible::RelationByType(uint32_t aType) return rel; } - case nsIAccessibleRelation::RELATION_CONTROLLED_BY: + case RelationType::CONTROLLED_BY: return Relation(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_controls)); - case nsIAccessibleRelation::RELATION_CONTROLLER_FOR: { + case RelationType::CONTROLLER_FOR: { Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_controls)); rel.AppendIter(new HTMLOutputIterator(Document(), mContent)); return rel; } - case nsIAccessibleRelation::RELATION_FLOWS_TO: + case RelationType::FLOWS_TO: return Relation(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_flowto)); - case nsIAccessibleRelation::RELATION_FLOWS_FROM: + case RelationType::FLOWS_FROM: return Relation(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_flowto)); - case nsIAccessibleRelation::RELATION_MEMBER_OF: + case RelationType::MEMBER_OF: return Relation(mDoc, GetAtomicRegion()); - case nsIAccessibleRelation::RELATION_SUBWINDOW_OF: - case nsIAccessibleRelation::RELATION_EMBEDS: - case nsIAccessibleRelation::RELATION_EMBEDDED_BY: - case nsIAccessibleRelation::RELATION_POPUP_FOR: - case nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF: + case RelationType::SUBWINDOW_OF: + case RelationType::EMBEDS: + case RelationType::EMBEDDED_BY: + case RelationType::POPUP_FOR: + case RelationType::PARENT_WINDOW_OF: return Relation(); - case nsIAccessibleRelation::RELATION_DEFAULT_BUTTON: { + case RelationType::DEFAULT_BUTTON: { if (mContent->IsHTML()) { // HTML form controls implements nsIFormControl interface. nsCOMPtr control(do_QueryInterface(mContent)); diff --git a/accessible/src/generic/Accessible.h b/accessible/src/generic/Accessible.h index 5741ab42775..ac63424760c 100644 --- a/accessible/src/generic/Accessible.h +++ b/accessible/src/generic/Accessible.h @@ -7,6 +7,7 @@ #define _Accessible_H_ #include "mozilla/a11y/AccTypes.h" +#include "mozilla/a11y/RelationType.h" #include "mozilla/a11y/Role.h" #include "mozilla/a11y/States.h" #include "nsAccessNode.h" @@ -294,7 +295,7 @@ public: /** * Get the relation of the given type. */ - virtual mozilla::a11y::Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType); ////////////////////////////////////////////////////////////////////////////// // Initializing methods diff --git a/accessible/src/generic/ApplicationAccessible.cpp b/accessible/src/generic/ApplicationAccessible.cpp index 0a0735b5ac9..e2d1b7bb6a4 100644 --- a/accessible/src/generic/ApplicationAccessible.cpp +++ b/accessible/src/generic/ApplicationAccessible.cpp @@ -141,7 +141,7 @@ ApplicationAccessible::FocusedChild() } Relation -ApplicationAccessible::RelationByType(uint32_t aRelationType) +ApplicationAccessible::RelationByType(RelationType aRelationType) { return Relation(); } diff --git a/accessible/src/generic/ApplicationAccessible.h b/accessible/src/generic/ApplicationAccessible.h index 033df8ed8a8..8ddc3eea488 100644 --- a/accessible/src/generic/ApplicationAccessible.h +++ b/accessible/src/generic/ApplicationAccessible.h @@ -70,7 +70,7 @@ public: virtual mozilla::a11y::role NativeRole(); virtual uint64_t State(); virtual uint64_t NativeState(); - virtual Relation RelationByType(uint32_t aRelType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild); diff --git a/accessible/src/generic/RootAccessible.cpp b/accessible/src/generic/RootAccessible.cpp index 0c24449dff9..bbc55a8e516 100644 --- a/accessible/src/generic/RootAccessible.cpp +++ b/accessible/src/generic/RootAccessible.cpp @@ -481,9 +481,9 @@ RootAccessible::Shutdown() // nsIAccessible method Relation -RootAccessible::RelationByType(uint32_t aType) +RootAccessible::RelationByType(RelationType aType) { - if (!mDocumentNode || aType != nsIAccessibleRelation::RELATION_EMBEDS) + if (!mDocumentNode || aType != RelationType::EMBEDS) return DocAccessibleWrap::RelationByType(aType); nsIDOMWindow* rootWindow = mDocumentNode->GetWindow(); diff --git a/accessible/src/generic/RootAccessible.h b/accessible/src/generic/RootAccessible.h index 6a016e5da58..0b2bd24069c 100644 --- a/accessible/src/generic/RootAccessible.h +++ b/accessible/src/generic/RootAccessible.h @@ -34,7 +34,7 @@ public: // Accessible virtual mozilla::a11y::ENameValueFlag Name(nsString& aName); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; virtual mozilla::a11y::role NativeRole(); virtual uint64_t NativeState(); diff --git a/accessible/src/html/HTMLElementAccessibles.cpp b/accessible/src/html/HTMLElementAccessibles.cpp index 07e9799867f..99ab04d9d0c 100644 --- a/accessible/src/html/HTMLElementAccessibles.cpp +++ b/accessible/src/html/HTMLElementAccessibles.cpp @@ -65,10 +65,10 @@ HTMLLabelAccessible::NativeName(nsString& aName) } Relation -HTMLLabelAccessible::RelationByType(uint32_t aType) +HTMLLabelAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) { + if (aType == RelationType::LABEL_FOR) { nsRefPtr label = dom::HTMLLabelElement::FromContent(mContent); rel.AppendTarget(mDoc, label->GetControl()); } @@ -89,10 +89,10 @@ HTMLLabelAccessible::NativeRole() NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible) Relation -HTMLOutputAccessible::RelationByType(uint32_t aType) +HTMLOutputAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_CONTROLLED_BY) + if (aType == RelationType::CONTROLLED_BY) rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for)); return rel; diff --git a/accessible/src/html/HTMLElementAccessibles.h b/accessible/src/html/HTMLElementAccessibles.h index cd2542c3f76..adebf0f0cbd 100644 --- a/accessible/src/html/HTMLElementAccessibles.h +++ b/accessible/src/html/HTMLElementAccessibles.h @@ -61,7 +61,7 @@ public: // Accessible virtual a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType) MOZ_OVERRIDE; + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; protected: virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE; @@ -82,7 +82,7 @@ public: // Accessible virtual a11y::role NativeRole(); virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; }; } // namespace a11y diff --git a/accessible/src/html/HTMLFormControlAccessible.cpp b/accessible/src/html/HTMLFormControlAccessible.cpp index b95d76f34ca..d694fd6964f 100644 --- a/accessible/src/html/HTMLFormControlAccessible.cpp +++ b/accessible/src/html/HTMLFormControlAccessible.cpp @@ -659,11 +659,11 @@ HTMLGroupboxAccessible::NativeName(nsString& aName) } Relation -HTMLGroupboxAccessible::RelationByType(uint32_t aType) +HTMLGroupboxAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessibleWrap::RelationByType(aType); // No override for label, so use for this
- if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY) + if (aType == RelationType::LABELLED_BY) rel.AppendTarget(mDoc, GetLegend()); return rel; @@ -680,10 +680,10 @@ HTMLLegendAccessible:: } Relation -HTMLLegendAccessible::RelationByType(uint32_t aType) +HTMLLegendAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessibleWrap::RelationByType(aType); - if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR) + if (aType != RelationType::LABEL_FOR) return rel; Accessible* groupbox = Parent(); @@ -742,10 +742,10 @@ HTMLFigureAccessible::NativeName(nsString& aName) } Relation -HTMLFigureAccessible::RelationByType(uint32_t aType) +HTMLFigureAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessibleWrap::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY) + if (aType == RelationType::LABELLED_BY) rel.AppendTarget(mDoc, Caption()); return rel; @@ -782,10 +782,10 @@ HTMLFigcaptionAccessible::NativeRole() } Relation -HTMLFigcaptionAccessible::RelationByType(uint32_t aType) +HTMLFigcaptionAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessibleWrap::RelationByType(aType); - if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR) + if (aType != RelationType::LABEL_FOR) return rel; Accessible* figure = Parent(); diff --git a/accessible/src/html/HTMLFormControlAccessible.h b/accessible/src/html/HTMLFormControlAccessible.h index 005969dcc94..e670c1a5e10 100644 --- a/accessible/src/html/HTMLFormControlAccessible.h +++ b/accessible/src/html/HTMLFormControlAccessible.h @@ -193,7 +193,7 @@ public: // Accessible virtual mozilla::a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; protected: // Accessible @@ -214,7 +214,7 @@ public: // Accessible virtual mozilla::a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; }; /** @@ -228,7 +228,7 @@ public: // Accessible virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; virtual mozilla::a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; protected: // Accessible @@ -249,7 +249,7 @@ public: // Accessible virtual mozilla::a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; }; } // namespace a11y diff --git a/accessible/src/html/HTMLTableAccessible.cpp b/accessible/src/html/HTMLTableAccessible.cpp index 4d78d6b778d..56de51094cd 100644 --- a/accessible/src/html/HTMLTableAccessible.cpp +++ b/accessible/src/html/HTMLTableAccessible.cpp @@ -451,10 +451,10 @@ HTMLTableAccessible::NativeAttributes() // HTMLTableAccessible: nsIAccessible implementation Relation -HTMLTableAccessible::RelationByType(uint32_t aType) +HTMLTableAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY) + if (aType == RelationType::LABELLED_BY) rel.AppendTarget(Caption()); return rel; @@ -1118,10 +1118,10 @@ HTMLTableAccessible::IsProbablyLayoutTable() //////////////////////////////////////////////////////////////////////////////// Relation -HTMLCaptionAccessible::RelationByType(uint32_t aType) +HTMLCaptionAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessible::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) + if (aType == RelationType::LABEL_FOR) rel.AppendTarget(Parent()); return rel; diff --git a/accessible/src/html/HTMLTableAccessible.h b/accessible/src/html/HTMLTableAccessible.h index c18c0eb9e46..691aa0842b0 100644 --- a/accessible/src/html/HTMLTableAccessible.h +++ b/accessible/src/html/HTMLTableAccessible.h @@ -172,7 +172,7 @@ public: virtual a11y::role NativeRole(); virtual uint64_t NativeState(); virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; - virtual Relation RelationByType(uint32_t aRelationType); + virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE; protected: // Accessible @@ -231,7 +231,7 @@ public: // Accessible virtual a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aRelationType); + virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE; }; } // namespace a11y diff --git a/accessible/src/mac/mozAccessible.mm b/accessible/src/mac/mozAccessible.mm index f584bc71b51..891bcbdac0b 100644 --- a/accessible/src/mac/mozAccessible.mm +++ b/accessible/src/mac/mozAccessible.mm @@ -193,7 +193,7 @@ GetClosestInterestingAccessible(id anObject) if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) return [self title]; if ([attribute isEqualToString:NSAccessibilityTitleUIElementAttribute]) { - Relation rel = mGeckoAccessible->RelationByType(nsIAccessibleRelation::RELATION_LABELLED_BY); + Relation rel = mGeckoAccessible->RelationByType(RelationType::LABELLED_BY); Accessible* tempAcc = rel.Next(); return tempAcc ? GetNativeFromGeckoAccessible(tempAcc) : nil; } diff --git a/accessible/src/windows/ia2/ia2Accessible.cpp b/accessible/src/windows/ia2/ia2Accessible.cpp index ce3a0cc5663..08cb8f64dd6 100644 --- a/accessible/src/windows/ia2/ia2Accessible.cpp +++ b/accessible/src/windows/ia2/ia2Accessible.cpp @@ -86,10 +86,10 @@ ia2Accessible::get_relation(long aRelationIndex, long relIdx = 0; for (unsigned int idx = 0; idx < ArrayLength(sRelationTypesForIA2); idx++) { - uint32_t relType = sRelationTypesForIA2[idx]; - Relation rel = acc->RelationByType(relType); + RelationType relationType = sRelationTypesForIA2[idx]; + Relation rel = acc->RelationByType(relationType); nsRefPtr ia2Relation = - new ia2AccessibleRelation(relType, &rel); + new ia2AccessibleRelation(relationType, &rel); if (ia2Relation->HasTargets()) { if (relIdx == aRelationIndex) { ia2Relation.forget(aRelation); @@ -122,10 +122,10 @@ ia2Accessible::get_relations(long aMaxRelations, for (unsigned int idx = 0; idx < ArrayLength(sRelationTypesForIA2) && *aNRelations < aMaxRelations; idx++) { - uint32_t relType = sRelationTypesForIA2[idx]; - Relation rel = acc->RelationByType(relType); + RelationType relationType = sRelationTypesForIA2[idx]; + Relation rel = acc->RelationByType(relationType); nsRefPtr ia2Rel = - new ia2AccessibleRelation(relType, &rel); + new ia2AccessibleRelation(relationType, &rel); if (ia2Rel->HasTargets()) { ia2Rel.forget(aRelation + (*aNRelations)); (*aNRelations)++; diff --git a/accessible/src/windows/ia2/ia2AccessibleRelation.cpp b/accessible/src/windows/ia2/ia2AccessibleRelation.cpp index 75d7e880133..aeba6ab4958 100644 --- a/accessible/src/windows/ia2/ia2AccessibleRelation.cpp +++ b/accessible/src/windows/ia2/ia2AccessibleRelation.cpp @@ -8,7 +8,6 @@ #include "ia2AccessibleRelation.h" #include "Relation.h" -#include "IUnknownImpl.h" #include "nsIAccessibleRelation.h" #include "nsID.h" @@ -16,8 +15,8 @@ using namespace mozilla::a11y; -ia2AccessibleRelation::ia2AccessibleRelation(uint32_t aType, Relation* aRel) : - mType(aType), mReferences(0) +ia2AccessibleRelation::ia2AccessibleRelation(RelationType aType, Relation* aRel) : + mType(aType) { Accessible* target = nullptr; while ((target = aRel->Next())) @@ -26,39 +25,10 @@ ia2AccessibleRelation::ia2AccessibleRelation(uint32_t aType, Relation* aRel) : // IUnknown -STDMETHODIMP -ia2AccessibleRelation::QueryInterface(REFIID iid, void** ppv) -{ - if (!ppv) - return E_INVALIDARG; - - *ppv = nullptr; - - if (IID_IAccessibleRelation == iid || IID_IUnknown == iid) { - *ppv = static_cast(this); - (reinterpret_cast(*ppv))->AddRef(); - return S_OK; - } - - return E_NOINTERFACE; -} - -ULONG STDMETHODCALLTYPE -ia2AccessibleRelation::AddRef() -{ - return mReferences++; -} - -ULONG STDMETHODCALLTYPE -ia2AccessibleRelation::Release() -{ - mReferences--; - ULONG references = mReferences; - if (!mReferences) - delete this; - - return references; -} +IMPL_IUNKNOWN_QUERY_HEAD(ia2AccessibleRelation) + IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleRelation) + IMPL_IUNKNOWN_QUERY_IFACE(IUnknown) +IMPL_IUNKNOWN_QUERY_TAIL // IAccessibleRelation @@ -73,56 +43,54 @@ ia2AccessibleRelation::get_relationType(BSTR *aRelationType) *aRelationType = nullptr; switch (mType) { - case nsIAccessibleRelation::RELATION_CONTROLLED_BY: + case RelationType::CONTROLLED_BY: *aRelationType = ::SysAllocString(IA2_RELATION_CONTROLLED_BY); break; - case nsIAccessibleRelation::RELATION_CONTROLLER_FOR: + case RelationType::CONTROLLER_FOR: *aRelationType = ::SysAllocString(IA2_RELATION_CONTROLLER_FOR); break; - case nsIAccessibleRelation::RELATION_DESCRIBED_BY: + case RelationType::DESCRIBED_BY: *aRelationType = ::SysAllocString(IA2_RELATION_DESCRIBED_BY); break; - case nsIAccessibleRelation::RELATION_DESCRIPTION_FOR: + case RelationType::DESCRIPTION_FOR: *aRelationType = ::SysAllocString(IA2_RELATION_DESCRIPTION_FOR); break; - case nsIAccessibleRelation::RELATION_EMBEDDED_BY: + case RelationType::EMBEDDED_BY: *aRelationType = ::SysAllocString(IA2_RELATION_EMBEDDED_BY); break; - case nsIAccessibleRelation::RELATION_EMBEDS: + case RelationType::EMBEDS: *aRelationType = ::SysAllocString(IA2_RELATION_EMBEDS); break; - case nsIAccessibleRelation::RELATION_FLOWS_FROM: + case RelationType::FLOWS_FROM: *aRelationType = ::SysAllocString(IA2_RELATION_FLOWS_FROM); break; - case nsIAccessibleRelation::RELATION_FLOWS_TO: + case RelationType::FLOWS_TO: *aRelationType = ::SysAllocString(IA2_RELATION_FLOWS_TO); break; - case nsIAccessibleRelation::RELATION_LABEL_FOR: + case RelationType::LABEL_FOR: *aRelationType = ::SysAllocString(IA2_RELATION_LABEL_FOR); break; - case nsIAccessibleRelation::RELATION_LABELLED_BY: + case RelationType::LABELLED_BY: *aRelationType = ::SysAllocString(IA2_RELATION_LABELED_BY); break; - case nsIAccessibleRelation::RELATION_MEMBER_OF: + case RelationType::MEMBER_OF: *aRelationType = ::SysAllocString(IA2_RELATION_MEMBER_OF); break; - case nsIAccessibleRelation::RELATION_NODE_CHILD_OF: + case RelationType::NODE_CHILD_OF: *aRelationType = ::SysAllocString(IA2_RELATION_NODE_CHILD_OF); break; - case nsIAccessibleRelation::RELATION_NODE_PARENT_OF: + case RelationType::NODE_PARENT_OF: *aRelationType = ::SysAllocString(IA2_RELATION_NODE_PARENT_OF); break; - case nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF: + case RelationType::PARENT_WINDOW_OF: *aRelationType = ::SysAllocString(IA2_RELATION_PARENT_WINDOW_OF); break; - case nsIAccessibleRelation::RELATION_POPUP_FOR: + case RelationType::POPUP_FOR: *aRelationType = ::SysAllocString(IA2_RELATION_POPUP_FOR); break; - case nsIAccessibleRelation::RELATION_SUBWINDOW_OF: + case RelationType::SUBWINDOW_OF: *aRelationType = ::SysAllocString(IA2_RELATION_SUBWINDOW_OF); break; - default: - return E_FAIL; } return *aRelationType ? S_OK : E_OUTOFMEMORY; diff --git a/accessible/src/windows/ia2/ia2AccessibleRelation.h b/accessible/src/windows/ia2/ia2AccessibleRelation.h index f5cdf2053cc..3f6602ca3bf 100644 --- a/accessible/src/windows/ia2/ia2AccessibleRelation.h +++ b/accessible/src/windows/ia2/ia2AccessibleRelation.h @@ -9,6 +9,7 @@ #define _NS_ACCESSIBLE_RELATION_WRAP_H #include "Accessible.h" +#include "IUnknownImpl.h" #include "nsIAccessibleRelation.h" #include "nsTArray.h" @@ -18,16 +19,13 @@ namespace mozilla { namespace a11y { -class ia2AccessibleRelation : public IAccessibleRelation +class ia2AccessibleRelation MOZ_FINAL : public IAccessibleRelation { public: - ia2AccessibleRelation(uint32_t aType, Relation* aRel); - virtual ~ia2AccessibleRelation() { } + ia2AccessibleRelation(RelationType aType, Relation* aRel); // IUnknown - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID aIID, void** aOutPtr); - virtual ULONG STDMETHODCALLTYPE AddRef(); - virtual ULONG STDMETHODCALLTYPE Release(); + DECL_IUNKNOWN // IAccessibleRelation virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relationType( @@ -56,32 +54,31 @@ private: ia2AccessibleRelation(const ia2AccessibleRelation&); ia2AccessibleRelation& operator = (const ia2AccessibleRelation&); - uint32_t mType; + RelationType mType; nsTArray > mTargets; - ULONG mReferences; }; /** * Relations exposed to IAccessible2. */ -static const uint32_t sRelationTypesForIA2[] = { - nsIAccessibleRelation::RELATION_LABELLED_BY, - nsIAccessibleRelation::RELATION_LABEL_FOR, - nsIAccessibleRelation::RELATION_DESCRIBED_BY, - nsIAccessibleRelation::RELATION_DESCRIPTION_FOR, - nsIAccessibleRelation::RELATION_NODE_CHILD_OF, - nsIAccessibleRelation::RELATION_NODE_PARENT_OF, - nsIAccessibleRelation::RELATION_CONTROLLED_BY, - nsIAccessibleRelation::RELATION_CONTROLLER_FOR, - nsIAccessibleRelation::RELATION_FLOWS_TO, - nsIAccessibleRelation::RELATION_FLOWS_FROM, - nsIAccessibleRelation::RELATION_MEMBER_OF, - nsIAccessibleRelation::RELATION_SUBWINDOW_OF, - nsIAccessibleRelation::RELATION_EMBEDS, - nsIAccessibleRelation::RELATION_EMBEDDED_BY, - nsIAccessibleRelation::RELATION_POPUP_FOR, - nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF +static const RelationType sRelationTypesForIA2[] = { + RelationType::LABELLED_BY, + RelationType::LABEL_FOR, + RelationType::DESCRIBED_BY, + RelationType::DESCRIPTION_FOR, + RelationType::NODE_CHILD_OF, + RelationType::NODE_PARENT_OF, + RelationType::CONTROLLED_BY, + RelationType::CONTROLLER_FOR, + RelationType::FLOWS_TO, + RelationType::FLOWS_FROM, + RelationType::MEMBER_OF, + RelationType::SUBWINDOW_OF, + RelationType::EMBEDS, + RelationType::EMBEDDED_BY, + RelationType::POPUP_FOR, + RelationType::PARENT_WINDOW_OF }; } // namespace a11y diff --git a/accessible/src/windows/msaa/AccessibleWrap.cpp b/accessible/src/windows/msaa/AccessibleWrap.cpp index 0459d7dec3f..e8bb71b4050 100644 --- a/accessible/src/windows/msaa/AccessibleWrap.cpp +++ b/accessible/src/windows/msaa/AccessibleWrap.cpp @@ -921,55 +921,55 @@ AccessibleWrap::accNavigate( // MSAA relationship extensions to accNavigate case NAVRELATION_CONTROLLED_BY: - xpRelation = nsIAccessibleRelation::RELATION_CONTROLLED_BY; + xpRelation = static_cast(RelationType::CONTROLLED_BY); break; case NAVRELATION_CONTROLLER_FOR: - xpRelation = nsIAccessibleRelation::RELATION_CONTROLLER_FOR; + xpRelation = static_cast(RelationType::CONTROLLER_FOR); break; case NAVRELATION_LABEL_FOR: - xpRelation = nsIAccessibleRelation::RELATION_LABEL_FOR; + xpRelation = static_cast(RelationType::LABEL_FOR); break; case NAVRELATION_LABELLED_BY: - xpRelation = nsIAccessibleRelation::RELATION_LABELLED_BY; + xpRelation = static_cast(RelationType::LABELLED_BY); break; case NAVRELATION_MEMBER_OF: - xpRelation = nsIAccessibleRelation::RELATION_MEMBER_OF; + xpRelation = static_cast(RelationType::MEMBER_OF); break; case NAVRELATION_NODE_CHILD_OF: - xpRelation = nsIAccessibleRelation::RELATION_NODE_CHILD_OF; + xpRelation = static_cast(RelationType::NODE_CHILD_OF); break; case NAVRELATION_FLOWS_TO: - xpRelation = nsIAccessibleRelation::RELATION_FLOWS_TO; + xpRelation = static_cast(RelationType::FLOWS_TO); break; case NAVRELATION_FLOWS_FROM: - xpRelation = nsIAccessibleRelation::RELATION_FLOWS_FROM; + xpRelation = static_cast(RelationType::FLOWS_FROM); break; case NAVRELATION_SUBWINDOW_OF: - xpRelation = nsIAccessibleRelation::RELATION_SUBWINDOW_OF; + xpRelation = static_cast(RelationType::SUBWINDOW_OF); break; case NAVRELATION_EMBEDS: - xpRelation = nsIAccessibleRelation::RELATION_EMBEDS; + xpRelation = static_cast(RelationType::EMBEDS); break; case NAVRELATION_EMBEDDED_BY: - xpRelation = nsIAccessibleRelation::RELATION_EMBEDDED_BY; + xpRelation = static_cast(RelationType::EMBEDDED_BY); break; case NAVRELATION_POPUP_FOR: - xpRelation = nsIAccessibleRelation::RELATION_POPUP_FOR; + xpRelation = static_cast(RelationType::POPUP_FOR); break; case NAVRELATION_PARENT_WINDOW_OF: - xpRelation = nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF; + xpRelation = static_cast(RelationType::PARENT_WINDOW_OF); break; case NAVRELATION_DEFAULT_BUTTON: - xpRelation = nsIAccessibleRelation::RELATION_DEFAULT_BUTTON; + xpRelation = static_cast(RelationType::DEFAULT_BUTTON); break; case NAVRELATION_DESCRIBED_BY: - xpRelation = nsIAccessibleRelation::RELATION_DESCRIBED_BY; + xpRelation = static_cast(RelationType::DESCRIBED_BY); break; case NAVRELATION_DESCRIPTION_FOR: - xpRelation = nsIAccessibleRelation::RELATION_DESCRIPTION_FOR; + xpRelation = static_cast(RelationType::DESCRIPTION_FOR); break; case NAVRELATION_NODE_PARENT_OF: - xpRelation = nsIAccessibleRelation::RELATION_NODE_PARENT_OF; + xpRelation = static_cast(RelationType::NODE_PARENT_OF); break; default: @@ -979,7 +979,7 @@ AccessibleWrap::accNavigate( pvarEndUpAt->vt = VT_EMPTY; if (xpRelation >= 0) { - Relation rel = RelationByType(xpRelation); + Relation rel = RelationByType(static_cast(xpRelation)); navAccessible = rel.Next(); } diff --git a/accessible/src/xul/XULElementAccessibles.cpp b/accessible/src/xul/XULElementAccessibles.cpp index 768f68b9952..2dede9fef03 100644 --- a/accessible/src/xul/XULElementAccessibles.cpp +++ b/accessible/src/xul/XULElementAccessibles.cpp @@ -87,10 +87,10 @@ XULLabelAccessible::NativeState() } Relation -XULLabelAccessible::RelationByType(uint32_t aType) +XULLabelAccessible::RelationByType(RelationType aType) { Relation rel = HyperTextAccessibleWrap::RelationByType(aType); - if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) { + if (aType == RelationType::LABEL_FOR) { // Caption is the label for groupbox nsIContent* parent = mContent->GetFlattenedTreeParent(); if (parent && parent->Tag() == nsGkAtoms::caption) { diff --git a/accessible/src/xul/XULElementAccessibles.h b/accessible/src/xul/XULElementAccessibles.h index c24607444f4..e77775c25a1 100644 --- a/accessible/src/xul/XULElementAccessibles.h +++ b/accessible/src/xul/XULElementAccessibles.h @@ -26,7 +26,7 @@ public: virtual void Shutdown(); virtual a11y::role NativeRole(); virtual uint64_t NativeState(); - virtual Relation RelationByType(uint32_t aRelationType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; void UpdateLabelValue(const nsString& aValue); diff --git a/accessible/src/xul/XULFormControlAccessible.cpp b/accessible/src/xul/XULFormControlAccessible.cpp index 32b1b4bd344..befb3ffb472 100644 --- a/accessible/src/xul/XULFormControlAccessible.cpp +++ b/accessible/src/xul/XULFormControlAccessible.cpp @@ -385,7 +385,7 @@ XULGroupboxAccessible::NativeName(nsString& aName) { // XXX: we use the first related accessible only. Accessible* label = - RelationByType(nsIAccessibleRelation::RELATION_LABELLED_BY).Next(); + RelationByType(RelationType::LABELLED_BY).Next(); if (label) return label->Name(aName); @@ -393,10 +393,10 @@ XULGroupboxAccessible::NativeName(nsString& aName) } Relation -XULGroupboxAccessible::RelationByType(uint32_t aType) +XULGroupboxAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY) + if (aType != RelationType::LABELLED_BY) return rel; // The label for xul:groupbox is generated from xul:label that is @@ -407,8 +407,7 @@ XULGroupboxAccessible::RelationByType(uint32_t aType) Accessible* childAcc = GetChildAt(childIdx); if (childAcc->Role() == roles::LABEL) { // Ensure that it's our label - Relation reverseRel = - childAcc->RelationByType(nsIAccessibleRelation::RELATION_LABEL_FOR); + Relation reverseRel = childAcc->RelationByType(RelationType::LABEL_FOR); Accessible* testGroupbox = nullptr; while ((testGroupbox = reverseRel.Next())) if (testGroupbox == this) { diff --git a/accessible/src/xul/XULFormControlAccessible.h b/accessible/src/xul/XULFormControlAccessible.h index 6c23b7a0e23..3d7dbd7b46d 100644 --- a/accessible/src/xul/XULFormControlAccessible.h +++ b/accessible/src/xul/XULFormControlAccessible.h @@ -115,7 +115,7 @@ public: // Accessible virtual mozilla::a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aRelationType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; protected: // Accessible diff --git a/accessible/src/xul/XULTabAccessible.cpp b/accessible/src/xul/XULTabAccessible.cpp index 7a374fd0e86..cfedaf405b5 100644 --- a/accessible/src/xul/XULTabAccessible.cpp +++ b/accessible/src/xul/XULTabAccessible.cpp @@ -108,10 +108,10 @@ XULTabAccessible::NativeInteractiveState() const // nsIAccessible Relation -XULTabAccessible::RelationByType(uint32_t aType) +XULTabAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR) + if (aType != RelationType::LABEL_FOR) return rel; // Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible. @@ -195,10 +195,10 @@ XULTabpanelAccessible::NativeRole() } Relation -XULTabpanelAccessible::RelationByType(uint32_t aType) +XULTabpanelAccessible::RelationByType(RelationType aType) { Relation rel = AccessibleWrap::RelationByType(aType); - if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY) + if (aType != RelationType::LABELLED_BY) return rel; // Expose 'LABELLED_BY' relation on tabpanel accessible for tab accessible. diff --git a/accessible/src/xul/XULTabAccessible.h b/accessible/src/xul/XULTabAccessible.h index b8fe6ecee09..c57fcd10f89 100644 --- a/accessible/src/xul/XULTabAccessible.h +++ b/accessible/src/xul/XULTabAccessible.h @@ -31,7 +31,7 @@ public: virtual a11y::role NativeRole(); virtual uint64_t NativeState(); virtual uint64_t NativeInteractiveState() const; - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; // ActionAccessible virtual uint8_t ActionCount(); @@ -91,7 +91,7 @@ public: // Accessible virtual a11y::role NativeRole(); - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; }; } // namespace a11y diff --git a/accessible/src/xul/XULTreeAccessible.cpp b/accessible/src/xul/XULTreeAccessible.cpp index f29f785a5cd..a280d7e4937 100644 --- a/accessible/src/xul/XULTreeAccessible.cpp +++ b/accessible/src/xul/XULTreeAccessible.cpp @@ -442,9 +442,9 @@ XULTreeAccessible::ChildCount() const } Relation -XULTreeAccessible::RelationByType(uint32_t aType) +XULTreeAccessible::RelationByType(RelationType aType) { - if (aType == nsIAccessibleRelation::RELATION_NODE_PARENT_OF) { + if (aType == RelationType::NODE_PARENT_OF) { if (mTreeView) return Relation(new XULTreeItemIterator(this, mTreeView, -1)); @@ -808,11 +808,11 @@ XULTreeItemAccessibleBase::TakeFocus() } Relation -XULTreeItemAccessibleBase::RelationByType(uint32_t aType) +XULTreeItemAccessibleBase::RelationByType(RelationType aType) { switch (aType) { - case nsIAccessibleRelation::RELATION_NODE_CHILD_OF: { + case RelationType::NODE_CHILD_OF: { int32_t parentIndex = -1; if (!NS_SUCCEEDED(mTreeView->GetParentIndex(mRow, &parentIndex))) return Relation(); @@ -824,7 +824,7 @@ XULTreeItemAccessibleBase::RelationByType(uint32_t aType) return Relation(treeAcc->GetTreeItemAccessible(parentIndex)); } - case nsIAccessibleRelation::RELATION_NODE_PARENT_OF: { + case RelationType::NODE_PARENT_OF: { bool isTrue = false; if (NS_FAILED(mTreeView->IsContainerEmpty(mRow, &isTrue)) || isTrue) return Relation(); diff --git a/accessible/src/xul/XULTreeAccessible.h b/accessible/src/xul/XULTreeAccessible.h index c6e987df56c..b94fb899e33 100644 --- a/accessible/src/xul/XULTreeAccessible.h +++ b/accessible/src/xul/XULTreeAccessible.h @@ -50,7 +50,7 @@ public: virtual Accessible* GetChildAt(uint32_t aIndex); virtual uint32_t ChildCount() const; - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; // SelectAccessible virtual already_AddRefed SelectedItems(); @@ -163,7 +163,7 @@ public: virtual uint64_t NativeState(); virtual uint64_t NativeInteractiveState() const; virtual int32_t IndexInParent() const; - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; virtual Accessible* FocusedChild(); // ActionAccessible diff --git a/accessible/src/xul/XULTreeGridAccessible.cpp b/accessible/src/xul/XULTreeGridAccessible.cpp index 1374641ccac..fe9ceab7f44 100644 --- a/accessible/src/xul/XULTreeGridAccessible.cpp +++ b/accessible/src/xul/XULTreeGridAccessible.cpp @@ -762,7 +762,7 @@ XULTreeGridCellAccessible::IndexInParent() const } Relation -XULTreeGridCellAccessible::RelationByType(uint32_t aType) +XULTreeGridCellAccessible::RelationByType(RelationType aType) { return Relation(); } diff --git a/accessible/src/xul/XULTreeGridAccessible.h b/accessible/src/xul/XULTreeGridAccessible.h index 341cc13c280..5e8d5e357b2 100644 --- a/accessible/src/xul/XULTreeGridAccessible.h +++ b/accessible/src/xul/XULTreeGridAccessible.h @@ -160,7 +160,7 @@ public: virtual Accessible* FocusedChild(); virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; virtual int32_t IndexInParent() const; - virtual Relation RelationByType(uint32_t aType); + virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE; virtual a11y::role NativeRole(); virtual uint64_t NativeState(); virtual uint64_t NativeInteractiveState() const; diff --git a/b2g/components/ErrorPage.jsm b/b2g/components/ErrorPage.jsm index 60f2f97312f..8b6c2985e63 100644 --- a/b2g/components/ErrorPage.jsm +++ b/b2g/components/ErrorPage.jsm @@ -157,8 +157,12 @@ let ErrorPage = { observe: function errorPageObserve(aSubject, aTopic, aData) { let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader); let mm = frameLoader.messageManager; + + // This won't happen from dom/ipc/preload.js in non-OOP builds. try { - mm.loadFrameScript(kErrorPageFrameScript, true); + if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) { + mm.loadFrameScript(kErrorPageFrameScript, true); + } } catch (e) { dump('Error loading ' + kErrorPageFrameScript + ' as frame script: ' + e + '\n'); } diff --git a/content/media/webrtc/MediaEngineTabVideoSource.cpp b/content/media/webrtc/MediaEngineTabVideoSource.cpp index 530e5fe9e2f..f8274432973 100644 --- a/content/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/content/media/webrtc/MediaEngineTabVideoSource.cpp @@ -256,7 +256,6 @@ MediaEngineTabVideoSource::Draw() { cairoData.mSurface = surf; cairoData.mSize = size; - ImageFormat cairoFormat = CAIRO_SURFACE; nsRefPtr image = new layers::CairoImage(); image->SetData(cairoData); diff --git a/content/svg/content/src/SVGPathSegUtils.h b/content/svg/content/src/SVGPathSegUtils.h index d75f8ae2e08..f386dd4b8ed 100644 --- a/content/svg/content/src/SVGPathSegUtils.h +++ b/content/svg/content/src/SVGPathSegUtils.h @@ -9,7 +9,6 @@ #include "gfxPoint.h" #include "nsDebug.h" #include "nsMemory.h" -#include "prtypes.h" namespace mozilla { @@ -113,13 +112,13 @@ public: * can simply do a bitwise uint32_t<->float copy. */ static float EncodeType(uint32_t aType) { - PR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(float)); + static_assert(sizeof(uint32_t) == sizeof(float), "sizeof uint32_t and float must be the same"); NS_ABORT_IF_FALSE(IsValidType(aType), "Seg type not recognized"); return *(reinterpret_cast(&aType)); } static uint32_t DecodeType(float aType) { - PR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(float)); + static_assert(sizeof(uint32_t) == sizeof(float), "sizeof uint32_t and float must be the same"); uint32_t type = *(reinterpret_cast(&aType)); NS_ABORT_IF_FALSE(IsValidType(type), "Seg type not recognized"); return type; @@ -150,7 +149,7 @@ public: PRUnichar('T'), // 18 == PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS PRUnichar('t') // 19 == PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL }; - PR_STATIC_ASSERT(NS_ARRAY_LENGTH(table) == NS_SVG_PATH_SEG_TYPE_COUNT); + static_assert(NS_ARRAY_LENGTH(table) == NS_SVG_PATH_SEG_TYPE_COUNT, "Unexpected table size"); return table[aType]; } @@ -180,7 +179,7 @@ public: 2, // 18 == PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS 2 // 19 == PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL }; - PR_STATIC_ASSERT(NS_ARRAY_LENGTH(table) == NS_SVG_PATH_SEG_TYPE_COUNT); + static_assert(NS_ARRAY_LENGTH(table) == NS_SVG_PATH_SEG_TYPE_COUNT, "Unexpected table size"); return table[aType]; } @@ -222,8 +221,8 @@ public: // When adding a new path segment type, ensure that the returned condition // below is still correct. - PR_STATIC_ASSERT(NS_SVG_PATH_SEG_LAST_VALID_TYPE == - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL); + static_assert(NS_SVG_PATH_SEG_LAST_VALID_TYPE == PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, + "Unexpected type"); return aType >= PATHSEG_MOVETO_ABS; } @@ -235,8 +234,8 @@ public: // When adding a new path segment type, ensure that the returned condition // below is still correct. - PR_STATIC_ASSERT(NS_SVG_PATH_SEG_LAST_VALID_TYPE == - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL); + static_assert(NS_SVG_PATH_SEG_LAST_VALID_TYPE == PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, + "Unexpected type"); return aType & 1; } @@ -248,8 +247,8 @@ public: // When adding a new path segment type, ensure that the returned condition // below is still correct. - PR_STATIC_ASSERT(NS_SVG_PATH_SEG_LAST_VALID_TYPE == - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL); + static_assert(NS_SVG_PATH_SEG_LAST_VALID_TYPE == PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, + "Unexpected type"); return aType | 1; } diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 526b7dd4620..cdc57802d74 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1419,10 +1419,10 @@ nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, JS::Handle id, bool *aI if (JSID_IS_INT(id)) { i = JSID_TO_INT(id); } else { - jsval idval; + JS::RootedValue idval(cx); double array_index; - if (!::JS_IdToValue(cx, id, &idval) || - !::JS_ValueToNumber(cx, idval, &array_index) || + if (!::JS_IdToValue(cx, id, idval.address()) || + !JS::ToNumber(cx, idval, &array_index) || !::JS_DoubleIsInt32(array_index, &i)) { return -1; } diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp index b1fdb8a5f6d..2cd4174b72e 100644 --- a/dom/bindings/DOMJSProxyHandler.cpp +++ b/dom/bindings/DOMJSProxyHandler.cpp @@ -267,11 +267,11 @@ DOMProxyHandler::has(JSContext* cx, JS::Handle proxy, JS::Handle id) { - JS::Value idval; + JS::RootedValue idval(cx); double array_index; int32_t i; - if (!::JS_IdToValue(cx, id, &idval) || - !::JS_ValueToNumber(cx, idval, &array_index) || + if (!::JS_IdToValue(cx, id, idval.address()) || + !JS::ToNumber(cx, idval, &array_index) || !::JS_DoubleIsInt32(array_index, &i)) { return -1; } diff --git a/dom/browser-element/BrowserElementChild.js b/dom/browser-element/BrowserElementChild.js index 0b87347aa13..3020e8aa99d 100644 --- a/dom/browser-element/BrowserElementChild.js +++ b/dom/browser-element/BrowserElementChild.js @@ -24,9 +24,10 @@ docShell.setFullscreenAllowed(infos.fullscreenAllowed); if (!('BrowserElementIsPreloaded' in this)) { - // This is a produc-specific file that's sometimes unavailable. + // Those are produc-specific files that's sometimes unavailable. try { Services.scriptloader.loadSubScript("chrome://browser/content/forms.js"); + Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js"); } catch (e) { } Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js"); diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index 7682b74e841..b7b57c8f3a9 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -320,6 +320,8 @@ BrowserElementChild.prototype = { let returnValue = this._waitForResult(win); + Services.obs.notifyObservers(null, 'BEC:ShownModalPrompt', null); + if (args.promptType == 'prompt' || args.promptType == 'confirm' || args.promptType == 'custom-prompt') { diff --git a/dom/browser-element/BrowserElementPanning.js b/dom/browser-element/BrowserElementPanning.js index 90c5067be99..26accaf8326 100644 --- a/dom/browser-element/BrowserElementPanning.js +++ b/dom/browser-element/BrowserElementPanning.js @@ -63,6 +63,8 @@ const ContentPanning = { addMessageListener("Viewport:Change", this._recvViewportChange.bind(this)); addMessageListener("Gesture:DoubleTap", this._recvDoubleTap.bind(this)); + addEventListener("visibilitychange", this._recvVisibilityChange.bind(this)); + Services.obs.addObserver(this, "BEC:ShownModalPrompt", false); }, handleEvent: function cp_handleEvent(evt) { @@ -110,6 +112,12 @@ const ContentPanning = { } }, + observe: function cp_observe(subject, topic, data) { + if (topic === 'BEC:ShownModalPrompt') { + this._resetHover(); + } + }, + position: new Point(0 , 0), findPrimaryPointer: function cp_findPrimaryPointer(touches) { @@ -496,6 +504,12 @@ const ContentPanning = { this._setActive(root.documentElement); }, + _resetHover: function cp_resetHover() { + const kStateHover = 0x00000004; + let element = content.document.createElement('foo'); + this._domUtils.setContentState(element, kStateHover); + }, + _setActive: function cp_setActive(elt) { const kStateActive = 0x00000001; this._domUtils.setContentState(elt, kStateActive); @@ -581,6 +595,13 @@ const ContentPanning = { } }, + _recvVisibilityChange: function(evt) { + if (!evt.target.hidden) + return; + + this._resetHover(); + }, + _shouldZoomToElement: function(aElement) { let win = aElement.ownerDocument.defaultView; if (win.getComputedStyle(aElement, null).display == "inline") diff --git a/dom/browser-element/mochitest/Makefile.in b/dom/browser-element/mochitest/Makefile.in index 535a2f521ac..d23b3e90ad1 100644 --- a/dom/browser-element/mochitest/Makefile.in +++ b/dom/browser-element/mochitest/Makefile.in @@ -218,7 +218,6 @@ MOCHITEST_FILES += \ test_browserElement_oop_PromptConfirm.html \ test_browserElement_oop_CookiesNotThirdParty.html \ test_browserElement_oop_Close.html \ - test_browserElement_oop_CloseFromOpener.html \ test_browserElement_oop_CloseApp.html \ test_browserElement_oop_OpenWindow.html \ test_browserElement_oop_OpenWindowInFrame.html \ @@ -244,6 +243,9 @@ MOCHITEST_FILES += \ test_browserElement_oop_BrowserWindowResize.html \ $(NULL) +# Disabled until bug 924771 makes it stop timing out +# test_browserElement_oop_CloseFromOpener.html \ + # Disabled until we fix bug 906096. # test_browserElement_oop_SetInputMethodActive.html \ diff --git a/dom/icc/interfaces/nsIDOMIccManager.idl b/dom/icc/interfaces/nsIDOMIccManager.idl index b8ee3675c12..bc6e6ed3828 100644 --- a/dom/icc/interfaces/nsIDOMIccManager.idl +++ b/dom/icc/interfaces/nsIDOMIccManager.idl @@ -5,7 +5,6 @@ #include "nsIDOMEventTarget.idl" #include "SimToolKit.idl" -interface nsIDOMContact; interface nsIDOMDOMRequest; interface nsIDOMEventListener; interface nsIDOMMozIccInfo; @@ -497,7 +496,7 @@ interface nsIDOMMozIccManager : nsIDOMEventTarget * PIN2 is only required for 'fdn'. */ nsIDOMDOMRequest updateContact(in DOMString contactType, - in nsISupports contact, + in jsval contact, [optional] in DOMString pin2); // End of UICC Phonebook Interfaces. diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl index 36d774b74e2..cf1b321bacd 100644 --- a/dom/icc/interfaces/nsIIccProvider.idl +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -4,7 +4,6 @@ #include "nsISupports.idl" -interface nsIDOMContact; interface nsIDOMDOMRequest; interface nsIDOMMozIccInfo; interface nsIDOMWindow; @@ -72,7 +71,7 @@ interface nsIIccProvider : nsISupports nsIDOMDOMRequest updateContact(in nsIDOMWindow window, in DOMString contactType, - in nsISupports contact, + in jsval contact, in DOMString pin2); /** diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp index bd0b34b0e03..efccd9c9cd0 100644 --- a/dom/icc/src/IccManager.cpp +++ b/dom/icc/src/IccManager.cpp @@ -234,7 +234,7 @@ IccManager::ReadContacts(const nsAString& aContactType, nsIDOMDOMRequest** aRequ NS_IMETHODIMP IccManager::UpdateContact(const nsAString& aContactType, - nsISupports* aContact, + const JS::Value& aContact, const nsAString& aPin2, nsIDOMDOMRequest** aRequest) { diff --git a/dom/ipc/preload.js b/dom/ipc/preload.js index 15315ac94bb..337c7664f15 100644 --- a/dom/ipc/preload.js +++ b/dom/ipc/preload.js @@ -91,9 +91,10 @@ const BrowserElementIsPreloaded = true; } catch(e) { } - // This is a produc-specific file that's sometimes unavailable. + // Those are produc-specific files that's sometimes unavailable. try { Services.scriptloader.loadSubScript("chrome://browser/content/forms.js", global); + Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js", global); } catch (e) { } Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js", global); diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index f8595d68e1a..bf269c34f05 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -891,6 +891,7 @@ RTCError.prototype = { // This is a separate object because we don't want to expose it to DOM. function PeerConnectionObserver() { this._dompc = null; + this._guard = new WeakReferent(this); } PeerConnectionObserver.prototype = { classDescription: "PeerConnectionObserver", @@ -1192,9 +1193,23 @@ PeerConnectionObserver.prototype = { getSupportedConstraints: function(dict) { return dict; + }, + + get weakReferent() { + return this._guard; } }; +// A PeerConnectionObserver member that c++ can do weak references on + +function WeakReferent(parent) { + this._parent = parent; // prevents parent from going away without us +} +WeakReferent.prototype = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, + Ci.nsISupportsWeakReference]), +}; + this.NSGetFactory = XPCOMUtils.generateNSGetFactory( [GlobalPCList, RTCIceCandidate, RTCSessionDescription, RTCPeerConnection, RTCStatsReport, PeerConnectionObserver] diff --git a/dom/webidl/PeerConnectionObserver.webidl b/dom/webidl/PeerConnectionObserver.webidl index 162ff8b4c08..a8bdbd73bfe 100644 --- a/dom/webidl/PeerConnectionObserver.webidl +++ b/dom/webidl/PeerConnectionObserver.webidl @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ +interface nsISupports; + [ChromeOnly, JSImplementation="@mozilla.org/dom/peerconnectionobserver;1", Constructor (object domPC)] @@ -40,6 +42,9 @@ interface PeerConnectionObserver void onAddTrack(); void onRemoveTrack(); + /* Used by c++ to know when Observer goes away */ + readonly attribute nsISupports weakReferent; + /* Helper function to access supported constraints defined in webidl. Needs to * be in a separate webidl object we hold, so putting it here was convenient. */ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 6835f8aaa75..170e608d2ce 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -4646,7 +4646,8 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp, // See if any of the optional arguments were passed. if (aArgc > 1) { double intervalMS = 0; - if (!JS_ValueToNumber(aCx, argv[1], &intervalMS)) { + JS::RootedValue interval(aCx, argv[1]); + if (!JS::ToNumber(aCx, interval, &intervalMS)) { return false; } newInfo->mInterval = TimeDuration::FromMilliseconds(intervalMS); diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 72293602e5e..81d22773c0a 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -578,6 +578,15 @@ public: virtual TemporaryRef Snapshot() = 0; virtual IntSize GetSize() = 0; + /** + * If possible returns the bits to this DrawTarget for direct manipulation. While + * the bits is locked any modifications to this DrawTarget is forbidden. + * Release takes the original data pointer for safety. + */ + virtual bool LockBits(uint8_t** aData, IntSize* aSize, + int32_t* aStride, SurfaceFormat* aFormat) { return false; } + virtual void ReleaseBits(uint8_t* aData) {} + /* Ensure that the DrawTarget backend has flushed all drawing operations to * this draw target. This must be called before using the backing surface of * this draw target outside of GFX 2D code. diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 57486ac858e..44a5a0cf8db 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -399,6 +399,7 @@ NeedIntermediateSurface(const Pattern& aPattern, const DrawOptions& aOptions) DrawTargetCairo::DrawTargetCairo() : mContext(nullptr) + , mLockedBits(nullptr) { } @@ -408,6 +409,7 @@ DrawTargetCairo::~DrawTargetCairo() if (mSurface) { cairo_surface_destroy(mSurface); } + MOZ_ASSERT(!mLockedBits); } IntSize @@ -433,6 +435,31 @@ DrawTargetCairo::Snapshot() return mSnapshot; } +bool +DrawTargetCairo::LockBits(uint8_t** aData, IntSize* aSize, + int32_t* aStride, SurfaceFormat* aFormat) +{ + if (cairo_surface_get_type(mSurface) == CAIRO_SURFACE_TYPE_IMAGE) { + WillChange(); + + mLockedBits = cairo_image_surface_get_data(mSurface); + *aData = mLockedBits; + *aSize = GetSize(); + *aStride = cairo_image_surface_get_stride(mSurface); + *aFormat = GetFormat(); + return true; + } + + return false; +} + +void +DrawTargetCairo::ReleaseBits(uint8_t* aData) +{ + MOZ_ASSERT(mLockedBits == aData); + mLockedBits = nullptr; +} + void DrawTargetCairo::Flush() { @@ -1152,6 +1179,7 @@ void DrawTargetCairo::WillChange(const Path* aPath /* = nullptr */) { MarkSnapshotIndependent(); + MOZ_ASSERT(!mLockedBits); } void diff --git a/gfx/2d/DrawTargetCairo.h b/gfx/2d/DrawTargetCairo.h index 7b30707462b..f23b6241dce 100644 --- a/gfx/2d/DrawTargetCairo.h +++ b/gfx/2d/DrawTargetCairo.h @@ -60,6 +60,10 @@ public: virtual TemporaryRef Snapshot(); virtual IntSize GetSize(); + virtual bool LockBits(uint8_t** aData, IntSize* aSize, + int32_t* aStride, SurfaceFormat* aFormat); + virtual void ReleaseBits(uint8_t* aData); + virtual void Flush(); virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, @@ -185,6 +189,8 @@ private: // data cairo_surface_t* mSurface; IntSize mSize; + uint8_t* mLockedBits; + // The latest snapshot of this surface. This needs to be told when this // target is modified. We keep it alive as a cache. RefPtr mSnapshot; diff --git a/gfx/layers/BufferUnrotate.cpp b/gfx/layers/BufferUnrotate.cpp new file mode 100644 index 00000000000..e5ba465e4cb --- /dev/null +++ b/gfx/layers/BufferUnrotate.cpp @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include // min & max +#include +#include +#include +#include + +void BufferUnrotate(uint8_t* aBuffer, int aByteWidth, int aHeight, + int aByteStride, int aXBoundary, int aYBoundary) +{ + if (aXBoundary != 0) { + uint8_t* line = new uint8_t[aByteWidth]; + uint32_t smallStart = 0; + uint32_t smallLen = aXBoundary; + uint32_t smallDest = aByteWidth - aXBoundary; + uint32_t largeStart = aXBoundary; + uint32_t largeLen = aByteWidth - aXBoundary; + uint32_t largeDest = 0; + if (aXBoundary > aByteWidth / 2) { + smallStart = aXBoundary; + smallLen = aByteWidth - aXBoundary; + smallDest = 0; + largeStart = 0; + largeLen = aXBoundary; + largeDest = smallLen; + } + + for (int y = 0; y < aHeight; y++) { + int yOffset = y * aByteStride; + memcpy(line, &aBuffer[yOffset + smallStart], smallLen); + memmove(&aBuffer[yOffset + largeDest], &aBuffer[yOffset + largeStart], largeLen); + memcpy(&aBuffer[yOffset + smallDest], line, smallLen); + } + + delete[] line; + } + + if (aYBoundary != 0) { + uint32_t smallestHeight = std::min(aHeight - aYBoundary, aYBoundary); + uint32_t largestHeight = std::max(aHeight - aYBoundary, aYBoundary); + uint32_t smallOffset = 0; + uint32_t largeOffset = aYBoundary * aByteStride; + uint32_t largeDestOffset = 0; + uint32_t smallDestOffset = largestHeight * aByteStride; + if (aYBoundary > aHeight / 2) { + smallOffset = aYBoundary * aByteStride; + largeOffset = 0; + largeDestOffset = smallestHeight * aByteStride; + smallDestOffset = 0; + } + + uint8_t* smallestSide = new uint8_t[aByteStride * smallestHeight]; + memcpy(smallestSide, &aBuffer[smallOffset], aByteStride * smallestHeight); + memmove(&aBuffer[largeDestOffset], &aBuffer[largeOffset], aByteStride * largestHeight); + memcpy(&aBuffer[smallDestOffset], smallestSide, aByteStride * smallestHeight); + delete[] smallestSide; + } +} + diff --git a/gfx/layers/BufferUnrotate.h b/gfx/layers/BufferUnrotate.h new file mode 100644 index 00000000000..a292d02fcfa --- /dev/null +++ b/gfx/layers/BufferUnrotate.h @@ -0,0 +1,14 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_BUFFERUNROTATE_H +#define GFX_BUFFERUNROTATE_H + +#include "mozilla/Types.h" + +void BufferUnrotate(uint8_t* aBuffer, int aByteWidth, int aHeight, + int aByteStride, int aXByteBoundary, int aYBoundary); + +#endif // GFX_BUFFERUNROTATE_H diff --git a/gfx/layers/ThebesLayerBuffer.cpp b/gfx/layers/ThebesLayerBuffer.cpp index 7be8fa56ce3..f41e987ce9c 100644 --- a/gfx/layers/ThebesLayerBuffer.cpp +++ b/gfx/layers/ThebesLayerBuffer.cpp @@ -8,6 +8,7 @@ #include // for max #include "BasicImplData.h" // for BasicImplData #include "BasicLayersImpl.h" // for ToData +#include "BufferUnrotate.h" // for BufferUnrotate #include "GeckoProfiler.h" // for PROFILER_LABEL #include "Layers.h" // for ThebesLayer, Layer, etc #include "gfxColor.h" // for gfxRGBA @@ -675,18 +676,54 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType, } } result.mDidSelfCopy = true; + mDidSelfCopy = true; // Don't set destBuffer; we special-case self-copies, and // just did the necessary work above. mBufferRect = destBufferRect; } else { - // We can't do a real self-copy because the buffer is rotated. - // So allocate a new buffer for the destination. - destBufferRect = ComputeBufferRect(neededRegion.GetBounds()); - CreateBuffer(contentType, destBufferRect, bufferFlags, - getter_AddRefs(destBuffer), getter_AddRefs(destBufferOnWhite), - &destDTBuffer, &destDTBufferOnWhite); - if (!destBuffer && !destDTBuffer) - return result; + // With azure and a data surface perform an buffer unrotate + // (SelfCopy). + if (IsAzureBuffer()) { + unsigned char* data; + IntSize size; + int32_t stride; + SurfaceFormat format; + + if (mDTBuffer->LockBits(&data, &size, &stride, &format)) { + uint8_t bytesPerPixel = BytesPerPixel(format); + BufferUnrotate(data, + size.width * bytesPerPixel, + size.height, stride, + newRotation.x * bytesPerPixel, newRotation.y); + mDTBuffer->ReleaseBits(data); + + if (mode == Layer::SURFACE_COMPONENT_ALPHA) { + mDTBufferOnWhite->LockBits(&data, &size, &stride, &format); + uint8_t bytesPerPixel = BytesPerPixel(format); + BufferUnrotate(data, + size.width * bytesPerPixel, + size.height, stride, + newRotation.x * bytesPerPixel, newRotation.y); + mDTBufferOnWhite->ReleaseBits(data); + } + + // Buffer unrotate moves all the pixels, note that + // we self copied for SyncBackToFrontBuffer + result.mDidSelfCopy = true; + mDidSelfCopy = true; + mBufferRect = destBufferRect; + mBufferRotation = nsIntPoint(0, 0); + } + } + + if (!result.mDidSelfCopy) { + destBufferRect = ComputeBufferRect(neededRegion.GetBounds()); + CreateBuffer(contentType, destBufferRect, bufferFlags, + getter_AddRefs(destBuffer), getter_AddRefs(destBufferOnWhite), + &destDTBuffer, &destDTBufferOnWhite); + if (!destBuffer && !destDTBuffer) + return result; + } } } else { mBufferRect = destBufferRect; diff --git a/gfx/layers/ThebesLayerBuffer.h b/gfx/layers/ThebesLayerBuffer.h index ff2af1745f4..45fdb0e502a 100644 --- a/gfx/layers/ThebesLayerBuffer.h +++ b/gfx/layers/ThebesLayerBuffer.h @@ -146,6 +146,9 @@ protected: * buffer at the other end, not 2D rotation! */ nsIntPoint mBufferRotation; + // When this is true it means that all pixels have moved inside the buffer. + // It's not possible to sync with another buffer without a full copy. + bool mDidSelfCopy; }; /** diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index f46f9044662..5ecf1568ebe 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -479,21 +479,13 @@ ContentClientDoubleBuffered::SyncFrontBufferToBackBuffer() nsIntRegion updateRegion = mFrontUpdatedRegion; - int32_t xBoundary = mBufferRect.XMost() - mBufferRotation.x; - int32_t yBoundary = mBufferRect.YMost() - mBufferRotation.y; - - // Figure out whether the area we want to copy wraps the edges of our buffer. - bool needFullCopy = (xBoundary < updateRegion.GetBounds().XMost() && - xBoundary > updateRegion.GetBounds().x) || - (yBoundary < updateRegion.GetBounds().YMost() && - yBoundary > updateRegion.GetBounds().y); - // This is a tricky trade off, we're going to get stuff out of our // frontbuffer now, but the next PaintThebes might throw it all (or mostly) // away if the visible region has changed. This is why in reality we want // this code integrated with PaintThebes to always do the optimal thing. - if (needFullCopy) { + if (mDidSelfCopy) { + mDidSelfCopy = false; // We can't easily draw our front buffer into us, since we're going to be // copying stuff around anyway it's easiest if we just move our situation // to non-rotated while we're at it. If this situation occurs we'll have diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index ecda4d43354..f230b3dfd42 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -100,7 +100,6 @@ ImageBridgeParent::RecvUpdateNoSwap(const EditArray& aEdits) return success; } - static void ConnectImageBridgeInParentProcess(ImageBridgeParent* aBridge, Transport* aTransport, @@ -179,8 +178,6 @@ bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor) return true; } - - MessageLoop * ImageBridgeParent::GetMessageLoop() { return mMessageLoop; } @@ -198,7 +195,7 @@ ImageBridgeParent::CloneToplevel(const InfallibleTArray& aFds mozilla::ipc::ProtocolCloneContext* aCtx) { for (unsigned int i = 0; i < aFds.Length(); i++) { - if (aFds[i].protocolId() == (int)GetProtocolId()) { + if (aFds[i].protocolId() == unsigned(GetProtocolId())) { Transport* transport = OpenDescriptor(aFds[i].fd(), Transport::MODE_SERVER); PImageBridgeParent* bridge = Create(transport, base::GetProcId(aPeerProcess)); diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 8a78512c0bf..0db42ef7222 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -194,6 +194,7 @@ CPP_SOURCES += [ 'basic/BasicLayerManager.cpp', 'basic/BasicLayersImpl.cpp', 'basic/BasicThebesLayer.cpp', + 'BufferUnrotate.cpp', 'client/CanvasClient.cpp', 'composite/CanvasLayerComposite.cpp', 'opengl/CanvasLayerOGL.cpp', diff --git a/gfx/src/nsColor.h b/gfx/src/nsColor.h index bcae9761f1a..a93fabcba0b 100644 --- a/gfx/src/nsColor.h +++ b/gfx/src/nsColor.h @@ -10,7 +10,6 @@ #include // for uint8_t, uint32_t #include "gfxCore.h" // for NS_GFX_ #include "nscore.h" // for nsAString -#include "prtypes.h" // for PR_BEGIN_MACRO, etc class nsAString; class nsString; diff --git a/gfx/tests/gtest/TestBufferRotation.cpp b/gfx/tests/gtest/TestBufferRotation.cpp new file mode 100644 index 00000000000..9fb972adbbc --- /dev/null +++ b/gfx/tests/gtest/TestBufferRotation.cpp @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gtest/gtest.h" + +#include "BufferUnrotate.h" + +static unsigned char* GenerateBuffer(int bytesPerPixel, + int width, int height, + int stride, int xBoundary, int yBoundary) +{ + unsigned char* buffer = new unsigned char[stride*height]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + int pos = ((yBoundary + y) % height) * stride + + ((xBoundary + x) % width) * bytesPerPixel; + for (int i = 0; i < bytesPerPixel; i++) { + buffer[pos+i] = (x+y+i*2)%256; + } + } + } + return buffer; +} + +static bool CheckBuffer(unsigned char* buffer, int bytesPerPixel, + int width, int height, int stride) +{ + int xBoundary = 0; + int yBoundary = 0; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + int pos = ((yBoundary + y) % height) * stride + + ((xBoundary + x) % width) * bytesPerPixel; + for (int i = 0; i < bytesPerPixel; i++) { + if (buffer[pos+i] != (x+y+i*2)%256) { + printf("Buffer differs at %i, %i, is %i\n", x, y, (int)buffer[pos+i]); + return false; + } + } + } + } + return true; +} + +TEST(Gfx, BufferUnrotateHorizontal) { + const int NUM_OF_TESTS = 8; + int bytesPerPixelList[2] = {2,4}; + int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99}; + int height[NUM_OF_TESTS] = {100, 99, 100, 99, 100, 99, 100, 99}; + int xBoundary[NUM_OF_TESTS] = {30, 30, 30, 30, 31, 31, 31, 31}; + int yBoundary[NUM_OF_TESTS] = {0, 0, 0, 0}; + + for (int bytesPerId = 0; bytesPerId < 2; bytesPerId++) { + int bytesPerPixel = bytesPerPixelList[bytesPerId]; + int stride = 256 * bytesPerPixel; + for (int testId = 0; testId < NUM_OF_TESTS; testId++) { + unsigned char* buffer = GenerateBuffer(bytesPerPixel, + width[testId], height[testId], stride, + xBoundary[testId], yBoundary[testId]); + BufferUnrotate(buffer, + width[testId] * bytesPerPixel, height[testId], stride, + xBoundary[testId] * bytesPerPixel, yBoundary[testId]); + + EXPECT_TRUE(CheckBuffer(buffer, bytesPerPixel, + width[testId], height[testId], stride)); + delete[] buffer; + } + } +} + +TEST(Gfx, BufferUnrotateVertical) { + const int NUM_OF_TESTS = 8; + int bytesPerPixelList[2] = {2,4}; + int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99}; + int height[NUM_OF_TESTS] = {100, 99, 100, 99, 100, 99, 100, 99}; + int xBoundary[NUM_OF_TESTS] = {0, 0, 0, 0}; + int yBoundary[NUM_OF_TESTS] = {30, 30, 30, 30, 31, 31, 31, 31}; + + for (int bytesPerId = 0; bytesPerId < 2; bytesPerId++) { + int bytesPerPixel = bytesPerPixelList[bytesPerId]; + int stride = 256 * bytesPerPixel; + for (int testId = 0; testId < NUM_OF_TESTS; testId++) { + unsigned char* buffer = GenerateBuffer(bytesPerPixel, + width[testId], height[testId], stride, + xBoundary[testId], yBoundary[testId]); + BufferUnrotate(buffer, width[testId] * bytesPerPixel, + height[testId], stride, + xBoundary[testId] * bytesPerPixel, yBoundary[testId]); + + EXPECT_TRUE(CheckBuffer(buffer, bytesPerPixel, + width[testId], height[testId], stride)); + delete[] buffer; + } + } +} + + +TEST(Gfx, BufferUnrotateBoth) { + const int NUM_OF_TESTS = 16; + int bytesPerPixelList[2] = {2,4}; + int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99}; + int height[NUM_OF_TESTS] = {100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99}; + int xBoundary[NUM_OF_TESTS] = {30, 30, 30, 30, 31, 31, 31, 31, 30, 30, 30, 30, 31, 31, 31, 31}; + int yBoundary[NUM_OF_TESTS] = {30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31}; + + for (int bytesPerId = 0; bytesPerId < 2; bytesPerId++) { + int bytesPerPixel = bytesPerPixelList[bytesPerId]; + int stride = 256 * bytesPerPixel; + for (int testId = 0; testId < NUM_OF_TESTS; testId++) { + unsigned char* buffer = GenerateBuffer(bytesPerPixel, + width[testId], height[testId], stride, + xBoundary[testId], yBoundary[testId]); + BufferUnrotate(buffer, + width[testId] * bytesPerPixel, height[testId], stride, + xBoundary[testId] * bytesPerPixel, yBoundary[testId]); + + EXPECT_TRUE(CheckBuffer(buffer, bytesPerPixel, + width[testId], height[testId], stride)); + delete[] buffer; + } + } +} + +TEST(Gfx, BufferUnrotateUneven) { + const int NUM_OF_TESTS = 16; + int bytesPerPixelList[2] = {2,4}; + int width[NUM_OF_TESTS] = {10, 100, 99, 39, 100, 40, 99, 39, 100, 50, 39, 99, 74, 60, 99, 39}; + int height[NUM_OF_TESTS] = {100, 39, 10, 99, 10, 99, 40, 99, 73, 39, 100, 39, 67, 99, 84, 99}; + int xBoundary[NUM_OF_TESTS] = {0, 0, 30, 30, 99, 31, 0, 31, 30, 30, 30, 30, 31, 31, 31, 38}; + int yBoundary[NUM_OF_TESTS] = {30, 30, 0, 30, 0, 30, 0, 30, 31, 31, 31, 31, 31, 31, 31, 98}; + + for (int bytesPerId = 0; bytesPerId < 2; bytesPerId++) { + int bytesPerPixel = bytesPerPixelList[bytesPerId]; + int stride = 256 * bytesPerPixel; + for (int testId = 0; testId < NUM_OF_TESTS; testId++) { + unsigned char* buffer = GenerateBuffer(bytesPerPixel, + width[testId], height[testId], stride, + xBoundary[testId], yBoundary[testId]); + BufferUnrotate(buffer, + width[testId]*bytesPerPixel, height[testId], stride, + xBoundary[testId]*bytesPerPixel, yBoundary[testId]); + + EXPECT_TRUE(CheckBuffer(buffer, bytesPerPixel, width[testId], height[testId], stride)); + delete[] buffer; + } + } +} + + diff --git a/gfx/tests/gtest/moz.build b/gfx/tests/gtest/moz.build index 48892108e39..52693c1bcec 100644 --- a/gfx/tests/gtest/moz.build +++ b/gfx/tests/gtest/moz.build @@ -21,6 +21,7 @@ GTEST_CPP_SOURCES += [ 'TestRegion.cpp', 'TestColorNames.cpp', 'TestTextures.cpp', + 'TestBufferRotation.cpp', ] # Because of gkmedia on windows we wont find these diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index 214045b9a26..94820f132f4 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -5,7 +5,6 @@ #include "mozilla/Util.h" -#include "prtypes.h" #include "prlink.h" #include "gfxTypes.h" diff --git a/gfx/thebes/gfxScriptItemizer.h b/gfx/thebes/gfxScriptItemizer.h index 3f48143ef35..618cfbb0766 100644 --- a/gfx/thebes/gfxScriptItemizer.h +++ b/gfx/thebes/gfxScriptItemizer.h @@ -51,7 +51,6 @@ #define GFX_SCRIPTITEMIZER_H #include -#include "prtypes.h" #include "nsUnicodeScriptCodes.h" #define PAREN_STACK_DEPTH 32 diff --git a/gfx/thebes/gfxUniscribeShaper.cpp b/gfx/thebes/gfxUniscribeShaper.cpp index 20d7d5723c5..006775aa2e7 100644 --- a/gfx/thebes/gfxUniscribeShaper.cpp +++ b/gfx/thebes/gfxUniscribeShaper.cpp @@ -3,7 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "prtypes.h" #include "gfxTypes.h" #include "gfxContext.h" diff --git a/gfx/thebes/gfxUniscribeShaper.h b/gfx/thebes/gfxUniscribeShaper.h index ccf28c36752..d1f4d8d459e 100644 --- a/gfx/thebes/gfxUniscribeShaper.h +++ b/gfx/thebes/gfxUniscribeShaper.h @@ -6,7 +6,6 @@ #ifndef GFX_UNISCRIBESHAPER_H #define GFX_UNISCRIBESHAPER_H -#include "prtypes.h" #include "gfxTypes.h" #include "gfxGDIFont.h" diff --git a/ipc/chromium/src/chrome/common/mach_ipc_mac.mm b/ipc/chromium/src/chrome/common/mach_ipc_mac.mm index 3c95ef6dfb2..c2a423d8cad 100644 --- a/ipc/chromium/src/chrome/common/mach_ipc_mac.mm +++ b/ipc/chromium/src/chrome/common/mach_ipc_mac.mm @@ -237,12 +237,15 @@ ReceivePort::~ReceivePort() { kern_return_t ReceivePort::WaitForMessage(MachReceiveMessage *out_message, mach_msg_timeout_t timeout) { if (!out_message) { + printf("WaitForMessage failed because out_message was null\n"); return KERN_INVALID_ARGUMENT; } // return any error condition encountered in constructor - if (init_result_ != KERN_SUCCESS) + if (init_result_ != KERN_SUCCESS) { + printf("WaitForMessage failed because init_result_ was %d\n", init_result_); return init_result_; + } out_message->Head()->msgh_bits = 0; out_message->Head()->msgh_local_port = port_; @@ -258,6 +261,7 @@ kern_return_t ReceivePort::WaitForMessage(MachReceiveMessage *out_message, timeout, // timeout in ms MACH_PORT_NULL); + printf("WaitForMessage returned %d\n", result); return result; } diff --git a/js/src/jit-test/tests/ion/regexp-clone.js b/js/src/jit-test/tests/ion/regexp-clone.js new file mode 100644 index 00000000000..2ed41967fbd --- /dev/null +++ b/js/src/jit-test/tests/ion/regexp-clone.js @@ -0,0 +1,8 @@ +var i=0; +function f() { + assertEq(/^[a-z0-9\.]+$/gi.test("Foo.Bar"), true); + i++; + if (i < 100) + f(); +} +f(); diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index f19f329b55a..63bc919a7b3 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -7454,7 +7454,9 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc, } if (native == js::array_concat) { - if (args.thisv().isObject() && args.thisv().toObject().is()) { + if (args.thisv().isObject() && args.thisv().toObject().is() && + !args.thisv().toObject().hasSingletonType()) + { res.set(NewDenseEmptyArray(cx, args.thisv().toObject().getProto(), TenuredObject)); if (!res) return false; diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 7b3e5d2e528..ae96fe50890 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -23,6 +23,7 @@ #include "jit/MIRGraph.h" #include "vm/ArgumentsObject.h" +#include "vm/RegExpStatics.h" #include "jsinferinlines.h" #include "jsobjinlines.h" @@ -8873,7 +8874,31 @@ IonBuilder::jsop_regexp(RegExpObject *reobj) if (!prototype) return false; - MRegExp *regexp = MRegExp::New(reobj, prototype); + JS_ASSERT(&reobj->JSObject::global() == &script()->global()); + + // JS semantics require regular expression literals to create different + // objects every time they execute. We only need to do this cloning if the + // script could actually observe the effect of such cloning, for instance + // by getting or setting properties on it. + // + // First, make sure the regex is one we can safely optimize. Lowering can + // then check if this regex object only flows into known natives and can + // avoid cloning in this case. + + bool mustClone = true; + types::TypeObjectKey *typeObj = types::TypeObjectKey::get(&script()->global()); + if (!typeObj->hasFlags(constraints(), types::OBJECT_FLAG_REGEXP_FLAGS_SET)) { + RegExpStatics *res = script()->global().getRegExpStatics(); + + DebugOnly origFlags = reobj->getFlags(); + DebugOnly staticsFlags = res->getFlags(); + JS_ASSERT((origFlags & staticsFlags) == staticsFlags); + + if (!reobj->global() && !reobj->sticky()) + mustClone = false; + } + + MRegExp *regexp = MRegExp::New(reobj, prototype, mustClone); current->add(regexp); current->push(regexp); @@ -8883,6 +8908,7 @@ IonBuilder::jsop_regexp(RegExpObject *reobj) // That would be incorrect for global/sticky, because lastIndex could be wrong. // Therefore setting the lastIndex to 0. That is faster than removing the movable flag. if (reobj->sticky() || reobj->global()) { + JS_ASSERT(mustClone); MConstant *zero = MConstant::New(Int32Value(0)); current->add(zero); diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index ec40db7fc8b..d3fd89d5105 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -1776,9 +1776,87 @@ LIRGenerator::visitToString(MToString *ins) } } +static bool +MustCloneRegExpForCall(MPassArg *arg) +{ + // |arg| is a regex literal flowing into a call. Return |false| iff + // this is a native call that does not let the regex escape. + + JS_ASSERT(arg->getArgument()->isRegExp()); + + for (MUseIterator iter(arg->usesBegin()); iter != arg->usesEnd(); iter++) { + MNode *node = iter->consumer(); + if (!node->isDefinition()) + return true; + + MDefinition *def = node->toDefinition(); + if (!def->isCall()) + return true; + + MCall *call = def->toCall(); + JSFunction *target = call->getSingleTarget(); + if (!target || !target->isNative()) + return true; + + if (iter->index() == MCall::IndexOfThis() && + (target->native() == regexp_exec || target->native() == regexp_test)) + { + continue; + } + + if (iter->index() == MCall::IndexOfArgument(0) && + (target->native() == str_split || + target->native() == str_replace || + target->native() == str_match || + target->native() == str_search)) + { + continue; + } + + return true; + } + + return false; +} + + +static bool +MustCloneRegExp(MRegExp *regexp) +{ + if (regexp->mustClone()) + return true; + + // If this regex literal only flows into known natives that don't let + // it escape, we don't have to clone it. + + for (MUseIterator iter(regexp->usesBegin()); iter != regexp->usesEnd(); iter++) { + MNode *node = iter->consumer(); + if (!node->isDefinition()) + return true; + + MDefinition *def = node->toDefinition(); + if (def->isRegExpTest() && iter->index() == 1) { + // Optimized RegExp.prototype.test. + JS_ASSERT(def->toRegExpTest()->regexp() == regexp); + continue; + } + + if (def->isPassArg() && !MustCloneRegExpForCall(def->toPassArg())) + continue; + + return true; + } + return false; +} + bool LIRGenerator::visitRegExp(MRegExp *ins) { + if (!MustCloneRegExp(ins)) { + RegExpObject *source = ins->source(); + return define(new LPointer(source), ins); + } + LRegExp *lir = new LRegExp(); return defineReturn(lir, ins) && assignSafepoint(lir, ins); } diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 935c26db51b..4b2ea4f9412 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -1832,6 +1832,13 @@ class MCall replaceOperand(NumNonArgumentOperands + index, def); } + static size_t IndexOfThis() { + return NumNonArgumentOperands; + } + static size_t IndexOfArgument(size_t index) { + return NumNonArgumentOperands + index + 1; // +1 to skip |this|. + } + // For TI-informed monomorphic callsites. JSFunction *getSingleTarget() const { return target_; @@ -4481,10 +4488,12 @@ class MRegExp : public MNullaryInstruction { CompilerRoot source_; CompilerRootObject prototype_; + bool mustClone_; - MRegExp(RegExpObject *source, JSObject *prototype) + MRegExp(RegExpObject *source, JSObject *prototype, bool mustClone) : source_(source), - prototype_(prototype) + prototype_(prototype), + mustClone_(mustClone) { setResultType(MIRType_Object); @@ -4495,10 +4504,13 @@ class MRegExp : public MNullaryInstruction public: INSTRUCTION_HEADER(RegExp) - static MRegExp *New(RegExpObject *source, JSObject *prototype) { - return new MRegExp(source, prototype); + static MRegExp *New(RegExpObject *source, JSObject *prototype, bool mustClone) { + return new MRegExp(source, prototype, mustClone); } + bool mustClone() const { + return mustClone_; + } RegExpObject *source() const { return source_; } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 9fdb5bf8910..383fdf15a7b 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -1059,11 +1059,14 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared testl(operand.valueReg(), operand.valueReg()); j(truthy ? NonZero : Zero, label); } + // This returns the tag in ScratchReg. Condition testStringTruthy(bool truthy, const ValueOperand &value) { unboxString(value, ScratchReg); Operand lengthAndFlags(ScratchReg, JSString::offsetOfLengthAndFlags()); - testq(lengthAndFlags, Imm32(-1 << JSString::LENGTH_SHIFT)); + movq(lengthAndFlags, ScratchReg); + shrq(Imm32(JSString::LENGTH_SHIFT), ScratchReg); + testq(ScratchReg, ScratchReg); return truthy ? Assembler::NonZero : Assembler::Zero; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index cccd7c80df4..d97609f0b8c 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -261,11 +261,11 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for return false; break; case 'd': - if (!JS_ValueToNumber(cx, *sp, va_arg(ap, double *))) + if (!ToNumber(cx, arg, va_arg(ap, double *))) return false; break; case 'I': - if (!JS_ValueToNumber(cx, *sp, &d)) + if (!ToNumber(cx, arg, &d)) return false; *va_arg(ap, double *) = ToInteger(d); break; @@ -356,7 +356,7 @@ JS_ConvertValue(JSContext *cx, HandleValue value, JSType type, MutableHandleValu vp.setString(str); break; case JSTYPE_NUMBER: - ok = JS_ValueToNumber(cx, value, &d); + ok = ToNumber(cx, value, &d); if (ok) vp.setDouble(d); break; @@ -429,13 +429,6 @@ JS_ValueToSource(JSContext *cx, jsval valueArg) return ValueToSource(cx, value); } -JS_PUBLIC_API(bool) -JS_ValueToNumber(JSContext *cx, jsval valueArg, double *dp) -{ - RootedValue value(cx, valueArg); - return JS::ToNumber(cx, value, dp); -} - JS_PUBLIC_API(bool) JS_DoubleIsInt32(double d, int32_t *ip) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 3020101327e..87cc9c29fa5 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1041,9 +1041,6 @@ JS_ValueToString(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToSource(JSContext *cx, jsval v); -extern JS_PUBLIC_API(bool) -JS_ValueToNumber(JSContext *cx, jsval v, double *dp); - namespace js { /* * DO NOT CALL THIS. Use JS::ToNumber diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 3433177fd44..3d0d87d4904 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -2834,16 +2834,17 @@ IsBefore(int64_t t1, int64_t t2) } static bool -Sleep_fn(JSContext *cx, unsigned argc, jsval *vp) +Sleep_fn(JSContext *cx, unsigned argc, Value *vp) { + CallArgs args = CallArgsFromVp(argc, vp); int64_t t_ticks; - if (argc == 0) { + if (args.length() == 0) { t_ticks = 0; } else { double t_secs; - if (!JS_ValueToNumber(cx, argc == 0 ? UndefinedValue() : vp[2], &t_secs)) + if (!ToNumber(cx, args[0], &t_secs)) return false; /* NB: The next condition also filter out NaNs. */ @@ -3092,24 +3093,26 @@ SetTimeoutValue(JSContext *cx, double t) } static bool -Timeout(JSContext *cx, unsigned argc, jsval *vp) +Timeout(JSContext *cx, unsigned argc, Value *vp) { - if (argc == 0) { - JS_SET_RVAL(cx, vp, JS_NumberValue(gTimeoutInterval)); + CallArgs args = CallArgsFromVp(argc, vp); + + if (args.length() == 0) { + args.rval().setNumber(gTimeoutInterval); return true; } - if (argc > 2) { + if (args.length() > 2) { JS_ReportError(cx, "Wrong number of arguments"); return false; } double t; - if (!JS_ValueToNumber(cx, JS_ARGV(cx, vp)[0], &t)) + if (!ToNumber(cx, args[0], &t)) return false; - if (argc > 1) { - RootedValue value(cx, JS_ARGV(cx, vp)[1]); + if (args.length() > 1) { + RootedValue value(cx, args[1]); if (!value.isObject() || !value.toObject().is()) { JS_ReportError(cx, "Second argument must be a timeout function"); return false; @@ -3117,7 +3120,7 @@ Timeout(JSContext *cx, unsigned argc, jsval *vp) gTimeoutFunc = value; } - JS_SET_RVAL(cx, vp, UndefinedValue()); + args.rval().setUndefined(); return SetTimeoutValue(cx, t); } @@ -4192,10 +4195,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { "dissrc([fun])", " Disassemble functions with source lines."), - JS_FN_HELP("dumpHeap", DumpHeap, 0, 0, -"dumpHeap([fileName[, start[, toFind[, maxDepth[, toIgnore]]]]])", -" Interface to JS_DumpHeap with output sent to file."), - JS_FN_HELP("dumpObject", DumpObject, 1, 0, "dumpObject()", " Dump an internal representation of an object."), @@ -4403,6 +4402,12 @@ static const JSFunctionSpecWithHelp fuzzing_unsafe_functions[] = { " Get a self-hosted value by its name. Note that these values don't get \n" " cached, so repeatedly getting the same value creates multiple distinct clones."), +#ifdef DEBUG + JS_FN_HELP("dumpHeap", DumpHeap, 0, 0, +"dumpHeap([fileName[, start[, toFind[, maxDepth[, toIgnore]]]]])", +" Interface to JS_DumpHeap with output sent to file."), +#endif + JS_FN_HELP("parent", Parent, 1, 0, "parent(obj)", " Returns the parent of obj."), diff --git a/js/xpconnect/src/dictionary_helper_gen.py b/js/xpconnect/src/dictionary_helper_gen.py index 889c38391b1..6b0f777417b 100644 --- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -302,10 +302,10 @@ def write_getter(a, iface, fd): elif realtype.count("int64_t"): fd.write(" NS_ENSURE_STATE(JS::ToInt64(aCx, v, &aDict.%s));\n" % a.name) elif realtype.count("double"): - fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &aDict.%s));\n" % a.name) + fd.write(" NS_ENSURE_STATE(JS::ToNumber(aCx, v, &aDict.%s));\n" % a.name) elif realtype.count("float"): fd.write(" double d;\n") - fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &d));") + fd.write(" NS_ENSURE_STATE(JS::ToNumber(aCx, v, &d));") fd.write(" aDict.%s = (float) d;\n" % a.name) elif realtype.count("nsAString"): if a.nullable: diff --git a/js/xpconnect/src/qsgen.py b/js/xpconnect/src/qsgen.py index 29d2242aeac..2e47d7406b4 100644 --- a/js/xpconnect/src/qsgen.py +++ b/js/xpconnect/src/qsgen.py @@ -423,13 +423,13 @@ argumentUnboxingTemplates = { 'float': " double ${name}_dbl;\n" - " if (!JS_ValueToNumber(cx, ${argVal}, &${name}_dbl))\n" + " if (!JS::ToNumber(cx, ${argVal}, &${name}_dbl))\n" " return false;\n" " float ${name} = (float) ${name}_dbl;\n", 'double': " double ${name};\n" - " if (!JS_ValueToNumber(cx, ${argVal}, &${name}))\n" + " if (!JS::ToNumber(cx, ${argVal}, &${name}))\n" " return false;\n", 'boolean': diff --git a/layout/reftests/webm-video/reftest.list b/layout/reftests/webm-video/reftest.list index cbf63a5e191..8ff9c12fdb6 100644 --- a/layout/reftests/webm-video/reftest.list +++ b/layout/reftests/webm-video/reftest.list @@ -31,4 +31,4 @@ random skip-if(Android||B2G) == poster-11.html poster-ref-blue140x100.html random skip-if(Android||B2G) == poster-12.html poster-ref-blue140x100.html skip-if(Android||B2G) == poster-13.html poster-ref-blue400x300.html skip-if(Android||B2G) == poster-15.html poster-ref-green70x30.html -skip-if(Android||B2G) == bug686957.html bug686957-ref.html +random-if(cocoaWidget) skip-if(Android||B2G) == bug686957.html bug686957-ref.html # bug 922951 for OS X diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 5f17923913c..4b4a185c84c 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -655,7 +655,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, MOZ_ASSERT(aThread); mThread = do_QueryInterface(aThread); - mPCObserver.Init(&aObserver); + mPCObserver.Set(&aObserver); // Find the STS thread @@ -1383,12 +1383,6 @@ PeerConnectionImpl::CloseInt() { PC_AUTO_ENTER_API_CALL_NO_CHECK(); - // Clear raw pointer to observer since PeerConnection.js does not guarantee - // the observer's existence past Close(). - // - // Any outstanding runnables hold RefPtr<> references to observer. - mPCObserver.Close(); - if (mInternal->mCall) { CSFLogInfo(logTag, "%s: Closing PeerConnectionImpl %s; " "ending call", __FUNCTION__, mHandle.c_str()); @@ -1762,5 +1756,30 @@ PeerConnectionImpl::GetRemoteStreams(nsTArray #endif } +// WeakConcretePtr gets around WeakPtr not working on concrete types by using +// the attribute getWeakReferent, a member that supports weak refs, as a guard. + +void +PeerConnectionImpl::WeakConcretePtr::Set(PeerConnectionObserver *aObserver) { + mObserver = aObserver; +#ifdef MOZILLA_INTERNAL_API + MOZ_ASSERT(NS_IsMainThread()); + JSErrorResult rv; + nsCOMPtr tmp = aObserver->GetWeakReferent(rv); + MOZ_ASSERT(!rv.Failed()); + mWeakPtr = do_GetWeakReference(tmp); +#else + mWeakPtr = do_GetWeakReference(aObserver); +#endif +} + +PeerConnectionObserver * +PeerConnectionImpl::WeakConcretePtr::MayGet() { +#ifdef MOZILLA_INTERNAL_API + MOZ_ASSERT(NS_IsMainThread()); +#endif + nsCOMPtr guard = do_QueryReferent(mWeakPtr); + return (!guard) ? nullptr : mObserver; +} } // end sipcc namespace diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index 237ba93d51d..de8fef6eb12 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -12,6 +12,9 @@ #include "prlock.h" #include "mozilla/RefPtr.h" +#include "nsWeakPtr.h" +#include "nsIWeakReferenceUtils.h" // for the definition of nsWeakPtr +#include "IPeerConnection.h" #include "sigslot.h" #include "nricectx.h" #include "nricemediastream.h" @@ -502,29 +505,19 @@ private: mozilla::dom::PCImplIceState mIceState; nsCOMPtr mThread; - // We hold a raw pointer to PeerConnectionObserver (no WeakRefs to concretes!) - // which is an invariant guaranteed to exist between Initialize() and Close(). - // We explicitly clear it in Close(). We wrap it in a helper, to encourage - // testing against nullptr before use. Use in Runnables requires wrapping - // access in RefPtr<> since they may execute after close. This is only safe - // to use on the main thread + // WeakConcretePtr to PeerConnectionObserver. TODO: Remove after bug 928535 // + // This is only safe to use on the main thread // TODO: Remove if we ever properly wire PeerConnection for cycle-collection. - class WeakReminder + class WeakConcretePtr { public: - WeakReminder() : mObserver(nullptr) {} - void Init(PeerConnectionObserver *aObserver) { - mObserver = aObserver; - } - void Close() { - mObserver = nullptr; - } - PeerConnectionObserver *MayGet() { - return mObserver; - } + WeakConcretePtr() : mObserver(nullptr) {} + void Set(PeerConnectionObserver *aObserver); + PeerConnectionObserver *MayGet(); private: PeerConnectionObserver *mObserver; + nsWeakPtr mWeakPtr; } mPCObserver; nsCOMPtr mWindow; diff --git a/media/webrtc/signaling/test/FakePCObserver.h b/media/webrtc/signaling/test/FakePCObserver.h index 54761a1c8cd..ddb42734168 100644 --- a/media/webrtc/signaling/test/FakePCObserver.h +++ b/media/webrtc/signaling/test/FakePCObserver.h @@ -21,6 +21,7 @@ #include "nsIDOMMediaStream.h" #include "mozilla/dom/PeerConnectionObserverEnumsBinding.h" #include "PeerConnectionImpl.h" +#include "nsWeakReference.h" namespace sipcc { class PeerConnectionImpl; @@ -32,7 +33,7 @@ class nsIDOMDataChannel; namespace test { using namespace mozilla::dom; -class AFakePCObserver : public nsISupports +class AFakePCObserver : public nsSupportsWeakReference { protected: typedef mozilla::ErrorResult ER; diff --git a/media/webrtc/signaling/test/signaling_unittests.cpp b/media/webrtc/signaling/test/signaling_unittests.cpp index 8122decd5dc..be6e9a6ea66 100644 --- a/media/webrtc/signaling/test/signaling_unittests.cpp +++ b/media/webrtc/signaling/test/signaling_unittests.cpp @@ -273,7 +273,7 @@ public: NS_IMETHODIMP OnIceCandidate(uint16_t level, const char *mid, const char *cand, ER&); }; -NS_IMPL_ISUPPORTS0(TestObserver) +NS_IMPL_ISUPPORTS1(TestObserver, nsISupportsWeakReference) NS_IMETHODIMP TestObserver::OnCreateOfferSuccess(const char* offer, ER&) diff --git a/mfbt/Char16.h b/mfbt/Char16.h index 2d342f933ef..fb182dfde20 100644 --- a/mfbt/Char16.h +++ b/mfbt/Char16.h @@ -22,7 +22,7 @@ * typedefs char16_t as an unsigned short. We would like to alias char16_t * to Windows's 16-bit wchar_t so we can declare UTF-16 literals as constant * expressions (and pass char16_t pointers to Windows APIs). We #define - * _CHAR16T here in order to prevent yvals.h to override our char16_t + * _CHAR16T here in order to prevent yvals.h from overriding our char16_t * typedefs, which we set to wchar_t for C++ code and to unsigned short for * C code. * diff --git a/netwerk/base/src/nsIncrementalDownload.cpp b/netwerk/base/src/nsIncrementalDownload.cpp index 946fa04aca5..4d12b86d98e 100644 --- a/netwerk/base/src/nsIncrementalDownload.cpp +++ b/netwerk/base/src/nsIncrementalDownload.cpp @@ -156,6 +156,8 @@ private: PRTime mLastProgressUpdate; nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; + nsCString mPartialValidator; + bool mCacheBust; }; nsIncrementalDownload::nsIncrementalDownload() @@ -172,6 +174,7 @@ nsIncrementalDownload::nsIncrementalDownload() , mLastProgressUpdate(0) , mRedirectCallback(nullptr) , mNewRedirectChannel(nullptr) + , mCacheBust(false) { } @@ -282,6 +285,17 @@ nsIncrementalDownload::ProcessTimeout() rv = http->SetRequestHeader(NS_LITERAL_CSTRING("Range"), range, false); if (NS_FAILED(rv)) return rv; + + if (!mPartialValidator.IsEmpty()) + http->SetRequestHeader(NS_LITERAL_CSTRING("If-Range"), + mPartialValidator, false); + + if (mCacheBust) { + http->SetRequestHeader(NS_LITERAL_CSTRING("Cache-Control"), + NS_LITERAL_CSTRING("no-cache"), false); + http->SetRequestHeader(NS_LITERAL_CSTRING("Pragma"), + NS_LITERAL_CSTRING("no-cache"), false); + } } rv = channel->AsyncOpen(this, nullptr); @@ -565,6 +579,65 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request, // We got a partial response, so clear this counter in case the next chunk // results in a 200 response. mNonPartialCount = 0; + + // confirm that the content-range response header is consistent with + // expectations on each 206. If it is not then drop this response and + // retry with no-cache set. + if (!mCacheBust) { + nsAutoCString buf; + int64_t startByte = 0; + bool confirmedOK = false; + + rv = http->GetResponseHeader(NS_LITERAL_CSTRING("Content-Range"), buf); + if (NS_FAILED(rv)) + return rv; // it isn't a useful 206 without a CONTENT-RANGE of some sort + + // Content-Range: bytes 0-299999/25604694 + int32_t p = buf.Find("bytes "); + + // first look for the starting point of the content-range + // to make sure it is what we expect + if (p != -1) { + char *endptr = nullptr; + const char *s = buf.get() + p + 6; + while (*s && *s == ' ') + s++; + startByte = strtol(s, &endptr, 10); + + if (*s && endptr && (endptr != s) && + (mCurrentSize == startByte)) { + + // ok the starting point is confirmed. We still need to check the + // total size of the range for consistency if this isn't + // the first chunk + if (mTotalSize == int64_t(-1)) { + // first chunk + confirmedOK = true; + } else { + int32_t slash = buf.FindChar('/'); + int64_t rangeSize = 0; + if (slash != kNotFound && + (PR_sscanf(buf.get() + slash + 1, "%lld", (int64_t *) &rangeSize) == 1) && + rangeSize == mTotalSize) { + confirmedOK = true; + } + } + } + } + + if (!confirmedOK) { + NS_WARNING("unexpected content-range"); + mCacheBust = true; + mChannel = nullptr; + if (++mNonPartialCount > MAX_RETRY_COUNT) { + NS_WARNING("unable to fetch a byte range; giving up"); + return NS_ERROR_FAILURE; + } + // Increase delay with each failure. + StartTimer(mInterval * mNonPartialCount); + return NS_ERROR_DOWNLOAD_NOT_PARTIAL; + } + } } // Do special processing after the first response. @@ -573,6 +646,11 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request, rv = http->GetURI(getter_AddRefs(mFinalURI)); if (NS_FAILED(rv)) return rv; + http->GetResponseHeader(NS_LITERAL_CSTRING("Etag"), mPartialValidator); + if (StringBeginsWith(mPartialValidator, NS_LITERAL_CSTRING("W/"))) + mPartialValidator.Truncate(); // don't use weak validators + if (mPartialValidator.IsEmpty()) + http->GetResponseHeader(NS_LITERAL_CSTRING("Last-Modified"), mPartialValidator); if (code == 206) { // OK, read the Content-Range header to determine the total size of this @@ -778,6 +856,16 @@ nsIncrementalDownload::AsyncOnChannelRedirect(nsIChannel *oldChannel, NS_ENSURE_SUCCESS(rv, rv); } + // A redirection changes the validator + mPartialValidator.Truncate(); + + if (mCacheBust) { + newHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Cache-Control"), + NS_LITERAL_CSTRING("no-cache"), false); + newHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Pragma"), + NS_LITERAL_CSTRING("no-cache"), false); + } + // Prepare to receive callback mRedirectCallback = cb; mNewRedirectChannel = newChannel; diff --git a/parser/html/nsHtml5ArrayCopy.h b/parser/html/nsHtml5ArrayCopy.h index 046273f7b53..b277a9513e3 100644 --- a/parser/html/nsHtml5ArrayCopy.h +++ b/parser/html/nsHtml5ArrayCopy.h @@ -23,7 +23,6 @@ #ifndef nsHtml5ArrayCopy_h #define nsHtml5ArrayCopy_h -#include "prtypes.h" class nsString; class nsHtml5StackNode; diff --git a/parser/html/nsHtml5Highlighter.h b/parser/html/nsHtml5Highlighter.h index 025f37fe749..f869b6c667c 100644 --- a/parser/html/nsHtml5Highlighter.h +++ b/parser/html/nsHtml5Highlighter.h @@ -4,7 +4,6 @@ #ifndef nsHtml5Highlighter_h #define nsHtml5Highlighter_h -#include "prtypes.h" #include "nsCOMPtr.h" #include "nsHtml5TreeOperation.h" #include "nsHtml5UTF16Buffer.h" diff --git a/parser/html/nsHtml5NamedCharacters.cpp b/parser/html/nsHtml5NamedCharacters.cpp index 040893e9b71..2c486cca634 100644 --- a/parser/html/nsHtml5NamedCharacters.cpp +++ b/parser/html/nsHtml5NamedCharacters.cpp @@ -21,7 +21,6 @@ */ #define nsHtml5NamedCharacters_cpp_ -#include "prtypes.h" #include "jArray.h" #include "nscore.h" #include "nsDebug.h" diff --git a/parser/html/nsHtml5NamedCharacters.h b/parser/html/nsHtml5NamedCharacters.h index 51eac319947..a0e81214587 100644 --- a/parser/html/nsHtml5NamedCharacters.h +++ b/parser/html/nsHtml5NamedCharacters.h @@ -23,7 +23,6 @@ #ifndef nsHtml5NamedCharacters_h #define nsHtml5NamedCharacters_h -#include "prtypes.h" #include "jArray.h" #include "nscore.h" #include "nsDebug.h" diff --git a/parser/html/nsHtml5NamedCharactersAccel.h b/parser/html/nsHtml5NamedCharactersAccel.h index 104e0bde368..8098c00c4fd 100644 --- a/parser/html/nsHtml5NamedCharactersAccel.h +++ b/parser/html/nsHtml5NamedCharactersAccel.h @@ -9,7 +9,6 @@ #ifndef nsHtml5NamedCharactersAccel_h #define nsHtml5NamedCharactersAccel_h -#include "prtypes.h" #include "jArray.h" #include "nscore.h" #include "nsDebug.h" diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp index 1f12cfd966f..618219f7339 100644 --- a/parser/html/nsHtml5Portability.cpp +++ b/parser/html/nsHtml5Portability.cpp @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "prtypes.h" #include "nsIAtom.h" #include "nsString.h" #include "jArray.h" diff --git a/parser/htmlparser/src/nsHTMLEntities.cpp b/parser/htmlparser/src/nsHTMLEntities.cpp index 005074b10de..e597cd8abcc 100644 --- a/parser/htmlparser/src/nsHTMLEntities.cpp +++ b/parser/htmlparser/src/nsHTMLEntities.cpp @@ -11,7 +11,6 @@ #include "nsString.h" #include "nsCRT.h" -#include "prtypes.h" #include "pldhash.h" using namespace mozilla; diff --git a/parser/htmlparser/src/nsScanner.h b/parser/htmlparser/src/nsScanner.h index 8443bfb4fdb..70eb287dfc9 100644 --- a/parser/htmlparser/src/nsScanner.h +++ b/parser/htmlparser/src/nsScanner.h @@ -22,7 +22,6 @@ #include "nsCOMPtr.h" #include "nsString.h" #include "nsIParser.h" -#include "prtypes.h" #include "nsIUnicodeDecoder.h" #include "nsScannerString.h" diff --git a/rdf/base/src/rdfutil.h b/rdf/base/src/rdfutil.h index 80657e8ebd9..284f8e57ae5 100644 --- a/rdf/base/src/rdfutil.h +++ b/rdf/base/src/rdfutil.h @@ -22,7 +22,6 @@ #ifndef rdfutil_h__ #define rdfutil_h__ -#include "prtypes.h" class nsACString; class nsCString; diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 6cbf435dc97..524499836a7 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "prio.h" -#include "prtypes.h" #include "pldhash.h" #include "nsXPCOMStrings.h" #include "mozilla/MemoryReporting.h" diff --git a/testing/mochitest/ssltunnel/ssltunnel.cpp b/testing/mochitest/ssltunnel/ssltunnel.cpp index 6c36fa269e3..3b58a205fa3 100644 --- a/testing/mochitest/ssltunnel/ssltunnel.cpp +++ b/testing/mochitest/ssltunnel/ssltunnel.cpp @@ -24,7 +24,6 @@ #include "prenv.h" #include "prnetdb.h" #include "prtpool.h" -#include "prtypes.h" #include "nsAlgorithm.h" #include "nss.h" #include "key.h" diff --git a/toolkit/components/ctypes/tests/jsctypes-test-errno.h b/toolkit/components/ctypes/tests/jsctypes-test-errno.h index 23762f7a628..adcd9bede01 100644 --- a/toolkit/components/ctypes/tests/jsctypes-test-errno.h +++ b/toolkit/components/ctypes/tests/jsctypes-test-errno.h @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nscore.h" -#include "prtypes.h" #define EXPORT_CDECL(type) NS_EXPORT type #define EXPORT_STDCALL(type) NS_EXPORT type NS_STDCALL diff --git a/toolkit/components/ctypes/tests/jsctypes-test.h b/toolkit/components/ctypes/tests/jsctypes-test.h index 6f1f5e8fd86..117c3b0650f 100644 --- a/toolkit/components/ctypes/tests/jsctypes-test.h +++ b/toolkit/components/ctypes/tests/jsctypes-test.h @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nscore.h" -#include "prtypes.h" #include "jspubtd.h" #define EXPORT_CDECL(type) NS_EXPORT type diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 22b224feb93..a59b441a7e3 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -395,7 +395,7 @@ GetIntFromJSObject(JSContext* aCtx, NS_ENSURE_ARG(JSVAL_IS_NUMBER(value)); double num; - rc = JS_ValueToNumber(aCtx, value, &num); + rc = JS::ToNumber(aCtx, value, &num); NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED); NS_ENSURE_ARG(IntType(num) == num); diff --git a/toolkit/components/places/nsPlacesMacros.h b/toolkit/components/places/nsPlacesMacros.h index af1306082c1..30bcbed1abb 100644 --- a/toolkit/components/places/nsPlacesMacros.h +++ b/toolkit/components/places/nsPlacesMacros.h @@ -3,7 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "prtypes.h" #include "nsIConsoleService.h" #include "nsIScriptError.h" diff --git a/xpcom/base/nsMemoryImpl.cpp b/xpcom/base/nsMemoryImpl.cpp index ac33c812055..f8b9bfc5a23 100644 --- a/xpcom/base/nsMemoryImpl.cpp +++ b/xpcom/base/nsMemoryImpl.cpp @@ -74,7 +74,7 @@ nsMemoryImpl::IsLowMemoryPlatform(bool *result) return NS_OK; } uint64_t mem = 0; - int rv = fscanf(fd, "MemTotal: %lu kB", &mem); + int rv = fscanf(fd, "MemTotal: %llu kB", &mem); if (fclose(fd)) { return NS_OK; } diff --git a/xpcom/glue/MainThreadUtils.h b/xpcom/glue/MainThreadUtils.h index c1d24011b72..2b7731ec618 100644 --- a/xpcom/glue/MainThreadUtils.h +++ b/xpcom/glue/MainThreadUtils.h @@ -29,14 +29,14 @@ bool NS_IsMainThread(); extern NS_TLS mozilla::threads::ID gTLSThreadID; #ifdef MOZ_ASAN // Temporary workaround, see bug 895845 -MOZ_ASAN_BLACKLIST static +MOZ_ASAN_BLACKLIST bool NS_IsMainThread(); #else inline -#endif bool NS_IsMainThread() { return gTLSThreadID == mozilla::threads::Main; } +#endif #else /** * Test to see if the current thread is the main thread. diff --git a/xpcom/glue/nsTextFormatter.h b/xpcom/glue/nsTextFormatter.h index 756c4acab2e..89cc31192e3 100644 --- a/xpcom/glue/nsTextFormatter.h +++ b/xpcom/glue/nsTextFormatter.h @@ -29,7 +29,6 @@ ** %f - float ** %g - float */ -#include "prtypes.h" #include "prio.h" #include #include diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp index 661f5a5dadf..a99c2dea3ca 100644 --- a/xpcom/glue/nsThreadUtils.cpp +++ b/xpcom/glue/nsThreadUtils.cpp @@ -114,7 +114,32 @@ NS_GetMainThread(nsIThread **result) #endif } -#ifndef MOZILLA_INTERNAL_API +#if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN) +extern DWORD gTLSThreadIDIndex; +bool +NS_IsMainThread() +{ + return TlsGetValue(gTLSThreadIDIndex) == (void*) mozilla::threads::Main; +} +#elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS) +#ifdef MOZ_ASAN +// Temporary workaround, see bug 895845 +bool NS_IsMainThread() +{ + return gTLSThreadID == mozilla::threads::Main; +} +#else +// NS_IsMainThread() is defined inline in MainThreadUtils.h +#endif +#else +#ifdef MOZILLA_INTERNAL_API +bool NS_IsMainThread() +{ + bool result = false; + nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result); + return bool(result); +} +#else bool NS_IsMainThread() { bool result = false; @@ -124,20 +149,7 @@ bool NS_IsMainThread() mgr->GetIsMainThread(&result); return bool(result); } -#elif defined(XP_WIN) -extern DWORD gTLSThreadIDIndex; -bool -NS_IsMainThread() -{ - return TlsGetValue(gTLSThreadIDIndex) == (void*) mozilla::threads::Main; -} -#elif !defined(NS_TLS) -bool NS_IsMainThread() -{ - bool result = false; - nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result); - return bool(result); -} +#endif #endif NS_METHOD diff --git a/xpcom/io/nsEscape.h b/xpcom/io/nsEscape.h index e66ac28f6d2..a734bce6ccb 100644 --- a/xpcom/io/nsEscape.h +++ b/xpcom/io/nsEscape.h @@ -8,7 +8,6 @@ #ifndef _ESCAPE_H_ #define _ESCAPE_H_ -#include "prtypes.h" #include "nscore.h" #include "nsError.h" #include "nsString.h" diff --git a/xpcom/io/nsWildCard.h b/xpcom/io/nsWildCard.h index ef6fd349d34..85bff098f0c 100644 --- a/xpcom/io/nsWildCard.h +++ b/xpcom/io/nsWildCard.h @@ -20,7 +20,6 @@ #ifndef nsWildCard_h__ #define nsWildCard_h__ -#include "prtypes.h" #include "nscore.h" /* --------------------------- Public routines ---------------------------- */ diff --git a/xpcom/tests/TestPRIntN.cpp b/xpcom/tests/TestPRIntN.cpp index 7648decbadc..afc155d702b 100644 --- a/xpcom/tests/TestPRIntN.cpp +++ b/xpcom/tests/TestPRIntN.cpp @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include - #include "prtypes.h" // This test is NOT intended to be run. It's a test to make sure diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp index ae5ce38e613..8a6345d11d3 100644 --- a/xpcom/threads/nsProcessCommon.cpp +++ b/xpcom/threads/nsProcessCommon.cpp @@ -17,7 +17,6 @@ #include "nsAutoPtr.h" #include "nsMemory.h" #include "nsProcess.h" -#include "prtypes.h" #include "prio.h" #include "prenv.h" #include "nsCRT.h" diff --git a/xulrunner/stub/nsXULStub.cpp b/xulrunner/stub/nsXULStub.cpp index 80221d75d05..54ca21b0356 100644 --- a/xulrunner/stub/nsXULStub.cpp +++ b/xulrunner/stub/nsXULStub.cpp @@ -4,7 +4,6 @@ #include "nsXPCOMGlue.h" #include "nsINIParser.h" -#include "prtypes.h" #include "nsXPCOMPrivate.h" // for XP MAXPATHLEN #include "nsMemory.h" // for NS_ARRAY_LENGTH #include "nsXULAppAPI.h"