static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) { int hash = ElementName.bufToHash(buf, length); int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash); if (index < 0) { return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner)); } else { ElementName elementName = ElementName.ELEMENT_NAMES[index]; @Local String name = elementName.name; if (!Portability.localEqualsBuffer(name, buf, offset, length)) { return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner)); } return elementName; } }
private void strBufToElementNameString() { if (containsHyphen) { // We've got a custom element or annotation-xml. @Local String annotationName = ElementName.ANNOTATION_XML.getName(); if (Portability.localEqualsBuffer(annotationName, strBuf, strBufLen)) { tagName = ElementName.ANNOTATION_XML; } else { nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner) // CPPONLY: , true ); tagName = nonInternedTagName; } } else { tagName = ElementName.elementNameByBuffer(strBuf, strBufLen, interner); if (tagName == null) { nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner) // CPPONLY: , false ); tagName = nonInternedTagName; } } containsHyphen = false; clearStrBufAfterUse(); }
/** * Short hand for well-known HTML elements. * * @param elementName * @param node */ void setValues(ElementName elementName, T node // [NOCPP[ , TaintableLocatorImpl locator // ]NOCPP] ) { assert isUnused(); this.flags = elementName.getFlags(); this.name = elementName.getName(); this.popName = elementName.getName(); this.ns = "http://www.w3.org/1999/xhtml"; this.node = node; this.attributes = null; this.refcount = 1; assert elementName.isInterned() : "Don't use this constructor for custom elements."; /* * Not used for formatting elements, so no need to track creator. */ // CPPONLY: this.htmlCreator = null; // [NOCPP[ this.locator = locator; // ]NOCPP] }
/** * Short hand for well-known HTML elements. * * @param elementName * @param node */ StackNode(ElementName elementName, T node // [NOCPP[ , TaintableLocatorImpl locator // ]NOCPP] ) { this.flags = elementName.getFlags(); this.name = elementName.name; this.popName = elementName.name; this.ns = "http://www.w3.org/1999/xhtml"; this.node = node; this.attributes = null; this.refcount = 1; assert !elementName.isCustom() : "Don't use this constructor for custom elements."; // [NOCPP[ this.locator = locator; // ]NOCPP] }
/** * The common-case HTML setter. * * @param elementName * @param node * @param popName */ void setValues(ElementName elementName, T node, @Local String popName // [NOCPP[ , TaintableLocatorImpl locator // ]NOCPP] ) { assert isUnused(); this.flags = elementName.getFlags(); this.name = elementName.getName(); this.popName = popName; this.ns = "http://www.w3.org/1999/xhtml"; this.node = node; this.attributes = null; this.refcount = 1; /* * Not used for formatting elements, so no need to track creator. */ // CPPONLY: this.htmlCreator = null; // [NOCPP[ this.locator = locator; // ]NOCPP] }
private void appendVoidElementToCurrentMayFosterMathML( ElementName elementName, HtmlAttributes attributes) throws SAXException { @Local String popName = elementName.getName(); // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/1998/Math/MathML"); if (!elementName.isInterned()) { popName = checkPopName(popName); } // ]NOCPP] T elt; StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes // CPPONLY: , htmlCreator(null) ); } else { elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node // CPPONLY: , htmlCreator(null) ); appendElement(elt, current.node); } elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt); elementPopped("http://www.w3.org/1998/Math/MathML", popName, elt); }
private void appendVoidElementToCurrentMayFosterSVG( ElementName elementName, HtmlAttributes attributes) throws SAXException { @Local String popName = elementName.getCamelCaseName(); // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/2000/svg"); if (!elementName.isInterned()) { popName = checkPopName(popName); } // ]NOCPP] T elt; StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes // CPPONLY: , svgCreator(elementName.getSvgCreator()) ); } else { elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node // CPPONLY: , svgCreator(elementName.getSvgCreator()) ); appendElement(elt, current.node); } elementPushed("http://www.w3.org/2000/svg", popName, elt); elementPopped("http://www.w3.org/2000/svg", popName, elt); }
needToDropLF = false; starttagloop: for (;;) { int group = elementName.getGroup(); @Local String name = elementName.getName(); if (isInForeign()) { StackNode<T> currentNode = stack[currentPtr]; case FONT: reconstructTheActiveFormattingElements(); maybeForgetEarlierDuplicateFormattingElement(elementName.getName(), attributes); appendToCurrentNodeAndPushFormattingElementMayFoster( elementName,
if (other.tagName == null) { tagName = null; } else if (other.tagName.isInterned()) { tagName = other.tagName; } else { nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner)
@Inline static ElementName elementNameByBuffer(@NoLength char[] buf, int length, Interner interner) { @Unsigned int hash = ElementName.bufToHash(buf, length); int[] hashes; hashes = ElementName.ELEMENT_HASHES; int index = levelOrderBinarySearch(hashes, hash); if (index < 0) { return null; } else { ElementName elementName = ElementName.ELEMENT_NAMES[index]; @Local String name = elementName.name; if (!Portability.localEqualsBuffer(name, buf, length)) { return null; } return elementName; } }
private void appendToCurrentNodeAndPushElementMayFoster(ElementName elementName, HtmlAttributes attributes, T form) throws SAXException { // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/1999/xhtml"); // ]NOCPP] // Can't be called for custom elements T elt; T formOwner = form == null || fragment || isTemplateContents() ? null : form; StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, formOwner // CPPONLY: , htmlCreator(elementName.getHtmlCreator()) ); } else { elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, formOwner, current.node // CPPONLY: , htmlCreator(elementName.getHtmlCreator()) ); appendElement(elt, current.node); } StackNode<T> node = createStackNode(elementName, elt // [NOCPP[ , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer) // ]NOCPP] ); push(node); }
elementName.getCamelCaseName(), elt elementName.getName(), false
private void endTagExpectationToArray() { switch (endTagExpectation.getGroup()) { case TreeBuilder.TITLE: endTagExpectationAsArray = TITLE_ARR;
private void strBufToElementNameString() { // if (strBufOffset != -1) { // return ElementName.elementNameByBuffer(buf, strBufOffset, strBufLen); // } else { tagName = ElementName.elementNameByBuffer(strBuf, 0, strBufLen, interner); // } }
public Tokenizer(TokenHandler tokenHandler, boolean newAttributesEachTime) { this.tokenHandler = tokenHandler; this.encodingDeclarationHandler = null; this.newAttributesEachTime = newAttributesEachTime; // ∳ is the longest valid char ref and // the semicolon never gets appended to the buffer. this.charRefBuf = new char[32]; this.bmpChar = new char[1]; this.astralChar = new char[2]; this.containsHyphen = false; this.tagName = null; this.nonInternedTagName = new ElementName(); this.attributeName = null; // CPPONLY: this.nonInternedAttributeName = new AttributeName(); this.doctypeName = null; this.publicIdentifier = null; this.systemIdentifier = null; this.attributes = null; }
/** * The common-case HTML constructor. * * @param elementName * @param node * @param popName */ StackNode(ElementName elementName, T node, @Local String popName // [NOCPP[ , TaintableLocatorImpl locator // ]NOCPP] ) { this.flags = elementName.getFlags(); this.name = elementName.name; this.popName = popName; this.ns = "http://www.w3.org/1999/xhtml"; this.node = node; this.attributes = null; this.refcount = 1; // [NOCPP[ this.locator = locator; // ]NOCPP] }
if (other.tagName == null) { tagName = null; } else if (other.tagName.isInterned()) { tagName = other.tagName; } else {
public void end() throws SAXException { strBuf = null; doctypeName = null; if (systemIdentifier != null) { Portability.releaseString(systemIdentifier); systemIdentifier = null; } if (publicIdentifier != null) { Portability.releaseString(publicIdentifier); publicIdentifier = null; } tagName = null; nonInternedTagName.setNameForNonInterned(null // CPPONLY: , false ); attributeName = null; // CPPONLY: nonInternedAttributeName.setNameForNonInterned(null); tokenHandler.endTokenization(); if (attributes != null) { // [NOCPP[ attributes = null; // ]NOCPP] // CPPONLY: attributes.clear(mappingLangToXmlLang); } }
private void appendVoidElementToCurrentMayFoster( ElementName elementName, HtmlAttributes attributes) throws SAXException { @Local String popName = elementName.getName(); // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/1999/xhtml"); if (!elementName.isInterned()) { popName = checkPopName(popName); } // ]NOCPP] T elt; StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes // CPPONLY: , htmlCreator(elementName.getHtmlCreator()) ); } else { elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node // CPPONLY: , htmlCreator(elementName.getHtmlCreator()) ); appendElement(elt, current.node); } elementPushed("http://www.w3.org/1999/xhtml", popName, elt); elementPopped("http://www.w3.org/1999/xhtml", popName, elt); }
/** * The common-case HTML setter. * * @param elementName * @param node * @param popName */ void setValues(ElementName elementName, T node, @Local String popName // [NOCPP[ , TaintableLocatorImpl locator // ]NOCPP] ) { assert isUnused(); this.flags = elementName.getFlags(); this.name = elementName.getName(); this.popName = popName; this.ns = "http://www.w3.org/1999/xhtml"; this.node = node; this.attributes = null; this.refcount = 1; /* * Not used for formatting elements, so no need to track creator. */ // CPPONLY: this.htmlCreator = null; // [NOCPP[ this.locator = locator; // ]NOCPP] }