[559646] HTML5 content model update: add template and slot tags, item* properties, promote autofocus to global attribute
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CMNodeListImpl.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CMNodeListImpl.java index 30d7abc..f46cf8f 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CMNodeListImpl.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CMNodeListImpl.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2020 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 @@ -12,7 +12,8 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - +import java.util.ArrayList; +import java.util.List; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList; @@ -24,14 +25,14 @@ */ class CMNodeListImpl implements CMNodeList { - private java.util.Vector nodes = null; + private List<CMNode> nodes = null; /** * CMNodeListImpl constructor comment. */ public CMNodeListImpl() { super(); - nodes = new java.util.Vector(); + nodes = new ArrayList<>(); } /** @@ -39,7 +40,7 @@ * @param node org.eclipse.wst.xml.core.internal.contentmodel.CMNode */ protected CMNode appendNode(CMNode node) { - nodes.addElement(node); + nodes.add(node); return node; } @@ -59,6 +60,6 @@ public CMNode item(int index) { if (index < 0 || index >= nodes.size()) return null; - return (CMNode) nodes.elementAt(index); + return nodes.get(index); } }
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHead.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHead.java index 901e783..efe7ca5 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHead.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHead.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2020 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 @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - - +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; +import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; @@ -59,10 +60,18 @@ // %head.misc; // ( | )* CMGroupImpl misc = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); - if (misc == null) - return; - String[] names = {HTML40Namespace.ElementName.SCRIPT, HTML40Namespace.ElementName.STYLE, HTML40Namespace.ElementName.META, HTML40Namespace.ElementName.LINK, HTML40Namespace.ElementName.OBJECT, HTML40Namespace.ElementName.ISINDEX}; - collection.getDeclarations(misc, Arrays.asList(names).iterator()); + + List<String> names = new ArrayList<>(Arrays.asList( + HTML40Namespace.ElementName.SCRIPT, + HTML40Namespace.ElementName.STYLE, + HTML40Namespace.ElementName.META, + HTML40Namespace.ElementName.LINK, + HTML40Namespace.ElementName.OBJECT, + HTML40Namespace.ElementName.ISINDEX)); + if (collection.getNamedItem(HTML50Namespace.ElementName.TEMPLATE) != null) { + names.add(HTML50Namespace.ElementName.TEMPLATE); + } + collection.getDeclarations(misc, names.iterator()); // 2nd, get a title CMNode title = collection.getNamedItem(HTML40Namespace.ElementName.TITLE); // 3rd, get a base
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHtml.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHtml.java index cc36d7c..5bb2a67 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHtml.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdHtml.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2020 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 @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - - import java.util.Arrays; import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; @@ -369,6 +367,13 @@ edec = collection.getNamedItem(HTML50Namespace.ElementName.RUBY); if (edec != null) content.appendChild(edec); + + edec = collection.getNamedItem(HTML50Namespace.ElementName.TEMPLATE); + if (edec != null) + content.appendChild(edec); + edec = collection.getNamedItem(HTML50Namespace.ElementName.SLOT); + if (edec != null) + content.appendChild(edec); } /**
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTableCellContainer.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTableCellContainer.java index 25def0c..32c53ae 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTableCellContainer.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTableCellContainer.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2020 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 @@ -12,9 +12,8 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - - import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; +import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; @@ -52,6 +51,9 @@ dec = collection.getNamedItem(HTML40Namespace.ElementName.TD); if (dec != null) content.appendChild(dec); + dec = collection.getNamedItem(HTML50Namespace.ElementName.TEMPLATE); + if (dec != null) + content.appendChild(dec); } /**
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTrContainer.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTrContainer.java index 26589ed..59de27c 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTrContainer.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/CtdTrContainer.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2020 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 @@ -12,9 +12,8 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - - import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; +import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; @@ -47,6 +46,9 @@ CMNode tr = collection.getNamedItem(HTML40Namespace.ElementName.TR); if (tr != null) content.appendChild(tr); + CMNode template = collection.getNamedItem(HTML50Namespace.ElementName.TEMPLATE); + if (template != null) + content.appendChild(template); } /**
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 65553a6..3a4ff90 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
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2019 IBM Corporation and others. + * Copyright (c) 2010, 2020 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 @@ -21,21 +21,29 @@ import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; public class HTML5AttributeCollection extends AttributeCollection implements HTML50Namespace { - /** html5 core attribs */ + /** html5 core/global attributes */ private static final String[] CORE = { ATTR_NAME_ACCESSKEY, ATTR_NAME_AUTOCAPITALIZE, + ATTR_NAME_AUTOFOCUS, ATTR_NAME_CLASS, ATTR_NAME_CONTENT_EDITABLE, ATTR_NAME_CONTEXT_MENU, ATTR_NAME_DIR, ATTR_NAME_DRAGGABLE, ATTR_NAME_DROPZONE, + ATTR_NAME_ENTERKEYHINT, ATTR_NAME_HIDDEN, ATTR_NAME_ID, ATTR_NAME_INPUTMODE, ATTR_NAME_IS, - ATTR_NAME_LANG, + ATTR_NAME_ITEMID, + ATTR_NAME_ITEMPROP, + ATTR_NAME_ITEMREF, + ATTR_NAME_ITEMSCOPE, + ATTR_NAME_ITEMTYPE, + ATTR_NAME_LANG, + ATTR_NAME_NONCE, ATTR_NAME_ROLE, ATTR_NAME_SLOT, ATTR_NAME_SPELLCHECK, @@ -176,6 +184,12 @@ atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); attr = new HTMLAttrDeclImpl(ATTR_NAME_DROPZONE, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ENTERKEYHINT)) { + // (errmsg CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ENTERKEYHINT, atype, CMAttributeDeclaration.OPTIONAL); + + } else if (attrName.equalsIgnoreCase(ATTR_NAME_FORM)) { // (form CDATA; #IMPLIED) atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); @@ -212,6 +226,26 @@ atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); attr = new HTMLAttrDeclImpl(ATTR_NAME_IS, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ITEMID)) { + atype = new HTMLCMDataTypeImpl(CMDataType.IDREF); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ITEMID, atype, CMAttributeDeclaration.OPTIONAL); + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ITEMPROP)) { + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ITEMPROP, atype, CMAttributeDeclaration.OPTIONAL); + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ITEMREF)) { + atype = new HTMLCMDataTypeImpl(CMDataType.IDREF); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ITEMREF, atype, CMAttributeDeclaration.OPTIONAL); + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ITEMSCOPE)) { + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ITEMSCOPE, atype, CMAttributeDeclaration.OPTIONAL); + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ITEMTYPE)) { + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ITEMTYPE, atype, CMAttributeDeclaration.OPTIONAL); + } else if (attrName.equalsIgnoreCase(ATTR_NAME_MIN)) { atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); attr = new HTMLAttrDeclImpl(ATTR_NAME_MIN, atype, CMAttributeDeclaration.OPTIONAL); @@ -220,6 +254,10 @@ atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); attr = new HTMLAttrDeclImpl(ATTR_NAME_MAX, atype, CMAttributeDeclaration.OPTIONAL); } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NONCE)) { + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NONCE, atype, CMAttributeDeclaration.OPTIONAL); + } else if (attrName.equalsIgnoreCase(ATTR_NAME_OPEN)) { atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); atype.setEnumValues(new String[] { ATTR_NAME_OPEN }); @@ -594,12 +632,12 @@ } public void getEvents(CMNamedNodeMapImpl declarations) { - Iterator names = Arrays.asList(EVENTS).iterator(); + Iterator<String> names = Arrays.asList(EVENTS).iterator(); getDeclarations(declarations, names); } public void getBodyEvents(CMNamedNodeMapImpl declarations) { - Iterator names = Arrays.asList(BODY_EVENTS).iterator(); + Iterator<String> names = Arrays.asList(BODY_EVENTS).iterator(); getDeclarations(declarations, names); } @@ -1016,7 +1054,11 @@ attr = new HTMLAttrDeclImpl(ATTR_NAME_VALUE, atype, CMAttributeDeclaration.OPTIONAL); attributes.putNamedItem(ATTR_NAME_VALUE, attr); - // gloabl attrs + // global attrs + getAttrs(attributes); + } + else if (elementName.equals(HTML50Namespace.ElementName.TEMPLATE)){ + // just global attrs getAttrs(attributes); } /*
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 d3af7a0..af08e1e 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, 2019 IBM Corporation and others. + * Copyright (c) 2010, 2020 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 @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contentmodel; - - import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Vector; +import java.util.List; import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; @@ -61,6 +60,8 @@ public static final int ID_TIME =132; public static final int ID_VIDEO =133; public static final int ID_MAIN =134; + public static final int ID_TEMPLATE =135; + public static final int ID_SLOT =136; // D205513 @@ -71,7 +72,7 @@ // NOTE: If the reflection is too slow, this method should // just return the literal value, like 105. // -- 5/25/2001 - Class clazz = Ids50.class; + Class<Ids50> clazz = Ids50.class; Field[] fields = clazz.getFields(); numofids = 0; for (int i = 0; i < fields.length; i++) { @@ -269,9 +270,11 @@ edec = new HedSectioning(SECTION, this); } + else if (elementName.equalsIgnoreCase(SLOT)) { + edec = new HedSLOT(this); + } else if (elementName.equalsIgnoreCase(SOURCE)) { edec = new HedSOURCE(this); - } else if (elementName.equalsIgnoreCase(STRIKE)) { edec = new HedFontStyle(STRIKE, this); @@ -286,6 +289,9 @@ else if (elementName.equalsIgnoreCase(TIME)) { edec = new HedTIME(this); } + else if (elementName.equalsIgnoreCase(TEMPLATE)) { + edec = new HedTEMPLATE(this); + } else if (elementName.equalsIgnoreCase(TT)) { edec = new HedFontStyle(TT, this); ((HTMLElemDeclImpl) edec).obsolete(true); @@ -313,18 +319,17 @@ return attributeCollection; } - public final Collection getNamesOfBlock() { + public final Collection<String> getNamesOfBlock() { // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE, FORM, ISINDEX, HR, // TABLE, FIELDSET, ADDRESS, RUBY, FIGURE String[] blockMisc = {HEADER, FOOTER, HGROUP, P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE, FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS, RUBY, FIGURE}; - Vector names = new Vector(Arrays.asList(blockMisc)); + List<String> names = new ArrayList<>(Arrays.asList(blockMisc)); // %heading; names.addAll(Arrays.asList(HEADING)); // %list; names.addAll(Arrays.asList(LIST)); // %preformatted; names.addAll(Arrays.asList(PREFORMATTED)); - return names; } @@ -351,6 +356,14 @@ if (node != null) { group.appendChild(node); } + node = getNamedItem(TEMPLATE); + if (node != null) { + group.appendChild(node); + } + node = getNamedItem(SLOT); + if (node != null) { + group.appendChild(node); + } } public void getInline(CMGroupImpl group) { @@ -542,6 +555,7 @@ fNames[Ids50.ID_SECTION] = SECTION; fNames[Ids.ID_SELECT] = SELECT; fNames[Ids.ID_SMALL] = SMALL; + fNames[Ids50.ID_SLOT] = SLOT; fNames[Ids50.ID_SOURCE] = SOURCE; fNames[Ids.ID_SPAN] = SPAN; fNames[Ids.ID_STRIKE] = STRIKE; @@ -554,6 +568,7 @@ fNames[Ids.ID_TABLE] = TABLE; fNames[Ids.ID_TBODY] = TBODY; fNames[Ids.ID_TD] = TD; + fNames[Ids50.ID_TEMPLATE] = TEMPLATE; fNames[Ids.ID_TEXTAREA] = TEXTAREA; fNames[Ids.ID_TFOOT] = TFOOT; fNames[Ids.ID_TH] = TH;
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedKEYGEN.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedKEYGEN.java index e4fcf77..a484573 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedKEYGEN.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedKEYGEN.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 2020 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 @@ -33,7 +33,7 @@ attributeCollection.getAttrs(attributes); - String[] names = { HTML50Namespace.ATTR_NAME_AUTOFOCUS, HTML50Namespace.ATTR_NAME_CHALLENGE, HTML40Namespace.ATTR_NAME_DISABLED, HTML50Namespace.ATTR_NAME_FORM, HTML50Namespace.ATTR_NAME_KEYTYPE, HTML40Namespace.ATTR_NAME_NAME}; + String[] names = { HTML50Namespace.ATTR_NAME_CHALLENGE, HTML40Namespace.ATTR_NAME_DISABLED, HTML50Namespace.ATTR_NAME_FORM, HTML50Namespace.ATTR_NAME_KEYTYPE, HTML40Namespace.ATTR_NAME_NAME}; attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); }
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedSLOT.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedSLOT.java new file mode 100644 index 0000000..0a8c153 --- /dev/null +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedSLOT.java
@@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2020 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.contentmodel; + +import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; +import org.eclipse.wst.xml.core.internal.contentmodel.CMContent; +import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; + +/** + * SCRIPT. + */ +final class HedSLOT extends HTMLElemDeclImpl { + + /** + */ + public HedSLOT(ElementCollection collection) { + super(HTML50Namespace.ElementName.SLOT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_CDATA; + layoutType = LAYOUT_OBJECT; + } + + /** + * SCRIPT. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + attributeCollection.createAttributeDeclarations(HTML50Namespace.ElementName.SLOT, attributes); + + } + + public CMContent getContent() { + return null; + } + + public int getContentType() { + return CMElementDeclaration.CDATA; + } +}
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedTEMPLATE.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedTEMPLATE.java new file mode 100644 index 0000000..e396c5f --- /dev/null +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contentmodel/HedTEMPLATE.java
@@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2020 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.contentmodel; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.wst.html.core.internal.provisional.HTML50Namespace; +import org.eclipse.wst.xml.core.internal.contentmodel.CMContent; +import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; +import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; +import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; +import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList; + +/** + * "template" : https://html.spec.whatwg.org/#the-template-element + * + * It's an unusual requirement of treating the contained text as content + * rather than children while considering it renderable, but for now, opt to + * treat them as children for the sake of editing. + */ +final class HedTEMPLATE extends HTMLElemDeclImpl { + + private CMContent fContent = null; + + public HedTEMPLATE(ElementCollection collection) { + super(HTML50Namespace.ElementName.TEMPLATE, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * SCRIPT. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + attributeCollection.createAttributeDeclarations(HTML50Namespace.ElementName.TEMPLATE, attributes); + } + + @Override + public CMContent getContent() { + if (fContent == null ) { + ComplexTypeDefinitionFactory factory = ComplexTypeDefinitionFactory.getInstance(); + String[] possibleTypes = new String[] { + ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER, + ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER, + ComplexTypeDefinitionFactory.CTYPE_DATALIST, + ComplexTypeDefinitionFactory.CTYPE_RUBY, + ComplexTypeDefinitionFactory.CTYPE_MEDIA_ELEMENT, + ComplexTypeDefinitionFactory.CTYPE_COLUMN_GROUP, + ComplexTypeDefinitionFactory.CTYPE_TABLE, + ComplexTypeDefinitionFactory.CTYPE_TR_CONTAINER, + ComplexTypeDefinitionFactory.CTYPE_FIELDSET, + ComplexTypeDefinitionFactory.CTYPE_SELECT + }; + CMGroupImpl group = new CMGroupImpl(CMGroup.ALL, 0, CMContentImpl.UNBOUNDED); + Set<CMNode> possibleChildren = new HashSet<>(); + for (int i = 0; i < possibleTypes.length; i++) { + ComplexTypeDefinition def = factory.createTypeDefinition(possibleTypes[i], elementCollection); + CMGroup content = def.getContent(); + CMNodeList childNodes = content.getChildNodes(); + for (int j = 0; j < childNodes.getLength(); j++) { + possibleChildren.add(childNodes.item(j)); + } + } + for (CMNode child: possibleChildren) { + group.appendChild(child); + } + fContent = group; + } + return fContent; + } + + @Override + public int getContentType() { + return CMElementDeclaration.MIXED; + } +}
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 d8cbdc7..1cf4011 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, 2019 IBM Corporation and others. + * Copyright (c) 2010, 2020 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 @@ -17,33 +17,35 @@ public static interface ElementName extends HTML40Namespace.ElementName { String ARTICLE = "article"; //$NON-NLS-1$ String ASIDE = "aside"; //$NON-NLS-1$ - String AUDIO = "audio"; - String CANVAS = "canvas"; - String COMMAND = "command"; - String DATALIST = "datalist"; - String DETAILS = "details"; + String AUDIO = "audio"; //$NON-NLS-1$ + String CANVAS = "canvas"; //$NON-NLS-1$ + String COMMAND = "command"; //$NON-NLS-1$ + String DATALIST = "datalist"; //$NON-NLS-1$ + String DETAILS = "details"; //$NON-NLS-1$ String FIGURE = "figure"; //$NON-NLS-1$ String FIGCAPTION = "figcaption"; //$NON-NLS-1$ String FOOTER = "footer"; //$NON-NLS-1$ - String HEADER = "header"; - String HGROUP = "hgroup"; - String KEYGEN = "keygen"; - String MAIN = "main"; - String MARK = "mark"; - String MATH = "math"; - String METER = "meter"; - String NAV = "nav"; - String OUTPUT = "output"; - String PROGRESS = "progress"; - String RP = "rp"; - String RT = "rt"; - String RUBY = "ruby"; + String HEADER = "header"; //$NON-NLS-1$ + String HGROUP = "hgroup"; //$NON-NLS-1$ + String KEYGEN = "keygen"; //$NON-NLS-1$ + String MAIN = "main"; //$NON-NLS-1$ + String MARK = "mark"; //$NON-NLS-1$ + String MATH = "math"; //$NON-NLS-1$ + String METER = "meter"; //$NON-NLS-1$ + String NAV = "nav"; //$NON-NLS-1$ + String OUTPUT = "output"; //$NON-NLS-1$ + String PROGRESS = "progress"; //$NON-NLS-1$ + String RP = "rp"; //$NON-NLS-1$ + String RT = "rt"; //$NON-NLS-1$ + String RUBY = "ruby"; //$NON-NLS-1$ String SECTION = "section"; //$NON-NLS-1$ - String SOURCE = "source"; - String SUMMARY = "summary"; - String SVG = "svg"; - String TIME = "time"; - String VIDEO = "video"; + String SLOT = "slot"; //$NON-NLS-1$ + String SOURCE = "source"; //$NON-NLS-1$ + String SUMMARY = "summary"; //$NON-NLS-1$ + String SVG = "svg"; //$NON-NLS-1$ + String TEMPLATE = "template"; //$NON-NLS-1$ + String TIME = "time"; //$NON-NLS-1$ + String VIDEO = "video"; //$NON-NLS-1$ } String HTML50_URI = "http://www.w3.org/TR/html50/"; @@ -55,8 +57,15 @@ 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_ENTERKEYHINT = "enterkeyhint"; // %coreattrs; //$NON-NLS-1$ String ATTR_NAME_INPUTMODE = "inputmode"; //$NON-NLS-1$ String ATTR_NAME_IS = "is"; //$NON-NLS-1$ + String ATTR_NAME_ITEMID = "itemid"; //$NON-NLS-1$ + String ATTR_NAME_ITEMPROP = "itemprop"; //$NON-NLS-1$ + String ATTR_NAME_ITEMREF = "itemref"; //$NON-NLS-1$ + String ATTR_NAME_ITEMSCOPE = "itemscope"; //$NON-NLS-1$ + String ATTR_NAME_ITEMTYPE = "itemtype"; //$NON-NLS-1$ + String ATTR_NAME_NONCE = "nonce"; //$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$
diff --git a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidationReporter.java b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidationReporter.java index c35ce70..96f6eaf 100644 --- a/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidationReporter.java +++ b/web/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidationReporter.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2011 IBM Corporation and others. + * Copyright (c) 2001, 2020 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 @@ -16,7 +16,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.wst.html.core.internal.validate.MessageFactory; -import org.eclipse.wst.html.core.internal.validation.HTMLValidator; import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; import org.eclipse.wst.sse.core.internal.validate.ErrorInfo;
diff --git a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/GenericCompletionProposalComputer.java b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/GenericCompletionProposalComputer.java index 6f0ef2a..5857772 100755 --- a/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/GenericCompletionProposalComputer.java +++ b/web/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/GenericCompletionProposalComputer.java
@@ -27,13 +27,14 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.ui.internal.genericeditor.ContentAssistProcessorRegistry; import org.eclipse.ui.internal.genericeditor.GenericEditorPlugin; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; import org.eclipse.wst.html.ui.internal.Logger; import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; import org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer; public class GenericCompletionProposalComputer implements ICompletionProposalComputer { List<IContentAssistProcessor> fContentAssistProcessors = null; + private String fLastErrorMessage; + private static final String fExampleFileName = "filename.html"; //$NON-NLS-1$ public void sessionEnded() { fContentAssistProcessors = null; @@ -46,6 +47,7 @@ @Override public List computeCompletionProposals(CompletionProposalInvocationContext context, IProgressMonitor monitor) { ISourceViewer viewer = null; + fLastErrorMessage = null; if (context.getViewer() instanceof ISourceViewer) { viewer = (ISourceViewer) context.getViewer(); } @@ -53,7 +55,7 @@ IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); ContentAssistProcessorRegistry contentAssistProcessorRegistry = GenericEditorPlugin.getDefault().getContentAssistProcessorRegistry(); Set<IContentType> types = new HashSet<>(); - types.addAll(Arrays.asList(contentTypeManager.findContentTypesFor("file.html"))); + types.addAll(Arrays.asList(contentTypeManager.findContentTypesFor(fExampleFileName))); IContentType contentType = contentTypeManager.getContentType(IContentTypeManager.CT_TEXT); types.add(contentType); try { @@ -67,6 +69,15 @@ for (IContentAssistProcessor processor : fContentAssistProcessors) { ICompletionProposal[] computed = processor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()); proposals.addAll(Arrays.asList(computed)); + String errorMessage = processor.getErrorMessage(); + if (errorMessage != null) { + if (fLastErrorMessage == null) { + fLastErrorMessage = processor.getErrorMessage(); + } + else { + fLastErrorMessage = fLastErrorMessage.concat("\n").concat(errorMessage); + } + } } return proposals; } @@ -74,6 +85,7 @@ @Override public List computeContextInformation(CompletionProposalInvocationContext context, IProgressMonitor monitor) { ISourceViewer viewer = null; + fLastErrorMessage = null; if (context.getViewer() instanceof ISourceViewer) { viewer = (ISourceViewer) context.getViewer(); } @@ -81,9 +93,8 @@ IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); ContentAssistProcessorRegistry contentAssistProcessorRegistry = GenericEditorPlugin.getDefault().getContentAssistProcessorRegistry(); Set<IContentType> types = new HashSet<>(); - IContentType contentType = contentTypeManager.getContentType(ContentTypeIdForHTML.ContentTypeID_HTML); - types.add(contentType); - contentType = contentTypeManager.getContentType("org.eclipse.core.runtime.text"); + types.addAll(Arrays.asList(contentTypeManager.findContentTypesFor(fExampleFileName))); + IContentType contentType = contentTypeManager.getContentType(IContentTypeManager.CT_TEXT); types.add(contentType); fContentAssistProcessors = contentAssistProcessorRegistry.getContentAssistProcessors(viewer, null, types); } @@ -91,13 +102,21 @@ for (IContentAssistProcessor processor : fContentAssistProcessors) { IContextInformation[] computed = processor.computeContextInformation(context.getViewer(), context.getInvocationOffset()); infos.addAll(Arrays.asList(computed)); + String errorMessage = processor.getErrorMessage(); + if (errorMessage != null) { + if (fLastErrorMessage == null) { + fLastErrorMessage = processor.getErrorMessage(); + } + else { + fLastErrorMessage = fLastErrorMessage.concat("\n").concat(errorMessage); + } + } } return infos; } @Override public String getErrorMessage() { - // TODO Auto-generated method stub - return null; + return fLastErrorMessage; } }
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 6a21a17..3803ee7 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, 2019 IBM Corporation and others. + * Copyright (c) 2010, 2020 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 @@ -12,11 +12,10 @@ *******************************************************************************/ package org.eclipse.wst.html.core.tests.html5.model; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; - import org.eclipse.wst.html.core.internal.contentmodel.HTML5AttributeCollection; import org.eclipse.wst.html.core.internal.contentmodel.HTMLAttributeDeclaration; import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocumentFactory; @@ -29,6 +28,8 @@ import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType; +import junit.framework.TestCase; + public class HTML5ContentModelTest extends TestCase { public HTML5ContentModelTest(String name) { @@ -45,12 +46,32 @@ CMNode elementDeclaration = document.getElements().getNamedItem(elementName); assertNotNull("no such element declaration:" + elementName, elementDeclaration); assertEquals("not an element declaration:" + elementDeclaration, CMNode.ELEMENT_DECLARATION, elementDeclaration.getNodeType()); + + CMNamedNodeMap attributes = ((CMElementDeclaration) elementDeclaration).getAttributes(); + + StringBuilder actualNames = new StringBuilder(); + for (int i = 0; i < attrNames.length; i++, actualNames.append(',')) { + actualNames.append(attrNames[i]); + assertNotNull("missing attribute declaration:" + attrNames[i] + " for element: " + elementName, attributes.getNamedItem(attrNames[i])); + } + assertEquals("Attributes defined in content model that are not expected by the test for element: " + elementName, attributes.getLength(), attrNames.length); + } + + private void checkAttrNames(String documentKey, String elementName, String[] attrNames, String sortedExpectedNames) { + 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()); CMNamedNodeMap attributes = ((CMElementDeclaration) elementDeclaration).getAttributes(); - for (int i = 0; i < attrNames.length; i++) { + StringBuilder actualNames = new StringBuilder(); + Arrays.sort(attrNames); + for (int i = 0; i < attrNames.length; i++, actualNames.append('\n')) { + actualNames.append(attrNames[i]); assertNotNull("missing attribute declaration:" + attrNames[i] + " for element: " + elementName, attributes.getNamedItem(attrNames[i])); } + assertEquals("List of attribute names does not match", sortedExpectedNames, actualNames.toString()); assertEquals("Attributes defined in content model that are not expected by the test for element: " + elementName, attributes.getLength(), attrNames.length); } @@ -84,6 +105,7 @@ CMNamedNodeMap elements = document.getElements(); for (int i = 0; i < elements.getLength(); i++) { CMNode item = elements.item(i); + assertNotNull(documentKey + " contained a null element declaration at index " + i, item); verifyElementDeclarationHasName(item); } } @@ -157,8 +179,9 @@ public void testAttributesOnHTML5Keygen() { checkAttrNames(CMDocType.HTML5_DOC_TYPE, HTML50Namespace.ElementName.KEYGEN, getMergedlist(getGlobalList(), - new String[]{HTML50Namespace.ATTR_NAME_AUTOFOCUS, HTML50Namespace.ATTR_NAME_CHALLENGE, HTML40Namespace.ATTR_NAME_DISABLED, - HTML50Namespace.ATTR_NAME_FORM, HTML50Namespace.ATTR_NAME_KEYTYPE, HTML40Namespace.ATTR_NAME_NAME})); + new String[]{HTML50Namespace.ATTR_NAME_CHALLENGE, HTML40Namespace.ATTR_NAME_DISABLED, + HTML50Namespace.ATTR_NAME_FORM, HTML50Namespace.ATTR_NAME_KEYTYPE, HTML40Namespace.ATTR_NAME_NAME}), + "accesskey\nautocapitalize\nautofocus\nchallenge\nclass\ncontenteditable\ncontextmenu\ndir\ndisabled\ndraggable\ndropzone\nenterkeyhint\nform\nhidden\nid\ninputmode\nis\nitemid\nitemprop\nitemref\nitemscope\nitemtype\nkeytype\nlang\nname\nnonce\nonabort\nonblur\noncancel\noncanplay\noncanplaythrough\nonchange\nonclick\nonclose\noncontextmenu\noncuechange\nondblclick\nondrag\nondragend\nondragenter\nondragexit\nondragleave\nondragover\nondragstart\nondrop\nondurationchange\nonemptied\nonended\nonerror\nonfocus\nonformchange\nonforminput\noninput\noninvalid\nonkeydown\nonkeypress\nonkeyup\nonload\nonloadeddata\nonloadedmetadata\nonloadstart\nonmousedown\nonmouseenter\nonmouseleave\nonmousemove\nonmouseout\nonmouseover\nonmouseup\nonmousewheel\nonpause\nonplay\nonplaying\nonprogress\nonratechange\nonreadystatechange\nonreset\nonresize\nonscroll\nonseeked\nonseeking\nonselect\nonshow\nonstalled\nonsubmit\nonsuspend\nontimeupdate\nontoggle\nonvolumechange\nonvolumeupdate\nonwaiting\nrole\nslot\nspellcheck\nstyle\ntabindex\ntitle\ntranslate\n"); }