void ShadowTree::removeAllShadowRoots() { if (!hasShadowRoot()) return; // Dont protect this ref count. Element* shadowHost = host(); while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.removeHead()) { InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); shadowHost->document()->removeFocusedNodeOfSubtree(oldRoot.get()); if (oldRoot->attached()) oldRoot->detach(); oldRoot->setShadowHost(0); oldRoot->setPrev(0); oldRoot->setNext(0); shadowHost->document()->adoptIfNeeded(oldRoot.get()); ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get()); } if (shadowHost->attached()) shadowHost->attachChildrenLazily(); }
void HTMLProgressElement::createShadowSubtree() { ASSERT(!hasShadowRoot()); RefPtr<ProgressBarElement> bar = ProgressBarElement::create(document()); m_value = ProgressValueElement::create(document()); bar->appendChild(m_value, ASSERT_NO_EXCEPTION); RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION); root->appendChild(bar, ASSERT_NO_EXCEPTION); }
void SVGTRefElement::updateReferencedText() { String textContent; if (Element* target = SVGURIReference::targetElementFromIRIString(href(), document())) textContent = target->textContent(); ASSERT(hasShadowRoot()); ShadowRoot* root = shadowTree()->oldestShadowRoot(); if (!root->firstChild()) root->appendChild(SVGShadowText::create(document(), textContent), ASSERT_NO_EXCEPTION); else root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION); }
void SVGTRefElement::detachTarget() { // Remove active listeners and clear the text content. clearEventListener(); String emptyContent; ExceptionCode ignore = 0; ASSERT(hasShadowRoot()); Node* container = shadowTree()->oldestShadowRoot()->firstChild(); if (container) container->setTextContent(emptyContent, ignore); // Mark the referenced ID as pending. String id; SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!hasPendingResources() && !id.isEmpty()) document()->accessSVGExtensions()->addPendingResource(id, this); }
void HTMLTextAreaElement::createShadowSubtree() { ASSERT(!hasShadowRoot()); RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot); root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO_EXCEPTION); }
ShadowTree::~ShadowTree() { if (hasShadowRoot()) removeAllShadowRoots(); }