当前位置: 首页>>代码示例>>C++>>正文


C++ ShadowRoot::commonAncestorTreeScope方法代码示例

本文整理汇总了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));
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例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));
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:20,代码来源:TreeScopeTest.cpp


注:本文中的ShadowRoot::commonAncestorTreeScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。