本文整理汇总了C++中ShadowRoot类的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot类的具体用法?C++ ShadowRoot怎么用?C++ ShadowRoot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShadowRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toShadowRoot
inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const
{
Node* parent = node->parentNode();
if (!parent)
return 0;
if (!parent->isShadowRoot())
return parent;
ShadowRoot* shadowRoot = toShadowRoot(parent);
ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
if (!shadowRoot->isYoungest())
return 0;
return shadowRoot->host();
}
示例2: shadowRoot
Node::InsertionNotificationRequest HTMLContentElement::insertedInto(ContainerNode* insertionPoint)
{
InsertionPoint::insertedInto(insertionPoint);
if (insertionPoint->inDocument() && isActive()) {
ShadowRoot* root = shadowRoot();
root->registerContentElement();
root->owner()->setShouldCollectSelectFeatureSet();
m_registeredWithShadowRoot = true;
}
return InsertionDone;
}
示例3: authorShadowRootOf
// FIXME: Move the following helper functions, authorShadowRootOf, firstWithinTraversingShadowTree,
// nextTraversingShadowTree to the best place, e.g. NodeTraversal.
static ShadowRoot* authorShadowRootOf(const ContainerNode& node)
{
if (!node.isElementNode() || !isShadowHost(&node))
return nullptr;
ElementShadow* shadow = toElement(node).shadow();
ASSERT(shadow);
for (ShadowRoot* shadowRoot = shadow->oldestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot()) {
if (shadowRoot->type() == ShadowRootType::OpenByDefault || shadowRoot->type() == ShadowRootType::Open)
return shadowRoot;
}
return nullptr;
}
示例4: setNeedsStyleRecalcForViewportUnits
void TreeScope::setNeedsStyleRecalcForViewportUnits() {
for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::nextIncludingPseudo(*element)) {
for (ShadowRoot* root = element->youngestShadowRoot(); root;
root = root->olderShadowRoot())
root->setNeedsStyleRecalcForViewportUnits();
const ComputedStyle* style = element->computedStyle();
if (style && style->hasViewportUnits())
element->setNeedsStyleRecalc(LocalStyleChange,
StyleChangeReasonForTracing::create(
StyleChangeReason::ViewportUnits));
}
}
示例5: ASSERT
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);
}
示例6: host
void ShadowRoot::removedFrom(ContainerNode* insertionPoint)
{
if (insertionPoint->inDocument() && m_registeredWithParentShadowRoot) {
ShadowRoot* root = host()->containingShadowRoot();
if (!root)
root = insertionPoint->containingShadowRoot();
if (root)
root->removeChildShadowRoot();
m_registeredWithParentShadowRoot = false;
}
DocumentFragment::removedFrom(insertionPoint);
}
示例7: toShadowRoot
ContainerNode* ComposedTreeTraversal::traverseParentOrHost(const Node& node)
{
ContainerNode* parent = node.parentNode();
if (!parent)
return nullptr;
if (!parent->isShadowRoot())
return parent;
ShadowRoot* shadowRoot = toShadowRoot(parent);
ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
if (!shadowRoot->isYoungest())
return nullptr;
return shadowRoot->host();
}
示例8: host
void ShadowRoot::removedFrom(ContainerNode* insertionPoint)
{
ShadowRoot* root = host()->containingShadowRoot();
if (!root)
root = insertionPoint->containingShadowRoot();
if (root)
root->removeChildShadowRoot();
if (inActiveDocument())
document().styleEngine()->removeTreeScope(*this);
DocumentFragment::removedFrom(insertionPoint);
}
示例9: ASSERT
void ShadowTree::attach()
{
// Children of m_selector is populated lazily in
// ensureSelector(), and here we just ensure that it is in clean state.
ASSERT(!selector().hasPopulated());
selector().willSelect();
for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
if (!root->attached())
root->attach();
}
selector().didSelect();
}
示例10: ASSERT
Node* ComposedTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, TraversalDirection direction)
{
ASSERT(node);
if (node->parentNode() && node->parentNode()->isShadowRoot()) {
ShadowRoot* parentShadowRoot = toShadowRoot(node->parentNode());
if (!parentShadowRoot->isYoungest()) {
HTMLShadowElement* assignedInsertionPoint = parentShadowRoot->shadowInsertionPointOfYoungerShadowRoot();
ASSERT(assignedInsertionPoint);
return traverseSiblingInCurrentTree(assignedInsertionPoint, direction);
}
}
return 0;
}
示例11: ASSERT
Node* ComposedShadowTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, TraversalDirection direction)
{
ASSERT(node);
if (node->parentNode() && node->parentNode()->isShadowRoot()) {
ShadowRoot* parentShadowRoot = toShadowRoot(node->parentNode());
if (!parentShadowRoot->isYoungest()) {
InsertionPoint* assignedInsertionPoint = ScopeContentDistribution::assignedTo(parentShadowRoot);
ASSERT(assignedInsertionPoint);
return traverseSiblingInCurrentTree(assignedInsertionPoint, direction);
}
}
return 0;
}
示例12: containingShadowRoot
ShadowRoot* HTMLShadowElement::olderShadowRoot()
{
ShadowRoot* containingRoot = containingShadowRoot();
if (!containingRoot)
return 0;
ContentDistributor::ensureDistribution(containingRoot);
ShadowRoot* older = containingRoot->olderShadowRoot();
if (!older || older->type() != ShadowRoot::AuthorShadowRoot || ScopeContentDistribution::assignedTo(older) != this)
return 0;
return older;
}
示例13: shouldBypassMainWorldCSP
static bool shouldBypassMainWorldCSP(Element* element)
{
// Main world CSP is bypassed within an isolated world.
LocalFrame* frame = element->document().frame();
if (frame && frame->script().shouldBypassMainWorldCSP())
return true;
// Main world CSP is bypassed for style elements in user agent shadow DOM.
ShadowRoot* root = element->containingShadowRoot();
if (root && root->type() == ShadowRootType::UserAgent)
return true;
return false;
}
示例14: attachShadowRoot
static void attachShadowRoot(ShadowRoot& shadowRoot)
{
if (shadowRoot.attached())
return;
StyleResolver& styleResolver = shadowRoot.document().ensureStyleResolver();
styleResolver.pushParentShadowRoot(&shadowRoot);
attachChildren(shadowRoot);
styleResolver.popParentShadowRoot(&shadowRoot);
shadowRoot.clearNeedsStyleRecalc();
shadowRoot.setAttached(true);
}
示例15: TEST
TEST(TreeScopeTest, CommonAncestorOfInclusiveTrees) {
// document
// | : Common ancestor is document.
// shadowRoot
Document* document = Document::create();
Element* html = document->createElement("html", StringOrDictionary());
document->appendChild(html);
ShadowRoot* shadowRoot =
html->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
EXPECT_EQ(document, document->commonAncestorTreeScope(*shadowRoot));
EXPECT_EQ(document, shadowRoot->commonAncestorTreeScope(*document));
}