зеркало из https://github.com/mozilla/gecko-dev.git
Bug 704583 - Add testing mode to FocusManager, p=enn,smaug r=smaug,enn
This commit is contained in:
Родитель
97476878ea
Коммит
3065412dbd
|
@ -161,11 +161,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
|
||||
nsFocusManager* nsFocusManager::sInstance = nsnull;
|
||||
bool nsFocusManager::sMouseFocusesFormControl = false;
|
||||
bool nsFocusManager::sTestMode = false;
|
||||
|
||||
static const char* kObservedPrefs[] = {
|
||||
"accessibility.browsewithcaret",
|
||||
"accessibility.tabfocus_applies_to_xul",
|
||||
"accessibility.mouse_focuses_formcontrol",
|
||||
"focusmanager.testmode",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -198,6 +200,8 @@ nsFocusManager::Init()
|
|||
sMouseFocusesFormControl =
|
||||
Preferences::GetBool("accessibility.mouse_focuses_formcontrol", false);
|
||||
|
||||
sTestMode = Preferences::GetBool("focusmanager.testmode", false);
|
||||
|
||||
Preferences::AddWeakObservers(fm, kObservedPrefs);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
|
@ -235,6 +239,9 @@ nsFocusManager::Observe(nsISupports *aSubject,
|
|||
Preferences::GetBool("accessibility.mouse_focuses_formcontrol",
|
||||
false);
|
||||
}
|
||||
else if (data.EqualsLiteral("focusmanager.testmode")) {
|
||||
sTestMode = Preferences::GetBool("focusmanager.testmode", false);
|
||||
}
|
||||
} else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
|
||||
mActiveWindow = nsnull;
|
||||
mFocusedWindow = nsnull;
|
||||
|
@ -1064,7 +1071,7 @@ nsFocusManager::NotifyFocusStateChange(nsIContent* aContent,
|
|||
void
|
||||
nsFocusManager::EnsureCurrentWidgetFocused()
|
||||
{
|
||||
if (!mFocusedWindow)
|
||||
if (!mFocusedWindow || sTestMode)
|
||||
return;
|
||||
|
||||
// get the main child widget for the focused window and ensure that the
|
||||
|
@ -1570,7 +1577,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
|
|||
if (mActiveWindow) {
|
||||
nsIFrame* contentFrame = content->GetPrimaryFrame();
|
||||
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
|
||||
// for the object frame.
|
||||
nsIViewManager* vm = presShell->GetViewManager();
|
||||
|
@ -1744,7 +1751,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||
if (objectFrame)
|
||||
objectFrameWidget = objectFrame->GetWidget();
|
||||
}
|
||||
if (aAdjustWidgets && !objectFrameWidget) {
|
||||
if (aAdjustWidgets && !objectFrameWidget && !sTestMode) {
|
||||
nsIViewManager* vm = presShell->GetViewManager();
|
||||
if (vm) {
|
||||
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
|
||||
// aIsNewDocument.
|
||||
if (presShell->GetDocument() == aContent->GetDocument()) {
|
||||
if (aAdjustWidgets && objectFrameWidget)
|
||||
if (aAdjustWidgets && objectFrameWidget && !sTestMode)
|
||||
objectFrameWidget->SetFocus(false);
|
||||
|
||||
// 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 root widget.
|
||||
if (aAdjustWidgets && objectFrameWidget &&
|
||||
mFocusedWindow == aWindow && mFocusedContent == nsnull) {
|
||||
mFocusedWindow == aWindow && mFocusedContent == nsnull &&
|
||||
!sTestMode) {
|
||||
nsIViewManager* vm = presShell->GetViewManager();
|
||||
if (vm) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
|
@ -1965,6 +1973,15 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
|
|||
if (!aWindow || aWindow == mActiveWindow || aWindow == mWindowBeingLowered)
|
||||
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)
|
||||
// Windows would rather we focus the child widget, otherwise, the toplevel
|
||||
// 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.
|
||||
nsCOMPtr<nsIDocument> mMouseDownEventHandlingDocument;
|
||||
|
||||
static bool sTestMode;
|
||||
|
||||
// the single focus manager
|
||||
static nsFocusManager* sInstance;
|
||||
};
|
||||
|
|
|
@ -259,6 +259,8 @@ pref("ui.scrollToClick", 0);
|
|||
pref("accessibility.tabfocus_applies_to_xul", true);
|
||||
#endif
|
||||
|
||||
pref("focusmanager.testmode", false);
|
||||
|
||||
pref("accessibility.usetexttospeech", "");
|
||||
pref("accessibility.usebrailledisplay", "");
|
||||
pref("accessibility.accesskeycausesactivation", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче