mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 660742 accessible should use mozilla::Preferences r=roc+davidb
This commit is contained in:
parent
b7f556606b
commit
09b6048d53
@ -89,8 +89,6 @@
|
|||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "prdtoa.h"
|
#include "prdtoa.h"
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsIPrefService.h"
|
|
||||||
#include "nsIPrefBranch.h"
|
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsArrayUtils.h"
|
#include "nsArrayUtils.h"
|
||||||
#include "nsIMutableArray.h"
|
#include "nsIMutableArray.h"
|
||||||
@ -106,6 +104,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -339,14 +340,9 @@ nsAccessible::Description(nsString& aDescription)
|
|||||||
static PRInt32
|
static PRInt32
|
||||||
GetAccessModifierMask(nsIContent* aContent)
|
GetAccessModifierMask(nsIContent* aContent)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
||||||
if (!prefBranch)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// use ui.key.generalAccessKey (unless it is -1)
|
// use ui.key.generalAccessKey (unless it is -1)
|
||||||
PRInt32 accessKey;
|
PRInt32 accessKey = -1;
|
||||||
nsresult rv = prefBranch->GetIntPref("ui.key.generalAccessKey", &accessKey);
|
nsresult rv = Preferences::GetInt("ui.key.generalAccessKey", accessKey);
|
||||||
if (NS_SUCCEEDED(rv) && accessKey != -1) {
|
if (NS_SUCCEEDED(rv) && accessKey != -1) {
|
||||||
switch (accessKey) {
|
switch (accessKey) {
|
||||||
case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT;
|
case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT;
|
||||||
@ -372,14 +368,13 @@ GetAccessModifierMask(nsIContent* aContent)
|
|||||||
PRInt32 itemType, accessModifierMask = 0;
|
PRInt32 itemType, accessModifierMask = 0;
|
||||||
treeItem->GetItemType(&itemType);
|
treeItem->GetItemType(&itemType);
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
|
case nsIDocShellTreeItem::typeChrome:
|
||||||
|
rv = Preferences::GetInt("ui.key.chromeAccess", &accessModifierMask);
|
||||||
|
break;
|
||||||
|
|
||||||
case nsIDocShellTreeItem::typeChrome:
|
case nsIDocShellTreeItem::typeContent:
|
||||||
rv = prefBranch->GetIntPref("ui.key.chromeAccess", &accessModifierMask);
|
rv = Preferences::GetInt("ui.key.contentAccess", &accessModifierMask);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsIDocShellTreeItem::typeContent:
|
|
||||||
rv = prefBranch->GetIntPref("ui.key.contentAccess", &accessModifierMask);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_SUCCEEDED(rv) ? accessModifierMask : 0;
|
return NS_SUCCEEDED(rv) ? accessModifierMask : 0;
|
||||||
|
@ -54,11 +54,13 @@
|
|||||||
#include "nsIDOMNSHTMLElement.h"
|
#include "nsIDOMNSHTMLElement.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsIPrefService.h"
|
|
||||||
#include "nsIPrefBranch.h"
|
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
|
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
/// the accessible library and cached methods
|
/// the accessible library and cached methods
|
||||||
HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull;
|
HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull;
|
||||||
HINSTANCE nsAccessNodeWrap::gmUserLib = nsnull;
|
HINSTANCE nsAccessNodeWrap::gmUserLib = nsnull;
|
||||||
@ -711,22 +713,16 @@ void nsAccessNodeWrap::TurnOffNewTabSwitchingForJawsAndWE()
|
|||||||
// Check to see if the pref for disallowing CtrlTab is already set.
|
// Check to see if the pref for disallowing CtrlTab is already set.
|
||||||
// If so, bail out.
|
// If so, bail out.
|
||||||
// If not, set it.
|
// If not, set it.
|
||||||
nsCOMPtr<nsIPrefBranch> prefs (do_GetService(NS_PREFSERVICE_CONTRACTID));
|
if (Preferences::HasUserValue(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF)) {
|
||||||
if (prefs) {
|
// This pref has been set before. There is no default for it.
|
||||||
PRBool hasDisallowNewCtrlTabPref = PR_FALSE;
|
// Do nothing further, respect the setting that's there.
|
||||||
nsresult rv = prefs->PrefHasUserValue(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF,
|
// That way, if noone touches it, it'll stay on after toggled once.
|
||||||
&hasDisallowNewCtrlTabPref);
|
// If someone decided to turn it off, we respect that, too.
|
||||||
if (NS_SUCCEEDED(rv) && hasDisallowNewCtrlTabPref) {
|
return;
|
||||||
// This pref has been set before. There is no default for it.
|
|
||||||
// Do nothing further, respect the setting that's there.
|
|
||||||
// That way, if noone touches it, it'll stay on after toggled once.
|
|
||||||
// If someone decided to turn it off, we respect that, too.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value has never been set, set it.
|
|
||||||
prefs->SetBoolPref(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, PR_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Value has never been set, set it.
|
||||||
|
Preferences::SetBool(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsAccessNodeWrap::DoATSpecificProcessing()
|
void nsAccessNodeWrap::DoATSpecificProcessing()
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "nsIScrollableFrame.h"
|
#include "nsIScrollableFrame.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsINodeInfo.h"
|
#include "nsINodeInfo.h"
|
||||||
#include "nsIPrefService.h"
|
|
||||||
#include "nsRootAccessible.h"
|
#include "nsRootAccessible.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsTextFormatter.h"
|
#include "nsTextFormatter.h"
|
||||||
|
@ -50,8 +50,6 @@
|
|||||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||||
#include "nsIDOMXULMultSelectCntrlEl.h"
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
||||||
#include "nsIDOMKeyEvent.h"
|
#include "nsIDOMKeyEvent.h"
|
||||||
#include "nsIPrefService.h"
|
|
||||||
#include "nsIPrefBranch.h"
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
@ -59,6 +57,10 @@
|
|||||||
#include "nsILookAndFeel.h"
|
#include "nsILookAndFeel.h"
|
||||||
#include "nsWidgetsCID.h"
|
#include "nsWidgetsCID.h"
|
||||||
|
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||||
|
|
||||||
@ -410,10 +412,7 @@ nsXULMenuitemAccessible::GetKeyboardShortcut(nsAString& aAccessKey)
|
|||||||
// No need to cache pref service, this happens rarely
|
// No need to cache pref service, this happens rarely
|
||||||
if (gMenuAccesskeyModifier == -1) {
|
if (gMenuAccesskeyModifier == -1) {
|
||||||
// Need to initialize cached global accesskey pref
|
// Need to initialize cached global accesskey pref
|
||||||
gMenuAccesskeyModifier = 0;
|
gMenuAccesskeyModifier = Preferences::GetInt("ui.key.menuAccessKey", 0);
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
||||||
if (prefBranch)
|
|
||||||
prefBranch->GetIntPref("ui.key.menuAccessKey", &gMenuAccesskeyModifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString propertyKey;
|
nsAutoString propertyKey;
|
||||||
|
@ -188,6 +188,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static nsresult ClearUser(const char* aPref);
|
static nsresult ClearUser(const char* aPref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the pref has a user value or not.
|
||||||
|
*/
|
||||||
|
static PRBool HasUserValue(const char* aPref);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds/Removes the observer for the root pref branch.
|
* Adds/Removes the observer for the root pref branch.
|
||||||
* The observer is referenced strongly if AddStrongObserver is used. On the
|
* The observer is referenced strongly if AddStrongObserver is used. On the
|
||||||
|
@ -1285,6 +1285,20 @@ Preferences::ClearUser(const char* aPref)
|
|||||||
return sPreferences->mRootBranch->ClearUserPref(aPref);
|
return sPreferences->mRootBranch->ClearUserPref(aPref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
PRBool
|
||||||
|
Preferences::HasUserValue(const char* aPref)
|
||||||
|
{
|
||||||
|
NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE);
|
||||||
|
PRBool hasUserValue;
|
||||||
|
nsresult rv =
|
||||||
|
sPreferences->mRootBranch->PrefHasUserValue(aPref, &hasUserValue);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
return hasUserValue;
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
nsresult
|
nsresult
|
||||||
Preferences::AddStrongObserver(nsIObserver* aObserver,
|
Preferences::AddStrongObserver(nsIObserver* aObserver,
|
||||||
|
Loading…
Reference in New Issue
Block a user