From 41a1f8c587e1d34567fe9317054b6176d0b48e28 Mon Sep 17 00:00:00 2001 From: Nitin Dahyabhai Date: Mon, 19 Aug 2019 18:46:01 -0400 Subject: [516758] HTML Editor doesn't recognize the HTML5 "main" tag Also add the "autocomplete", "inputmode", and "is" global attributes Change-Id: I6251f8adc8c4a2633484faab958f359348562abe Signed-off-by: Nitin Dahyabhai --- .../org.eclipse.wst.html.core/META-INF/MANIFEST.MF | 2 +- web/bundles/org.eclipse.wst.html.core/pom.xml | 2 +- .../contentmodel/HTML5AttributeCollection.java | 36 +++++++++++++++++++--- .../contentmodel/HTML5ElementCollection.java | 9 ++++-- .../core/internal/provisional/HTML50Namespace.java | 15 ++++++++- .../META-INF/MANIFEST.MF | 2 +- web/tests/org.eclipse.wst.html.core.tests/pom.xml | 2 +- .../tests/html5/model/HTML5ContentModelTest.java | 8 +++-- 8 files changed, 63 insertions(+), 13 deletions(-) diff --git a/web/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF b/web/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF index c903ee2543..37c01235f2 100644 --- a/web/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF +++ b/web/bundles/org.eclipse.wst.html.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.html.core; singleton:=true -Bundle-Version: 1.3.100.qualifier +Bundle-Version: 1.3.200.qualifier Bundle-Activator: org.eclipse.wst.html.core.internal.HTMLCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/web/bundles/org.eclipse.wst.html.core/pom.xml b/web/bundles/org.eclipse.wst.html.core/pom.xml index 14d19721e5..79472e9cc0 100644 --- a/web/bundles/org.eclipse.wst.html.core/pom.xml +++ b/web/bundles/org.eclipse.wst.html.core/pom.xml @@ -21,6 +21,6 @@ org.eclipse.webtools.sourceediting org.eclipse.wst.html.core - 1.3.100-SNAPSHOT + 1.3.200-SNAPSHOT eclipse-plugin diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5AttributeCollection.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5AttributeCollection.java index efad0aae94..65553a697d 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5AttributeCollection.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5AttributeCollection.java @@ -24,6 +24,7 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM /** html5 core attribs */ private static final String[] CORE = { ATTR_NAME_ACCESSKEY, + ATTR_NAME_AUTOCAPITALIZE, ATTR_NAME_CLASS, ATTR_NAME_CONTENT_EDITABLE, ATTR_NAME_CONTEXT_MENU, @@ -32,8 +33,11 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM ATTR_NAME_DROPZONE, ATTR_NAME_HIDDEN, ATTR_NAME_ID, + ATTR_NAME_INPUTMODE, + ATTR_NAME_IS, ATTR_NAME_LANG, ATTR_NAME_ROLE, + ATTR_NAME_SLOT, ATTR_NAME_SPELLCHECK, ATTR_NAME_STYLE, ATTR_NAME_TABINDEX, @@ -133,6 +137,14 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM atype.setEnumValues(values); attr = new HTMLAttrDeclImpl(ATTR_NAME_AUTOFOCUS, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_AUTOCAPITALIZE)) { + // (contenteditable (EMPTY|TRUE|FALSE|INHERIT) TRUE) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_ON, ATTR_VALUE_OFF, ATTR_VALUE_NONE, ATTR_VALUE_SENTENCES, ATTR_VALUE_WORDS, ATTR_VALUE_CHARACTERS}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_NONE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_AUTOCAPITALIZE, atype, CMAttributeDeclaration.OPTIONAL); + } else if (attrName.equalsIgnoreCase(ATTR_NAME_CONTENT_EDITABLE)) { // (contenteditable (EMPTY|TRUE|FALSE|INHERIT) TRUE) atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); @@ -189,9 +201,16 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); attr = new HTMLAttrDeclImpl(ATTR_NAME_HIGH, atype, CMAttributeDeclaration.OPTIONAL); } - else if (attrName.equalsIgnoreCase(ATTR_NAME_OPTIMUM)) { - atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); - attr = new HTMLAttrDeclImpl(ATTR_NAME_OPTIMUM, atype, CMAttributeDeclaration.OPTIONAL); + else if (attrName.equalsIgnoreCase(ATTR_NAME_INPUTMODE)) { + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_NONE, ATTR_VALUE_TEXT, ATTR_VALUE_DECIMAL, ATTR_VALUE_NUMERIC, ATTR_VALUE_TEL, ATTR_VALUE_SEARCH, ATTR_VALUE_EMAIL, ATTR_VALUE_URL}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_INPUTMODE, atype, CMAttributeDeclaration.OPTIONAL); + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_IS)) { + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_IS, atype, CMAttributeDeclaration.OPTIONAL); } else if (attrName.equalsIgnoreCase(ATTR_NAME_MIN)) { atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); @@ -206,6 +225,10 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM atype.setEnumValues(new String[] { ATTR_NAME_OPEN }); attr = new HTMLAttrDeclImpl(ATTR_NAME_OPEN, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_OPTIMUM)) { + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_OPTIMUM, atype, CMAttributeDeclaration.OPTIONAL); + } else if (attrName.equalsIgnoreCase(ATTR_NAME_PUBDATE)) { atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); atype.setEnumValues(new String[] { ATTR_NAME_PUBDATE }); @@ -216,6 +239,11 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); attr = new HTMLAttrDeclImpl(ATTR_NAME_ROLE, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SLOT)) { + // (span NUMBER 1) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SLOT, atype, CMAttributeDeclaration.OPTIONAL); + } else if (attrName.equalsIgnoreCase(ATTR_NAME_SPELLCHECK)) { // (spellcheck (EMPTY|TRUE|FALSE) TRUE) atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); @@ -561,7 +589,7 @@ public class HTML5AttributeCollection extends AttributeCollection implements HTM } public void getCore(CMNamedNodeMapImpl declarations) { - Iterator names = Arrays.asList(CORE).iterator(); + Iterator names = Arrays.asList(CORE).iterator(); getDeclarations(declarations, names); } diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5ElementCollection.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5ElementCollection.java index 65e6cb3623..d3af7a0c7c 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5ElementCollection.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HTML5ElementCollection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 2019 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -60,6 +60,7 @@ class HTML5ElementCollection extends ElementCollection implements org.eclipse.ws public static final int ID_SVG =131; public static final int ID_TIME =132; public static final int ID_VIDEO =133; + public static final int ID_MAIN =134; // D205513 @@ -111,7 +112,7 @@ class HTML5ElementCollection extends ElementCollection implements org.eclipse.ws /** %preformatted;. PRE */ private static final String[] PREFORMATTED = {PRE}; /** %sectioning;. ARTICLE | ASIDE | NAV | SECTION */ - private static final String[] SECTIONING = { ARTICLE, ASIDE, NAV, SECTION }; + private static final String[] SECTIONING = { ARTICLE, ASIDE, NAV, SECTION, MAIN }; /** %embedded;. AUDIO|CANVAS|EMBED|IFRAME|IMG|MATH|OBJECT|SVG|VIDEO */ private static final String[] EMBEDDED = { AUDIO, CANVAS, EMBED, IFRAME, IMG, MATH, OBJECT, SVG, VIDEO}; @@ -219,6 +220,9 @@ class HTML5ElementCollection extends ElementCollection implements org.eclipse.ws edec = new HedKEYGEN(this); } + else if (elementName.equalsIgnoreCase(MAIN)) { + edec = new HedSectioning(HTML50Namespace.ElementName.MAIN,this); + } else if (elementName.equalsIgnoreCase(MARK)) { edec = new HedPhrase(HTML50Namespace.ElementName.MARK,this); @@ -508,6 +512,7 @@ class HTML5ElementCollection extends ElementCollection implements org.eclipse.ws fNames[Ids.ID_LI] = LI; fNames[Ids.ID_LINK] = LINK; fNames[Ids.ID_MAP] = MAP; + fNames[Ids50.ID_MAIN] = MAIN; fNames[Ids50.ID_MARK] = MARK; fNames[Ids.ID_MARQUEE] = MARQUEE; fNames[Ids50.ID_MATH] = MATH; diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/HTML50Namespace.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/HTML50Namespace.java index b04104650a..d8cbdc732b 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/HTML50Namespace.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/HTML50Namespace.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2017 IBM Corporation and others. + * Copyright (c) 2010, 2019 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ public interface HTML50Namespace extends HTML40Namespace { String HEADER = "header"; String HGROUP = "hgroup"; String KEYGEN = "keygen"; + String MAIN = "main"; String MARK = "mark"; String MATH = "math"; String METER = "meter"; @@ -49,11 +50,15 @@ public interface HTML50Namespace extends HTML40Namespace { String HTML50_TAG_PREFIX = ""; // global attribute names + String ATTR_NAME_AUTOCAPITALIZE = "autocapitalize"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_CONTENT_EDITABLE = "contenteditable"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_CONTEXT_MENU = "contextmenu"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_DRAGGABLE = "draggable"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_DROPZONE = "dropzone"; // %coreattrs; //$NON-NLS-1$ + String ATTR_NAME_INPUTMODE = "inputmode"; //$NON-NLS-1$ + String ATTR_NAME_IS = "is"; //$NON-NLS-1$ String ATTR_NAME_ROLE = "role"; // %coreattrs; //$NON_NLS-1$ + String ATTR_NAME_SLOT = "slot"; //$NON-NLS-1$ String ATTR_NAME_SPELLCHECK = "spellcheck"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_TRANSLATE = "translate"; // %coreattrs; //$NON-NLS-1$ @@ -189,9 +194,17 @@ public interface HTML50Namespace extends HTML40Namespace { String ATTR_VALUE_COLOR = "color"; //input type //$NON-NLS-1$ String ATTR_VALUE_NUMBER_STRING = "number"; //input type //$NON-NLS-1$ + //Input modes + String ATTR_VALUE_DECIMAL = "decimal"; //input type //$NON-NLS-1$ + String ATTR_VALUE_NUMERIC = "numeric"; //input type //$NON-NLS-1$ + String ATTR_VALUE_ON = "on"; //input autocomplete //$NON-NLS-1$ String ATTR_VALUE_OFF = "off"; //input autocomplete //$NON-NLS-1$ + String ATTR_VALUE_CHARACTERS = "characters"; //global attr autocapitalize //$NON-NLS-1$ + String ATTR_VALUE_SENTENCES = "sentences"; //global attr autocapitalize //$NON-NLS-1$ + String ATTR_VALUE_WORDS = "words"; //global attr autocapitalize //$NON-NLS-1$ + String ATTR_VALUE_PUT = "PUT"; //input formmethod //$NON-NLS-1$ String ATTR_VALUE_DELETE = "DELETE"; //input formmethod //$NON-NLS-1$ diff --git a/web/tests/org.eclipse.wst.html.core.tests/META-INF/MANIFEST.MF b/web/tests/org.eclipse.wst.html.core.tests/META-INF/MANIFEST.MF index eff46024ca..2f2adb945d 100644 --- a/web/tests/org.eclipse.wst.html.core.tests/META-INF/MANIFEST.MF +++ b/web/tests/org.eclipse.wst.html.core.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.wst.html.core.tests;singleton:=true -Bundle-Version: 1.1.0.qualifier +Bundle-Version: 1.1.100.qualifier Bundle-Activator: org.eclipse.wst.html.core.tests.HTMLCoreTestsPlugin Bundle-Vendor: %Bundle-Vendor.0 Bundle-Localization: plugin diff --git a/web/tests/org.eclipse.wst.html.core.tests/pom.xml b/web/tests/org.eclipse.wst.html.core.tests/pom.xml index 5d084303b1..61dbac7f3b 100644 --- a/web/tests/org.eclipse.wst.html.core.tests/pom.xml +++ b/web/tests/org.eclipse.wst.html.core.tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.webtools.sourceediting org.eclipse.wst.html.core.tests - 1.1.0-SNAPSHOT + 1.1.100-SNAPSHOT eclipse-test-plugin diff --git a/web/tests/org.eclipse.wst.html.core.tests/src/org/eclipse/wst/html/core/tests/html5/model/HTML5ContentModelTest.java b/web/tests/org.eclipse.wst.html.core.tests/src/org/eclipse/wst/html/core/tests/html5/model/HTML5ContentModelTest.java index 82b4bdfeca..6a21a178e6 100644 --- a/web/tests/org.eclipse.wst.html.core.tests/src/org/eclipse/wst/html/core/tests/html5/model/HTML5ContentModelTest.java +++ b/web/tests/org.eclipse.wst.html.core.tests/src/org/eclipse/wst/html/core/tests/html5/model/HTML5ContentModelTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2017 IBM Corporation and others. + * Copyright (c) 2010, 2019 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -43,8 +43,8 @@ public class HTML5ContentModelTest extends TestCase { private void checkAttrNames(String documentKey, String elementName, String[] attrNames) { CMDocument document = HTMLCMDocumentFactory.getCMDocument(documentKey); CMNode elementDeclaration = document.getElements().getNamedItem(elementName); + assertNotNull("no such element declaration:" + elementName, elementDeclaration); assertEquals("not an element declaration:" + elementDeclaration, CMNode.ELEMENT_DECLARATION, elementDeclaration.getNodeType()); - assertNotNull("missing element declaration:" + elementName, elementDeclaration); CMNamedNodeMap attributes = ((CMElementDeclaration) elementDeclaration).getAttributes(); @@ -162,6 +162,10 @@ public class HTML5ContentModelTest extends TestCase { } + public void testAttributesOnHTML5Main() { + checkAttrNames(CMDocType.HTML5_DOC_TYPE, HTML50Namespace.ElementName.MAIN, getGlobalList()); + } + public void testAttributesOnHTML5Mark() { checkAttrNames(CMDocType.HTML5_DOC_TYPE, HTML50Namespace.ElementName.MARK, getGlobalList()); } -- cgit v1.2.3