本文整理汇总了C++中ShadowRoot::commonAncestorTreeScope方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot::commonAncestorTreeScope方法的具体用法?C++ ShadowRoot::commonAncestorTreeScope怎么用?C++ ShadowRoot::commonAncestorTreeScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadowRoot
的用法示例。
在下文中一共展示了ShadowRoot::commonAncestorTreeScope方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringOrDictionary
TEST(TreeScopeTest, CommonAncestorOfTreesAtDifferentDepths) {
// document
// / \ : Common ancestor is document.
// Y B
// /
// A
Document* document = Document::create();
Element* html = document->createElement("html", StringOrDictionary());
document->appendChild(html);
Element* head = document->createElement("head", StringOrDictionary());
html->appendChild(head);
Element* body = document->createElement("body", StringOrDictionary());
html->appendChild(body);
ShadowRoot* shadowRootY =
head->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
ShadowRoot* shadowRootB =
body->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
Element* divInY = document->createElement("div", StringOrDictionary());
shadowRootY->appendChild(divInY);
ShadowRoot* shadowRootA =
divInY->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
EXPECT_EQ(document, shadowRootA->commonAncestorTreeScope(*shadowRootB));
EXPECT_EQ(document, shadowRootB->commonAncestorTreeScope(*shadowRootA));
}
示例2:
TEST(TreeScopeTest, CommonAncestorOfSiblingTrees)
{
// document
// / \ : Common ancestor is document.
// A B
Document* document = Document::create();
Element* html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION);
document->appendChild(html, ASSERT_NO_EXCEPTION);
Element* head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION);
html->appendChild(head);
Element* body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION);
html->appendChild(body);
ShadowRoot* shadowRootA = head->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
ShadowRoot* shadowRootB = body->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
EXPECT_EQ(document, shadowRootA->commonAncestorTreeScope(*shadowRootB));
EXPECT_EQ(document, shadowRootB->commonAncestorTreeScope(*shadowRootA));
}