StackNode<T> node = listOfActiveFormattingElements[i]; if (node != null) { StackNode<T> newNode = new StackNode<T>(-1); newNode.setValues(node.getFlags(), node.ns, node.name, node.node, node.popName, node.attributes.cloneAttributes(null) , node.getLocator() int listIndex = findInListOfActiveFormattingElements(node); if (listIndex == -1) { StackNode<T> newNode = new StackNode<T>(-1); newNode.setValues(node.getFlags(), node.ns, node.name, node.node, node.popName, null , node.getLocator() } else { stackCopy[i] = listCopy[listIndex]; stackCopy[i].retain();
private boolean isSpecialParentInForeign(StackNode<T> stackNode) { @NsUri String ns = stackNode.ns; return ("http://www.w3.org/1999/xhtml" == ns) || (stackNode.isHtmlIntegrationPoint()) || (("http://www.w3.org/1998/Math/MathML" == ns) && (stackNode.getGroup() == MI_MO_MN_MS_MTEXT)); }
@SuppressWarnings("unchecked") private StackNode<T> getUnusedStackNode() { // Search for an unused stack node. while (stackNodesIdx < numStackNodes) { if (stackNodes[stackNodesIdx].isUnused()) { return stackNodes[stackNodesIdx++]; } stackNodesIdx++; } if (stackNodesIdx < stackNodes.length) { // No unused stack nodes, but there is still space in the storage array. stackNodes[stackNodesIdx] = new StackNode<T>(stackNodesIdx); numStackNodes++; return stackNodes[stackNodesIdx++]; } // Could not find an unused stack node and storage array is full. StackNode<T>[] newStack = new StackNode[stackNodes.length + 64]; System.arraycopy(stackNodes, 0, newStack, 0, stackNodes.length); stackNodes = newStack; // Create a new stack node and return it. stackNodes[stackNodesIdx] = new StackNode<T>(stackNodesIdx); numStackNodes++; return stackNodes[stackNodesIdx++]; }
} else if (node.isScoping()) { inScope = false; if (node.isSpecial()) { break; T clone = createElement("http://www.w3.org/1999/xhtml", node.name, node.attributes.cloneAttributes(null)); StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns, node.name, clone, node.popName, node.attributes , node.getLocator() node.dropAttributes(); // adopt ownership to newNode stack[nodePos] = newNode; newNode.retain(); // retain for list listOfActiveFormattingElements[nodeListPos] = newNode; node.release(); // release from stack node.release(); // release from list node = newNode; if (commonAncestor.isFosterParenting()) { fatal(); detachFromParent(lastNode.node); formattingElt.name, formattingElt.attributes.cloneAttributes(null)); StackNode<T> formattingClone = new StackNode<T>( formattingElt.getFlags(), formattingElt.ns,
T clone = createElement("http://www.w3.org/1999/xhtml", entry.name, entry.attributes.cloneAttributes(null)); StackNode<T> entryClone = new StackNode<T>(entry.getFlags(), entry.ns, entry.name, clone, entry.popName, entry.attributes , entry.getLocator() entry.dropAttributes(); // transfer ownership to entryClone StackNode<T> currentNode = stack[currentPtr]; if (currentNode.isFosterParenting()) { insertIntoFosterParent(clone); } else { entry.release(); entryClone.retain();
StackNode<T> currentNode = stack[currentPtr]; @NsUri String currNs = currentNode.ns; if (!(currentNode.isHtmlIntegrationPoint() || (currNs == "http://www.w3.org/1998/Math/MathML" && ((currentNode.getGroup() == MI_MO_MN_MS_MTEXT && group != MGLYPH_OR_MALIGNMARK) || (currentNode.getGroup() == ANNOTATION_XML && group == SVG))))) { switch (group) { case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U: case TBODY_OR_THEAD_OR_TFOOT: eltPos = findLastInTableScopeOrRootTemplateTbodyTheadTfoot(); if (eltPos == 0 || stack[eltPos].getGroup() == TEMPLATE) { assert fragment || isTemplateContents(); errStrayStartTag(name); case FRAMESET: if (mode == FRAMESET_OK) { if (currentPtr == 0 || stack[1].getGroup() != BODY) { assert fragment || isTemplateContents(); errStrayStartTag(name); if (currentPtr == 0 || stack[1].getGroup() != BODY || isTemplateContents()) { assert fragment || isTemplateContents(); errStrayStartTag(name); case H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6: implicitlyCloseP(); if (stack[currentPtr].getGroup() == H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6) { errHeadingWhenHeadingOpen(); pop(); if (node.getGroup() == group) { // LI or
private void appendVoidElementToCurrentMayFoster( @Local String name, 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 = createElement("http://www.w3.org/1999/xhtml", name, attributes, fragment ? null : form); StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); insertIntoFosterParent(elt); } else { appendElement(elt, current.node); } elementPushed("http://www.w3.org/1999/xhtml", name, elt); elementPopped("http://www.w3.org/1999/xhtml", name, elt); }
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 = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, fragment ? null : form); StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); insertIntoFosterParent(elt); } else { appendElement(elt, current.node); } StackNode<T> node = new StackNode<T>(elementName, elt // [NOCPP[ , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer) // ]NOCPP] ); push(node); }
private void appendToCurrentNodeAndPushFormattingElementMayFoster( ElementName elementName, HtmlAttributes attributes) throws SAXException { // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/1999/xhtml"); // ]NOCPP] // This method can't be called for custom elements T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes); StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); insertIntoFosterParent(elt); } else { appendElement(elt, current.node); } StackNode<T> node = new StackNode<T>(elementName, elt, attributes.cloneAttributes(null) // [NOCPP[ , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer) // ]NOCPP] ); push(node); append(node); node.retain(); // append doesn't retain itself }
/** * Reports the name and location of an unclosed element. * * @throws SAXException */ private final void reportUnclosedElementNameAndLocation(int pos) throws SAXException { StackNode<T> node = stack[pos]; if (node.isOptionalEndTag()) { return; } TaintableLocatorImpl locator = node.getLocator(); if (locator.isTainted()) { return; } locator.markTainted(); SAXParseException spe = new SAXParseException( "Unclosed element \u201C" + node.popName + "\u201D.", locator); errorHandler.error(spe); }
case TABLE: eltPos = findLastInTableScopeOrRootTemplateTbodyTheadTfoot(); if (eltPos == 0 || stack[eltPos].getGroup() == TEMPLATE) { assert fragment || isTemplateContents(); errStrayEndTag(name); if (errorHandler != null) { uncloseloop1: for (int i = 2; i <= currentPtr; i++) { switch (stack[i].getGroup()) { case DD_OR_DT: case LI: switch (stack[i].getGroup()) { case DD_OR_DT: case LI: } else if (eltPos == 0 || node.isSpecial()) { errStrayEndTag(name); break endtagloop; switch (group) { case COLGROUP: if (currentPtr == 0 || stack[currentPtr].getGroup() == TreeBuilder.TEMPLATE) { assert fragment || isTemplateContents(); break endtagloop; default: if (currentPtr == 0 || stack[currentPtr].getGroup() ==
private int findLastInListScope(@Local String name) { for (int i = currentPtr; i > 0; i--) { if (stack[i].name == name) { return i; } else if (stack[i].isScoping() || stack[i].name == "ul" || stack[i].name == "ol") { return TreeBuilder.NOT_FOUND_ON_STACK; } } return TreeBuilder.NOT_FOUND_ON_STACK; }
if (current.isFosterParenting()) { fatal(); elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes push(node); append(node); node.retain(); // append doesn't retain itself
private void pushHeadPointerOntoStack() throws SAXException { assert headPointer != null; assert !fragment; assert mode == AFTER_HEAD; fatal(); silentPush(new StackNode<T>(ElementName.HEAD, headPointer // [NOCPP[ , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer) // ]NOCPP] )); }
} else if (node.isScoping()) { inScope = false; if (node.isSpecial()) { break; StackNode<T> newNode = createStackNode(node.getFlags(), node.ns, node.name, clone, node.popName, node.attributes , node.getLocator() node.dropAttributes(); // adopt ownership to newNode stack[nodePos] = newNode; newNode.retain(); // retain for list listOfActiveFormattingElements[nodeListPos] = newNode; node.release(this); // release from stack node.release(this); // release from list node = newNode; if (commonAncestor.isFosterParenting()) { fatal(); detachFromParent(lastNode.node); formattingElt.getFlags(), formattingElt.ns, formattingElt.name, clone, formattingElt.popName, formattingElt.attributes formattingElt.dropAttributes(); // transfer ownership to
if (currentNode.isFosterParenting()) { clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name, entry.attributes.cloneAttributes(null) StackNode<T> entryClone = createStackNode(entry.getFlags(), entry.ns, entry.name, clone, entry.popName, entry.attributes , entry.getLocator() entry.dropAttributes(); // transfer ownership to entryClone entry.release(this); entryClone.retain();
StackNode<T> currentNode = stack[currentPtr]; @NsUri String currNs = currentNode.ns; if (!(currentNode.isHtmlIntegrationPoint() || (currNs == "http://www.w3.org/1998/Math/MathML" && ((currentNode.getGroup() == MI_MO_MN_MS_MTEXT && group != MGLYPH_OR_MALIGNMARK) || (currentNode.getGroup() == ANNOTATION_XML && group == SVG))))) { switch (group) { case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U: case FRAMESET: if (mode == FRAMESET_OK) { if (currentPtr == 0 || stack[1].getGroup() != BODY) { assert fragment; errStrayStartTag(name); case BODY: if (currentPtr == 0 || stack[1].getGroup() != BODY) { assert fragment; errStrayStartTag(name); case H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6: implicitlyCloseP(); if (stack[currentPtr].getGroup() == H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6) { errHeadingWhenHeadingOpen(); pop(); if (node.getGroup() == group) { // LI or } else if (node.isScoping() || (node.isSpecial() && node.name != "p"
private void appendVoidElementToCurrentMayFoster( ElementName elementName, HtmlAttributes attributes) throws SAXException { @Local String popName = elementName.name; // [NOCPP[ checkAttributes(attributes, "http://www.w3.org/1999/xhtml"); if (elementName.isCustom()) { popName = checkPopName(popName); } // ]NOCPP] T elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes); StackNode<T> current = stack[currentPtr]; if (current.isFosterParenting()) { fatal(); insertIntoFosterParent(elt); } else { appendElement(elt, current.node); } elementPushed("http://www.w3.org/1999/xhtml", popName, elt); elementPopped("http://www.w3.org/1999/xhtml", popName, elt); }