Skip to content

Commit

Permalink
Merge inbound to m-c.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvandermeulen committed Apr 1, 2013
2 parents 73d1b04 + 590e536 commit 5e12b3d
Show file tree
Hide file tree
Showing 182 changed files with 3,842 additions and 2,759 deletions.
1 change: 1 addition & 0 deletions accessible/src/base/TextAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "TextAttrs.h"

#include "Accessible-inl.h"
#include "HyperTextAccessibleWrap.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/base/nsAccUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ nsAccUtils::GetSelectableContainer(Accessible* aAccessible, uint64_t aState)

Accessible* parent = aAccessible;
while ((parent = parent->Parent()) && !parent->IsSelect()) {
if (Role(parent) == nsIAccessibleRole::ROLE_PANE)
if (parent->Role() == roles::PANE)
return nullptr;
}
return parent;
Expand Down
25 changes: 6 additions & 19 deletions accessible/src/base/nsAccUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#ifndef nsAccUtils_h_
#define nsAccUtils_h_

#include "nsIAccessible.h"
#include "nsIAccessibleRole.h"
#include "mozilla/a11y/Accessible.h"
#include "nsIAccessibleText.h"

#include "nsAccessibilityService.h"
Expand Down Expand Up @@ -192,18 +191,6 @@ class nsAccUtils
*/
static nsIntPoint GetScreenCoordsForParent(Accessible* aAccessible);

/**
* Return the role of the given accessible.
*/
static uint32_t Role(nsIAccessible *aAcc)
{
uint32_t role = nsIAccessibleRole::ROLE_NOTHING;
if (aAcc)
aAcc->GetRole(&role);

return role;
}

/**
* Get the ARIA attribute characteristics for a given ARIA attribute.
*
Expand Down Expand Up @@ -240,12 +227,12 @@ class nsAccUtils
/**
* Return true if the given accessible is embedded object.
*/
static bool IsEmbeddedObject(nsIAccessible *aAcc)
static bool IsEmbeddedObject(Accessible* aAcc)
{
uint32_t role = Role(aAcc);
return role != nsIAccessibleRole::ROLE_TEXT_LEAF &&
role != nsIAccessibleRole::ROLE_WHITESPACE &&
role != nsIAccessibleRole::ROLE_STATICTEXT;
uint32_t role = aAcc->Role();
return role != roles::TEXT_LEAF &&
role != roles::WHITESPACE &&
role != roles::STATICTEXT;
}

/**
Expand Down
73 changes: 73 additions & 0 deletions accessible/src/base/nsAccessibilityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#endif

#ifdef XP_WIN
#include "mozilla/a11y/Compatibility.h"
#include "HTMLWin32ObjectAccessible.h"
#endif

Expand All @@ -63,6 +64,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Util.h"
#include "nsDeckFrame.h"

Expand Down Expand Up @@ -210,6 +212,45 @@ nsAccessibilityService::GetRootDocumentAccessible(nsIPresShell* aPresShell,
return nullptr;
}

#ifdef XP_WIN
static StaticAutoPtr<nsTArray<nsCOMPtr<nsIContent> > > sPendingPlugins;
static StaticAutoPtr<nsTArray<nsCOMPtr<nsITimer> > > sPluginTimers;

class PluginTimerCallBack MOZ_FINAL : public nsITimerCallback
{
public:
PluginTimerCallBack(nsIContent* aContent) : mContent(aContent) {}

NS_DECL_ISUPPORTS

NS_IMETHODIMP Notify(nsITimer* aTimer) MOZ_FINAL
{
nsIPresShell* ps = mContent->OwnerDoc()->GetShell();
if (ps) {
DocAccessible* doc = ps->GetDocAccessible();
if (doc) {
// Make sure that if we created an accessible for the plugin that wasn't
// a plugin accessible we remove it before creating the right accessible.
doc->RecreateAccessible(mContent);
sPluginTimers->RemoveElement(aTimer);
return NS_OK;
}
}

// We couldn't get a doc accessible so presumably the document went away.
// In this case don't leak our ref to the content or timer.
sPendingPlugins->RemoveElement(mContent);
sPluginTimers->RemoveElement(aTimer);
return NS_OK;
}

private:
nsCOMPtr<nsIContent> mContent;
};

NS_IMPL_ISUPPORTS1(PluginTimerCallBack, nsITimerCallback)
#endif

already_AddRefed<Accessible>
nsAccessibilityService::CreatePluginAccessible(nsObjectFrame* aFrame,
nsIContent* aContent,
Expand All @@ -225,6 +266,23 @@ nsAccessibilityService::CreatePluginAccessible(nsObjectFrame* aFrame,
if (NS_SUCCEEDED(aFrame->GetPluginInstance(getter_AddRefs(pluginInstance))) &&
pluginInstance) {
#ifdef XP_WIN
if (!sPendingPlugins->Contains(aContent) &&
(Preferences::GetBool("accessibility.delay_plugins") ||
Compatibility::IsJAWS() || Compatibility::IsWE())) {
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
nsRefPtr<PluginTimerCallBack> cb = new PluginTimerCallBack(aContent);
timer->InitWithCallback(cb, Preferences::GetUint("accessibility.delay_plugin_time"),
nsITimer::TYPE_ONE_SHOT);
sPluginTimers->AppendElement(timer);
sPendingPlugins->AppendElement(aContent);
return nullptr;
}

// We need to remove aContent from the pending plugins here to avoid
// reentrancy. When the timer fires it calls
// DocAccessible::ContentInserted() which does the work async.
sPendingPlugins->RemoveElement(aContent);

// Note: pluginPort will be null if windowless.
HWND pluginPort = nullptr;
aFrame->GetPluginPort(&pluginPort);
Expand Down Expand Up @@ -1004,6 +1062,11 @@ nsAccessibilityService::Init()
NS_LITERAL_CSTRING("Active"));
#endif

#ifdef XP_WIN
sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >;
sPluginTimers = new nsTArray<nsCOMPtr<nsITimer> >;
#endif

gIsShutdown = false;

// Now its safe to start platform accessibility.
Expand All @@ -1030,6 +1093,16 @@ nsAccessibilityService::Shutdown()

SelectionManager::Shutdown();

#ifdef XP_WIN
sPendingPlugins = nullptr;

uint32_t timerCount = sPluginTimers->Length();
for (uint32_t i = 0; i < timerCount; i++)
sPluginTimers->ElementAt(i)->Cancel();

sPluginTimers = nullptr;
#endif

// Application is going to be closed, shutdown accessibility and mark
// accessibility service as shutdown to prevent calls of its methods.
// Don't null accessibility service static member at this point to be safe
Expand Down
7 changes: 5 additions & 2 deletions accessible/src/generic/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "nsAccessibleRelation.h"
#include "nsAccessibilityService.h"
#include "nsIAccessibleRelation.h"
#include "nsIAccessibleRole.h"
#include "nsEventShell.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
Expand Down Expand Up @@ -2654,7 +2655,8 @@ Accessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
return false;

for (uint32_t idx = aIndex + 1; idx < mChildren.Length(); idx++) {
NS_ASSERTION(mChildren[idx]->mIndexInParent == idx - 1, "Accessible child index doesn't match");
NS_ASSERTION(static_cast<uint32_t>(mChildren[idx]->mIndexInParent) == idx - 1,
"Accessible child index doesn't match");
mChildren[idx]->mIndexInParent = idx;
}

Expand Down Expand Up @@ -2685,7 +2687,8 @@ Accessible::RemoveChild(Accessible* aChild)
}

for (uint32_t idx = index + 1; idx < mChildren.Length(); idx++) {
NS_ASSERTION(mChildren[idx]->mIndexInParent == idx, "Accessible child index doesn't match");
NS_ASSERTION(static_cast<uint32_t>(mChildren[idx]->mIndexInParent) == idx,
"Accessible child index doesn't match");
mChildren[idx]->mIndexInParent = idx - 1;
}

Expand Down
Loading

0 comments on commit 5e12b3d

Please sign in to comment.