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

7170427: setGlobalCurrentFocusCycleRoot unexpectedly throws SecurityException

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