提交 5821288d 编写于 作者: A ant

7170427: setGlobalCurrentFocusCycleRoot unexpectedly throws SecurityException

Reviewed-by: art
上级 14e624c2
......@@ -7947,32 +7947,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (rootAncestor != null) {
Container rootAncestorRootAncestor =
rootAncestor.getFocusCycleRootAncestor();
final Container fcr = (rootAncestorRootAncestor != null) ?
Container fcr = (rootAncestorRootAncestor != null) ?
rootAncestorRootAncestor : rootAncestor;
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(fcr);
return null;
}
});
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(fcr);
rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
} else {
final Window window = getContainingWindow();
Window window = getContainingWindow();
if (window != null) {
Component toFocus = window.getFocusTraversalPolicy().
getDefaultComponent(window);
if (toFocus != null) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(window);
return null;
}
});
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(window);
toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
}
}
......
......@@ -3245,7 +3245,7 @@ public class Container extends Component {
if (root != currentFocusCycleRoot) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(root);
setGlobalCurrentFocusCycleRootPriv(root);
}
return root;
}
......@@ -3302,7 +3302,7 @@ public class Container extends Component {
Container cont = kfm.getCurrentFocusCycleRoot();
if (cont == this || isParentOf(cont)) {
kfm.setGlobalCurrentFocusCycleRoot(null);
kfm.setGlobalCurrentFocusCycleRootPriv(null);
}
}
......@@ -3506,7 +3506,7 @@ public class Container extends Component {
public void transferFocusDownCycle() {
if (isFocusCycleRoot()) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(this);
setGlobalCurrentFocusCycleRootPriv(this);
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
......
......@@ -637,8 +637,8 @@ public abstract class KeyboardFocusManager
}
void clearGlobalFocusOwnerPriv() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
clearGlobalFocusOwner();
return null;
}
......@@ -1287,6 +1287,15 @@ public abstract class KeyboardFocusManager
newFocusCycleRoot);
}
void setGlobalCurrentFocusCycleRootPriv(final Container newFocusCycleRoot) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
setGlobalCurrentFocusCycleRoot(newFocusCycleRoot);
return null;
}
});
}
/**
* Adds a PropertyChangeListener to the listener list. The listener is
* registered for all bound properties of this class, including the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册