зеркало из https://github.com/mozilla/pjs.git
Bug 670317, add a focus manager flag to restrict tab navigation to the same frame, r=smaug
This commit is contained in:
Родитель
461d95548f
Коммит
6321188cf8
|
@ -188,7 +188,8 @@ nsHTMLLegendElement::Focus()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> result;
|
nsCOMPtr<nsIDOMElement> result;
|
||||||
return fm->MoveFocus(nsnull, this, nsIFocusManager::MOVEFOCUS_FORWARD, 0,
|
return fm->MoveFocus(nsnull, this, nsIFocusManager::MOVEFOCUS_FORWARD,
|
||||||
|
nsIFocusManager::FLAG_NOPARENTFRAME,
|
||||||
getter_AddRefs(result));
|
getter_AddRefs(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -527,8 +527,9 @@ nsFocusManager::MoveFocus(nsIDOMWindow* aWindow, nsIDOMElement* aStartElement,
|
||||||
|
|
||||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
bool noParentTraversal = aFlags & FLAG_NOPARENTFRAME;
|
||||||
nsCOMPtr<nsIContent> newFocus;
|
nsCOMPtr<nsIContent> newFocus;
|
||||||
nsresult rv = DetermineElementToMoveFocus(window, startContent, aType,
|
nsresult rv = DetermineElementToMoveFocus(window, startContent, aType, noParentTraversal,
|
||||||
getter_AddRefs(newFocus));
|
getter_AddRefs(newFocus));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -2332,7 +2333,7 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
|
||||||
nsresult
|
nsresult
|
||||||
nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
||||||
nsIContent* aStartContent,
|
nsIContent* aStartContent,
|
||||||
PRInt32 aType,
|
PRInt32 aType, bool aNoParentTraversal,
|
||||||
nsIContent** aNextContent)
|
nsIContent** aNextContent)
|
||||||
{
|
{
|
||||||
*aNextContent = nsnull;
|
*aNextContent = nsnull;
|
||||||
|
@ -2562,6 +2563,12 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
||||||
skipOriginalContentCheck = false;
|
skipOriginalContentCheck = false;
|
||||||
ignoreTabIndex = false;
|
ignoreTabIndex = false;
|
||||||
|
|
||||||
|
if (aNoParentTraversal) {
|
||||||
|
startContent = rootContent;
|
||||||
|
tabIndex = forward ? 1 : 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// reached the beginning or end of the document. Traverse up to the parent
|
// reached the beginning or end of the document. Traverse up to the parent
|
||||||
// document and try again.
|
// document and try again.
|
||||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(docShell);
|
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(docShell);
|
||||||
|
|
|
@ -347,11 +347,13 @@ protected:
|
||||||
* the element to start navigation from. For tab key navigation,
|
* the element to start navigation from. For tab key navigation,
|
||||||
* this should be the currently focused element.
|
* this should be the currently focused element.
|
||||||
*
|
*
|
||||||
* aType is the type passed to MoveFocus.
|
* aType is the type passed to MoveFocus. If aNoParentTraversal is set,
|
||||||
|
* navigation is not done to parent documents and iteration returns to the
|
||||||
|
* beginning (or end) of the starting document.
|
||||||
*/
|
*/
|
||||||
nsresult DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
nsresult DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
||||||
nsIContent* aStart,
|
nsIContent* aStart,
|
||||||
PRInt32 aType,
|
PRInt32 aType, bool aNoParentTraversal,
|
||||||
nsIContent** aNextContent);
|
nsIContent** aNextContent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -190,6 +190,14 @@ interface nsIFocusManager : nsISupports
|
||||||
*/
|
*/
|
||||||
const unsigned long FLAG_NOSWITCHFRAME = 4;
|
const unsigned long FLAG_NOSWITCHFRAME = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This flag is only used when passed to moveFocus. If set, focus is never
|
||||||
|
* moved to the parent frame of the starting element's document, instead
|
||||||
|
* iterating around to the beginning of that document again. Child frames
|
||||||
|
* are navigated as normal.
|
||||||
|
*/
|
||||||
|
const unsigned long FLAG_NOPARENTFRAME = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Focus is changing due to a mouse operation, for instance the mouse was
|
* Focus is changing due to a mouse operation, for instance the mouse was
|
||||||
* clicked on an element.
|
* clicked on an element.
|
||||||
|
|
|
@ -80,6 +80,7 @@ _TEST_FILES = \
|
||||||
test_browserFrame5.html \
|
test_browserFrame5.html \
|
||||||
test_browserFrame6.html \
|
test_browserFrame6.html \
|
||||||
test_for_of.html \
|
test_for_of.html \
|
||||||
|
test_focus_legend_noparent.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
_CHROME_FILES = \
|
_CHROME_FILES = \
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
function runTest()
|
||||||
|
{
|
||||||
|
window.focus();
|
||||||
|
var g = document.createElementNS("http://www.w3.org/1999/xhtml", "legend");
|
||||||
|
document.body.appendChild(g);
|
||||||
|
setTimeout(g.focus.bind(g), 0);
|
||||||
|
setTimeout(done, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function done()
|
||||||
|
{
|
||||||
|
ok(document.hasFocus(), "document is still focused");
|
||||||
|
is(document.activeElement, document.body, "document has no focused element")
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForFocus(runTest);
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<body onblur="dump('blurred window!\n')"></body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче