提交 7bd29c94 编写于 作者: D denis

7186952: Improve clipboard access

Reviewed-by: serb, ahgross
上级 f1fd07e6
...@@ -109,12 +109,6 @@ public class TextComponent extends Component implements Accessible { ...@@ -109,12 +109,6 @@ public class TextComponent extends Component implements Accessible {
// the background color of non-editable TextComponents. // the background color of non-editable TextComponents.
boolean backgroundSetByClientCode = false; boolean backgroundSetByClientCode = false;
/**
* True if this <code>TextComponent</code> has access
* to the System clipboard.
*/
transient private boolean canAccessClipboard;
transient protected TextListener textListener; transient protected TextListener textListener;
/* /*
...@@ -139,7 +133,6 @@ public class TextComponent extends Component implements Accessible { ...@@ -139,7 +133,6 @@ public class TextComponent extends Component implements Accessible {
GraphicsEnvironment.checkHeadless(); GraphicsEnvironment.checkHeadless();
this.text = (text != null) ? text : ""; this.text = (text != null) ? text : "";
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
checkSystemClipboardAccess();
} }
private void enableInputMethodsIfNecessary() { private void enableInputMethodsIfNecessary() {
...@@ -734,17 +727,14 @@ public class TextComponent extends Component implements Accessible { ...@@ -734,17 +727,14 @@ public class TextComponent extends Component implements Accessible {
/** /**
* Assigns a valid value to the canAccessClipboard instance variable. * Assigns a valid value to the canAccessClipboard instance variable.
*/ */
private void checkSystemClipboardAccess() { private boolean canAccessClipboard() {
canAccessClipboard = true;
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm == null) return true;
try { try {
sm.checkSystemClipboardAccess(); sm.checkSystemClipboardAccess();
} return true;
catch (SecurityException e) { } catch (SecurityException e) {}
canAccessClipboard = false; return false;
}
}
} }
/* /*
...@@ -827,7 +817,6 @@ public class TextComponent extends Component implements Accessible { ...@@ -827,7 +817,6 @@ public class TextComponent extends Component implements Accessible {
} }
} }
enableInputMethodsIfNecessary(); enableInputMethodsIfNecessary();
checkSystemClipboardAccess();
} }
......
...@@ -53,14 +53,12 @@ struct EnableEditingStruct { ...@@ -53,14 +53,12 @@ struct EnableEditingStruct {
* AwtTextComponent fields * AwtTextComponent fields
*/ */
/* java.awt.TextComponent fields */
jfieldID AwtTextComponent::canAccessClipboardID;
/************************************************************************ /************************************************************************
* AwtTextComponent methods * AwtTextComponent methods
*/ */
jmethodID AwtTextComponent::canAccessClipboardMID;
AwtTextComponent::AwtTextComponent() { AwtTextComponent::AwtTextComponent() {
m_synthetic = FALSE; m_synthetic = FALSE;
m_lStartPos = -1; m_lStartPos = -1;
...@@ -367,8 +365,7 @@ AwtTextComponent::WmPaste() ...@@ -367,8 +365,7 @@ AwtTextComponent::WmPaste()
} }
jobject target = GetTarget(env); jobject target = GetTarget(env);
jboolean canAccessClipboard = jboolean canAccessClipboard =
env->GetBooleanField(target, env->CallBooleanMethod (target, AwtTextComponent::canAccessClipboardMID);
AwtTextComponent::canAccessClipboardID);
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
return (canAccessClipboard) ? mrDoDefault : mrConsume; return (canAccessClipboard) ? mrDoDefault : mrConsume;
} }
...@@ -854,12 +851,13 @@ Java_sun_awt_windows_WTextComponentPeer_initIDs(JNIEnv *env, jclass cls) ...@@ -854,12 +851,13 @@ Java_sun_awt_windows_WTextComponentPeer_initIDs(JNIEnv *env, jclass cls)
{ {
TRY; TRY;
cls = env->FindClass("java/awt/TextComponent"); jclass textComponentClassID = env->FindClass("java/awt/TextComponent");
if (cls != NULL) { AwtTextComponent::canAccessClipboardMID =
AwtTextComponent::canAccessClipboardID = env->GetMethodID(textComponentClassID,
env->GetFieldID(cls, "canAccessClipboard", "Z"); "canAccessClipboard", "()Z");
DASSERT(AwtTextComponent::canAccessClipboardID != NULL); env->DeleteLocalRef(textComponentClassID);
}
DASSERT(AwtTextComponent::canAccessClipboardMID != NULL);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -42,8 +42,7 @@ ...@@ -42,8 +42,7 @@
class AwtTextComponent : public AwtComponent { class AwtTextComponent : public AwtComponent {
public: public:
/* java.awt.TextComponent canAccessClipboard field ID */ static jmethodID canAccessClipboardMID;
static jfieldID canAccessClipboardID;
AwtTextComponent(); AwtTextComponent();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册