mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Merge inbound to m-c.
This commit is contained in:
commit
e5eac232d0
2
CLOBBER
2
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
|
||||
|
@ -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++) {
|
||||
|
@ -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"
|
||||
|
||||
|
119
accessible/src/base/RelationType.h
Normal file
119
accessible/src/base/RelationType.h
Normal file
@ -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
|
@ -19,6 +19,7 @@ EXPORTS.mozilla.a11y += [
|
||||
'DocManager.h',
|
||||
'FocusManager.h',
|
||||
'Platform.h',
|
||||
'RelationType.h',
|
||||
'Role.h',
|
||||
'SelectionManager.h',
|
||||
'States.h',
|
||||
|
@ -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<uint32_t>(RelationType::LAST));
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
Relation rel = RelationByType(aType);
|
||||
Relation rel = RelationByType(static_cast<RelationType>(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<nsIFormControl> control(do_QueryInterface(mContent));
|
||||
|
@ -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
|
||||
|
@ -141,7 +141,7 @@ ApplicationAccessible::FocusedChild()
|
||||
}
|
||||
|
||||
Relation
|
||||
ApplicationAccessible::RelationByType(uint32_t aRelationType)
|
||||
ApplicationAccessible::RelationByType(RelationType aRelationType)
|
||||
{
|
||||
return Relation();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<dom::HTMLLabelElement> 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;
|
||||
|
@ -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<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(uint32_t aType);
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -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 <legend> for this <fieldset>
|
||||
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();
|
||||
|
@ -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<nsIPersistentProperties> 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
|
||||
|
@ -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;
|
||||
|
@ -172,7 +172,7 @@ public:
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual already_AddRefed<nsIPersistentProperties> 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<ia2AccessibleRelation> 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<ia2AccessibleRelation> ia2Rel =
|
||||
new ia2AccessibleRelation(relType, &rel);
|
||||
new ia2AccessibleRelation(relationType, &rel);
|
||||
if (ia2Rel->HasTargets()) {
|
||||
ia2Rel.forget(aRelation + (*aNRelations));
|
||||
(*aNRelations)++;
|
||||
|
@ -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<IAccessibleRelation*>(this);
|
||||
(reinterpret_cast<IUnknown*>(*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;
|
||||
|
@ -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<nsRefPtr<Accessible> > 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
|
||||
|
@ -921,55 +921,55 @@ AccessibleWrap::accNavigate(
|
||||
|
||||
// MSAA relationship extensions to accNavigate
|
||||
case NAVRELATION_CONTROLLED_BY:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_CONTROLLED_BY;
|
||||
xpRelation = static_cast<int32_t>(RelationType::CONTROLLED_BY);
|
||||
break;
|
||||
case NAVRELATION_CONTROLLER_FOR:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_CONTROLLER_FOR;
|
||||
xpRelation = static_cast<int32_t>(RelationType::CONTROLLER_FOR);
|
||||
break;
|
||||
case NAVRELATION_LABEL_FOR:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_LABEL_FOR;
|
||||
xpRelation = static_cast<int32_t>(RelationType::LABEL_FOR);
|
||||
break;
|
||||
case NAVRELATION_LABELLED_BY:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_LABELLED_BY;
|
||||
xpRelation = static_cast<int32_t>(RelationType::LABELLED_BY);
|
||||
break;
|
||||
case NAVRELATION_MEMBER_OF:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_MEMBER_OF;
|
||||
xpRelation = static_cast<int32_t>(RelationType::MEMBER_OF);
|
||||
break;
|
||||
case NAVRELATION_NODE_CHILD_OF:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_NODE_CHILD_OF;
|
||||
xpRelation = static_cast<int32_t>(RelationType::NODE_CHILD_OF);
|
||||
break;
|
||||
case NAVRELATION_FLOWS_TO:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_FLOWS_TO;
|
||||
xpRelation = static_cast<int32_t>(RelationType::FLOWS_TO);
|
||||
break;
|
||||
case NAVRELATION_FLOWS_FROM:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_FLOWS_FROM;
|
||||
xpRelation = static_cast<int32_t>(RelationType::FLOWS_FROM);
|
||||
break;
|
||||
case NAVRELATION_SUBWINDOW_OF:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_SUBWINDOW_OF;
|
||||
xpRelation = static_cast<int32_t>(RelationType::SUBWINDOW_OF);
|
||||
break;
|
||||
case NAVRELATION_EMBEDS:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_EMBEDS;
|
||||
xpRelation = static_cast<int32_t>(RelationType::EMBEDS);
|
||||
break;
|
||||
case NAVRELATION_EMBEDDED_BY:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_EMBEDDED_BY;
|
||||
xpRelation = static_cast<int32_t>(RelationType::EMBEDDED_BY);
|
||||
break;
|
||||
case NAVRELATION_POPUP_FOR:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_POPUP_FOR;
|
||||
xpRelation = static_cast<int32_t>(RelationType::POPUP_FOR);
|
||||
break;
|
||||
case NAVRELATION_PARENT_WINDOW_OF:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF;
|
||||
xpRelation = static_cast<int32_t>(RelationType::PARENT_WINDOW_OF);
|
||||
break;
|
||||
case NAVRELATION_DEFAULT_BUTTON:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_DEFAULT_BUTTON;
|
||||
xpRelation = static_cast<int32_t>(RelationType::DEFAULT_BUTTON);
|
||||
break;
|
||||
case NAVRELATION_DESCRIBED_BY:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_DESCRIBED_BY;
|
||||
xpRelation = static_cast<int32_t>(RelationType::DESCRIBED_BY);
|
||||
break;
|
||||
case NAVRELATION_DESCRIPTION_FOR:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_DESCRIPTION_FOR;
|
||||
xpRelation = static_cast<int32_t>(RelationType::DESCRIPTION_FOR);
|
||||
break;
|
||||
case NAVRELATION_NODE_PARENT_OF:
|
||||
xpRelation = nsIAccessibleRelation::RELATION_NODE_PARENT_OF;
|
||||
xpRelation = static_cast<int32_t>(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<RelationType>(xpRelation));
|
||||
navAccessible = rel.Next();
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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<nsIArray> 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
|
||||
|
@ -762,7 +762,7 @@ XULTreeGridCellAccessible::IndexInParent() const
|
||||
}
|
||||
|
||||
Relation
|
||||
XULTreeGridCellAccessible::RelationByType(uint32_t aType)
|
||||
XULTreeGridCellAccessible::RelationByType(RelationType aType)
|
||||
{
|
||||
return Relation();
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
virtual Accessible* FocusedChild();
|
||||
virtual already_AddRefed<nsIPersistentProperties> 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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -256,7 +256,6 @@ MediaEngineTabVideoSource::Draw() {
|
||||
cairoData.mSurface = surf;
|
||||
cairoData.mSize = size;
|
||||
|
||||
ImageFormat cairoFormat = CAIRO_SURFACE;
|
||||
nsRefPtr<layers::CairoImage> image = new layers::CairoImage();
|
||||
|
||||
image->SetData(cairoData);
|
||||
|
@ -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<float*>(&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<uint32_t*>(&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;
|
||||
}
|
||||
|
@ -1419,10 +1419,10 @@ nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, JS::Handle<jsid> 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;
|
||||
}
|
||||
|
@ -267,11 +267,11 @@ DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid
|
||||
int32_t
|
||||
IdToInt32(JSContext* cx, JS::Handle<jsid> 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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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') {
|
||||
|
@ -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")
|
||||
|
@ -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 \
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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]
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -578,6 +578,15 @@ public:
|
||||
virtual TemporaryRef<SourceSurface> 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.
|
||||
|
@ -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
|
||||
|
@ -60,6 +60,10 @@ public:
|
||||
virtual TemporaryRef<SourceSurface> 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<SourceSurfaceCairo> mSnapshot;
|
||||
|
63
gfx/layers/BufferUnrotate.cpp
Normal file
63
gfx/layers/BufferUnrotate.cpp
Normal file
@ -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 <algorithm> // min & max
|
||||
#include <cstdlib>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
14
gfx/layers/BufferUnrotate.h
Normal file
14
gfx/layers/BufferUnrotate.h
Normal file
@ -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
|
@ -8,6 +8,7 @@
|
||||
#include <algorithm> // 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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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<ProtocolFdMapping>& 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));
|
||||
|
@ -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',
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <stdint.h> // 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;
|
||||
|
151
gfx/tests/gtest/TestBufferRotation.cpp
Normal file
151
gfx/tests/gtest/TestBufferRotation.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ GTEST_CPP_SOURCES += [
|
||||
'TestRegion.cpp',
|
||||
'TestColorNames.cpp',
|
||||
'TestTextures.cpp',
|
||||
'TestBufferRotation.cpp',
|
||||
]
|
||||
|
||||
# Because of gkmedia on windows we wont find these
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prlink.h"
|
||||
#include "gfxTypes.h"
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
||||
#define GFX_SCRIPTITEMIZER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "prtypes.h"
|
||||
#include "nsUnicodeScriptCodes.h"
|
||||
|
||||
#define PAREN_STACK_DEPTH 32
|
||||
|
@ -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"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef GFX_UNISCRIBESHAPER_H
|
||||
#define GFX_UNISCRIBESHAPER_H
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxGDIFont.h"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
8
js/src/jit-test/tests/ion/regexp-clone.js
Normal file
8
js/src/jit-test/tests/ion/regexp-clone.js
Normal file
@ -0,0 +1,8 @@
|
||||
var i=0;
|
||||
function f() {
|
||||
assertEq(/^[a-z0-9\.]+$/gi.test("Foo.Bar"), true);
|
||||
i++;
|
||||
if (i < 100)
|
||||
f();
|
||||
}
|
||||
f();
|
@ -7454,7 +7454,9 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
|
||||
}
|
||||
|
||||
if (native == js::array_concat) {
|
||||
if (args.thisv().isObject() && args.thisv().toObject().is<ArrayObject>()) {
|
||||
if (args.thisv().isObject() && args.thisv().toObject().is<ArrayObject>() &&
|
||||
!args.thisv().toObject().hasSingletonType())
|
||||
{
|
||||
res.set(NewDenseEmptyArray(cx, args.thisv().toObject().getProto(), TenuredObject));
|
||||
if (!res)
|
||||
return false;
|
||||
|
@ -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<uint32_t> origFlags = reobj->getFlags();
|
||||
DebugOnly<uint32_t> 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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<RegExpObject *> 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_;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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<JSFunction>()) {
|
||||
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."),
|
||||
|
@ -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:
|
||||
|
@ -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':
|
||||
|
@ -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
|
||||
|
@ -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<nsRefPtr<mozilla::DOMMediaStream >
|
||||
#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<nsISupports> 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<nsISupports> guard = do_QueryReferent(mWeakPtr);
|
||||
return (!guard) ? nullptr : mObserver;
|
||||
}
|
||||
|
||||
} // end sipcc namespace
|
||||
|
@ -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<nsIThread> 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<nsPIDOMWindow> mWindow;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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&)
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -156,6 +156,8 @@ private:
|
||||
PRTime mLastProgressUpdate;
|
||||
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
|
||||
nsCOMPtr<nsIChannel> 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;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#ifndef nsHtml5ArrayCopy_h
|
||||
#define nsHtml5ArrayCopy_h
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsString;
|
||||
class nsHtml5StackNode;
|
||||
|
@ -4,7 +4,6 @@
|
||||
#ifndef nsHtml5Highlighter_h
|
||||
#define nsHtml5Highlighter_h
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHtml5TreeOperation.h"
|
||||
#include "nsHtml5UTF16Buffer.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
#define nsHtml5NamedCharacters_cpp_
|
||||
#include "prtypes.h"
|
||||
#include "jArray.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#ifndef nsHtml5NamedCharacters_h
|
||||
#define nsHtml5NamedCharacters_h
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "jArray.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#ifndef nsHtml5NamedCharactersAccel_h
|
||||
#define nsHtml5NamedCharactersAccel_h
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "jArray.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
|
@ -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"
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prtypes.h"
|
||||
#include "pldhash.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIParser.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsScannerString.h"
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#ifndef rdfutil_h__
|
||||
#define rdfutil_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsACString;
|
||||
class nsCString;
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user