diff options
author | Grant Gayed <ggayed> | 2010-02-11 16:22:26 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2010-02-11 16:22:26 +0000 |
commit | ee09a6fd6c7f7798b399f04305eba07bfa747bfc (patch) | |
tree | cda4191aa2e545045f19b6516b9a3c9d7948c65f | |
parent | 045a153a59f5da9f1700cc6b72a0ab716d6fc7bf (diff) | |
download | eclipse.platform.swt-ee09a6fd6c7f7798b399f04305eba07bfa747bfc.tar.gz eclipse.platform.swt-ee09a6fd6c7f7798b399f04305eba07bfa747bfc.tar.xz eclipse.platform.swt-ee09a6fd6c7f7798b399f04305eba07bfa747bfc.zip |
*** empty log message ***
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java | 23 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java | 23 |
2 files changed, 26 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java index 1a06324367..e1f5b7998c 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java @@ -472,19 +472,22 @@ boolean close (boolean showPrompters) { public boolean execute(String script) { int frame = Cocoa.objc_msgSend(webView, Cocoa.S_mainFrame); int context = Cocoa.objc_msgSend(frame, Cocoa.S_globalContext); - int scriptString = 0, urlString = 0; + + byte[] bytes = null; + try { + bytes = (script + '\0').getBytes("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + bytes = (script + '\0').getBytes(); + } + int scriptString = OS.JSStringCreateWithUTF8CString(bytes); + try { - byte[] bytes = script.getBytes("UTF-8"); //$NON-NLS-1$ - byte[] temp = new byte[bytes.length + 1]; /* null-terminate */ - System.arraycopy(bytes, 0, temp, 0, bytes.length); - scriptString = OS.JSStringCreateWithUTF8CString(temp); - bytes = getUrl().getBytes("UTF-8"); //$NON-NLS-1$ - temp = new byte[bytes.length + 1]; /* null-terminate */ - System.arraycopy(bytes, 0, temp, 0, bytes.length); - urlString = OS.JSStringCreateWithUTF8CString(temp); + bytes = (getUrl() + '\0').getBytes("UTF-8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { - return false; + bytes = (getUrl() + '\0').getBytes(); } + int urlString = OS.JSStringCreateWithUTF8CString(bytes); + int result = OS.JSEvaluateScript(context, scriptString, 0, urlString, 0, null); OS.JSStringRelease(urlString); OS.JSStringRelease(scriptString); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java index 297a1d19b8..34eef69074 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java @@ -458,19 +458,22 @@ boolean close (boolean showPrompters) { public boolean execute (String script) { WebFrame frame = webView.mainFrame(); int /*long*/ context = frame.globalContext(); - int /*long*/ scriptString = 0, urlString = 0; + + byte[] bytes = null; + try { + bytes = (script + '\0').getBytes("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + bytes = (script + '\0').getBytes(); + } + int /*long*/ scriptString = OS.JSStringCreateWithUTF8CString(bytes); + try { - byte[] bytes = script.getBytes("UTF-8"); //$NON-NLS-1$ - byte[] temp = new byte[bytes.length + 1]; /* null-terminate */ - System.arraycopy(bytes, 0, temp, 0, bytes.length); - scriptString = OS.JSStringCreateWithUTF8CString(temp); - bytes = getUrl().getBytes("UTF-8"); //$NON-NLS-1$ - temp = new byte[bytes.length + 1]; /* null-terminate */ - System.arraycopy(bytes, 0, temp, 0, bytes.length); - urlString = OS.JSStringCreateWithUTF8CString(temp); + bytes = (getUrl() + '\0').getBytes("UTF-8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { - return false; + bytes = (getUrl() + '\0').getBytes(); } + int /*long*/ urlString = OS.JSStringCreateWithUTF8CString(bytes); + int /*long*/ result = OS.JSEvaluateScript(context, scriptString, 0, urlString, 0, null); OS.JSStringRelease(urlString); OS.JSStringRelease(scriptString); |