static bool wasInShadowTreeBeforeInserted(HTMLSlotElement& slot,
                                          ContainerNode& insertionPoint) {
  ShadowRoot* root1 = slot.containingShadowRoot();
  ShadowRoot* root2 = insertionPoint.containingShadowRoot();
  if (root1 && root2 && root1 == root2)
    return false;
  return root1;
}
Exemple #2
0
void HTMLSlotElement::removedFrom(ContainerNode& insertionPoint)
{
    // ContainerNode::removeBetween always sets the removed child's tree scope to Document's but InShadowRoot flag is unset in Node::removedFrom.
    // So if InShadowRoot flag is set but this element's tree scope is Document's, this element has just been removed from a shadow root.
    if (insertionPoint.isInShadowTree() && isInShadowTree() && &treeScope() == &document()) {
        auto* oldShadowRoot = insertionPoint.containingShadowRoot();
        ASSERT(oldShadowRoot);
        oldShadowRoot->removeSlotElementByName(attributeWithoutSynchronization(nameAttr), *this);
    }

    HTMLElement::removedFrom(insertionPoint);
}
static Node* determineScopingNodeForStyleScoped(HTMLStyleElement* ownerElement, StyleSheetContents* styleSheetContents)
{
    ASSERT(ownerElement && ownerElement->isRegisteredAsScoped());

    if (ownerElement->isInShadowTree()) {
        if (hasDistributedRule(styleSheetContents)) {
            ContainerNode* scope = ownerElement;
            do {
                scope = scope->containingShadowRoot()->shadowHost();
            } while (scope->isInShadowTree());

            return scope;
        }
        if (ownerElement->isRegisteredAsScoped())
            return ownerElement->containingShadowRoot()->shadowHost();
    }

    return ownerElement->isRegisteredInShadowRoot() ? ownerElement->containingShadowRoot()->shadowHost() : ownerElement->parentNode();
}
void HTMLFormControlElementWithState::removedFrom(ContainerNode& insertionPoint)
{
    if (insertionPoint.inDocument() && !containingShadowRoot() && !insertionPoint.containingShadowRoot())
        document().formController().unregisterFormElementWithState(this);
    HTMLFormControlElement::removedFrom(insertionPoint);
}