diff options
author | Alexandr Miloslavskiy | 2019-02-27 09:58:33 +0000 |
---|---|---|
committer | Niraj Modi | 2019-03-26 15:52:36 +0000 |
commit | 1e2e1e226eceeee889f564c1f3edfae534aab204 (patch) | |
tree | 611c58ff62d9240799256a514c121019b5c52582 | |
parent | 3c1f0cb92345c3b1be5b870447fff4ccc52859f0 (diff) | |
download | eclipse.platform.swt-1e2e1e226eceeee889f564c1f3edfae534aab204.tar.gz eclipse.platform.swt-1e2e1e226eceeee889f564c1f3edfae534aab204.tar.xz eclipse.platform.swt-1e2e1e226eceeee889f564c1f3edfae534aab204.zip |
Bug 488855 - [Win32] Browser widget under windows calls a method in the wrong thread
The problem is that Internet Explorer sometimes calls 'WebSite#MapUrlToZone' from
non-main thread. This causes errors in 'Widget#checkWidget' when 'WebSite' tries to
get to its 'IE' parent via .getParent(). In order to solve the problem I removed the
code in question; now 'IE' tells 'WebSite' what to do.
I also noticed that there are other similar pieces of code, for example in
'WebSite#ProcessUrlAction'. However, it uses '_getUrl().startsWith(IE.ABOUT_BLANK)'
this time. I found that 'WebSite#MapUrlToZone' also used this approach previously,
but it was changed due to performance reasons. Still, it's not clear whether all
instances of '_getUrl().startsWith(IE.ABOUT_BLANK)' can be changed safely to
'IE#isAboutBlank' and I don't have the time to test it, so I left it as is.
I tried to test the original problem for which 'WebSite#MapUrlToZone' was made,
but it no longer reproduces for me. Probably it was solved independently in new IE.
Change-Id: Icd27bb6481e4f6792fc844380d0da9dbdc82adff
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java | 24 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java | 8 |
2 files changed, 21 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java index 51dacb3a76..143d8269c9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java @@ -478,7 +478,7 @@ public void create(Composite parent, int style) { long /*int*/ pCancel1 = cancel1.getByRef(); OS.MoveMemory(pCancel1, new short[] {OS.VARIANT_FALSE}, 2); } - isAboutBlank = false; + setAboutBlank(false); break; } else { /* @@ -536,7 +536,7 @@ public void create(Composite parent, int style) { Variant variant1 = new Variant(auto); /* does not need to be disposed */ IDispatch top1 = variant1.getDispatch(); if (top1.getAddress() == dispatch1.getAddress()) { - isAboutBlank = url1.startsWith(ABOUT_BLANK); + setAboutBlank(url1.startsWith(ABOUT_BLANK)); } } break; @@ -701,7 +701,7 @@ public void create(Composite parent, int style) { Variant variant3 = new Variant(auto); /* does not need to be disposed */ IDispatch top3 = variant3.getDispatch(); if (top3.getAddress() == dispatch3.getAddress()) { - isAboutBlank = url3.startsWith(ABOUT_BLANK); + setAboutBlank(url3.startsWith(ABOUT_BLANK)); lastNavigateURL = url3; } } @@ -1431,6 +1431,20 @@ void setHTML (String string) { } } +private void setAboutBlank(boolean value) { + isAboutBlank = value; + updateForceTrusted(); +} + +private void setUntrustedText(boolean value) { + untrustedText = value; + updateForceTrusted(); +} + +private void updateForceTrusted() { + site.isForceTrusted = isAboutBlank && !untrustedText; +} + @Override public boolean setText(final String html, boolean trusted) { /* @@ -1452,7 +1466,7 @@ public boolean setText(final String html, boolean trusted) { */ boolean blankLoading = this.html != null; this.html = html; - untrustedText = !trusted; + setUntrustedText(!trusted); if (blankLoading) return true; /* @@ -1567,7 +1581,7 @@ public void stop() { * Ensure that isAboutBlank is set accurately since Stop can be issued at * any stage in the page load cycle. */ - isAboutBlank = getUrl().startsWith(ABOUT_BLANK); + setAboutBlank(getUrl().startsWith(ABOUT_BLANK)); uncRedirect = null; int[] rgdispid = auto.getIDsOfNames(new String[] { "Stop" }); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java index cdc6d449da..7e46b73010 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java @@ -31,6 +31,7 @@ class WebSite extends OleControlSite { COMObject iAuthenticate; COMObject iDispatch; boolean ignoreNextMessage, ignoreAllMessages; + boolean isForceTrusted; Boolean canExecuteApplets; static final int OLECMDID_SHOWSCRIPTERROR = 40; @@ -559,12 +560,7 @@ int MapUrlToZone(long /*int*/ pwszUrl, long /*int*/ pdwZone, int dwFlags) { * to follow local links. The workaround is to return URLZONE_INTRANET * instead of the default value URLZONE_LOCAL_MACHINE. */ - IE ie = (IE)((Browser)getParent().getParent()).webBrowser; - /* - * For some reason IE8 invokes this function after the Browser has - * been disposed. To detect this case check for ie.auto != null. - */ - if (ie.auto != null && ie.isAboutBlank && !ie.untrustedText) { + if (isForceTrusted) { OS.MoveMemory(pdwZone, new int[] {IE.URLZONE_INTRANET}, 4); return COM.S_OK; } |