diff options
author | Brian de Alwis | 2016-05-05 03:49:07 +0000 |
---|---|---|
committer | Dani Megert | 2016-05-09 15:48:18 +0000 |
commit | 2c355fd21d97d7d855816e81b27ebca21412fce7 (patch) | |
tree | 0bb542ff1ece28b944c226cea411b1e15e3aaa6f /org.eclipse.ui.intro | |
parent | d35398c5b143526f1ef0505b683f79e18eb30e41 (diff) | |
download | eclipse.platform.ua-2c355fd21d97d7d855816e81b27ebca21412fce7.tar.gz eclipse.platform.ua-2c355fd21d97d7d855816e81b27ebca21412fce7.tar.xz eclipse.platform.ua-2c355fd21d97d7d855816e81b27ebca21412fce7.zip |
Bug 490678 - Intro branding image does not appear under WindowsI20160509-2000
Make MS/IE-specific filter generation in conditional on IE < 9 as
background-size is reported to work in IE 9+. Verified that intro
branding image is properly shown on IE 11 and Edge.
Change-Id: I5b54d5a5c38d02a0d6402d7e5d79b704c4976962
Diffstat (limited to 'org.eclipse.ui.intro')
-rw-r--r-- | org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java index 3307bf9f6..0f0ad3a10 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java @@ -16,10 +16,12 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.reflect.Field; import java.net.URL; import org.eclipse.core.runtime.Platform; import org.eclipse.help.internal.util.ProductPreferences; +import org.eclipse.swt.browser.Browser; import org.eclipse.ui.internal.intro.impl.FontSelection; import org.eclipse.ui.internal.intro.impl.IIntroConstants; import org.eclipse.ui.internal.intro.impl.IntroPlugin; @@ -39,6 +41,7 @@ import org.eclipse.ui.internal.intro.impl.model.IntroText; import org.eclipse.ui.internal.intro.impl.model.IntroTheme; import org.eclipse.ui.internal.intro.impl.model.loader.ContentProviderManager; import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil; +import org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation; import org.eclipse.ui.internal.intro.impl.util.Log; import org.eclipse.ui.intro.config.IIntroContentProvider; import org.eclipse.ui.intro.config.IIntroContentProviderSite; @@ -48,6 +51,7 @@ public class IntroHTMLGenerator { private AbstractIntroPage introPage; private IIntroContentProviderSite providerSite; + private boolean backgroundSizeWorks; /** * Generates the HTML code that will be presented in the browser widget for the provided intro @@ -64,11 +68,42 @@ public class IntroHTMLGenerator { this.introPage = page; this.providerSite = providerSite; + initializeBackgroundSizeWorks(); + // generate and add the appropriate encoding to the top of the document // generateEncoding(); // create the main HTML element, and all of its contents. return generateHTMLElement(); } + + private void initializeBackgroundSizeWorks() { + // Internet Explorer <= 9 doesn't properly handle background-size + backgroundSizeWorks = true; + try { + if (getBrowser() != null && "ie".equals(getBrowser().getBrowserType())) { //$NON-NLS-1$ + Class<?> ieClass = Class.forName("org.eclipse.swt.browser.IE"); //$NON-NLS-1$ + Field field = ieClass.getDeclaredField("IEVersion"); //$NON-NLS-1$ + field.setAccessible(true); + int value = field.getInt(ieClass); + // We specifically care about background-size which works in 9+ + backgroundSizeWorks = value <= 0 || value >= 9; + } + } catch(Exception e) { + // IE not found + } + } + + /** + * Return the SWT Browser instance being used to render the intro. + * + * @return the browser or {@code null} if the browser could not be determined + */ + private Browser getBrowser() { + if (providerSite instanceof BrowserIntroPartImplementation) { + return ((BrowserIntroPartImplementation) providerSite).getBrowser(); + } + return null; + } /* * private HTMLElement generateEncoding() { HTMLElement encoding = new HTMLElement(""); @@ -376,7 +411,7 @@ public class IntroHTMLGenerator { imageUrl = BundleUtil.getResolvedResourceLocation(element.getBase(), imageUrl, element .getBundle()); String style; - if (Platform.getWS().equals(Platform.WS_WIN32) && imageUrl.toLowerCase().endsWith(".png")) { //$NON-NLS-1$ + if (Platform.getWS().equals(Platform.WS_WIN32) && !backgroundSizeWorks && imageUrl.toLowerCase().endsWith(".png")) { //$NON-NLS-1$ // IE 5.5+ does not handle alphas in PNGs without // this hack. Remove when IE7 becomes widespread style = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imageUrl + "', sizingMethod='crop');"; //$NON-NLS-1$ //$NON-NLS-2$ @@ -969,7 +1004,7 @@ public class IntroHTMLGenerator { HTMLElement image = new FormattedHTMLElement(IIntroHTMLConstants.ELEMENT_IMG, indentLevel, true, false); boolean pngOnWin32 = imageSrc != null && Platform.getWS().equals(Platform.WS_WIN32) - && imageSrc.toLowerCase().endsWith(".png"); //$NON-NLS-1$ + && !backgroundSizeWorks && imageSrc.toLowerCase().endsWith(".png"); //$NON-NLS-1$ if (imageSrc == null || pngOnWin32) { // we must handle PNGs here - IE does not support alpha blanding well. // We will set the alpha image loader and load the real image |