void ElementShadow::addShadowRoot(Element* shadowHost, PassRefPtr<ShadowRoot> shadowRoot, ShadowRoot::ShadowRootType type, ExceptionCode& ec) { ASSERT(shadowHost); ASSERT(shadowRoot); if (!validateShadowRoot(shadowHost->document(), shadowRoot.get(), ec)) return; if (type == ShadowRoot::AuthorShadowRoot) shadowHost->willAddAuthorShadowRoot(); shadowRoot->setHost(shadowHost); shadowRoot->setParentTreeScope(shadowHost->treeScope()); m_shadowRoots.push(shadowRoot.get()); m_distributor.didShadowBoundaryChange(shadowHost); ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get()); // Existence of shadow roots requires the host and its children to do traversal using ComposedShadowTreeWalker. shadowHost->setNeedsShadowTreeWalker(); // FIXME(94905): ShadowHost should be reattached during recalcStyle. // Set some flag here and recreate shadow hosts' renderer in // Element::recalcStyle. if (shadowHost->attached()) shadowHost->lazyReattach(); InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); }
void ShadowTree::addShadowRoot(Element* shadowHost, PassRefPtr<ShadowRoot> shadowRoot, ExceptionCode& ec) { ASSERT(shadowHost); ASSERT(shadowRoot); if (!validateShadowRoot(shadowHost->document(), shadowRoot.get(), ec)) return; shadowRoot->setShadowHost(shadowHost); ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get()); if (shadowHost->attached()) { shadowRoot->lazyAttach(); detach(); shadowHost->detachChildren(); } m_shadowRoots.push(shadowRoot.get()); InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); }