mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Merge inbound to m-c a=merge
This commit is contained in:
commit
725423ccde
@ -21,11 +21,7 @@ static gboolean
|
||||
doActionCB(AtkAction *aAction, gint aActionIndex)
|
||||
{
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||
if (!accWrap)
|
||||
return FALSE;
|
||||
|
||||
nsresult rv = accWrap->DoAction(aActionIndex);
|
||||
return (NS_FAILED(rv)) ? FALSE : TRUE;
|
||||
return accWrap && accWrap->DoAction(aActionIndex);
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -51,14 +47,13 @@ getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
|
||||
static const gchar*
|
||||
getActionNameCB(AtkAction *aAction, gint aActionIndex)
|
||||
{
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||
if (!accWrap)
|
||||
return nullptr;
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||
if (!accWrap)
|
||||
return nullptr;
|
||||
|
||||
nsAutoString autoStr;
|
||||
nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return AccessibleWrap::ReturnString(autoStr);
|
||||
nsAutoString autoStr;
|
||||
accWrap->ActionNameAt(aActionIndex, autoStr);
|
||||
return AccessibleWrap::ReturnString(autoStr);
|
||||
}
|
||||
|
||||
static const gchar*
|
||||
|
@ -39,8 +39,8 @@ grabFocusCB(AtkComponent* aComponent)
|
||||
if (!accWrap)
|
||||
return FALSE;
|
||||
|
||||
nsresult rv = accWrap->TakeFocus();
|
||||
return (NS_FAILED(rv)) ? FALSE : TRUE;
|
||||
accWrap->TakeFocus();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,23 +80,21 @@ getExtentsHelper(AccessibleWrap* aAccWrap,
|
||||
if (!aAccWrap || aAccWrap->IsDefunct())
|
||||
return;
|
||||
|
||||
int32_t x = 0, y = 0, width = 0, height = 0;
|
||||
// Returned in screen coordinates
|
||||
nsresult rv = aAccWrap->GetBounds(&x, &y, &width, &height);
|
||||
if (NS_FAILED(rv))
|
||||
nsIntRect screenRect = aAccWrap->Bounds();
|
||||
if (screenRect.IsEmpty())
|
||||
return;
|
||||
|
||||
if (aCoordType == ATK_XY_WINDOW) {
|
||||
nsIntPoint winCoords =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
|
||||
x -= winCoords.x;
|
||||
y -= winCoords.y;
|
||||
screenRect.x -= winCoords.x;
|
||||
screenRect.y -= winCoords.y;
|
||||
}
|
||||
|
||||
*aX = x;
|
||||
*aY = y;
|
||||
*aWidth = width;
|
||||
*aHeight = height;
|
||||
*aX = screenRect.x;
|
||||
*aY = screenRect.y;
|
||||
*aWidth = screenRect.width;
|
||||
*aHeight = screenRect.height;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -584,12 +584,11 @@ nsAccessiblePivot::MoveToPoint(nsIAccessibleTraversalRule* aRule,
|
||||
|
||||
// Match if no node below this is a match
|
||||
if ((filtered & nsIAccessibleTraversalRule::FILTER_MATCH) && !match) {
|
||||
int32_t childX, childY, childWidth, childHeight;
|
||||
child->GetBounds(&childX, &childY, &childWidth, &childHeight);
|
||||
nsIntRect childRect = child->Bounds();
|
||||
// Double-check child's bounds since the deepest child may have been out
|
||||
// of bounds. This assures we don't return a false positive.
|
||||
if (aX >= childX && aX < childX + childWidth &&
|
||||
aY >= childY && aY < childY + childHeight)
|
||||
if (aX >= childRect.x && aX < childRect.x + childRect.width &&
|
||||
aY >= childRect.y && aY < childRect.y + childRect.height)
|
||||
match = child;
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,9 @@
|
||||
#ifndef mozilla_a11y_Accessible_inl_h_
|
||||
#define mozilla_a11y_Accessible_inl_h_
|
||||
|
||||
#include "Accessible.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "nsCoreUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
@ -59,6 +60,13 @@ Accessible::HasNumericValue() const
|
||||
return mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue;
|
||||
}
|
||||
|
||||
inline void
|
||||
Accessible::ScrollTo(uint32_t aHow) const
|
||||
{
|
||||
if (mContent)
|
||||
nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow);
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,8 +11,8 @@
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "mozilla/a11y/States.h"
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleHyperLink.h"
|
||||
#include "xpcAccessible.h"
|
||||
#include "xpcAccessibleHyperLink.h"
|
||||
#include "nsIAccessibleStates.h"
|
||||
#include "xpcAccessibleSelectable.h"
|
||||
#include "xpcAccessibleValue.h"
|
||||
@ -27,6 +27,7 @@ struct nsRoleMapEntry;
|
||||
struct nsRect;
|
||||
class nsIFrame;
|
||||
class nsIAtom;
|
||||
struct nsIntRect;
|
||||
class nsView;
|
||||
|
||||
namespace mozilla {
|
||||
@ -122,8 +123,8 @@ typedef nsRefPtrHashtable<nsPtrHashKey<const void>, Accessible>
|
||||
{ 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad } \
|
||||
}
|
||||
|
||||
class Accessible : public nsIAccessible,
|
||||
public nsIAccessibleHyperLink,
|
||||
class Accessible : public xpcAccessible,
|
||||
public xpcAccessibleHyperLink,
|
||||
public xpcAccessibleSelectable,
|
||||
public xpcAccessibleValue
|
||||
{
|
||||
@ -133,10 +134,11 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
|
||||
|
||||
NS_DECL_NSIACCESSIBLE
|
||||
NS_DECL_NSIACCESSIBLEHYPERLINK
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetNativeInterface(void** aOutAccessible);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
|
||||
@ -520,10 +522,40 @@ public:
|
||||
*/
|
||||
void TestChildCache(Accessible* aCachedChild) const;
|
||||
|
||||
/**
|
||||
* Return boundaries in screen coordinates.
|
||||
*/
|
||||
virtual nsIntRect Bounds() const;
|
||||
|
||||
/**
|
||||
* Return boundaries rect relative the bounding frame.
|
||||
*/
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const;
|
||||
|
||||
/**
|
||||
* Selects the accessible within its container if applicable.
|
||||
*/
|
||||
virtual void SetSelected(bool aSelect);
|
||||
|
||||
/**
|
||||
* Select the accessible within its container.
|
||||
*/
|
||||
void TakeSelection();
|
||||
|
||||
/**
|
||||
* Focus the accessible.
|
||||
*/
|
||||
virtual void TakeFocus();
|
||||
|
||||
/**
|
||||
* Scroll the accessible into view.
|
||||
*/
|
||||
void ScrollTo(uint32_t aHow) const;
|
||||
|
||||
/**
|
||||
* Scroll the accessible to the given point.
|
||||
*/
|
||||
void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Downcasting and types
|
||||
@ -621,6 +653,26 @@ public:
|
||||
*/
|
||||
virtual uint8_t ActionCount();
|
||||
|
||||
/**
|
||||
* Return action name at given index.
|
||||
*/
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
/**
|
||||
* Default to localized action name.
|
||||
*/
|
||||
void ActionDescriptionAt(uint8_t aIndex, nsAString& aDescription)
|
||||
{
|
||||
nsAutoString name;
|
||||
ActionNameAt(aIndex, name);
|
||||
TranslateString(name, aDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the accessible action.
|
||||
*/
|
||||
virtual bool DoAction(uint8_t aIndex);
|
||||
|
||||
/**
|
||||
* Return access key, such as Alt+D.
|
||||
*/
|
||||
@ -633,7 +685,8 @@ public:
|
||||
virtual KeyBinding KeyboardShortcut() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// HyperLinkAccessible
|
||||
// HyperLinkAccessible (any embedded object in text can implement HyperLink,
|
||||
// which helps determine where it is located within containing text).
|
||||
|
||||
/**
|
||||
* Return true if the accessible is hyper link accessible.
|
||||
@ -977,9 +1030,9 @@ protected:
|
||||
|
||||
/**
|
||||
* Return the action rule based on ARIA enum constants EActionRule
|
||||
* (see ARIAMap.h). Used by ActionCount() and GetActionName().
|
||||
* (see ARIAMap.h). Used by ActionCount() and ActionNameAt().
|
||||
*/
|
||||
uint32_t GetActionRule();
|
||||
uint32_t GetActionRule() const;
|
||||
|
||||
/**
|
||||
* Return group info.
|
||||
@ -1028,6 +1081,7 @@ protected:
|
||||
void StaticAsserts() const;
|
||||
|
||||
friend class DocAccessible;
|
||||
friend class xpcAccessible;
|
||||
|
||||
nsAutoPtr<mozilla::a11y::EmbeddedObjCollector> mEmbeddedObjCollector;
|
||||
int32_t mIndexOfEmbeddedChild;
|
||||
|
@ -39,30 +39,6 @@ NS_IMPL_ISUPPORTS_INHERITED(ApplicationAccessible, Accessible,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAccessible
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetParent(nsIAccessible** aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
*aAccessible = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetNextSibling(nsIAccessible** aNextSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNextSibling);
|
||||
*aNextSibling = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPreviousSibling);
|
||||
*aPreviousSibling = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ENameValueFlag
|
||||
ApplicationAccessible::Name(nsString& aName)
|
||||
{
|
||||
@ -146,64 +122,10 @@ ApplicationAccessible::RelationByType(RelationType aRelationType)
|
||||
return Relation();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight)
|
||||
nsIntRect
|
||||
ApplicationAccessible::Bounds() const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aX);
|
||||
*aX = 0;
|
||||
NS_ENSURE_ARG_POINTER(aY);
|
||||
*aY = 0;
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
*aWidth = 0;
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
*aHeight = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::SetSelected(bool aIsSelected)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::TakeSelection()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::TakeFocus()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
ApplicationAccessible::ActionCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetActionDescription(uint8_t aIndex,
|
||||
nsAString& aDescription)
|
||||
{
|
||||
aDescription.Truncate();
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
return NS_OK;
|
||||
return nsIntRect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -355,35 +277,3 @@ ApplicationAccessible::GetSiblingAtOffset(int32_t aOffset,
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAccessible
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRootDocument);
|
||||
*aRootDocument = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::ScrollTo(uint32_t aScrollType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::ScrollToPoint(uint32_t aCoordinateType,
|
||||
int32_t aX, int32_t aY)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ApplicationAccessible::GetLanguage(nsAString& aLanguage)
|
||||
{
|
||||
aLanguage.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -37,37 +37,21 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument);
|
||||
NS_IMETHOD ScrollTo(uint32_t aScrollType);
|
||||
NS_IMETHOD ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
|
||||
NS_IMETHOD GetLanguage(nsAString& aLanguage);
|
||||
NS_IMETHOD GetParent(nsIAccessible **aParent);
|
||||
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
|
||||
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
|
||||
NS_IMETHOD GetBounds(int32_t *aX, int32_t *aY,
|
||||
int32_t *aWidth, int32_t *aHeight);
|
||||
NS_IMETHOD SetSelected(bool aIsSelected);
|
||||
NS_IMETHOD TakeSelection();
|
||||
NS_IMETHOD TakeFocus();
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString &aName);
|
||||
NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString &aDescription);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// nsIAccessibleApplication
|
||||
NS_DECL_NSIACCESSIBLEAPPLICATION
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual GroupPos GroupPosition();
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
virtual void ApplyARIAState(uint64_t* aState) const;
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t State();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t State() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
||||
@ -77,7 +61,6 @@ public:
|
||||
virtual void InvalidateChildren();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual KeyBinding AccessKey() const;
|
||||
|
||||
protected:
|
||||
|
@ -81,10 +81,13 @@ NS_IMPL_ISUPPORTS_INHERITED0(LinkableAccessible, AccessibleWrap)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LinkableAccessible. nsIAccessible
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
LinkableAccessible::TakeFocus()
|
||||
{
|
||||
return mActionAcc ? mActionAcc->TakeFocus() : AccessibleWrap::TakeFocus();
|
||||
if (mActionAcc)
|
||||
mActionAcc->TakeFocus();
|
||||
else
|
||||
AccessibleWrap::TakeFocus();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -116,31 +119,25 @@ LinkableAccessible::ActionCount()
|
||||
return (mIsOnclick || mIsLink) ? 1 : 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LinkableAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
LinkableAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
// Action 0 (default action): Jump to link
|
||||
if (aIndex == eAction_Jump) {
|
||||
if (mIsLink) {
|
||||
if (mIsLink)
|
||||
aName.AssignLiteral("jump");
|
||||
return NS_OK;
|
||||
}
|
||||
else if (mIsOnclick) {
|
||||
else if (mIsOnclick)
|
||||
aName.AssignLiteral("click");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
LinkableAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
return mActionAcc ? mActionAcc->DoAction(aIndex) :
|
||||
AccessibleWrap::DoAction(aIndex);
|
||||
|
@ -60,18 +60,16 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD TakeFocus();
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual uint64_t NativeLinkState() const;
|
||||
virtual void Shutdown() MOZ_OVERRIDE;
|
||||
virtual void Value(nsString& aValue) MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
|
||||
virtual void TakeFocus() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t index) MOZ_OVERRIDE;
|
||||
virtual KeyBinding AccessKey() const;
|
||||
|
||||
// HyperLinkAccessible
|
||||
@ -104,7 +102,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~EnumRoleAccessible() { }
|
||||
|
@ -313,20 +313,14 @@ DocAccessible::FocusedChild()
|
||||
return FocusMgr()->FocusedAccessible();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
DocAccessible::TakeFocus()
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Focus the document.
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
NS_ENSURE_STATE(fm);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> newFocus;
|
||||
return fm->MoveFocus(mDocumentNode->GetWindow(), nullptr,
|
||||
nsIFocusManager::MOVEFOCUS_ROOT, 0,
|
||||
getter_AddRefs(newFocus));
|
||||
fm->MoveFocus(mDocumentNode->GetWindow(), nullptr,
|
||||
nsFocusManager::MOVEFOCUS_ROOT, 0, getter_AddRefs(newFocus));
|
||||
}
|
||||
|
||||
|
||||
@ -645,19 +639,19 @@ DocAccessible::GetFrame() const
|
||||
}
|
||||
|
||||
// DocAccessible protected member
|
||||
void
|
||||
DocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
nsRect
|
||||
DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const
|
||||
{
|
||||
*aRelativeFrame = GetFrame();
|
||||
|
||||
nsIDocument *document = mDocumentNode;
|
||||
nsIDocument *parentDoc = nullptr;
|
||||
|
||||
nsRect bounds;
|
||||
while (document) {
|
||||
nsIPresShell *presShell = document->GetShell();
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
if (!presShell)
|
||||
return nsRect();
|
||||
|
||||
nsRect scrollPort;
|
||||
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollableExternal();
|
||||
@ -665,9 +659,9 @@ DocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
scrollPort = sf->GetScrollPortRect();
|
||||
} else {
|
||||
nsIFrame* rootFrame = presShell->GetRootFrame();
|
||||
if (!rootFrame) {
|
||||
return;
|
||||
}
|
||||
if (!rootFrame)
|
||||
return nsRect();
|
||||
|
||||
scrollPort = rootFrame->GetRect();
|
||||
}
|
||||
|
||||
@ -676,14 +670,16 @@ DocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
|
||||
// this document, but we're intersecting rectangles derived from
|
||||
// multiple documents and assuming they're all in the same coordinate
|
||||
// system. See bug 514117.
|
||||
aBounds.IntersectRect(scrollPort, aBounds);
|
||||
bounds.IntersectRect(scrollPort, bounds);
|
||||
}
|
||||
else { // First time through loop
|
||||
aBounds = scrollPort;
|
||||
bounds = scrollPort;
|
||||
}
|
||||
|
||||
document = parentDoc = document->GetParentDocument();
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
// DocAccessible protected member
|
||||
|
@ -59,9 +59,6 @@ public:
|
||||
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD TakeFocus(void);
|
||||
|
||||
// nsIScrollPositionListener
|
||||
virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) {}
|
||||
virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
|
||||
@ -79,18 +76,20 @@ public:
|
||||
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual Accessible* FocusedChild();
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual bool NativelyUnavailable() const;
|
||||
virtual void ApplyARIAState(uint64_t* aState) const;
|
||||
virtual already_AddRefed<nsIPersistentProperties> Attributes();
|
||||
|
||||
virtual void TakeFocus() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef A11Y_LOG
|
||||
virtual nsresult HandleAccEvent(AccEvent* aEvent);
|
||||
#endif
|
||||
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const MOZ_OVERRIDE;
|
||||
|
||||
// HyperTextAccessible
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() const;
|
||||
|
@ -174,24 +174,21 @@ RadioButtonAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RadioButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
RadioButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
aName.AssignLiteral("select");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("select");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
RadioButtonAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
role
|
||||
|
@ -31,8 +31,8 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
@ -57,15 +57,13 @@ class RadioButtonAccessible : public LeafAccessible
|
||||
public:
|
||||
RadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
|
@ -57,8 +57,8 @@ public:
|
||||
// Accessible
|
||||
virtual int32_t GetLevelInternal();
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
virtual void InvalidateChildren();
|
||||
virtual bool RemoveChild(Accessible* aAccessible);
|
||||
|
@ -109,34 +109,26 @@ ImageAccessible::ActionCount()
|
||||
return HasLongDesc() ? actionCount + 1 : actionCount;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
ImageAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (IsLongDescIndex(aIndex) && HasLongDesc()) {
|
||||
if (IsLongDescIndex(aIndex) && HasLongDesc())
|
||||
aName.AssignLiteral("showlongdesc");
|
||||
return NS_OK;
|
||||
}
|
||||
return LinkableAccessible::GetActionName(aIndex, aName);
|
||||
else
|
||||
LinkableAccessible::ActionNameAt(aIndex, aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
ImageAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the long description uri and open in a new window.
|
||||
if (!IsLongDescIndex(aIndex))
|
||||
return LinkableAccessible::DoAction(aIndex);
|
||||
|
||||
nsCOMPtr<nsIURI> uri = GetLongDescURI();
|
||||
if (!uri)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
nsAutoCString utf8spec;
|
||||
uri->GetSpec(utf8spec);
|
||||
@ -145,11 +137,12 @@ ImageAccessible::DoAction(uint8_t aIndex)
|
||||
nsIDocument* document = mContent->OwnerDoc();
|
||||
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
|
||||
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(piWindow);
|
||||
NS_ENSURE_STATE(win);
|
||||
if (!win)
|
||||
return false;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> tmp;
|
||||
return win->Open(spec, EmptyString(), EmptyString(),
|
||||
getter_AddRefs(tmp));
|
||||
return NS_SUCCEEDED(win->Open(spec, EmptyString(), EmptyString(),
|
||||
getter_AddRefs(tmp)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -158,20 +151,28 @@ ImageAccessible::DoAction(uint8_t aIndex)
|
||||
NS_IMETHODIMP
|
||||
ImageAccessible::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
|
||||
{
|
||||
int32_t width, height;
|
||||
nsresult rv = GetBounds(aX, aY, &width, &height);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_ARG_POINTER(aX);
|
||||
NS_ENSURE_ARG_POINTER(aY);
|
||||
|
||||
nsIntRect rect = Bounds();
|
||||
*aX = rect.x;
|
||||
*aY = rect.y;
|
||||
nsAccUtils::ConvertScreenCoordsTo(aX, aY, aCoordType, this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageAccessible::GetImageSize(int32_t* aWidth, int32_t* aHeight)
|
||||
{
|
||||
int32_t x, y;
|
||||
return GetBounds(&x, &y, aWidth, aHeight);
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
|
||||
nsIntRect rect = Bounds();
|
||||
*aWidth = rect.width;
|
||||
*aHeight = rect.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
|
@ -28,20 +28,18 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// nsIAccessibleImage
|
||||
NS_DECL_NSIACCESSIBLEIMAGE
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~ImageAccessible();
|
||||
@ -65,7 +63,7 @@ private:
|
||||
already_AddRefed<nsIURI> GetLongDescURI() const;
|
||||
|
||||
/**
|
||||
* Used by GetActionName and DoAction to ensure the index for opening the
|
||||
* Used by ActionNameAt and DoAction to ensure the index for opening the
|
||||
* longdesc URL is valid.
|
||||
* It is always assumed that the highest possible index opens the longdesc.
|
||||
* This doesn't check that there is actually a longdesc, just that the index
|
||||
|
@ -51,11 +51,9 @@ Accessible*
|
||||
OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
||||
EWhichChildAtPoint aWhichChild)
|
||||
{
|
||||
int32_t docX = 0, docY = 0, docWidth = 0, docHeight = 0;
|
||||
nsresult rv = GetBounds(&docX, &docY, &docWidth, &docHeight);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
if (aX < docX || aX >= docX + docWidth || aY < docY || aY >= docY + docHeight)
|
||||
nsIntRect docRect = Bounds();
|
||||
if (aX < docRect.x || aX >= docRect.x + docRect.width ||
|
||||
aY < docRect.y || aY >= docRect.y + docRect.height)
|
||||
return nullptr;
|
||||
|
||||
// Always return the inner doc as direct child accessible unless bounds
|
||||
@ -68,39 +66,6 @@ OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
||||
return child;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAccessible
|
||||
|
||||
uint8_t
|
||||
OuterDocAccessible::ActionCount()
|
||||
{
|
||||
// Internal frame, which is the doc's parent, should not have a click action.
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OuterDocAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OuterDocAccessible::GetActionDescription(uint8_t aIndex,
|
||||
nsAString& aDescription)
|
||||
{
|
||||
aDescription.Truncate();
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OuterDocAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accessible public
|
||||
|
||||
|
@ -27,14 +27,9 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
||||
EWhichChildAtPoint aWhichChild);
|
||||
|
||||
@ -42,9 +37,6 @@ public:
|
||||
virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) MOZ_OVERRIDE;
|
||||
virtual bool RemoveChild(Accessible* aAccessible);
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
|
||||
protected:
|
||||
virtual ~OuterDocAccessible();
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// RootAccessible
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
/**
|
||||
* Return the caption accessible if any for this table.
|
||||
*/
|
||||
virtual Accessible* Caption() { return nullptr; }
|
||||
virtual Accessible* Caption() const { return nullptr; }
|
||||
|
||||
/**
|
||||
* Get the summary for this table.
|
||||
|
@ -30,7 +30,7 @@ role
|
||||
TextLeafAccessible::NativeRole()
|
||||
{
|
||||
nsIFrame* frame = GetFrame();
|
||||
if (frame && frame->IsGeneratedContentFrame())
|
||||
if (frame && frame->IsGeneratedContentFrame())
|
||||
return roles::STATICTEXT;
|
||||
|
||||
return roles::TEXT_LEAF;
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
virtual ~TextLeafAccessible();
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
|
||||
uint32_t aLength = UINT32_MAX);
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~HTMLCanvasAccessible() { }
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
LeafAccessible(aContent, aDoc) {}
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -39,8 +39,8 @@ public:
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Accessible
|
||||
@ -60,7 +60,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
@ -81,7 +81,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -51,33 +51,28 @@ HTMLCheckboxAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCheckboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) { // 0 is the magic value for default action
|
||||
// cycle, check or uncheck
|
||||
uint64_t state = NativeState();
|
||||
|
||||
if (state & states::CHECKED)
|
||||
aName.AssignLiteral("uncheck");
|
||||
aName.AssignLiteral("uncheck");
|
||||
else if (state & states::MIXED)
|
||||
aName.AssignLiteral("cycle");
|
||||
aName.AssignLiteral("cycle");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
|
||||
return NS_OK;
|
||||
aName.AssignLiteral("check");
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLCheckboxAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -189,24 +184,21 @@ HTMLButtonAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
aName.AssignLiteral("press");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("press");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLButtonAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -293,7 +285,7 @@ HTMLTextFieldAccessible::
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(HTMLTextFieldAccessible,
|
||||
Accessible,
|
||||
Accessible,
|
||||
nsIAccessibleText,
|
||||
nsIAccessibleEditableText)
|
||||
|
||||
@ -445,23 +437,21 @@ HTMLTextFieldAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextFieldAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLTextFieldAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("activate");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLTextFieldAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex == 0)
|
||||
return TakeFocus();
|
||||
if (aIndex != 0)
|
||||
return false;
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
TakeFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEditor>
|
||||
@ -707,7 +697,7 @@ HTMLGroupboxAccessible::NativeRole()
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
HTMLGroupboxAccessible::GetLegend()
|
||||
HTMLGroupboxAccessible::GetLegend() const
|
||||
{
|
||||
for (nsIContent* legendContent = mContent->GetFirstChild(); legendContent;
|
||||
legendContent = legendContent->GetNextSibling()) {
|
||||
|
@ -34,16 +34,14 @@ public:
|
||||
mStateFlags |= eIgnoreDOMUIEvent;
|
||||
}
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -66,7 +64,7 @@ public:
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual void GetPositionAndSizeInternal(int32_t *aPosInSet,
|
||||
int32_t *aSetSize);
|
||||
};
|
||||
@ -84,17 +82,15 @@ public:
|
||||
|
||||
HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t State();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t State() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -119,22 +115,20 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// HyperTextAccessible
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() const;
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual void ApplyARIAState(uint64_t* aState) const;
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -162,7 +156,7 @@ public:
|
||||
HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
|
||||
};
|
||||
|
||||
@ -205,7 +199,7 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
@ -228,7 +222,7 @@ public:
|
||||
HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
@ -236,7 +230,7 @@ protected:
|
||||
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
|
||||
|
||||
// HTMLGroupboxAccessible
|
||||
nsIContent* GetLegend();
|
||||
nsIContent* GetLegend() const;
|
||||
};
|
||||
|
||||
|
||||
@ -249,7 +243,7 @@ public:
|
||||
HTMLLegendAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
@ -263,7 +257,7 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
@ -284,7 +278,7 @@ public:
|
||||
HTMLFigcaptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
@ -236,24 +236,25 @@ HTMLAreaAccessible::CacheChildren()
|
||||
// No children for aria accessible.
|
||||
}
|
||||
|
||||
void
|
||||
HTMLAreaAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
nsRect
|
||||
HTMLAreaAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
|
||||
{
|
||||
nsIFrame* frame = GetFrame();
|
||||
if (!frame)
|
||||
return;
|
||||
return nsRect();
|
||||
|
||||
nsImageFrame* imageFrame = do_QueryFrame(frame);
|
||||
nsImageMap* map = imageFrame->GetImageMap();
|
||||
|
||||
nsresult rv = map->GetBoundsForAreaContent(mContent, aBounds);
|
||||
nsRect bounds;
|
||||
nsresult rv = map->GetBoundsForAreaContent(mContent, bounds);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
return nsRect();
|
||||
|
||||
// XXX Areas are screwy; they return their rects as a pair of points, one pair
|
||||
// stored into the width and height.
|
||||
aBounds.width -= aBounds.x;
|
||||
aBounds.height -= aBounds.y;
|
||||
|
||||
*aBoundingFrame = frame;
|
||||
bounds.width -= bounds.x;
|
||||
bounds.height -= bounds.y;
|
||||
return bounds;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// HyperLinkAccessible
|
||||
virtual uint32_t AnchorCount();
|
||||
@ -62,7 +62,7 @@ public:
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
||||
EWhichChildAtPoint aWhichChild);
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
|
||||
|
||||
// HyperLinkAccessible
|
||||
virtual uint32_t StartOffset();
|
||||
|
@ -92,23 +92,22 @@ HTMLLinkAccessible::ActionCount()
|
||||
return IsLinked() ? 1 : HyperTextAccessible::ActionCount();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLLinkAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLLinkAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
if (!IsLinked())
|
||||
return HyperTextAccessible::GetActionName(aIndex, aName);
|
||||
if (!IsLinked()) {
|
||||
HyperTextAccessible::ActionNameAt(aIndex, aName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Action 0 (default action): Jump to link
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
aName.AssignLiteral("jump");
|
||||
return NS_OK;
|
||||
if (aIndex == eAction_Jump)
|
||||
aName.AssignLiteral("jump");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLLinkAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (!IsLinked())
|
||||
@ -116,13 +115,10 @@ HTMLLinkAccessible::DoAction(uint8_t aIndex)
|
||||
|
||||
// Action 0 (default action): Jump to link
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -145,11 +141,8 @@ HTMLLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
|
||||
// Protected members
|
||||
|
||||
bool
|
||||
HTMLLinkAccessible::IsLinked()
|
||||
HTMLLinkAccessible::IsLinked() const
|
||||
{
|
||||
if (IsDefunct())
|
||||
return false;
|
||||
|
||||
EventStates state = mContent->AsElement()->State();
|
||||
return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED);
|
||||
|
@ -15,22 +15,20 @@ class HTMLLinkAccessible : public HyperTextAccessibleWrap
|
||||
{
|
||||
public:
|
||||
HTMLLinkAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeLinkState() const;
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// HyperLinkAccessible
|
||||
virtual bool IsLink();
|
||||
@ -44,7 +42,7 @@ protected:
|
||||
/**
|
||||
* Returns true if the link has href attribute.
|
||||
*/
|
||||
bool IsLinked();
|
||||
bool IsLinked() const;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -81,21 +81,18 @@ HTMLLIAccessible::NativeState()
|
||||
return HyperTextAccessibleWrap::NativeState() | states::READONLY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLLIAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight)
|
||||
nsIntRect
|
||||
HTMLLIAccessible::Bounds() const
|
||||
{
|
||||
nsresult rv = AccessibleWrap::GetBounds(aX, aY, aWidth, aHeight);
|
||||
if (NS_FAILED(rv) || !mBullet || mBullet->IsInside())
|
||||
return rv;
|
||||
nsIntRect rect = AccessibleWrap::Bounds();
|
||||
if (rect.IsEmpty() || !mBullet || mBullet->IsInside())
|
||||
return rect;
|
||||
|
||||
int32_t bulletX = 0, bulletY = 0, bulletWidth = 0, bulletHeight = 0;
|
||||
rv = mBullet->GetBounds(&bulletX, &bulletY, &bulletWidth, &bulletHeight);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsIntRect bulletRect = mBullet->Bounds();
|
||||
|
||||
*aWidth += *aX - bulletX;
|
||||
*aX = bulletX; // Move x coordinate of list item over to cover bullet as well
|
||||
return NS_OK;
|
||||
rect.width += rect.x - bulletRect.x;
|
||||
rect.x = bulletRect.x; // Move x coordinate of list item over to cover bullet as well
|
||||
return rect;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,8 +28,8 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~HTMLListAccessible() { }
|
||||
@ -47,14 +47,11 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight);
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// HTMLLIAccessible
|
||||
HTMLListBulletAccessible* Bullet() const { return mBullet; }
|
||||
@ -83,8 +80,8 @@ public:
|
||||
// Accessible
|
||||
virtual nsIFrame* GetFrame() const;
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
|
||||
uint32_t aLength = UINT32_MAX);
|
||||
|
||||
|
@ -231,16 +231,15 @@ HTMLSelectOptionAccessible::NativeState()
|
||||
// <select> is not collapsed: compare bounds to calculate OFFSCREEN
|
||||
Accessible* listAcc = Parent();
|
||||
if (listAcc) {
|
||||
int32_t optionX, optionY, optionWidth, optionHeight;
|
||||
int32_t listX, listY, listWidth, listHeight;
|
||||
GetBounds(&optionX, &optionY, &optionWidth, &optionHeight);
|
||||
listAcc->GetBounds(&listX, &listY, &listWidth, &listHeight);
|
||||
if (optionY < listY || optionY + optionHeight > listY + listHeight) {
|
||||
nsIntRect optionRect = Bounds();
|
||||
nsIntRect listRect = listAcc->Bounds();
|
||||
if (optionRect.y < listRect.y ||
|
||||
optionRect.y + optionRect.height > listRect.y + listRect.height) {
|
||||
state |= states::OFFSCREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -265,25 +264,21 @@ HTMLSelectOptionAccessible::GetLevelInternal()
|
||||
return level;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSelectOptionAccessible::GetBoundsRect(nsRect& aTotalBounds,
|
||||
nsIFrame** aBoundingFrame)
|
||||
nsRect
|
||||
HTMLSelectOptionAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
|
||||
{
|
||||
Accessible* combobox = GetCombobox();
|
||||
if (combobox && (combobox->State() & states::COLLAPSED))
|
||||
combobox->GetBoundsRect(aTotalBounds, aBoundingFrame);
|
||||
else
|
||||
HyperTextAccessibleWrap::GetBoundsRect(aTotalBounds, aBoundingFrame);
|
||||
return combobox->RelativeBounds(aBoundingFrame);
|
||||
|
||||
return HyperTextAccessibleWrap::RelativeBounds(aBoundingFrame);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSelectOptionAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLSelectOptionAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Select) {
|
||||
aName.AssignLiteral("select");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Select)
|
||||
aName.AssignLiteral("select");
|
||||
}
|
||||
|
||||
uint8_t
|
||||
@ -292,27 +287,22 @@ HTMLSelectOptionAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLSelectOptionAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Select)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
HTMLSelectOptionAccessible::SetSelected(bool aSelect)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
HTMLOptionElement* option = HTMLOptionElement::FromContent(mContent);
|
||||
return option ? option->SetSelected(aSelect) : NS_ERROR_FAILURE;
|
||||
if (option)
|
||||
option->SetSelected(aSelect);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -344,24 +334,24 @@ HTMLSelectOptGroupAccessible::NativeInteractiveState() const
|
||||
return NativelyUnavailable() ? states::UNAVAILABLE : 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSelectOptGroupAccessible::DoAction(uint8_t index)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSelectOptGroupAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
HTMLSelectOptGroupAccessible::ActionCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSelectOptGroupAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLSelectOptGroupAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLComboboxAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -477,41 +467,30 @@ HTMLComboboxAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
HTMLComboboxAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our action name is the reverse of our state:
|
||||
* if we are closed -> open is our name.
|
||||
* if we are open -> closed is our name.
|
||||
* Uses the frame to get the state, updated on every click
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
HTMLComboboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
HTMLComboboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex != HTMLComboboxAccessible::eAction_Click) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
|
||||
if (!comboFrame) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (comboFrame->IsDroppedDown())
|
||||
aName.AssignLiteral("close");
|
||||
else
|
||||
aName.AssignLiteral("open");
|
||||
if (aIndex != HTMLComboboxAccessible::eAction_Click)
|
||||
return;
|
||||
|
||||
return NS_OK;
|
||||
nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
|
||||
if (!comboFrame)
|
||||
return;
|
||||
|
||||
if (comboFrame->IsDroppedDown())
|
||||
aName.AssignLiteral("close");
|
||||
else
|
||||
aName.AssignLiteral("open");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -625,37 +604,32 @@ HTMLComboboxListAccessible::NativeState()
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the areaFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void
|
||||
HTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
nsRect
|
||||
HTMLComboboxListAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
|
||||
{
|
||||
*aBoundingFrame = nullptr;
|
||||
|
||||
Accessible* comboAcc = Parent();
|
||||
if (!comboAcc)
|
||||
return;
|
||||
return nsRect();
|
||||
|
||||
if (0 == (comboAcc->State() & states::COLLAPSED)) {
|
||||
HTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame);
|
||||
return;
|
||||
return HTMLSelectListAccessible::RelativeBounds(aBoundingFrame);
|
||||
}
|
||||
|
||||
// Get the first option.
|
||||
nsIContent* content = mContent->GetFirstChild();
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
if (!content)
|
||||
return nsRect();
|
||||
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
*aBoundingFrame = nullptr;
|
||||
return;
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
*aBoundingFrame = frame->GetParent();
|
||||
aBounds = (*aBoundingFrame)->GetRect();
|
||||
return (*aBoundingFrame)->GetRect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -39,8 +39,8 @@ public:
|
||||
virtual ~HTMLSelectListAccessible() {}
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// SelectAccessible
|
||||
virtual bool SelectAll();
|
||||
@ -70,21 +70,19 @@ public:
|
||||
HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
virtual ~HTMLSelectOptionAccessible() {}
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD SetSelected(bool aSelect);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
virtual int32_t GetLevelInternal();
|
||||
virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
|
||||
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
|
||||
virtual void SetSelected(bool aSelect) MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual Accessible* ContainerWidget() const;
|
||||
@ -142,16 +140,14 @@ public:
|
||||
{ mType = eHTMLOptGroupType; }
|
||||
virtual ~HTMLSelectOptGroupAccessible() {}
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
/** ------------------------------------------------------ */
|
||||
@ -171,20 +167,18 @@ public:
|
||||
HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
virtual ~HTMLComboboxAccessible() {}
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual void InvalidateChildren();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -221,9 +215,9 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual nsIFrame* GetFrame() const;
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsActiveWidget() const;
|
||||
|
@ -460,7 +460,7 @@ HTMLTableAccessible::RelationByType(RelationType aType)
|
||||
// HTMLTableAccessible: nsIAccessibleTable implementation
|
||||
|
||||
Accessible*
|
||||
HTMLTableAccessible::Caption()
|
||||
HTMLTableAccessible::Caption() const
|
||||
{
|
||||
Accessible* child = mChildren.SafeElementAt(0, nullptr);
|
||||
return child && child->Role() == roles::CAPTION ? child : nullptr;
|
||||
|
@ -39,9 +39,9 @@ public:
|
||||
// Accessible
|
||||
virtual TableCellAccessible* AsTableCell() { return this; }
|
||||
virtual void Shutdown();
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
|
||||
// TableCellAccessible
|
||||
@ -83,7 +83,7 @@ public:
|
||||
HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~HTMLTableRowAccessible() { }
|
||||
@ -138,7 +138,7 @@ public:
|
||||
NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
|
||||
|
||||
// TableAccessible
|
||||
virtual Accessible* Caption();
|
||||
virtual Accessible* Caption() const;
|
||||
virtual void Summary(nsString& aSummary);
|
||||
virtual uint32_t ColCount();
|
||||
virtual uint32_t RowCount();
|
||||
@ -171,8 +171,8 @@ public:
|
||||
virtual void Shutdown();
|
||||
virtual TableAccessible* AsTable() { return this; }
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
|
||||
|
||||
@ -234,7 +234,7 @@ public:
|
||||
// nsIAccessible
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ interface nsIAccessibleRelation;
|
||||
* Mozilla creates the implementations of nsIAccessible on demand.
|
||||
* See http://www.mozilla.org/projects/ui/accessibility for more information.
|
||||
*/
|
||||
[scriptable, uuid(ee62158b-bb83-424b-a88d-d7d7f9cf460d)]
|
||||
[scriptable, uuid(66b110b0-c25a-4784-8623-f6ba40c7cfee)]
|
||||
interface nsIAccessible : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -96,7 +96,7 @@ interface nsIAccessible : nsISupports
|
||||
* compute the name. Any string value, including the empty string, should be
|
||||
* considered author-intentional, and respected.
|
||||
*/
|
||||
attribute AString name;
|
||||
readonly attribute AString name;
|
||||
|
||||
/**
|
||||
* Accessible value -- a number or a secondary text equivalent for this node
|
||||
@ -198,6 +198,7 @@ interface nsIAccessible : nsISupports
|
||||
/**
|
||||
* Nth accessible child using zero-based index or last child if index less than zero
|
||||
*/
|
||||
[binaryname(ScriptableGetChildAt)]
|
||||
nsIAccessible getChildAt(in long aChildIndex);
|
||||
|
||||
/**
|
||||
@ -220,6 +221,7 @@ interface nsIAccessible : nsISupports
|
||||
/**
|
||||
* Add or remove this accessible to the current selection
|
||||
*/
|
||||
[binaryname(ScriptableSetSelected)]
|
||||
void setSelected(in boolean isSelected);
|
||||
|
||||
/**
|
||||
@ -231,6 +233,7 @@ interface nsIAccessible : nsISupports
|
||||
/**
|
||||
* Select this accessible node only
|
||||
*/
|
||||
[binaryname(ScriptableTakeSelection)]
|
||||
void takeSelection();
|
||||
|
||||
/**
|
||||
@ -241,6 +244,7 @@ interface nsIAccessible : nsISupports
|
||||
* will still set focus on that node, although normally that will not be visually
|
||||
* indicated in most style sheets.
|
||||
*/
|
||||
[binaryname(ScriptableTakeFocus)]
|
||||
void takeFocus();
|
||||
|
||||
/**
|
||||
@ -262,7 +266,8 @@ interface nsIAccessible : nsISupports
|
||||
* Perform the accessible action at the given zero-based index
|
||||
* Action number 0 is the default action
|
||||
*/
|
||||
void doAction(in uint8_t index);
|
||||
[binaryname(ScriptableDoAction)]
|
||||
void doAction(in uint8_t index);
|
||||
|
||||
/**
|
||||
* Makes an object visible on screen.
|
||||
@ -271,6 +276,7 @@ interface nsIAccessible : nsISupports
|
||||
* the screen (see nsIAccessibleScrollType for
|
||||
* available constants).
|
||||
*/
|
||||
[binaryname(ScriptableScrollTo)]
|
||||
void scrollTo(in unsigned long aScrollType);
|
||||
|
||||
/**
|
||||
@ -282,6 +288,7 @@ interface nsIAccessible : nsISupports
|
||||
* @param x [in] - defines the x coordinate
|
||||
* @param y [in] - defines the y coordinate
|
||||
*/
|
||||
[binaryname(ScriptableScrollToPoint)]
|
||||
void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
|
||||
|
||||
/**
|
||||
|
@ -374,13 +374,12 @@ GetClosestInterestingAccessible(id anObject)
|
||||
if (!mGeckoAccessible)
|
||||
return nil;
|
||||
|
||||
int32_t x = 0, y = 0, width = 0, height = 0;
|
||||
mGeckoAccessible->GetBounds(&x, &y, &width, &height);
|
||||
nsIntRect rect = mGeckoAccessible->Bounds();
|
||||
|
||||
NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
|
||||
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
|
||||
NSPoint p = NSMakePoint(static_cast<CGFloat>(x) / scaleFactor,
|
||||
[mainView frame].size.height - static_cast<CGFloat>(y + height) / scaleFactor);
|
||||
NSPoint p = NSMakePoint(static_cast<CGFloat>(rect.x) / scaleFactor,
|
||||
[mainView frame].size.height - static_cast<CGFloat>(rect.y + rect.height) / scaleFactor);
|
||||
|
||||
return [NSValue valueWithPoint:p];
|
||||
|
||||
@ -610,9 +609,9 @@ GetClosestInterestingAccessible(id anObject)
|
||||
{
|
||||
if (!mGeckoAccessible)
|
||||
return NO;
|
||||
|
||||
nsresult rv = mGeckoAccessible->TakeFocus();
|
||||
return NS_SUCCEEDED(rv);
|
||||
|
||||
mGeckoAccessible->TakeFocus();
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isEnabled
|
||||
|
@ -221,8 +221,8 @@ ia2Accessible::scrollToPoint(enum IA2CoordinateType aCoordType,
|
||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
|
||||
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
|
||||
|
||||
nsresult rv = acc->ScrollToPoint(geckoCoordType, aX, aY);
|
||||
return GetHRESULT(rv);
|
||||
acc->ScrollToPoint(geckoCoordType, aX, aY);
|
||||
return S_OK;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ ia2AccessibleAction::doAction(long aActionIndex)
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
uint8_t index = static_cast<uint8_t>(aActionIndex);
|
||||
nsresult rv = acc->DoAction(index);
|
||||
return GetHRESULT(rv);
|
||||
return acc->DoAction(index) ? S_OK : E_INVALIDARG;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
}
|
||||
@ -167,12 +166,9 @@ ia2AccessibleAction::get_name(long aActionIndex, BSTR *aName)
|
||||
|
||||
nsAutoString name;
|
||||
uint8_t index = static_cast<uint8_t>(aActionIndex);
|
||||
nsresult rv = acc->GetActionName(index, name);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
acc->ActionNameAt(index, name);
|
||||
if (name.IsEmpty())
|
||||
return S_FALSE;
|
||||
return E_INVALIDARG;
|
||||
|
||||
*aName = ::SysAllocStringLen(name.get(), name.Length());
|
||||
return *aName ? S_OK : E_OUTOFMEMORY;
|
||||
|
@ -58,31 +58,22 @@ ia2AccessibleComponent::get_locationInParent(long* aX, long* aY)
|
||||
if (state & states::INVISIBLE)
|
||||
return S_OK;
|
||||
|
||||
int32_t x = 0, y = 0, width = 0, height = 0;
|
||||
nsresult rv = acc->GetBounds(&x, &y, &width, &height);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
Accessible* parentAcc = acc->Parent();
|
||||
nsIntRect rect = acc->Bounds();
|
||||
|
||||
// The coordinates of the returned position are relative to this object's
|
||||
// parent or relative to the screen on which this object is rendered if it
|
||||
// has no parent.
|
||||
if (!parentAcc) {
|
||||
*aX = x;
|
||||
*aY = y;
|
||||
if (!acc->Parent()) {
|
||||
*aX = rect.x;
|
||||
*aY = rect.y;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// The coordinates of the bounding box are given relative to the parent's
|
||||
// coordinate system.
|
||||
int32_t parentx = 0, parenty = 0;
|
||||
rv = acc->GetBounds(&parentx, &parenty, &width, &height);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
*aX = x - parentx;
|
||||
*aY = y - parenty;
|
||||
nsIntRect parentRect = acc->Parent()->Bounds();
|
||||
*aX = rect.x - parentRect.x;
|
||||
*aY = rect.y - parentRect.y;
|
||||
return S_OK;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
|
@ -778,9 +778,7 @@ AccessibleWrap::get_accDefaultAction(
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
nsAutoString defaultAction;
|
||||
if (NS_FAILED(xpAccessible->GetActionName(0, defaultAction)))
|
||||
return E_FAIL;
|
||||
|
||||
xpAccessible->ActionNameAt(0, defaultAction);
|
||||
*pszDefaultAction = ::SysAllocStringLen(defaultAction.get(),
|
||||
defaultAction.Length());
|
||||
return *pszDefaultAction ? S_OK : E_OUTOFMEMORY;
|
||||
@ -859,14 +857,11 @@ AccessibleWrap::accLocation(
|
||||
if (xpAccessible->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
int32_t x, y, width, height;
|
||||
if (NS_FAILED(xpAccessible->GetBounds(&x, &y, &width, &height)))
|
||||
return E_FAIL;
|
||||
|
||||
*pxLeft = x;
|
||||
*pyTop = y;
|
||||
*pcxWidth = width;
|
||||
*pcyHeight = height;
|
||||
nsIntRect rect = xpAccessible->Bounds();
|
||||
*pxLeft = rect.x;
|
||||
*pyTop = rect.y;
|
||||
*pcxWidth = rect.width;
|
||||
*pcyHeight = rect.height;
|
||||
return S_OK;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
@ -1004,7 +999,7 @@ AccessibleWrap::accDoDefaultAction(
|
||||
if (xpAccessible->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
return GetHRESULT(xpAccessible->DoAction(0));
|
||||
return xpAccessible->DoAction(0) ? S_OK : E_INVALIDARG;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
}
|
||||
|
@ -129,13 +129,12 @@ DocAccessibleWrap::DoInitialUpdate()
|
||||
rootDocument->GetNativeWindow());
|
||||
|
||||
bool isActive = true;
|
||||
int32_t x = CW_USEDEFAULT, y = CW_USEDEFAULT, width = 0, height = 0;
|
||||
nsIntRect rect(CW_USEDEFAULT, CW_USEDEFAULT, 0, 0);
|
||||
if (Compatibility::IsDolphin()) {
|
||||
GetBounds(&x, &y, &width, &height);
|
||||
int32_t rootX = 0, rootY = 0, rootWidth = 0, rootHeight = 0;
|
||||
rootDocument->GetBounds(&rootX, &rootY, &rootWidth, &rootHeight);
|
||||
x = rootX - x;
|
||||
y -= rootY;
|
||||
rect = Bounds();
|
||||
nsIntRect rootRect = rootDocument->Bounds();
|
||||
rect.x = rootRect.x - rect.x;
|
||||
rect.y -= rootRect.y;
|
||||
|
||||
nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
||||
@ -144,7 +143,8 @@ DocAccessibleWrap::DoInitialUpdate()
|
||||
|
||||
HWND parentWnd = reinterpret_cast<HWND>(nativeData);
|
||||
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
|
||||
x, y, width, height, isActive);
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height, isActive);
|
||||
|
||||
nsWinUtils::sHWNDCache->Put(mHWND, this);
|
||||
|
||||
|
@ -75,11 +75,8 @@ sdnTextAccessible::get_clippedSubstringBounds(unsigned int aStartIndex,
|
||||
NS_ASSERTION(document,
|
||||
"There must always be a doc accessible, but there isn't. Crash!");
|
||||
|
||||
nscoord docX = 0, docY = 0, docWidth = 0, docHeight = 0;
|
||||
document->GetBounds(&docX, &docY, &docWidth, &docHeight);
|
||||
|
||||
nsIntRect docRect = document->Bounds();
|
||||
nsIntRect unclippedRect(x, y, width, height);
|
||||
nsIntRect docRect(docX, docY, docWidth, docHeight);
|
||||
|
||||
nsIntRect clippedRect;
|
||||
clippedRect.IntersectRect(unclippedRect, docRect);
|
||||
|
@ -5,6 +5,8 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'xpcAccessible.h',
|
||||
'xpcAccessibleHyperLink.h',
|
||||
'xpcAccessibleHyperText.h',
|
||||
'xpcAccessibleSelectable.h',
|
||||
'xpcAccessibleValue.h',
|
||||
@ -12,6 +14,8 @@ EXPORTS += [
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsAccessibleRelation.cpp',
|
||||
'xpcAccessible.cpp',
|
||||
'xpcAccessibleHyperLink.cpp',
|
||||
'xpcAccessibleHyperText.cpp',
|
||||
'xpcAccessibleSelectable.cpp',
|
||||
'xpcAccessibleTable.cpp',
|
||||
|
572
accessible/xpcom/xpcAccessible.cpp
Normal file
572
accessible/xpcom/xpcAccessible.cpp
Normal file
@ -0,0 +1,572 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#include "xpcAccessible.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsIAccessibleRelation.h"
|
||||
#include "nsIAccessibleRole.h"
|
||||
#include "nsAccessibleRelation.h"
|
||||
#include "Relation.h"
|
||||
#include "Role.h"
|
||||
#include "RootAccessible.h"
|
||||
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetParent(nsIAccessible** aParent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aParent = static_cast<Accessible*>(this)->Parent());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNextSibling);
|
||||
*aNextSibling = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
NS_IF_ADDREF(*aNextSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(1, &rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPreviousSibling);
|
||||
*aPreviousSibling = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
NS_IF_ADDREF(*aPreviousSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(-1, &rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFirstChild);
|
||||
*aFirstChild = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aFirstChild = static_cast<Accessible*>(this)->FirstChild());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLastChild);
|
||||
*aLastChild = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aLastChild = static_cast<Accessible*>(this)->LastChild());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetChildCount(int32_t* aChildCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChildCount);
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aChildCount = static_cast<Accessible*>(this)->ChildCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableGetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChild);
|
||||
*aChild = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// If child index is negative, then return last child.
|
||||
// XXX: do we really need this?
|
||||
if (aChildIndex < 0)
|
||||
aChildIndex = static_cast<Accessible*>(this)->ChildCount() - 1;
|
||||
|
||||
Accessible* child = static_cast<Accessible*>(this)->GetChildAt(aChildIndex);
|
||||
if (!child)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
NS_ADDREF(*aChild = child);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetChildren(nsIArray** aChildren)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChildren);
|
||||
*aChildren = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> children =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t childCount = static_cast<Accessible*>(this)->ChildCount();
|
||||
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsIAccessible* child = static_cast<Accessible*>(this)->GetChildAt(childIdx);
|
||||
children->AppendElement(child, false);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aChildren = children);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIndexInParent);
|
||||
|
||||
*aIndexInParent = static_cast<Accessible*>(this)->IndexInParent();
|
||||
return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetDOMNode(nsIDOMNode** aDOMNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDOMNode);
|
||||
*aDOMNode = nullptr;
|
||||
|
||||
nsINode *node = static_cast<Accessible*>(this)->GetNode();
|
||||
if (node)
|
||||
CallQueryInterface(node, aDOMNode);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
|
||||
NS_IF_ADDREF(*aDocument = static_cast<Accessible*>(this)->Document());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRootDocument);
|
||||
|
||||
NS_IF_ADDREF(*aRootDocument = static_cast<Accessible*>(this)->RootAccessible());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetRole(uint32_t* aRole)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRole);
|
||||
*aRole = nsIAccessibleRole::ROLE_NOTHING;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aRole = static_cast<Accessible*>(this)->Role();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
|
||||
nsAccUtils::To32States(static_cast<Accessible*>(this)->State(),
|
||||
aState, aExtraState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetName(nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString name;
|
||||
static_cast<Accessible*>(this)->Name(name);
|
||||
aName.Assign(name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetDescription(nsAString& aDescription)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString desc;
|
||||
static_cast<Accessible*>(this)->Description(desc);
|
||||
aDescription.Assign(desc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetLanguage(nsAString& aLanguage)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->Language(aLanguage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetValue(nsAString& aValue)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString value;
|
||||
static_cast<Accessible*>(this)->Value(value);
|
||||
aValue.Assign(value);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetHelp(nsAString& aHelp)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetAccessKey(nsAString& aAccessKey)
|
||||
{
|
||||
aAccessKey.Truncate();
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->AccessKey().ToString(aAccessKey);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
|
||||
{
|
||||
aKeyBinding.Truncate();
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->KeyboardShortcut().ToString(aKeyBinding);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAttributes);
|
||||
*aAttributes = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||
static_cast<Accessible*>(this)->Attributes();
|
||||
attributes.swap(*aAttributes);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aX);
|
||||
*aX = 0;
|
||||
NS_ENSURE_ARG_POINTER(aY);
|
||||
*aY = 0;
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
*aWidth = 0;
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
*aHeight = 0;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsIntRect rect = static_cast<Accessible*>(this)->Bounds();
|
||||
*aX = rect.x;
|
||||
*aY = rect.y;
|
||||
*aWidth = rect.width;
|
||||
*aHeight = rect.height;;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableGroupPosition(int32_t* aGroupLevel,
|
||||
int32_t* aSimilarItemsInGroup,
|
||||
int32_t* aPositionInGroup)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aGroupLevel);
|
||||
*aGroupLevel = 0;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
|
||||
*aSimilarItemsInGroup = 0;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aPositionInGroup);
|
||||
*aPositionInGroup = 0;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GroupPos groupPos = static_cast<Accessible*>(this)->GroupPosition();
|
||||
|
||||
*aGroupLevel = groupPos.level;
|
||||
*aSimilarItemsInGroup = groupPos.setSize;
|
||||
*aPositionInGroup = groupPos.posInSet;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetRelationByType(uint32_t aType,
|
||||
nsIAccessibleRelation** aRelation)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRelation);
|
||||
*aRelation = nullptr;
|
||||
|
||||
NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
Relation rel = static_cast<Accessible*>(this)->RelationByType(static_cast<RelationType>(aType));
|
||||
NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
|
||||
return *aRelation ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetRelations(nsIArray** aRelations)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRelations);
|
||||
*aRelations = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
static const uint32_t relationTypes[] = {
|
||||
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,
|
||||
nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION
|
||||
};
|
||||
|
||||
for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
|
||||
nsCOMPtr<nsIAccessibleRelation> relation;
|
||||
nsresult rv = GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && relation) {
|
||||
uint32_t targets = 0;
|
||||
relation->GetTargetsCount(&targets);
|
||||
if (targets)
|
||||
relations->AppendElement(relation, false);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aRelations = relations);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChild);
|
||||
*aChild = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aChild = static_cast<Accessible*>(this)->FocusedChild());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
|
||||
nsIAccessible** aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
*aAccessible = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aAccessible =
|
||||
static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
|
||||
Accessible::eDirectChild));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
|
||||
nsIAccessible** aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
*aAccessible = nullptr;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_IF_ADDREF(*aAccessible =
|
||||
static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
|
||||
Accessible::eDeepestChild));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableSetSelected(bool aSelect)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->SetSelected(aSelect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ExtendSelection()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableTakeSelection()
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->TakeSelection();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableTakeFocus()
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->TakeFocus();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetActionCount(uint8_t* aActionCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aActionCount);
|
||||
*aActionCount = 0;
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aActionCount = static_cast<Accessible*>(this)->ActionCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
static_cast<Accessible*>(this)->ActionNameAt(aIndex, aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
static_cast<Accessible*>(this)->ActionDescriptionAt(aIndex, aDescription);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableDoAction(uint8_t aIndex)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return static_cast<Accessible*>(this)->DoAction(aIndex) ?
|
||||
NS_OK : NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableScrollTo(uint32_t aHow)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->ScrollTo(aHow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::ScriptableScrollToPoint(uint32_t aCoordinateType,
|
||||
int32_t aX, int32_t aY)
|
||||
{
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
static_cast<Accessible*>(this)->ScrollToPoint(aCoordinateType, aX, aY);
|
||||
return NS_OK;
|
||||
}
|
88
accessible/xpcom/xpcAccessible.h
Normal file
88
accessible/xpcom/xpcAccessible.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* -*- 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_xpcAccessible_h_
|
||||
#define mozilla_a11y_xpcAccessible_h_
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
|
||||
class nsIAccessible;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class xpcAccessible : public nsIAccessible
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD GetParent(nsIAccessible** aParent) MOZ_FINAL;
|
||||
NS_IMETHOD GetNextSibling(nsIAccessible** aNextSibling) MOZ_FINAL;
|
||||
NS_IMETHOD GetPreviousSibling(nsIAccessible** aPreviousSibling) MOZ_FINAL;
|
||||
NS_IMETHOD GetFirstChild(nsIAccessible** aFirstChild) MOZ_FINAL;
|
||||
NS_IMETHOD GetLastChild(nsIAccessible** aLastChild) MOZ_FINAL;
|
||||
NS_IMETHOD GetChildCount(int32_t* aChildCount) MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableGetChildAt(int32_t aChildIndex,
|
||||
nsIAccessible** aChild) MOZ_FINAL;
|
||||
NS_IMETHOD GetChildren(nsIArray** aChildren) MOZ_FINAL;
|
||||
NS_IMETHOD GetIndexInParent(int32_t* aIndexInParent) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode) MOZ_FINAL;
|
||||
NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
|
||||
NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetRole(uint32_t* aRole) MOZ_FINAL;
|
||||
NS_IMETHOD GetState(uint32_t* aState, uint32_t* aExtraState) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetDescription(nsAString& aDescription) MOZ_FINAL;
|
||||
NS_IMETHOD GetName(nsAString& aName) MOZ_FINAL;
|
||||
NS_IMETHOD GetLanguage(nsAString& aLanguage) MOZ_FINAL;
|
||||
NS_IMETHOD GetValue(nsAString& aValue) MOZ_FINAL;
|
||||
NS_IMETHOD GetHelp(nsAString& aHelp) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetAccessKey(nsAString& aAccessKey) MOZ_FINAL;
|
||||
NS_IMETHOD GetKeyboardShortcut(nsAString& aKeyBinding) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetAttributes(nsIPersistentProperties** aAttributes) MOZ_FINAL;
|
||||
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableGroupPosition(int32_t* aGroupLevel,
|
||||
int32_t* aSimilarItemsInGroup,
|
||||
int32_t* aPositionInGroup) MOZ_FINAL;
|
||||
NS_IMETHOD GetRelationByType(uint32_t aType,
|
||||
nsIAccessibleRelation** aRelation) MOZ_FINAL;
|
||||
NS_IMETHOD GetRelations(nsIArray** aRelations) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetFocusedChild(nsIAccessible** aChild) MOZ_FINAL;
|
||||
NS_IMETHOD GetChildAtPoint(int32_t aX, int32_t aY,
|
||||
nsIAccessible** aAccessible) MOZ_FINAL;
|
||||
NS_IMETHOD GetDeepestChildAtPoint(int32_t aX, int32_t aY,
|
||||
nsIAccessible** aAccessible) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD ScriptableSetSelected(bool aSelect) MOZ_FINAL;
|
||||
NS_IMETHOD ExtendSelection() MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableTakeSelection() MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableTakeFocus() MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD GetActionCount(uint8_t* aActionCount) MOZ_FINAL;
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName) MOZ_FINAL;
|
||||
NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription) MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableDoAction(uint8_t aIndex) MOZ_FINAL;
|
||||
|
||||
NS_IMETHOD ScriptableScrollTo(uint32_t aHow) MOZ_FINAL;
|
||||
NS_IMETHOD ScriptableScrollToPoint(uint32_t aCoordinateType,
|
||||
int32_t aX, int32_t aY) MOZ_FINAL;
|
||||
|
||||
private:
|
||||
xpcAccessible() { }
|
||||
friend class Accessible;
|
||||
|
||||
xpcAccessible(const xpcAccessible&) MOZ_DELETE;
|
||||
xpcAccessible& operator =(const xpcAccessible&) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
97
accessible/xpcom/xpcAccessibleHyperLink.cpp
Normal file
97
accessible/xpcom/xpcAccessibleHyperLink.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#include "xpcAccessibleHyperLink.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStartIndex);
|
||||
*aStartIndex = 0;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aStartIndex = static_cast<Accessible*>(this)->StartOffset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEndIndex);
|
||||
*aEndIndex = 0;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aEndIndex = static_cast<Accessible*>(this)->EndOffset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAnchorCount);
|
||||
*aAnchorCount = 0;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aAnchorCount = static_cast<Accessible*>(this)->AnchorCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
||||
Accessible* thisAcc = static_cast<Accessible*>(this);
|
||||
if (thisAcc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsRefPtr<nsIURI>(thisAcc->AnchorURIAt(aIndex)).forget(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
*aAccessible = nullptr;
|
||||
|
||||
Accessible* thisAcc = static_cast<Accessible*>(this);
|
||||
if (thisAcc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
NS_IF_ADDREF(*aAccessible = thisAcc->AnchorAt(aIndex));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleHyperLink::GetValid(bool* aValid)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValid);
|
||||
*aValid = false;
|
||||
|
||||
if (static_cast<Accessible*>(this)->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aValid = static_cast<Accessible*>(this)->IsLinkValid();
|
||||
return NS_OK;
|
||||
}
|
38
accessible/xpcom/xpcAccessibleHyperLink.h
Normal file
38
accessible/xpcom/xpcAccessibleHyperLink.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* -*- 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_xpcAccessibleHyperLink_h_
|
||||
#define mozilla_a11y_xpcAccessibleHyperLink_h_
|
||||
|
||||
#include "nsIAccessibleHyperLink.h"
|
||||
|
||||
class nsIAccessible;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class xpcAccessibleHyperLink : public nsIAccessibleHyperLink
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD GetAnchorCount(int32_t* aAnchorCount) MOZ_FINAL;
|
||||
NS_IMETHOD GetStartIndex(int32_t* aStartIndex) MOZ_FINAL;
|
||||
NS_IMETHOD GetEndIndex(int32_t* aEndIndex) MOZ_FINAL;
|
||||
NS_IMETHOD GetURI(int32_t aIndex, nsIURI** aURI) MOZ_FINAL;
|
||||
NS_IMETHOD GetAnchor(int32_t aIndex, nsIAccessible** aAccessible) MOZ_FINAL;
|
||||
NS_IMETHOD GetValid(bool* aValid) MOZ_FINAL;
|
||||
|
||||
private:
|
||||
xpcAccessibleHyperLink() { }
|
||||
friend class Accessible;
|
||||
|
||||
xpcAccessibleHyperLink(const xpcAccessibleHyperLink&) MOZ_DELETE;
|
||||
xpcAccessibleHyperLink& operator =(const xpcAccessibleHyperLink&) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
@ -24,8 +24,8 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
|
@ -22,9 +22,9 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual Accessible* ContainerWidget() const;
|
||||
@ -40,8 +40,8 @@ public:
|
||||
XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
|
@ -120,53 +120,40 @@ XULComboboxAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULComboboxAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != XULComboboxAccessible::eAction_Click) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aIndex != XULComboboxAccessible::eAction_Click)
|
||||
return false;
|
||||
|
||||
// Programmaticaly toggle the combo box.
|
||||
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
|
||||
if (!menuList) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bool isDroppedDown;
|
||||
if (!menuList)
|
||||
return false;
|
||||
|
||||
bool isDroppedDown = false;
|
||||
menuList->GetOpen(&isDroppedDown);
|
||||
return menuList->SetOpen(!isDroppedDown);
|
||||
menuList->SetOpen(!isDroppedDown);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULComboboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULComboboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex != XULComboboxAccessible::eAction_Click) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Our action name is the reverse of our state:
|
||||
// if we are close -> open is our name.
|
||||
// if we are open -> close is our name.
|
||||
// Uses the frame to get the state, updated on every click.
|
||||
aName.Truncate();
|
||||
if (aIndex != XULComboboxAccessible::eAction_Click)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
|
||||
if (!menuList) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bool isDroppedDown;
|
||||
if (!menuList)
|
||||
return;
|
||||
|
||||
bool isDroppedDown = false;
|
||||
menuList->GetOpen(&isDroppedDown);
|
||||
if (isDroppedDown)
|
||||
aName.AssignLiteral("close");
|
||||
aName.AssignLiteral("close");
|
||||
else
|
||||
aName.AssignLiteral("open");
|
||||
|
||||
return NS_OK;
|
||||
aName.AssignLiteral("open");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -21,19 +21,17 @@ public:
|
||||
|
||||
XULComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
// Accessible
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState();
|
||||
virtual bool CanHaveAnonChildren();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsActiveWidget() const;
|
||||
|
@ -233,29 +233,23 @@ XULLinkAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULLinkAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULLinkAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
aName.AssignLiteral("jump");
|
||||
return NS_OK;
|
||||
if (aIndex == eAction_Jump)
|
||||
aName.AssignLiteral("jump");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULLinkAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Jump)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -24,8 +24,8 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
void UpdateLabelValue(const nsString& aValue);
|
||||
@ -75,8 +75,8 @@ public:
|
||||
XULTooltipAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
class XULLinkAccessible : public XULLabelAccessible
|
||||
@ -87,17 +87,15 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeLinkState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// HyperLinkAccessible
|
||||
virtual bool IsLink();
|
||||
|
@ -65,24 +65,21 @@ XULButtonAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
aName.AssignLiteral("press");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("press");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULButtonAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -196,7 +193,7 @@ XULButtonAccessible::IsAcceptableChild(Accessible* aPossibleChild) const
|
||||
// XULButtonAccessible protected
|
||||
|
||||
bool
|
||||
XULButtonAccessible::ContainsMenu()
|
||||
XULButtonAccessible::ContainsMenu() const
|
||||
{
|
||||
static nsIContent::AttrValuesArray strings[] =
|
||||
{&nsGkAtoms::menu, &nsGkAtoms::menuButton, nullptr};
|
||||
@ -223,7 +220,7 @@ XULDropmarkerAccessible::ActionCount()
|
||||
}
|
||||
|
||||
bool
|
||||
XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen)
|
||||
XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen) const
|
||||
{
|
||||
bool isOpen = false;
|
||||
|
||||
@ -248,34 +245,26 @@ XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen)
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of our only action
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
XULDropmarkerAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULDropmarkerAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
if (aIndex == eAction_Click) {
|
||||
if (DropmarkerOpen(false))
|
||||
aName.AssignLiteral("close");
|
||||
else
|
||||
aName.AssignLiteral("open");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the Dropmarker to do its action
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULDropmarkerAccessible::DoAction(uint8_t index)
|
||||
{
|
||||
if (index == eAction_Click) {
|
||||
DropmarkerOpen(true); // Reverse the open attribute
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
}
|
||||
|
||||
role
|
||||
@ -312,36 +301,25 @@ XULCheckboxAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of our only action
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
XULCheckboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
// check or uncheck
|
||||
|
||||
if (NativeState() & states::CHECKED)
|
||||
aName.AssignLiteral("uncheck");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the checkbox to do its only action -- check( or uncheck) itself
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULCheckboxAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -35,16 +35,14 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -58,7 +56,7 @@ protected:
|
||||
virtual ~XULButtonAccessible();
|
||||
|
||||
// XULButtonAccessible
|
||||
bool ContainsMenu();
|
||||
bool ContainsMenu() const;
|
||||
};
|
||||
|
||||
|
||||
@ -71,16 +69,14 @@ public:
|
||||
enum { eAction_Click = 0 };
|
||||
XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -92,19 +88,17 @@ public:
|
||||
enum { eAction_Click = 0 };
|
||||
XULDropmarkerAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
bool DropmarkerOpen(bool aToggleOpen);
|
||||
bool DropmarkerOpen(bool aToggleOpen) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -116,7 +110,7 @@ public:
|
||||
XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
@ -134,8 +128,8 @@ public:
|
||||
XULRadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual Accessible* ContainerWidget() const;
|
||||
@ -150,8 +144,8 @@ public:
|
||||
XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -168,7 +162,7 @@ public:
|
||||
XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -196,7 +190,7 @@ public:
|
||||
XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Accessible
|
||||
@ -213,8 +207,8 @@ public:
|
||||
DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -76,24 +76,21 @@ XULColumnItemAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULColumnItemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULColumnItemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
aName.AssignLiteral("click");
|
||||
return NS_OK;
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("click");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULColumnItemAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -593,7 +590,7 @@ XULListitemAccessible::~XULListitemAccessible()
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
|
||||
|
||||
Accessible*
|
||||
XULListitemAccessible::GetListAccessible()
|
||||
XULListitemAccessible::GetListAccessible() const
|
||||
{
|
||||
if (IsDefunct())
|
||||
return nullptr;
|
||||
@ -696,21 +693,16 @@ XULListitemAccessible::NativeInteractiveState() const
|
||||
states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULListitemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULListitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click && mIsCheckbox) {
|
||||
// check or uncheck
|
||||
uint64_t states = NativeState();
|
||||
|
||||
if (states & states::CHECKED)
|
||||
aName.AssignLiteral("uncheck");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -43,16 +43,14 @@ class XULColumnItemAccessible : public LeafAccessible
|
||||
public:
|
||||
XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
enum { eAction_Click = 0 };
|
||||
};
|
||||
@ -95,8 +93,8 @@ public:
|
||||
virtual void Shutdown();
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual TableAccessible* AsTable() { return this; }
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -123,17 +121,16 @@ public:
|
||||
|
||||
XULListitemAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t index, nsAString& aName);
|
||||
// Don't use XUL menuitems's description attribute
|
||||
|
||||
// Accessible
|
||||
virtual void Description(nsString& aDesc);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual bool CanHaveAnonChildren();
|
||||
|
||||
// Actions
|
||||
virtual void ActionNameAt(uint8_t index, nsAString& aName) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual Accessible* ContainerWidget() const;
|
||||
|
||||
@ -148,7 +145,7 @@ protected:
|
||||
/**
|
||||
* Return listbox accessible for the listitem.
|
||||
*/
|
||||
Accessible* GetListAccessible();
|
||||
Accessible* GetListAccessible() const;
|
||||
|
||||
private:
|
||||
bool mIsCheckbox;
|
||||
@ -175,7 +172,7 @@ public:
|
||||
virtual TableCellAccessible* AsTableCell() { return this; }
|
||||
virtual void Shutdown();
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// TableCellAccessible
|
||||
virtual TableAccessible* Table() const MOZ_OVERRIDE;
|
||||
|
@ -274,26 +274,22 @@ XULMenuitemAccessible::CanHaveAnonChildren()
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULMenuitemAccessible::DoAction(uint8_t index)
|
||||
{
|
||||
if (index == eAction_Click) { // default action
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** select us! close combo box if necessary*/
|
||||
NS_IMETHODIMP
|
||||
XULMenuitemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULMenuitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Click) {
|
||||
aName.AssignLiteral("click");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Click)
|
||||
aName.AssignLiteral("click");
|
||||
}
|
||||
|
||||
uint8_t
|
||||
@ -383,16 +379,16 @@ XULMenuSeparatorAccessible::NativeRole()
|
||||
return roles::SEPARATOR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULMenuSeparatorAccessible::DoAction(uint8_t index)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULMenuSeparatorAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULMenuSeparatorAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aName.Truncate();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
|
@ -23,21 +23,19 @@ public:
|
||||
|
||||
XULMenuitemAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
// Accessible
|
||||
virtual void Description(nsString& aDescription);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual int32_t GetLevelInternal();
|
||||
|
||||
virtual bool CanHaveAnonChildren();
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
virtual KeyBinding AccessKey() const;
|
||||
virtual KeyBinding KeyboardShortcut() const;
|
||||
|
||||
@ -59,16 +57,14 @@ class XULMenuSeparatorAccessible : public XULMenuitemAccessible
|
||||
public:
|
||||
XULMenuSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Accessible
|
||||
@ -85,8 +81,8 @@ public:
|
||||
XULMenupopupAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
@ -109,7 +105,7 @@ public:
|
||||
XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// Widget
|
||||
virtual bool IsActiveWidget() const;
|
||||
|
@ -71,27 +71,25 @@ XULSliderAccessible::ActionCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULSliderAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
NS_ENSURE_ARG(aIndex == 0);
|
||||
|
||||
aName.AssignLiteral("activate");
|
||||
return NS_OK;
|
||||
if (aIndex == 0)
|
||||
aName.AssignLiteral("activate");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULSliderAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
NS_ENSURE_ARG(aIndex == 0);
|
||||
if (aIndex != 0)
|
||||
return false;
|
||||
|
||||
nsIContent* sliderElm = GetSliderElement();
|
||||
if (sliderElm)
|
||||
DoCommand(sliderElm);
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -21,14 +21,10 @@ class XULSliderAccessible : public AccessibleWrap
|
||||
public:
|
||||
XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual bool NativelyUnavailable() const;
|
||||
virtual bool CanHaveAnonChildren();
|
||||
|
||||
@ -40,7 +36,9 @@ public:
|
||||
virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -68,7 +66,7 @@ public:
|
||||
XULThumbAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -39,30 +39,24 @@ XULTabAccessible::ActionCount()
|
||||
}
|
||||
|
||||
/** Return the name of our only action */
|
||||
NS_IMETHODIMP
|
||||
XULTabAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULTabAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (aIndex == eAction_Switch) {
|
||||
aName.AssignLiteral("switch");
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (aIndex == eAction_Switch)
|
||||
aName.AssignLiteral("switch");
|
||||
}
|
||||
|
||||
/** Tell the tab to do its action */
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULTabAccessible::DoAction(uint8_t index)
|
||||
{
|
||||
if (index == eAction_Switch) {
|
||||
nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mContent));
|
||||
if ( tab )
|
||||
{
|
||||
if (tab) {
|
||||
tab->Click();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -23,18 +23,16 @@ public:
|
||||
|
||||
XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t index);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
@ -48,10 +46,10 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Accessible
|
||||
@ -70,7 +68,7 @@ public:
|
||||
{ mType = eXULTabpanelsType; }
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
@ -87,7 +85,7 @@ public:
|
||||
XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
@ -733,34 +733,23 @@ XULTreeItemAccessibleBase::FocusedChild()
|
||||
return FocusMgr()->FocusedAccessible() == this ? this : nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULTreeItemAccessibleBase::GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight)
|
||||
nsIntRect
|
||||
XULTreeItemAccessibleBase::Bounds() const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aX);
|
||||
*aX = 0;
|
||||
NS_ENSURE_ARG_POINTER(aY);
|
||||
*aY = 0;
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
*aWidth = 0;
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
*aHeight = 0;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get x coordinate and width from treechildren element, get y coordinate and
|
||||
// height from tree cell.
|
||||
|
||||
nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
|
||||
NS_ENSURE_STATE(boxObj);
|
||||
if (!boxObj)
|
||||
return nsIntRect();
|
||||
|
||||
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
|
||||
|
||||
int32_t x = 0, y = 0, width = 0, height = 0;
|
||||
nsresult rv = mTree->GetCoordsForCellItem(mRow, column, EmptyCString(),
|
||||
&x, &y, &width, &height);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsIntRect();
|
||||
|
||||
boxObj->GetWidth(&width);
|
||||
|
||||
@ -772,45 +761,35 @@ XULTreeItemAccessibleBase::GetBounds(int32_t* aX, int32_t* aY,
|
||||
y += tcY;
|
||||
|
||||
nsPresContext* presContext = mDoc->PresContext();
|
||||
*aX = presContext->CSSPixelsToDevPixels(x);
|
||||
*aY = presContext->CSSPixelsToDevPixels(y);
|
||||
*aWidth = presContext->CSSPixelsToDevPixels(width);
|
||||
*aHeight = presContext->CSSPixelsToDevPixels(height);
|
||||
|
||||
return NS_OK;
|
||||
return nsIntRect(presContext->CSSPixelsToDevPixels(x),
|
||||
presContext->CSSPixelsToDevPixels(y),
|
||||
presContext->CSSPixelsToDevPixels(width),
|
||||
presContext->CSSPixelsToDevPixels(height));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
XULTreeItemAccessibleBase::SetSelected(bool aSelect)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsITreeSelection> selection;
|
||||
mTreeView->GetSelection(getter_AddRefs(selection));
|
||||
if (selection) {
|
||||
bool isSelected;
|
||||
bool isSelected = false;
|
||||
selection->IsSelected(mRow, &isSelected);
|
||||
if (isSelected != aSelect)
|
||||
selection->ToggleSelect(mRow);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
XULTreeItemAccessibleBase::TakeFocus()
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsITreeSelection> selection;
|
||||
mTreeView->GetSelection(getter_AddRefs(selection));
|
||||
if (selection)
|
||||
selection->SetCurrentIndex(mRow);
|
||||
|
||||
// focus event will be fired here
|
||||
return Accessible::TakeFocus();
|
||||
Accessible::TakeFocus();
|
||||
}
|
||||
|
||||
Relation
|
||||
@ -855,43 +834,33 @@ XULTreeItemAccessibleBase::ActionCount()
|
||||
return IsExpandable() ? 2 : 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULTreeItemAccessibleBase::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULTreeItemAccessibleBase::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex == eAction_Click) {
|
||||
aName.AssignLiteral("activate");
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (aIndex == eAction_Expand && IsExpandable()) {
|
||||
bool isContainerOpen;
|
||||
bool isContainerOpen = false;
|
||||
mTreeView->IsContainerOpen(mRow, &isContainerOpen);
|
||||
if (isContainerOpen)
|
||||
aName.AssignLiteral("collapse");
|
||||
else
|
||||
aName.AssignLiteral("expand");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULTreeItemAccessibleBase::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aIndex != eAction_Click &&
|
||||
(aIndex != eAction_Expand || !IsExpandable()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
|
||||
DoCommand(nullptr, aIndex);
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -41,8 +41,8 @@ public:
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
||||
EWhichChildAtPoint aWhichChild);
|
||||
|
||||
@ -146,27 +146,22 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessibleBase,
|
||||
AccessibleWrap)
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetBounds(int32_t *aX, int32_t *aY,
|
||||
int32_t *aWidth, int32_t *aHeight);
|
||||
|
||||
NS_IMETHOD SetSelected(bool aSelect);
|
||||
NS_IMETHOD TakeFocus();
|
||||
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual GroupPos GroupPosition();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual int32_t IndexInParent() const;
|
||||
virtual void Shutdown() MOZ_OVERRIDE;
|
||||
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
|
||||
virtual GroupPos GroupPosition() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
virtual int32_t IndexInParent() const MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
virtual Accessible* FocusedChild();
|
||||
virtual Accessible* FocusedChild() MOZ_OVERRIDE;
|
||||
virtual void SetSelected(bool aSelect) MOZ_OVERRIDE;
|
||||
virtual void TakeFocus() MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual Accessible* ContainerWidget() const;
|
||||
@ -240,7 +235,7 @@ public:
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
// XULTreeItemAccessibleBase
|
||||
virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
|
||||
|
@ -146,13 +146,11 @@ XULTreeGridAccessible::ColDescription(uint32_t aColIdx, nsString& aDescription)
|
||||
{
|
||||
aDescription.Truncate();
|
||||
|
||||
nsCOMPtr<nsIAccessible> treeColumns;
|
||||
Accessible::GetFirstChild(getter_AddRefs(treeColumns));
|
||||
Accessible* treeColumns = Accessible::GetChildAt(0);
|
||||
if (treeColumns) {
|
||||
nsCOMPtr<nsIAccessible> treeColumnItem;
|
||||
treeColumns->GetChildAt(aColIdx, getter_AddRefs(treeColumnItem));
|
||||
Accessible* treeColumnItem = treeColumns->GetChildAt(aColIdx);
|
||||
if (treeColumnItem)
|
||||
treeColumnItem->GetName(aDescription);
|
||||
treeColumnItem->Name(aDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,32 +511,21 @@ XULTreeGridCellAccessible::Name(nsString& aName)
|
||||
return eNameOK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULTreeGridCellAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight)
|
||||
nsIntRect
|
||||
XULTreeGridCellAccessible::Bounds() const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aX);
|
||||
*aX = 0;
|
||||
NS_ENSURE_ARG_POINTER(aY);
|
||||
*aY = 0;
|
||||
NS_ENSURE_ARG_POINTER(aWidth);
|
||||
*aWidth = 0;
|
||||
NS_ENSURE_ARG_POINTER(aHeight);
|
||||
*aHeight = 0;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get bounds for tree cell and add x and y of treechildren element to
|
||||
// x and y of the cell.
|
||||
nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
|
||||
NS_ENSURE_STATE(boxObj);
|
||||
if (!boxObj)
|
||||
return nsIntRect();
|
||||
|
||||
int32_t x = 0, y = 0, width = 0, height = 0;
|
||||
nsresult rv = mTree->GetCoordsForCellItem(mRow, mColumn,
|
||||
NS_LITERAL_CSTRING("cell"),
|
||||
&x, &y, &width, &height);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsIntRect();
|
||||
|
||||
int32_t tcX = 0, tcY = 0;
|
||||
boxObj->GetScreenX(&tcX);
|
||||
@ -547,12 +534,10 @@ XULTreeGridCellAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
y += tcY;
|
||||
|
||||
nsPresContext* presContext = mDoc->PresContext();
|
||||
*aX = presContext->CSSPixelsToDevPixels(x);
|
||||
*aY = presContext->CSSPixelsToDevPixels(y);
|
||||
*aWidth = presContext->CSSPixelsToDevPixels(width);
|
||||
*aHeight = presContext->CSSPixelsToDevPixels(height);
|
||||
|
||||
return NS_OK;
|
||||
return nsIntRect(presContext->CSSPixelsToDevPixels(x),
|
||||
presContext->CSSPixelsToDevPixels(y),
|
||||
presContext->CSSPixelsToDevPixels(width),
|
||||
presContext->CSSPixelsToDevPixels(height));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
@ -571,25 +556,22 @@ XULTreeGridCellAccessible::ActionCount()
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULTreeGridCellAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
void
|
||||
XULTreeGridCellAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct() || !mTreeView)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aIndex != eAction_Click || !mTreeView)
|
||||
return;
|
||||
|
||||
bool isCycler = false;
|
||||
mColumn->GetCycler(&isCycler);
|
||||
if (isCycler) {
|
||||
aName.AssignLiteral("cycle");
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t type;
|
||||
int16_t type = 0;
|
||||
mColumn->GetType(&type);
|
||||
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
|
||||
nsAutoString value;
|
||||
@ -598,37 +580,30 @@ XULTreeGridCellAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
||||
aName.AssignLiteral("uncheck");
|
||||
else
|
||||
aName.AssignLiteral("check");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bool
|
||||
XULTreeGridCellAccessible::DoAction(uint8_t aIndex)
|
||||
{
|
||||
if (aIndex != eAction_Click)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
bool isCycler = false;
|
||||
mColumn->GetCycler(&isCycler);
|
||||
if (isCycler) {
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t type;
|
||||
mColumn->GetType(&type);
|
||||
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
|
||||
DoCommand();
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual TableAccessible* AsTable() { return this; }
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~XULTreeGridAccessible();
|
||||
@ -88,7 +88,7 @@ public:
|
||||
|
||||
// Accessible
|
||||
virtual void Shutdown();
|
||||
virtual a11y::role NativeRole();
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
||||
EWhichChildAtPoint aWhichChild);
|
||||
@ -141,31 +141,26 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible,
|
||||
LeafAccessible)
|
||||
|
||||
// nsIAccessible
|
||||
|
||||
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight);
|
||||
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// nsIAccessibleTableCell
|
||||
NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
|
||||
|
||||
// Accessible
|
||||
virtual TableCellAccessible* AsTableCell() { return this; }
|
||||
virtual void Shutdown();
|
||||
virtual nsIntRect Bounds() const MOZ_OVERRIDE;
|
||||
virtual ENameValueFlag Name(nsString& aName);
|
||||
virtual Accessible* FocusedChild();
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual int32_t IndexInParent() const;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
virtual uint64_t NativeInteractiveState() const;
|
||||
virtual a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeState() MOZ_OVERRIDE;
|
||||
virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
virtual uint8_t ActionCount() MOZ_OVERRIDE;
|
||||
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
|
||||
virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
|
||||
|
||||
// TableCellAccessible
|
||||
virtual TableAccessible* Table() const MOZ_OVERRIDE;
|
||||
|
@ -1288,11 +1288,11 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
|
||||
|
||||
nsresult nsScriptSecurityManager::Init()
|
||||
{
|
||||
InitPrefs();
|
||||
|
||||
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
InitPrefs();
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
mozilla::services::GetStringBundleService();
|
||||
if (!bundleService)
|
||||
|
@ -9137,7 +9137,7 @@ fi
|
||||
|
||||
if test -n "$MOZ_USING_CCACHE"; then
|
||||
# Avoid double prepending ccache by omitting --with-ccache in building NSPR.
|
||||
_SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--with-ccache[^ ]*//'`"
|
||||
_SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--with-ccache[[^ ]]*//'`"
|
||||
fi
|
||||
|
||||
MOZ_SUBCONFIGURE_NSPR()
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "nsLineBreaker.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "gfxFont.h" // for the gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_* values
|
||||
#include "gfxTextRun.h" // for the gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_* values
|
||||
#include "nsHyphenationManager.h"
|
||||
#include "nsHyphenator.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
@ -6,8 +6,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "CubebUtils.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "prdtoa.h"
|
||||
|
||||
#define PREF_VOLUME_SCALE "media.volume_scale"
|
||||
@ -15,18 +18,28 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace {
|
||||
|
||||
// Prefered samplerate, in Hz (characteristic of the
|
||||
// hardware/mixer/platform/API used).
|
||||
Atomic<uint32_t> sPreferredSampleRate;
|
||||
|
||||
// This mutex protects the variables below.
|
||||
StaticMutex sMutex;
|
||||
cubeb* sCubebContext;
|
||||
double sVolumeScale;
|
||||
uint32_t sCubebLatency;
|
||||
bool sCubebLatencyPrefSet;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
extern PRLogModuleInfo* gAudioStreamLog;
|
||||
|
||||
static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
|
||||
|
||||
StaticMutex CubebUtils::sMutex;
|
||||
cubeb* CubebUtils::sCubebContext;
|
||||
uint32_t CubebUtils::sPreferredSampleRate;
|
||||
double CubebUtils::sVolumeScale;
|
||||
uint32_t CubebUtils::sCubebLatency;
|
||||
bool CubebUtils::sCubebLatencyPrefSet;
|
||||
namespace CubebUtils {
|
||||
|
||||
/*static*/ void CubebUtils::PrefChanged(const char* aPref, void* aClosure)
|
||||
void PrefChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
|
||||
nsAdoptingString value = Preferences::GetString(aPref);
|
||||
@ -48,7 +61,7 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ bool CubebUtils::GetFirstStream()
|
||||
bool GetFirstStream()
|
||||
{
|
||||
static bool sFirstStream = true;
|
||||
|
||||
@ -58,29 +71,36 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*static*/ double CubebUtils::GetVolumeScale()
|
||||
double GetVolumeScale()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sVolumeScale;
|
||||
}
|
||||
|
||||
/*static*/ cubeb* CubebUtils::GetCubebContext()
|
||||
cubeb* GetCubebContext()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return GetCubebContextUnlocked();
|
||||
}
|
||||
|
||||
/*static*/ void CubebUtils::InitPreferredSampleRate()
|
||||
void InitPreferredSampleRate()
|
||||
{
|
||||
// The mutex is used here to prohibit concurrent initialization calls, but
|
||||
// sPreferredSampleRate itself is safe to access without the mutex because
|
||||
// it is using atomic storage.
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
uint32_t preferredSampleRate = 0;
|
||||
if (sPreferredSampleRate == 0 &&
|
||||
cubeb_get_preferred_sample_rate(GetCubebContextUnlocked(),
|
||||
&sPreferredSampleRate) != CUBEB_OK) {
|
||||
&preferredSampleRate) == CUBEB_OK) {
|
||||
sPreferredSampleRate = preferredSampleRate;
|
||||
} else {
|
||||
// Query failed, use a sensible default.
|
||||
sPreferredSampleRate = 44100;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ cubeb* CubebUtils::GetCubebContextUnlocked()
|
||||
cubeb* GetCubebContextUnlocked()
|
||||
{
|
||||
sMutex.AssertCurrentThreadOwns();
|
||||
if (sCubebContext ||
|
||||
@ -91,19 +111,19 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*static*/ uint32_t CubebUtils::GetCubebLatency()
|
||||
uint32_t GetCubebLatency()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sCubebLatency;
|
||||
}
|
||||
|
||||
/*static*/ bool CubebUtils::CubebLatencyPrefSet()
|
||||
bool CubebLatencyPrefSet()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sCubebLatencyPrefSet;
|
||||
}
|
||||
|
||||
/*static*/ void CubebUtils::InitLibrary()
|
||||
void InitLibrary()
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
gAudioStreamLog = PR_NewLogModule("AudioStream");
|
||||
@ -114,7 +134,7 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
Preferences::RegisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
|
||||
}
|
||||
|
||||
/*static*/ void CubebUtils::ShutdownLibrary()
|
||||
void ShutdownLibrary()
|
||||
{
|
||||
Preferences::UnregisterCallback(PrefChanged, PREF_VOLUME_SCALE);
|
||||
Preferences::UnregisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
|
||||
@ -126,20 +146,20 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ int CubebUtils::MaxNumberOfChannels()
|
||||
uint32_t MaxNumberOfChannels()
|
||||
{
|
||||
cubeb* cubebContext = CubebUtils::GetCubebContext();
|
||||
cubeb* cubebContext = GetCubebContext();
|
||||
uint32_t maxNumberOfChannels;
|
||||
if (cubebContext &&
|
||||
cubeb_get_max_channel_count(cubebContext,
|
||||
&maxNumberOfChannels) == CUBEB_OK) {
|
||||
return static_cast<int>(maxNumberOfChannels);
|
||||
return maxNumberOfChannels;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*static*/ int CubebUtils::PreferredSampleRate()
|
||||
uint32_t PreferredSampleRate()
|
||||
{
|
||||
MOZ_ASSERT(sPreferredSampleRate,
|
||||
"sPreferredSampleRate has not been initialized!");
|
||||
@ -147,7 +167,7 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__) && defined(MOZ_B2G)
|
||||
/*static*/ cubeb_stream_type CubebUtils::ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
{
|
||||
switch(aChannel) {
|
||||
case dom::AudioChannel::Normal:
|
||||
@ -171,4 +191,5 @@ bool CubebUtils::sCubebLatencyPrefSet;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace CubebUtils
|
||||
} // namespace mozilla
|
||||
|
@ -8,65 +8,42 @@
|
||||
#define CubebUtils_h_
|
||||
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
|
||||
{
|
||||
public:
|
||||
static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace CubebUtils {
|
||||
|
||||
class CubebUtils {
|
||||
public:
|
||||
// Initialize Audio Library. Some Audio backends require initializing the
|
||||
// library before using it.
|
||||
static void InitLibrary();
|
||||
// Initialize Audio Library. Some Audio backends require initializing the
|
||||
// library before using it.
|
||||
void InitLibrary();
|
||||
|
||||
// Shutdown Audio Library. Some Audio backends require shutting down the
|
||||
// library after using it.
|
||||
static void ShutdownLibrary();
|
||||
// Shutdown Audio Library. Some Audio backends require shutting down the
|
||||
// library after using it.
|
||||
void ShutdownLibrary();
|
||||
|
||||
// Returns the maximum number of channels supported by the audio hardware.
|
||||
static int MaxNumberOfChannels();
|
||||
// Returns the maximum number of channels supported by the audio hardware.
|
||||
uint32_t MaxNumberOfChannels();
|
||||
|
||||
// Queries the samplerate the hardware/mixer runs at, and stores it.
|
||||
// Can be called on any thread. When this returns, it is safe to call
|
||||
// PreferredSampleRate without locking.
|
||||
static void InitPreferredSampleRate();
|
||||
// Get the aformentionned sample rate. Does not lock.
|
||||
static int PreferredSampleRate();
|
||||
// Queries the samplerate the hardware/mixer runs at, and stores it.
|
||||
// Can be called on any thread. When this returns, it is safe to call
|
||||
// PreferredSampleRate.
|
||||
void InitPreferredSampleRate();
|
||||
|
||||
static void PrefChanged(const char* aPref, void* aClosure);
|
||||
static double GetVolumeScale();
|
||||
static bool GetFirstStream();
|
||||
static cubeb* GetCubebContext();
|
||||
static cubeb* GetCubebContextUnlocked();
|
||||
static uint32_t GetCubebLatency();
|
||||
static bool CubebLatencyPrefSet();
|
||||
// Get the aforementioned sample rate. Thread safe.
|
||||
uint32_t PreferredSampleRate();
|
||||
|
||||
void PrefChanged(const char* aPref, void* aClosure);
|
||||
double GetVolumeScale();
|
||||
bool GetFirstStream();
|
||||
cubeb* GetCubebContext();
|
||||
cubeb* GetCubebContextUnlocked();
|
||||
uint32_t GetCubebLatency();
|
||||
bool CubebLatencyPrefSet();
|
||||
#if defined(__ANDROID__) && defined(MOZ_B2G)
|
||||
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
||||
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
// This mutex protects the static members below.
|
||||
static StaticMutex sMutex;
|
||||
static cubeb* sCubebContext;
|
||||
|
||||
// Prefered samplerate, in Hz (characteristic of the
|
||||
// hardware/mixer/platform/API used).
|
||||
static uint32_t sPreferredSampleRate;
|
||||
|
||||
static double sVolumeScale;
|
||||
static uint32_t sCubebLatency;
|
||||
static bool sCubebLatencyPrefSet;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
} // namespace CubebUtils
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // CubebUtils_h_
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "DecoderTraits.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#ifdef MOZ_ANDROID_OMX
|
||||
@ -219,6 +220,7 @@ static const char* const gOmxTypes[] = {
|
||||
"audio/mpeg",
|
||||
"audio/mp4",
|
||||
"audio/amr",
|
||||
"audio/3gpp",
|
||||
"video/mp4",
|
||||
"video/3gpp",
|
||||
"video/3gpp2",
|
||||
@ -542,7 +544,7 @@ InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner)
|
||||
if (IsOmxSupportedType(aType)) {
|
||||
// AMR audio is enabled for MMS, but we are discouraging Web and App
|
||||
// developers from using AMR, thus we only allow AMR to be played on WebApps.
|
||||
if (aType.EqualsASCII("audio/amr")) {
|
||||
if (aType.EqualsLiteral(AUDIO_AMR) || aType.EqualsLiteral(AUDIO_3GPP)) {
|
||||
dom::HTMLMediaElement* element = aOwner->GetMediaElement();
|
||||
if (!element) {
|
||||
return nullptr;
|
||||
@ -715,7 +717,8 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType)
|
||||
#ifdef MOZ_OMX_DECODER
|
||||
// We support amr inside WebApps on firefoxOS but not in general web content.
|
||||
// Ensure we dont create a VideoDocument when accessing amr URLs directly.
|
||||
(IsOmxSupportedType(aType) && !aType.EqualsASCII("audio/amr")) ||
|
||||
(IsOmxSupportedType(aType) &&
|
||||
(!aType.EqualsLiteral(AUDIO_AMR) && !aType.EqualsLiteral(AUDIO_3GPP))) ||
|
||||
#endif
|
||||
#ifdef MOZ_WEBM
|
||||
IsWebMType(aType) ||
|
||||
|
@ -14,8 +14,14 @@
|
||||
|
||||
struct cubeb_stream;
|
||||
|
||||
namespace mozilla {
|
||||
template <>
|
||||
class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
|
||||
{
|
||||
public:
|
||||
static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Assume we can run an iteration of the MediaStreamGraph loop in this much time
|
||||
|
@ -132,7 +132,11 @@ public:
|
||||
|
||||
// Returns true if the parser needs more data for duration estimation.
|
||||
bool NeedsData();
|
||||
|
||||
// Assign the total lenght of this mp3 stream
|
||||
void SetLength(int64_t aLength) {
|
||||
MutexAutoLock mon(mLock);
|
||||
mLength = aLength;
|
||||
}
|
||||
private:
|
||||
|
||||
// Parses aBuffer, starting at offset 0. Returns the number of bytes
|
||||
|
@ -1911,6 +1911,11 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
|
||||
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
|
||||
DECODER_LOG("Decoding Media Headers");
|
||||
|
||||
if (mReader->IsWaitingMediaResources()) {
|
||||
StartWaitForResources();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult res;
|
||||
MediaInfo info;
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ MFTDecoder::SetDecoderOutputType()
|
||||
}
|
||||
|
||||
HRESULT
|
||||
MFTDecoder::SendMFTMessage(MFT_MESSAGE_TYPE aMsg, UINT32 aData)
|
||||
MFTDecoder::SendMFTMessage(MFT_MESSAGE_TYPE aMsg, ULONG_PTR aData)
|
||||
{
|
||||
NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
|
||||
HRESULT hr = mDecoder->ProcessMessage(aMsg, aData);
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
HRESULT Flush();
|
||||
|
||||
// Sends a message to the MFT.
|
||||
HRESULT SendMFTMessage(MFT_MESSAGE_TYPE aMsg, UINT32 aData);
|
||||
HRESULT SendMFTMessage(MFT_MESSAGE_TYPE aMsg, ULONG_PTR aData);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -257,7 +257,7 @@ GMPThreadImpl::Join()
|
||||
}
|
||||
|
||||
GMPMutexImpl::GMPMutexImpl()
|
||||
: mMutex("gmp-mutex")
|
||||
: mMonitor("gmp-mutex")
|
||||
{
|
||||
MOZ_COUNT_CTOR(GMPMutexImpl);
|
||||
}
|
||||
@ -276,13 +276,13 @@ GMPMutexImpl::Destroy()
|
||||
void
|
||||
GMPMutexImpl::Acquire()
|
||||
{
|
||||
mMutex.Lock();
|
||||
mMonitor.Enter();
|
||||
}
|
||||
|
||||
void
|
||||
GMPMutexImpl::Release()
|
||||
{
|
||||
mMutex.Unlock();
|
||||
mMonitor.Exit();
|
||||
}
|
||||
|
||||
} // namespace gmp
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "gmp-platform.h"
|
||||
#include "base/thread.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
@ -46,7 +47,7 @@ public:
|
||||
virtual void Destroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
Mutex mMutex;
|
||||
ReentrantMonitor mMonitor;
|
||||
};
|
||||
|
||||
} // namespace gmp
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
virtual void Join() = 0; // Deletes object after join completes.
|
||||
};
|
||||
|
||||
// A re-entrant monitor; can be locked from the same thread multiple times.
|
||||
// Must be unlocked the same number of times it's locked.
|
||||
class GMPMutex {
|
||||
public:
|
||||
virtual ~GMPMutex() {}
|
||||
|
@ -105,6 +105,10 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
// MediaSourceDecoder uses DurationChange to set the duration
|
||||
// without hitting the checks in SetDuration.
|
||||
friend class mozilla::MediaSourceDecoder;
|
||||
|
||||
~MediaSource();
|
||||
|
||||
explicit MediaSource(nsPIDOMWindow* aWindow);
|
||||
|
@ -76,6 +76,7 @@ MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable)
|
||||
if (!mMediaSource) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
double duration = mMediaSource->Duration();
|
||||
if (IsNaN(duration)) {
|
||||
// Return empty range.
|
||||
@ -169,7 +170,7 @@ MediaSourceDecoder::SetMediaSourceDuration(double aDuration)
|
||||
return;
|
||||
}
|
||||
ErrorResult dummy;
|
||||
mMediaSource->SetDuration(aDuration, dummy);
|
||||
mMediaSource->DurationChange(aDuration, dummy);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -470,14 +470,10 @@ MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
|
||||
nsresult
|
||||
MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
|
||||
{
|
||||
bool waiting = IsWaitingMediaResources();
|
||||
MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata waiting=%d tracks=%u/%u audio=%p video=%p",
|
||||
this, waiting, mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
|
||||
MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata tracks=%u/%u audio=%p video=%p",
|
||||
this, mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
|
||||
mAudioTrack.get(), mVideoTrack.get());
|
||||
// ReadMetadata is called *before* checking IsWaitingMediaResources.
|
||||
if (waiting) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mEssentialTrackBuffers.Clear();
|
||||
if (!mAudioTrack && !mVideoTrack) {
|
||||
MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata missing track: mAudioTrack=%p mVideoTrack=%p",
|
||||
|
@ -103,20 +103,19 @@ public:
|
||||
}
|
||||
|
||||
// Evict data in queue if the total queue size is greater than
|
||||
// aThreshold past the offset. Returns true if some data was
|
||||
// actually evicted.
|
||||
bool Evict(uint64_t aOffset, uint32_t aThreshold) {
|
||||
bool evicted = false;
|
||||
// aThreshold past the offset. Returns amount evicted.
|
||||
uint32_t Evict(uint64_t aOffset, uint32_t aThreshold) {
|
||||
uint32_t evicted = 0;
|
||||
while (GetLength() - mOffset > aThreshold) {
|
||||
ResourceItem* item = ResourceAt(0);
|
||||
if (item->mData.Length() + mOffset > aOffset) {
|
||||
break;
|
||||
}
|
||||
mOffset += item->mData.Length();
|
||||
evicted += item->mData.Length();
|
||||
SBR_DEBUGV("ResourceQueue(%p)::Evict(%llu, %u) removed chunk length=%u",
|
||||
this, aOffset, aThreshold, item->mData.Length());
|
||||
delete PopFront();
|
||||
evicted = true;
|
||||
}
|
||||
return evicted;
|
||||
}
|
||||
|
@ -514,6 +514,8 @@ SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aMediaSource);
|
||||
mEvictionThreshold = Preferences::GetUint("media.mediasource.eviction_threshold",
|
||||
75 * (1 << 20));
|
||||
mParser = ContainerParser::CreateForMIMEType(aType);
|
||||
mTrackBuffer = new TrackBuffer(aMediaSource->GetDecoder(), aType);
|
||||
MSE_DEBUG("SourceBuffer(%p)::SourceBuffer: Create mParser=%p mTrackBuffer=%p",
|
||||
@ -659,8 +661,8 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
|
||||
// about.
|
||||
// TODO: Make the eviction threshold smaller for audio-only streams.
|
||||
// TODO: Drive evictions off memory pressure notifications.
|
||||
const uint32_t evict_threshold = 75 * (1 << 20);
|
||||
bool evicted = mTrackBuffer->EvictData(evict_threshold);
|
||||
// TODO: Consider a global eviction threshold rather than per TrackBuffer.
|
||||
bool evicted = mTrackBuffer->EvictData(mEvictionThreshold);
|
||||
if (evicted) {
|
||||
MSE_DEBUG("SourceBuffer(%p)::AppendData Evict; current buffered start=%f",
|
||||
this, GetBufferedStart());
|
||||
|
@ -139,6 +139,8 @@ private:
|
||||
|
||||
const nsCString mType;
|
||||
|
||||
uint32_t mEvictionThreshold;
|
||||
|
||||
nsAutoPtr<ContainerParser> mParser;
|
||||
|
||||
nsRefPtr<TrackBuffer> mTrackBuffer;
|
||||
|
@ -147,7 +147,7 @@ SourceBufferResource::ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCo
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
uint32_t
|
||||
SourceBufferResource::EvictData(uint32_t aThreshold)
|
||||
{
|
||||
SBR_DEBUG("SourceBufferResource(%p)::EvictData(aThreshold=%u)", this, aThreshold);
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { UNIMPLEMENTED(); *aIsReliable = false; return 0; }
|
||||
virtual int64_t GetLength() MOZ_OVERRIDE { return mInputBuffer.GetLength(); }
|
||||
virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE {
|
||||
ReentrantMonitorAutoEnter mon(mMonitor);
|
||||
MOZ_ASSERT(aOffset >= 0);
|
||||
if (uint64_t(aOffset) < mInputBuffer.GetOffset()) {
|
||||
return mInputBuffer.GetOffset();
|
||||
@ -83,6 +84,7 @@ public:
|
||||
|
||||
virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mMonitor);
|
||||
if (mInputBuffer.GetLength()) {
|
||||
aRanges.AppendElement(MediaByteRange(mInputBuffer.GetOffset(),
|
||||
mInputBuffer.GetLength()));
|
||||
@ -114,12 +116,18 @@ public:
|
||||
void AppendData(const uint8_t* aData, uint32_t aLength);
|
||||
void Ended();
|
||||
// Remove data from resource if it holds more than the threshold
|
||||
// number of bytes. Returns true if some data was evicted.
|
||||
bool EvictData(uint32_t aThreshold);
|
||||
// number of bytes. Returns amount evicted.
|
||||
uint32_t EvictData(uint32_t aThreshold);
|
||||
|
||||
// Remove data from resource before the given offset.
|
||||
void EvictBefore(uint64_t aOffset);
|
||||
|
||||
// Returns the amount of data currently retained by this resource.
|
||||
int64_t GetSize() {
|
||||
ReentrantMonitorAutoEnter mon(mMonitor);
|
||||
return mInputBuffer.GetLength() - mInputBuffer.GetOffset();
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Dump(const char* aPath) {
|
||||
mInputBuffer.Dump(aPath);
|
||||
|
@ -124,20 +124,36 @@ bool
|
||||
TrackBuffer::EvictData(uint32_t aThreshold)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// XXX Call EvictData on mDecoders?
|
||||
return mCurrentDecoder->GetResource()->EvictData(aThreshold);
|
||||
|
||||
int64_t totalSize = 0;
|
||||
for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
|
||||
totalSize += mDecoders[i]->GetResource()->GetSize();
|
||||
}
|
||||
|
||||
int64_t toEvict = totalSize - aThreshold;
|
||||
if (toEvict <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
|
||||
MSE_DEBUG("TrackBuffer(%p)::EvictData decoder=%u threshold=%u toEvict=%lld",
|
||||
this, i, aThreshold, toEvict);
|
||||
toEvict -= mDecoders[i]->GetResource()->EvictData(toEvict);
|
||||
}
|
||||
return toEvict < (totalSize - aThreshold);
|
||||
}
|
||||
|
||||
void
|
||||
TrackBuffer::EvictBefore(double aTime)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// XXX Call EvictBefore on mDecoders?
|
||||
int64_t endOffset = mCurrentDecoder->ConvertToByteOffset(aTime);
|
||||
if (endOffset > 0) {
|
||||
mCurrentDecoder->GetResource()->EvictBefore(endOffset);
|
||||
for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
|
||||
int64_t endOffset = mDecoders[i]->ConvertToByteOffset(aTime);
|
||||
if (endOffset > 0) {
|
||||
MSE_DEBUG("TrackBuffer(%p)::EvictBefore decoder=%u offset=%lld", this, i, endOffset);
|
||||
mDecoders[i]->GetResource()->EvictBefore(endOffset);
|
||||
}
|
||||
}
|
||||
MSE_DEBUG("TrackBuffer(%p)::EvictBefore offset=%lld", this, endOffset);
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -72,9 +72,8 @@ runWithMSE(function () {
|
||||
});
|
||||
|
||||
v.addEventListener("ended", function () {
|
||||
// XXX: Duration should be exactly 4.0, see bug 1065207.
|
||||
is(v.duration, 4.001, "Video has correct duration");
|
||||
is(v.currentTime, 4.001, "Video has played to end");
|
||||
is(v.duration, 4, "Video has correct duration");
|
||||
is(v.currentTime, 4, "Video has played to end");
|
||||
v.parentNode.removeChild(v);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
@ -32,9 +32,8 @@ runWithMSE(function (ms, v) {
|
||||
});
|
||||
|
||||
v.addEventListener("ended", function () {
|
||||
// XXX: Duration should be exactly 4.0, see bug 1065207.
|
||||
is(v.duration, 4.001, "Video has correct duration");
|
||||
is(v.currentTime, 4.001, "Video has played to end");
|
||||
is(v.duration, 4, "Video has correct duration");
|
||||
is(v.currentTime, 4, "Video has played to end");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
@ -34,9 +34,8 @@ runWithMSE(function (ms, v) {
|
||||
});
|
||||
|
||||
v.addEventListener("ended", function () {
|
||||
// XXX: Duration should be exactly 4.0, see bug 1065207.
|
||||
is(v.duration, 4.001, "Video has correct duration");
|
||||
is(v.currentTime, 4.001, "Video has played to end");
|
||||
is(v.duration, 4, "Video has correct duration");
|
||||
is(v.currentTime, 4, "Video has played to end");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
@ -35,13 +35,106 @@ extern PRLogModuleInfo* gMediaDecoderLog;
|
||||
#define DECODER_LOG(type, msg)
|
||||
#endif
|
||||
|
||||
class OmxReaderProcessCachedDataTask : public Task
|
||||
{
|
||||
public:
|
||||
OmxReaderProcessCachedDataTask(MediaOmxReader* aOmxReader, int64_t aOffset)
|
||||
: mOmxReader(aOmxReader),
|
||||
mOffset(aOffset)
|
||||
{ }
|
||||
|
||||
void Run()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(mOmxReader.get());
|
||||
mOmxReader->ProcessCachedData(mOffset, false);
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<MediaOmxReader> mOmxReader;
|
||||
int64_t mOffset;
|
||||
};
|
||||
|
||||
// When loading an MP3 stream from a file, we need to parse the file's
|
||||
// content to find its duration. Reading files of 100 MiB or more can
|
||||
// delay the player app noticably, so the file is read and decoded in
|
||||
// smaller chunks.
|
||||
//
|
||||
// We first read on the decode thread, but parsing must be done on the
|
||||
// main thread. After we read the file's initial MiBs in the decode
|
||||
// thread, an instance of this class is scheduled to the main thread for
|
||||
// parsing the MP3 stream. The decode thread waits until it has finished.
|
||||
//
|
||||
// If there is more data available from the file, the runnable dispatches
|
||||
// a task to the IO thread for retrieving the next chunk of data, and
|
||||
// the IO task dispatches a runnable to the main thread for parsing the
|
||||
// data. This goes on until all of the MP3 file has been parsed.
|
||||
|
||||
class OmxReaderNotifyDataArrivedRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OmxReaderNotifyDataArrivedRunnable(MediaOmxReader* aOmxReader,
|
||||
const char* aBuffer, uint64_t aLength,
|
||||
int64_t aOffset, uint64_t aFullLength)
|
||||
: mOmxReader(aOmxReader),
|
||||
mBuffer(aBuffer),
|
||||
mLength(aLength),
|
||||
mOffset(aOffset),
|
||||
mFullLength(aFullLength)
|
||||
{
|
||||
MOZ_ASSERT(mOmxReader.get());
|
||||
MOZ_ASSERT(mBuffer.get() || !mLength);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
||||
NotifyDataArrived();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
void NotifyDataArrived()
|
||||
{
|
||||
const char* buffer = mBuffer.get();
|
||||
|
||||
while (mLength) {
|
||||
uint32_t length = std::min<uint64_t>(mLength, UINT32_MAX);
|
||||
mOmxReader->NotifyDataArrived(buffer, length,
|
||||
mOffset);
|
||||
buffer += length;
|
||||
mLength -= length;
|
||||
mOffset += length;
|
||||
}
|
||||
|
||||
if (mOffset < mFullLength) {
|
||||
// We cannot read data in the main thread because it
|
||||
// might block for too long. Instead we post an IO task
|
||||
// to the IO thread if there is more data available.
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
||||
new OmxReaderProcessCachedDataTask(mOmxReader.get(), mOffset));
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<MediaOmxReader> mOmxReader;
|
||||
nsAutoArrayPtr<const char> mBuffer;
|
||||
uint64_t mLength;
|
||||
int64_t mOffset;
|
||||
uint64_t mFullLength;
|
||||
};
|
||||
|
||||
MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder)
|
||||
: MediaOmxCommonReader(aDecoder)
|
||||
, mMP3FrameParser(-1)
|
||||
, mHasVideo(false)
|
||||
, mHasAudio(false)
|
||||
, mVideoSeekTimeUs(-1)
|
||||
, mAudioSeekTimeUs(-1)
|
||||
, mSkipCount(0)
|
||||
, mUseParserDuration(false)
|
||||
, mLastParserDuration(-1)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (!gMediaDecoderLog) {
|
||||
@ -143,6 +236,15 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool isMP3 = mDecoder->GetResource()->GetContentType().EqualsASCII(AUDIO_MP3);
|
||||
if (isMP3) {
|
||||
// When read sdcard's file on b2g platform at constructor,
|
||||
// the mDecoder->GetResource()->GetLength() would return -1.
|
||||
// Delay set the total duration on this function.
|
||||
mMP3FrameParser.SetLength(mDecoder->GetResource()->GetLength());
|
||||
ProcessCachedData(0, true);
|
||||
}
|
||||
|
||||
if (!mOmxDecoder->TryLoad()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -151,12 +253,24 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set the total duration (the max of the audio and video track).
|
||||
int64_t durationUs;
|
||||
mOmxDecoder->GetDuration(&durationUs);
|
||||
if (durationUs) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->SetMediaDuration(durationUs);
|
||||
if (isMP3 && mMP3FrameParser.IsMP3()) {
|
||||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
// The MP3FrameParser may reported a duration;
|
||||
// return -1 if no frame has been parsed.
|
||||
if (duration >= 0) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mUseParserDuration = true;
|
||||
mLastParserDuration = duration;
|
||||
mDecoder->SetMediaDuration(mLastParserDuration);
|
||||
}
|
||||
} else {
|
||||
// Set the total duration (the max of the audio and video track).
|
||||
int64_t durationUs;
|
||||
mOmxDecoder->GetDuration(&durationUs);
|
||||
if (durationUs) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->SetMediaDuration(durationUs);
|
||||
}
|
||||
}
|
||||
|
||||
if (mOmxDecoder->HasVideo()) {
|
||||
@ -334,10 +448,22 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
|
||||
void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
|
||||
{
|
||||
android::OmxDecoder *omxDecoder = mOmxDecoder.get();
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (omxDecoder) {
|
||||
omxDecoder->NotifyDataArrived(aBuffer, aLength, aOffset);
|
||||
if (HasVideo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mMP3FrameParser.NeedsData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
|
||||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
if (duration != mLastParserDuration && mUseParserDuration) {
|
||||
mLastParserDuration = duration;
|
||||
mDecoder->UpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,6 +545,48 @@ void MediaOmxReader::EnsureActive() {
|
||||
NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding");
|
||||
}
|
||||
|
||||
int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset, bool aWaitForCompletion)
|
||||
{
|
||||
// We read data in chunks of 32 KiB. We can reduce this
|
||||
// value if media, such as sdcards, is too slow.
|
||||
// Because of SD card's slowness, need to keep sReadSize to small size.
|
||||
// See Bug 914870.
|
||||
static const int64_t sReadSize = 32 * 1024;
|
||||
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread.");
|
||||
|
||||
MOZ_ASSERT(mDecoder->GetResource());
|
||||
int64_t resourceLength = mDecoder->GetResource()->GetCachedDataEnd(0);
|
||||
NS_ENSURE_TRUE(resourceLength >= 0, -1);
|
||||
|
||||
if (aOffset >= resourceLength) {
|
||||
return 0; // Cache is empty, nothing to do
|
||||
}
|
||||
|
||||
int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
|
||||
|
||||
nsAutoArrayPtr<char> buffer(new char[bufferLength]);
|
||||
|
||||
nsresult rv = mDecoder->GetResource()->ReadFromCache(buffer.get(),
|
||||
aOffset, bufferLength);
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
nsRefPtr<OmxReaderNotifyDataArrivedRunnable> runnable(
|
||||
new OmxReaderNotifyDataArrivedRunnable(this,
|
||||
buffer.forget(),
|
||||
bufferLength,
|
||||
aOffset,
|
||||
resourceLength));
|
||||
if (aWaitForCompletion) {
|
||||
rv = NS_DispatchToMainThread(runnable.get(), NS_DISPATCH_SYNC);
|
||||
} else {
|
||||
rv = NS_DispatchToMainThread(runnable.get());
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
return resourceLength - aOffset - bufferLength;
|
||||
}
|
||||
|
||||
android::sp<android::MediaSource> MediaOmxReader::GetAudioOffloadTrack()
|
||||
{
|
||||
if (!mOmxDecoder.get()) {
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "MediaOmxCommonReader.h"
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "MP3FrameParser.h"
|
||||
#include "nsRect.h"
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include <stagefright/MediaSource.h>
|
||||
@ -35,12 +37,13 @@ class MediaOmxReader : public MediaOmxCommonReader
|
||||
nsIntSize mInitialFrame;
|
||||
int64_t mVideoSeekTimeUs;
|
||||
int64_t mAudioSeekTimeUs;
|
||||
int64_t mLastParserDuration;
|
||||
int32_t mSkipCount;
|
||||
|
||||
bool mUseParserDuration;
|
||||
protected:
|
||||
android::sp<android::OmxDecoder> mOmxDecoder;
|
||||
android::sp<android::MediaExtractor> mExtractor;
|
||||
|
||||
MP3FrameParser mMP3FrameParser;
|
||||
// Called by ReadMetadata() during MediaDecoderStateMachine::DecodeMetadata()
|
||||
// on decode thread. It create and initialize the OMX decoder including
|
||||
// setting up custom extractor. The extractor provide the essential
|
||||
@ -90,6 +93,8 @@ public:
|
||||
|
||||
void ReleaseDecoder();
|
||||
|
||||
int64_t ProcessCachedData(int64_t aOffset, bool aWaitForCompletion);
|
||||
|
||||
android::sp<android::MediaSource> GetAudioOffloadTrack();
|
||||
};
|
||||
|
||||
|
@ -44,156 +44,6 @@ using namespace MPAPI;
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::layers;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ReleaseOmxDecoderRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ReleaseOmxDecoderRunnable(const android::sp<android::OmxDecoder>& aOmxDecoder)
|
||||
: mOmxDecoder(aOmxDecoder)
|
||||
{
|
||||
}
|
||||
|
||||
NS_METHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mOmxDecoder = nullptr; // release OmxDecoder
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
android::sp<android::OmxDecoder> mOmxDecoder;
|
||||
};
|
||||
|
||||
class OmxDecoderProcessCachedDataTask : public Task
|
||||
{
|
||||
public:
|
||||
OmxDecoderProcessCachedDataTask(android::OmxDecoder* aOmxDecoder, int64_t aOffset)
|
||||
: mOmxDecoder(aOmxDecoder),
|
||||
mOffset(aOffset)
|
||||
{ }
|
||||
|
||||
void Run()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(mOmxDecoder.get());
|
||||
int64_t rem = mOmxDecoder->ProcessCachedData(mOffset, false);
|
||||
|
||||
if (rem <= 0) {
|
||||
ReleaseOmxDecoderRunnable* r = new ReleaseOmxDecoderRunnable(mOmxDecoder);
|
||||
mOmxDecoder.clear();
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
android::sp<android::OmxDecoder> mOmxDecoder;
|
||||
int64_t mOffset;
|
||||
};
|
||||
|
||||
// When loading an MP3 stream from a file, we need to parse the file's
|
||||
// content to find its duration. Reading files of 100 MiB or more can
|
||||
// delay the player app noticably, so the file is read and decoded in
|
||||
// smaller chunks.
|
||||
//
|
||||
// We first read on the decode thread, but parsing must be done on the
|
||||
// main thread. After we read the file's initial MiBs in the decode
|
||||
// thread, an instance of this class is scheduled to the main thread for
|
||||
// parsing the MP3 stream. The decode thread waits until it has finished.
|
||||
//
|
||||
// If there is more data available from the file, the runnable dispatches
|
||||
// a task to the IO thread for retrieving the next chunk of data, and
|
||||
// the IO task dispatches a runnable to the main thread for parsing the
|
||||
// data. This goes on until all of the MP3 file has been parsed.
|
||||
|
||||
class OmxDecoderNotifyDataArrivedRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OmxDecoderNotifyDataArrivedRunnable(android::OmxDecoder* aOmxDecoder,
|
||||
const char* aBuffer, uint64_t aLength,
|
||||
int64_t aOffset, uint64_t aFullLength)
|
||||
: mOmxDecoder(aOmxDecoder),
|
||||
mBuffer(aBuffer),
|
||||
mLength(aLength),
|
||||
mOffset(aOffset),
|
||||
mFullLength(aFullLength),
|
||||
mCompletedMonitor("OmxDecoderNotifyDataArrived.mCompleted"),
|
||||
mCompleted(false)
|
||||
{
|
||||
MOZ_ASSERT(mOmxDecoder.get());
|
||||
MOZ_ASSERT(mBuffer.get() || !mLength);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
||||
NotifyDataArrived();
|
||||
Completed();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void WaitForCompletion()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
MonitorAutoLock mon(mCompletedMonitor);
|
||||
if (!mCompleted) {
|
||||
mCompletedMonitor.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void NotifyDataArrived()
|
||||
{
|
||||
const char* buffer = mBuffer.get();
|
||||
|
||||
while (mLength) {
|
||||
uint32_t length = std::min<uint64_t>(mLength, UINT32_MAX);
|
||||
bool success = mOmxDecoder->NotifyDataArrived(buffer, mLength,
|
||||
mOffset);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
|
||||
buffer += length;
|
||||
mLength -= length;
|
||||
mOffset += length;
|
||||
}
|
||||
|
||||
if (mOffset < mFullLength) {
|
||||
// We cannot read data in the main thread because it
|
||||
// might block for too long. Instead we post an IO task
|
||||
// to the IO thread if there is more data available.
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
||||
new OmxDecoderProcessCachedDataTask(mOmxDecoder.get(), mOffset));
|
||||
}
|
||||
}
|
||||
|
||||
// Call this function at the end of Run() to notify waiting
|
||||
// threads.
|
||||
void Completed()
|
||||
{
|
||||
MonitorAutoLock mon(mCompletedMonitor);
|
||||
MOZ_ASSERT(!mCompleted);
|
||||
mCompleted = true;
|
||||
mCompletedMonitor.Notify();
|
||||
}
|
||||
|
||||
android::sp<android::OmxDecoder> mOmxDecoder;
|
||||
nsAutoArrayPtr<const char> mBuffer;
|
||||
uint64_t mLength;
|
||||
int64_t mOffset;
|
||||
uint64_t mFullLength;
|
||||
|
||||
Monitor mCompletedMonitor;
|
||||
bool mCompleted;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using namespace android;
|
||||
|
||||
OmxDecoder::OmxDecoder(MediaResource *aResource,
|
||||
@ -211,8 +61,6 @@ OmxDecoder::OmxDecoder(MediaResource *aResource,
|
||||
mAudioChannels(-1),
|
||||
mAudioSampleRate(-1),
|
||||
mDurationUs(-1),
|
||||
mMP3FrameParser(aResource->GetLength()),
|
||||
mIsMp3(false),
|
||||
mVideoBuffer(nullptr),
|
||||
mAudioBuffer(nullptr),
|
||||
mIsVideoSeeking(false),
|
||||
@ -268,9 +116,6 @@ bool OmxDecoder::Init(sp<MediaExtractor>& extractor) {
|
||||
|
||||
const char* extractorMime;
|
||||
sp<MetaData> meta = extractor->getMetaData();
|
||||
if (meta->findCString(kKeyMIMEType, &extractorMime) && !strcasecmp(extractorMime, AUDIO_MP3)) {
|
||||
mIsMp3 = true;
|
||||
}
|
||||
|
||||
ssize_t audioTrackIndex = -1;
|
||||
ssize_t videoTrackIndex = -1;
|
||||
@ -342,17 +187,6 @@ bool OmxDecoder::TryLoad() {
|
||||
const char* audioMime;
|
||||
sp<MetaData> meta = mAudioTrack->getFormat();
|
||||
|
||||
if (mIsMp3) {
|
||||
// Feed MP3 parser with cached data. Local files will be fully
|
||||
// cached already, network streams will update with sucessive
|
||||
// calls to NotifyDataArrived.
|
||||
if (ProcessCachedData(0, true) >= 0) {
|
||||
durationUs = mMP3FrameParser.GetDuration();
|
||||
if (durationUs > totalDurationUs) {
|
||||
totalDurationUs = durationUs;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((durationUs == -1) && meta->findInt64(kKeyDuration, &durationUs)) {
|
||||
if (durationUs > totalDurationUs) {
|
||||
totalDurationUs = durationUs;
|
||||
@ -635,27 +469,6 @@ void OmxDecoder::ReleaseDecoder()
|
||||
mDecoder = nullptr;
|
||||
}
|
||||
|
||||
bool OmxDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
|
||||
{
|
||||
if (!mAudioTrack.get() || !mIsMp3 || !mMP3FrameParser.IsMP3() || !mDecoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
|
||||
|
||||
int64_t durationUs = mMP3FrameParser.GetDuration();
|
||||
|
||||
if (durationUs != mDurationUs) {
|
||||
mDurationUs = durationUs;
|
||||
|
||||
MOZ_ASSERT(mDecoder);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->UpdateEstimatedMediaDuration(mDurationUs);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OmxDecoder::ReleaseVideoBuffer() {
|
||||
if (mVideoBuffer) {
|
||||
mVideoBuffer->release();
|
||||
@ -1085,46 +898,3 @@ OmxDecoder::RecycleCallback(TextureClient* aClient, void* aClosure)
|
||||
OmxDecoder* decoder = static_cast<OmxDecoder*>(aClosure);
|
||||
decoder->RecycleCallbackImp(aClient);
|
||||
}
|
||||
|
||||
int64_t OmxDecoder::ProcessCachedData(int64_t aOffset, bool aWaitForCompletion)
|
||||
{
|
||||
// We read data in chunks of 32 KiB. We can reduce this
|
||||
// value if media, such as sdcards, is too slow.
|
||||
// Because of SD card's slowness, need to keep sReadSize to small size.
|
||||
// See Bug 914870.
|
||||
static const int64_t sReadSize = 32 * 1024;
|
||||
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread.");
|
||||
|
||||
MOZ_ASSERT(mResource);
|
||||
|
||||
int64_t resourceLength = mResource->GetCachedDataEnd(0);
|
||||
NS_ENSURE_TRUE(resourceLength >= 0, -1);
|
||||
|
||||
if (aOffset >= resourceLength) {
|
||||
return 0; // Cache is empty, nothing to do
|
||||
}
|
||||
|
||||
int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
|
||||
|
||||
nsAutoArrayPtr<char> buffer(new char[bufferLength]);
|
||||
|
||||
nsresult rv = mResource->ReadFromCache(buffer.get(), aOffset, bufferLength);
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
nsRefPtr<OmxDecoderNotifyDataArrivedRunnable> runnable(
|
||||
new OmxDecoderNotifyDataArrivedRunnable(this,
|
||||
buffer.forget(),
|
||||
bufferLength,
|
||||
aOffset,
|
||||
resourceLength));
|
||||
|
||||
rv = NS_DispatchToMainThread(runnable.get());
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
if (aWaitForCompletion) {
|
||||
runnable->WaitForCompletion();
|
||||
}
|
||||
|
||||
return resourceLength - aOffset - bufferLength;
|
||||
}
|
||||
|
@ -162,8 +162,6 @@ public:
|
||||
|
||||
void ReleaseDecoder();
|
||||
|
||||
bool NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
|
||||
|
||||
void GetDuration(int64_t *durationUs) {
|
||||
*durationUs = mDurationUs;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user