Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/nu/validator/htmlparser/impl/TreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4597,17 +4597,29 @@ private boolean adoptionAgencyEndTag(@Local String name) throws SAXException {
node.release(this); // release from list
node = newNode;
// } XXX AAA CHANGE
// When the sanitizer replaces the clone with its children,
// the spec does not move lastNode into it, so that lastNode
// keeps both its position and its identity, and redirects the
// content of the clone to the common ancestor instead.
// CPPONLY: if (!sanitizerRedirectsClone(node.node, insertionCommonAncestor)) {
detachFromParent(lastNode.node);
appendElement(lastNode.node, nodeFromStackWithBlinkCompat(nodePos));
lastNode = node;
// CPPONLY: }
}
// If we insert into a foster parent, for simplicity, we insert
// accoding to the spec without Blink's depth limit.
if (commonAncestor.isFosterParenting()) {
fatal();
detachFromParent(lastNode.node);
insertIntoFosterParent(lastNode.node);
insertIntoFosterParent(lastNode.node
// CPPONLY: , furthestBlock.node
);
} else {
// The content of a furthest block that the sanitizer replaced
// with its children follows the content it already has, so it
// goes wherever lastNode goes.
// CPPONLY: sanitizerRedirectFurthestBlock(furthestBlock.node, insertionCommonAncestor);
detachFromParent(lastNode.node);
appendElement(lastNode.node, insertionCommonAncestor);
}
Expand Down Expand Up @@ -4955,16 +4967,20 @@ private StackNode<T> createStackNode(ElementName elementName, T node, @Local Str
return instance;
}

private void insertIntoFosterParent(T child) throws SAXException {
private void insertIntoFosterParent(T child
// CPPONLY: , T furthestBlock
) throws SAXException {
int tablePos = findLastOrRoot(TreeBuilder.TABLE);
int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);

if (templatePos >= tablePos) {
// CPPONLY: sanitizerRedirectFurthestBlock(furthestBlock, stack[templatePos].node);
appendElement(child, stack[templatePos].node);
return;
}

StackNode<T> node = stack[tablePos];
// CPPONLY: sanitizerRedirectFurthestBlockToFosterParent(furthestBlock, node.node, stack[tablePos - 1].node);
insertFosterParentedChild(child, node.node, stack[tablePos - 1].node);
}

Expand Down Expand Up @@ -5293,14 +5309,18 @@ private void appendToCurrentNodeAndPushTemplateElement(HtmlAttributes attributes
// This method can't be called for custom elements
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
// All accesses to `attributes` must happen before `createElement`.
// The sanitizer runs on the token first, so that the attributes read
// below are the ones the template element ends up with.
boolean sanitizerDropsTemplate = false;
// CPPONLY: sanitizerDropsTemplate = sanitizerDropsTemplateToken(attributes);
String shadowRootMode = null;
boolean shadowRootIsClonable = false;
boolean shadowRootIsSerializable = false;
boolean shadowRootDelegatesFocus = false;
boolean shadowRootCustomElementRegistry = false;
String shadowRootReferenceTarget = null;
String shadowRootSlotAssignment = null;
if (isAllowDeclarativeShadowRoots()) {
if (isAllowDeclarativeShadowRoots() && !sanitizerDropsTemplate) {
shadowRootMode = Portability.newStringFromString(attributes.getValue(AttributeName.SHADOWROOTMODE));
if (shadowRootMode != null) {
shadowRootIsClonable = attributes.contains(AttributeName.SHADOWROOTCLONABLE);
Expand Down
Loading