diff --git a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF index aaac5dfae17..56ae7855043 100644 --- a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %help_system_plugin_name Bundle-SymbolicName: org.eclipse.help.ui; singleton:=true -Bundle-Version: 4.8.0.qualifier +Bundle-Version: 4.8.100.qualifier Bundle-Activator: org.eclipse.help.ui.internal.HelpUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java index 639abb8bbf1..9bf2bc93cd9 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java @@ -36,6 +36,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.browser.BrowserFunction; import org.eclipse.swt.browser.LocationAdapter; import org.eclipse.swt.browser.LocationEvent; import org.eclipse.swt.browser.LocationListener; @@ -166,16 +167,13 @@ public void controlResized(ControlEvent e) { shell.open(); //browser.setUrl("about:blank"); + addNeedModalBrowserFunction(browser); + addResetNeedModalLocationListener(browser); + browser.addLocationListener(new LocationAdapter() { @Override public void changing(LocationEvent e) { - // hack to know when help webapp needs modal window - modalRequestTime = 0; - if (e.location != null - && e.location.startsWith("javascript://needModal")) { //$NON-NLS-1$ - modalRequestTime = System.currentTimeMillis(); - } if (!e.doit && e.location != null && e.location.startsWith("https://")) { //$NON-NLS-1$ try { @@ -211,19 +209,33 @@ public EmbeddedBrowser(WindowEvent event, Shell parent) { initialize(browser); event.browser = browser; - browser.addLocationListener(new LocationAdapter() { + addNeedModalBrowserFunction(browser); + addResetNeedModalLocationListener(browser); + } - @Override - public void changing(LocationEvent e) { - // hack to know when help webapp needs modal window - modalRequestTime = 0; - if (e.location != null - && e.location.startsWith("javascript://needModal")) { //$NON-NLS-1$ + // hack to know when help webapp needs modal window + // use a browser function to be more robust + // see also https://github.com/eclipse-platform/eclipse.platform.swt/issues/2006 + private void addNeedModalBrowserFunction(Browser browser) { + browser.getDisplay().asyncExec(() -> { + if (browser.isDisposed()) { + return; + } + new BrowserFunction(browser, "swtHintNeedModalPopup") { //$NON-NLS-1$ + @Override + public Object function(Object[] arguments) { + super.function(arguments); modalRequestTime = System.currentTimeMillis(); + return null; } - } + }; }); } + + private void addResetNeedModalLocationListener(Browser browser) { + LocationListener.changingAdapter(e -> modalRequestTime = 0); + } + private static void initializeShell(Shell s) { s.setText(initialTitle); final Image[] shellImages = createImages(); diff --git a/ua/org.eclipse.help.webapp/advanced/navActions.js b/ua/org.eclipse.help.webapp/advanced/navActions.js index f864cb5728d..5e8d340a4f5 100644 --- a/ua/org.eclipse.help.webapp/advanced/navActions.js +++ b/ua/org.eclipse.help.webapp/advanced/navActions.js @@ -193,7 +193,7 @@ function quickSearch(quickSearchType, errorMsg) { //search this topic and all s } // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); // Defect 593 ends var quickSearchWindow = window.open("quickSearch.jsp" + parameters, "QuickSearch", "location=no, status=no,resizable=yes,height="+h+",width="+w +",left="+l+",top="+t); diff --git a/ua/org.eclipse.help.webapp/advanced/searchScoped.jsp b/ua/org.eclipse.help.webapp/advanced/searchScoped.jsp index 8c629a23ea7..d30337a11a9 100644 --- a/ua/org.eclipse.help.webapp/advanced/searchScoped.jsp +++ b/ua/org.eclipse.help.webapp/advanced/searchScoped.jsp @@ -183,7 +183,7 @@ if (data.isIE()){ // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); advancedDialog = window.open("workingSetManager.jsp?workingSet="+encodeURIComponent(workingSet), "advancedDialog", "resizable=yes,height="+h+",width="+w+",left="+l+",top="+t ); advancedDialog.focus(); } diff --git a/ua/org.eclipse.help.webapp/advanced/searchSimple.jsp b/ua/org.eclipse.help.webapp/advanced/searchSimple.jsp index 9d7e80a73ec..99fa8c33809 100644 --- a/ua/org.eclipse.help.webapp/advanced/searchSimple.jsp +++ b/ua/org.eclipse.help.webapp/advanced/searchSimple.jsp @@ -144,7 +144,7 @@ function saveSelectedBooks(books) function openAdvanced() { - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); advancedDialog = window.open("advanced.jsp?searchWord="+encodeURIComponent(document.getElementById("searchWord").value), "advancedDialog", "resizable=yes,height="+h+",width="+w ); advancedDialog.focus(); } diff --git a/ua/org.eclipse.help.webapp/advanced/views.jsp b/ua/org.eclipse.help.webapp/advanced/views.jsp index 55c35c8cbd2..a64b1118450 100644 --- a/ua/org.eclipse.help.webapp/advanced/views.jsp +++ b/ua/org.eclipse.help.webapp/advanced/views.jsp @@ -89,7 +89,7 @@ if (data.isIE()){ // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); confirmShowAllDialog = window.open("confirmShowAll.jsp", "confirmShowAllDialog", "resizable=no,height="+h+",width="+w+",left="+l+",top="+t ); confirmShowAllDialog.focus(); } @@ -112,7 +112,7 @@ if (data.isIE()){ // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); selectScopeDialog = window.open("selectScope.jsp", "selectScopeDialog", "resizable=no,height="+h+",width="+w+",left="+l+",top="+t ); selectScopeDialog.focus(); } diff --git a/ua/org.eclipse.help.webapp/advanced/workingSetManager.jsp b/ua/org.eclipse.help.webapp/advanced/workingSetManager.jsp index 2514d8d6951..2d04497d7f9 100644 --- a/ua/org.eclipse.help.webapp/advanced/workingSetManager.jsp +++ b/ua/org.eclipse.help.webapp/advanced/workingSetManager.jsp @@ -224,7 +224,7 @@ function newWorkingSet() { %> // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); workingSetDialog = window.open("workingSet.jsp?operation=add&workingSet="+encodeURIComponent(getWorkingSet()), "workingSetDialog", "resizable=yes,height="+h+",width="+w +",left="+l+",top="+t); workingSetDialog.focus(); } @@ -247,7 +247,7 @@ function editWorkingSet() { // move the dialog just a bit higher than the middle if (t-50 > 0) t = t-50; - window.location="javascript://needModal"; + if (typeof top.swtHintNeedModalPopup === "function") top.swtHintNeedModalPopup(); workingSetDialog = window.open("workingSet.jsp?operation=edit&workingSet="+encodeURIComponent(getWorkingSet()), "workingSetDialog", "resizable=no,height="+h+",width="+w+",left="+l+",top="+t ); workingSetDialog.focus(); }