mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 704583 - Add testing mode to FocusManager, p=enn,smaug r=smaug,enn
This commit is contained in:
parent
97476878ea
commit
3065412dbd
@ -161,11 +161,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||||||
|
|
||||||
nsFocusManager* nsFocusManager::sInstance = nsnull;
|
nsFocusManager* nsFocusManager::sInstance = nsnull;
|
||||||
bool nsFocusManager::sMouseFocusesFormControl = false;
|
bool nsFocusManager::sMouseFocusesFormControl = false;
|
||||||
|
bool nsFocusManager::sTestMode = false;
|
||||||
|
|
||||||
static const char* kObservedPrefs[] = {
|
static const char* kObservedPrefs[] = {
|
||||||
"accessibility.browsewithcaret",
|
"accessibility.browsewithcaret",
|
||||||
"accessibility.tabfocus_applies_to_xul",
|
"accessibility.tabfocus_applies_to_xul",
|
||||||
"accessibility.mouse_focuses_formcontrol",
|
"accessibility.mouse_focuses_formcontrol",
|
||||||
|
"focusmanager.testmode",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,6 +200,8 @@ nsFocusManager::Init()
|
|||||||
sMouseFocusesFormControl =
|
sMouseFocusesFormControl =
|
||||||
Preferences::GetBool("accessibility.mouse_focuses_formcontrol", false);
|
Preferences::GetBool("accessibility.mouse_focuses_formcontrol", false);
|
||||||
|
|
||||||
|
sTestMode = Preferences::GetBool("focusmanager.testmode", false);
|
||||||
|
|
||||||
Preferences::AddWeakObservers(fm, kObservedPrefs);
|
Preferences::AddWeakObservers(fm, kObservedPrefs);
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||||
@ -235,6 +239,9 @@ nsFocusManager::Observe(nsISupports *aSubject,
|
|||||||
Preferences::GetBool("accessibility.mouse_focuses_formcontrol",
|
Preferences::GetBool("accessibility.mouse_focuses_formcontrol",
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
else if (data.EqualsLiteral("focusmanager.testmode")) {
|
||||||
|
sTestMode = Preferences::GetBool("focusmanager.testmode", false);
|
||||||
|
}
|
||||||
} else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
|
} else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
|
||||||
mActiveWindow = nsnull;
|
mActiveWindow = nsnull;
|
||||||
mFocusedWindow = nsnull;
|
mFocusedWindow = nsnull;
|
||||||
@ -1064,7 +1071,7 @@ nsFocusManager::NotifyFocusStateChange(nsIContent* aContent,
|
|||||||
void
|
void
|
||||||
nsFocusManager::EnsureCurrentWidgetFocused()
|
nsFocusManager::EnsureCurrentWidgetFocused()
|
||||||
{
|
{
|
||||||
if (!mFocusedWindow)
|
if (!mFocusedWindow || sTestMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get the main child widget for the focused window and ensure that the
|
// get the main child widget for the focused window and ensure that the
|
||||||
@ -1570,7 +1577,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
|
|||||||
if (mActiveWindow) {
|
if (mActiveWindow) {
|
||||||
nsIFrame* contentFrame = content->GetPrimaryFrame();
|
nsIFrame* contentFrame = content->GetPrimaryFrame();
|
||||||
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
|
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
|
||||||
if (aAdjustWidgets && objectFrame) {
|
if (aAdjustWidgets && objectFrame && !sTestMode) {
|
||||||
// note that the presshell's widget is being retrieved here, not the one
|
// note that the presshell's widget is being retrieved here, not the one
|
||||||
// for the object frame.
|
// for the object frame.
|
||||||
nsIViewManager* vm = presShell->GetViewManager();
|
nsIViewManager* vm = presShell->GetViewManager();
|
||||||
@ -1744,7 +1751,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||||||
if (objectFrame)
|
if (objectFrame)
|
||||||
objectFrameWidget = objectFrame->GetWidget();
|
objectFrameWidget = objectFrame->GetWidget();
|
||||||
}
|
}
|
||||||
if (aAdjustWidgets && !objectFrameWidget) {
|
if (aAdjustWidgets && !objectFrameWidget && !sTestMode) {
|
||||||
nsIViewManager* vm = presShell->GetViewManager();
|
nsIViewManager* vm = presShell->GetViewManager();
|
||||||
if (vm) {
|
if (vm) {
|
||||||
nsCOMPtr<nsIWidget> widget;
|
nsCOMPtr<nsIWidget> widget;
|
||||||
@ -1791,7 +1798,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||||||
// no longer be in the same document, due to the events we fired above when
|
// no longer be in the same document, due to the events we fired above when
|
||||||
// aIsNewDocument.
|
// aIsNewDocument.
|
||||||
if (presShell->GetDocument() == aContent->GetDocument()) {
|
if (presShell->GetDocument() == aContent->GetDocument()) {
|
||||||
if (aAdjustWidgets && objectFrameWidget)
|
if (aAdjustWidgets && objectFrameWidget && !sTestMode)
|
||||||
objectFrameWidget->SetFocus(false);
|
objectFrameWidget->SetFocus(false);
|
||||||
|
|
||||||
// if the object being focused is a remote browser, activate remote content
|
// if the object being focused is a remote browser, activate remote content
|
||||||
@ -1833,7 +1840,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||||||
// the plugin not to be focusable, update the system focus by focusing
|
// the plugin not to be focusable, update the system focus by focusing
|
||||||
// the root widget.
|
// the root widget.
|
||||||
if (aAdjustWidgets && objectFrameWidget &&
|
if (aAdjustWidgets && objectFrameWidget &&
|
||||||
mFocusedWindow == aWindow && mFocusedContent == nsnull) {
|
mFocusedWindow == aWindow && mFocusedContent == nsnull &&
|
||||||
|
!sTestMode) {
|
||||||
nsIViewManager* vm = presShell->GetViewManager();
|
nsIViewManager* vm = presShell->GetViewManager();
|
||||||
if (vm) {
|
if (vm) {
|
||||||
nsCOMPtr<nsIWidget> widget;
|
nsCOMPtr<nsIWidget> widget;
|
||||||
@ -1965,6 +1973,15 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
|
|||||||
if (!aWindow || aWindow == mActiveWindow || aWindow == mWindowBeingLowered)
|
if (!aWindow || aWindow == mActiveWindow || aWindow == mWindowBeingLowered)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (sTestMode) {
|
||||||
|
// In test mode, emulate the existing window being lowered and the new
|
||||||
|
// window being raised.
|
||||||
|
if (mActiveWindow)
|
||||||
|
WindowLowered(mActiveWindow);
|
||||||
|
WindowRaised(aWindow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
#if defined(XP_WIN) || defined(XP_OS2)
|
||||||
// Windows would rather we focus the child widget, otherwise, the toplevel
|
// Windows would rather we focus the child widget, otherwise, the toplevel
|
||||||
// widget will always end up being focused. Fortunately, focusing the child
|
// widget will always end up being focused. Fortunately, focusing the child
|
||||||
|
@ -527,6 +527,8 @@ private:
|
|||||||
// can access the document node, the caller should succeed in moving focus.
|
// can access the document node, the caller should succeed in moving focus.
|
||||||
nsCOMPtr<nsIDocument> mMouseDownEventHandlingDocument;
|
nsCOMPtr<nsIDocument> mMouseDownEventHandlingDocument;
|
||||||
|
|
||||||
|
static bool sTestMode;
|
||||||
|
|
||||||
// the single focus manager
|
// the single focus manager
|
||||||
static nsFocusManager* sInstance;
|
static nsFocusManager* sInstance;
|
||||||
};
|
};
|
||||||
|
@ -259,6 +259,8 @@ pref("ui.scrollToClick", 0);
|
|||||||
pref("accessibility.tabfocus_applies_to_xul", true);
|
pref("accessibility.tabfocus_applies_to_xul", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pref("focusmanager.testmode", false);
|
||||||
|
|
||||||
pref("accessibility.usetexttospeech", "");
|
pref("accessibility.usetexttospeech", "");
|
||||||
pref("accessibility.usebrailledisplay", "");
|
pref("accessibility.usebrailledisplay", "");
|
||||||
pref("accessibility.accesskeycausesactivation", true);
|
pref("accessibility.accesskeycausesactivation", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user