diff options
author | Brian de Alwis | 2016-08-18 15:05:35 +0000 |
---|---|---|
committer | Brian de Alwis | 2016-08-18 15:05:35 +0000 |
commit | 13c830c52c10111f4e49972e9468bcb3e19b9860 (patch) | |
tree | 62039d5cfd670c2920b6a284550f07ac870abc7c /org.eclipse.ui.intro | |
parent | 0e34cc5cf787a09860c14d469ae7df7c3e29756c (diff) | |
download | eclipse.platform.ua-13c830c52c10111f4e49972e9468bcb3e19b9860.tar.gz eclipse.platform.ua-13c830c52c10111f4e49972e9468bcb3e19b9860.tar.xz eclipse.platform.ua-13c830c52c10111f4e49972e9468bcb3e19b9860.zip |
Bug 497924 - [Welcome] Solstice should trigger generation of doctype so as to guide IEI20160823-0759
- Add support for marking a theme as HTML5 via the standardSupport property
- Use HTML5 property to add an HTML5 doctype
- When in HTML5 and on IE, add a X-UA-Compatible IE=edge meta element
to disable IE's 'compat view'
Change-Id: Icb75e8384adc0afa2ae5e334f5bcd91496c57cba
Diffstat (limited to 'org.eclipse.ui.intro')
3 files changed, 46 insertions, 7 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/FormattedHTMLElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/FormattedHTMLElement.java index 953dc5b70..316d78969 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/FormattedHTMLElement.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/FormattedHTMLElement.java @@ -31,8 +31,11 @@ public class FormattedHTMLElement extends HTMLElement { super(name); this.indentLevel = indentLevel; this.spanMultipleLines = spanMultipleLines; - // default - endTagRequired = true; + // void tags do not have close tags + boolean isVoidTag = IIntroHTMLConstants.ELEMENT_META.equalsIgnoreCase(name) + || IIntroHTMLConstants.ELEMENT_BASE.equalsIgnoreCase(name) + || IIntroHTMLConstants.ELEMENT_LINK.equalsIgnoreCase(name); + endTagRequired = !isVoidTag; } public FormattedHTMLElement(String name, int indentLevel, boolean spanMultipleLines, boolean endTagRequired) { 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 0f0ad3a10..e9b53ee1b 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 @@ -18,6 +18,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Field; import java.net.URL; +import java.util.Map; import org.eclipse.core.runtime.Platform; import org.eclipse.help.internal.util.ProductPreferences; @@ -80,7 +81,7 @@ public class IntroHTMLGenerator { // Internet Explorer <= 9 doesn't properly handle background-size backgroundSizeWorks = true; try { - if (getBrowser() != null && "ie".equals(getBrowser().getBrowserType())) { //$NON-NLS-1$ + if (isIE()) { Class<?> ieClass = Class.forName("org.eclipse.swt.browser.IE"); //$NON-NLS-1$ Field field = ieClass.getDeclaredField("IEVersion"); //$NON-NLS-1$ field.setAccessible(true); @@ -93,6 +94,10 @@ public class IntroHTMLGenerator { } } + private boolean isIE() { + return getBrowser() != null && "ie".equals(getBrowser().getBrowserType()); //$NON-NLS-1$ + } + /** * Return the SWT Browser instance being used to render the intro. * @@ -163,9 +168,10 @@ public class IntroHTMLGenerator { */ private HTMLElement generateHeadElement(int indentLevel) { HTMLElement head = new FormattedHTMLElement(IIntroHTMLConstants.ELEMENT_HEAD, indentLevel, true); + addBrowserRenderingDirectives(head, indentLevel + 1); // add the title head.addContent(generateTitleElement(introPage.getTitle(), indentLevel + 1)); - head.addContent(generateUTF8CharsetElement()); + head.addContent(generateUTF8CharsetElement(indentLevel + 1)); // create the BASE element String basePath = BundleUtil.getResolvedResourceLocation(introPage.getBase(), introPage.getBundle()); HTMLElement base = generateBaseElement(indentLevel + 1, basePath); @@ -220,8 +226,36 @@ public class IntroHTMLGenerator { return head; } - private HTMLElement generateUTF8CharsetElement() { - HTMLElement meta = new FormattedHTMLElement(IIntroHTMLConstants.ELEMENT_META, 0, false); + /** + * Add any browser-specific rendering quirks + * + * @param indentLevel + */ + private void addBrowserRenderingDirectives(HTMLElement head, int indentLevel) { + /* IE renders intranet content in Compat View by default */ + if (isIE() && "html5".equals(getThemeProperty("standardSupport"))) { //$NON-NLS-1$ //$NON-NLS-2$ + // "Edge mode tells Internet Explorer to display content in the highest mode available" + HTMLElement meta = new FormattedHTMLElement(IIntroHTMLConstants.ELEMENT_META, indentLevel, true); + meta.addAttribute(IIntroHTMLConstants.ATTRIBUTE_HTTP_EQUIV, "X-UA-Compatible"); //$NON-NLS-1$ + meta.addAttribute(IIntroHTMLConstants.ATTRIBUTE_CONTENT, "IE=edge"); //$NON-NLS-1$ + head.addContent(meta); + } + } + + private String getThemeProperty(String key) { + IntroTheme theme = introPage.getModelRoot().getTheme(); + if (theme == null) { + return null; + } + Map<String, String> properties = theme.getProperties(); + if (properties == null) { + return null; + } + return properties.get(key); + } + + private HTMLElement generateUTF8CharsetElement(int indentLevel) { + HTMLElement meta = new FormattedHTMLElement(IIntroHTMLConstants.ELEMENT_META, indentLevel, false); meta.addAttribute(IIntroHTMLConstants.ATTRIBUTE_HTTP_EQUIV, IIntroHTMLConstants.CONTENT_TYPE); meta.addAttribute(IIntroHTMLConstants.ATTRIBUTE_CONTENT, IIntroHTMLConstants.TYPE_HTML_UTF_8); return meta; diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java index 860bd783c..548829a2c 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java @@ -330,7 +330,9 @@ public class BrowserIntroPartImplementation extends if (props!=null) { String value = (String)props.get("standardSupport"); //$NON-NLS-1$ String doctype=null; - if ("strict".equalsIgnoreCase(value)) //$NON-NLS-1$ + if ("html5".equalsIgnoreCase(value)) //$NON-NLS-1$ + doctype = "<!DOCTYPE html>\n"; //$NON-NLS-1$ + else if ("strict".equalsIgnoreCase(value)) //$NON-NLS-1$ doctype = generateDoctype(true); else if ("loose".equalsIgnoreCase(value)) //$NON-NLS-1$ doctype = generateDoctype(false); |