本文整理汇总了C++中ShadowRoot::appendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot::appendChild方法的具体用法?C++ ShadowRoot::appendChild怎么用?C++ ShadowRoot::appendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadowRoot
的用法示例。
在下文中一共展示了ShadowRoot::appendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createShadowSubtree
void TextFieldInputType::createShadowSubtree()
{
ASSERT(element().shadow());
ShadowRoot* shadowRoot = element().userAgentShadowRoot();
ASSERT(!shadowRoot->hasChildren());
Document& document = element().document();
bool shouldHaveSpinButton = this->shouldHaveSpinButton();
bool shouldHaveDataListIndicator = element().hasValidDataListOptions();
bool createsContainer = shouldHaveSpinButton || shouldHaveDataListIndicator || needsContainer();
RefPtrWillBeRawPtr<TextControlInnerEditorElement> innerEditor = TextControlInnerEditorElement::create(document);
if (!createsContainer) {
shadowRoot->appendChild(innerEditor.release());
return;
}
RefPtrWillBeRawPtr<TextControlInnerContainer> container = TextControlInnerContainer::create(document);
container->setShadowPseudoId(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
shadowRoot->appendChild(container);
RefPtrWillBeRawPtr<EditingViewPortElement> editingViewPort = EditingViewPortElement::create(document);
editingViewPort->appendChild(innerEditor.release());
container->appendChild(editingViewPort.release());
if (shouldHaveDataListIndicator)
container->appendChild(DataListIndicatorElement::create(document));
// FIXME: Because of a special handling for a spin button in
// LayoutTextControlSingleLine, we need to put it to the last position. It's
// inconsistent with multiple-fields date/time types.
if (shouldHaveSpinButton)
container->appendChild(SpinButtonElement::create(document, *this));
// See listAttributeTargetChanged too.
}
示例2: didAddClosedShadowRoot
void HTMLSummaryElement::didAddClosedShadowRoot(ShadowRoot& root)
{
RefPtrWillBeRawPtr<DetailsMarkerControl> markerControl = DetailsMarkerControl::create(document());
markerControl->setIdAttribute(ShadowElementNames::detailsMarker());
root.appendChild(markerControl);
root.appendChild(HTMLContentElement::create(document()));
}
示例3: didAddUserAgentShadowRoot
void HTMLOptGroupElement::didAddUserAgentShadowRoot(ShadowRoot& root) {
DEFINE_STATIC_LOCAL(AtomicString, labelPadding, ("0 2px 1px 2px"));
DEFINE_STATIC_LOCAL(AtomicString, labelMinHeight, ("1.2em"));
HTMLDivElement* label = HTMLDivElement::create(document());
label->setAttribute(roleAttr, AtomicString("group"));
label->setAttribute(aria_labelAttr, AtomicString());
label->setInlineStyleProperty(CSSPropertyPadding, labelPadding);
label->setInlineStyleProperty(CSSPropertyMinHeight, labelMinHeight);
label->setIdAttribute(ShadowElementNames::optGroupLabel());
root.appendChild(label);
HTMLContentElement* content = HTMLContentElement::create(document());
content->setAttribute(selectAttr, "option,hr");
root.appendChild(content);
}
示例4: 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));
}
示例5: createShadowSubtree
void TextFieldInputType::createShadowSubtree()
{
ASSERT(element().shadowRoot());
ASSERT(!m_innerText);
ASSERT(!m_innerBlock);
ASSERT(!m_innerSpinButton);
Document& document = element().document();
bool shouldHaveSpinButton = this->shouldHaveSpinButton();
bool createsContainer = shouldHaveSpinButton || needsContainer();
m_innerText = TextControlInnerTextElement::create(document);
if (!createsContainer) {
element().userAgentShadowRoot()->appendChild(m_innerText, IGNORE_EXCEPTION);
return;
}
ShadowRoot* shadowRoot = element().userAgentShadowRoot();
m_container = TextControlInnerContainer::create(document);
m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
shadowRoot->appendChild(m_container, IGNORE_EXCEPTION);
m_innerBlock = TextControlInnerElement::create(document);
m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION);
m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION);
if (shouldHaveSpinButton) {
m_innerSpinButton = SpinButtonElement::create(document, *this);
m_container->appendChild(m_innerSpinButton, IGNORE_EXCEPTION);
}
}
示例6: createElementWithId
TEST_F(CustomElementUpgradeSorterTest, sorter_shadow) {
// A*
// + {ShadowRoot}
// | + B
// | + C*
// + D*
Element* a = createElementWithId("a-a", "a");
Element* b = createElementWithId("a-a", "b");
Element* c = createElementWithId("a-a", "c");
Element* d = createElementWithId("a-a", "d");
document()->documentElement()->appendChild(a);
ShadowRoot* s = attachShadowTo(a);
a->appendChild(d);
s->appendChild(b);
b->appendChild(c);
CustomElementUpgradeSorter sort;
sort.add(a);
sort.add(c);
sort.add(d);
HeapVector<Member<Element>> elements;
sort.sorted(&elements, document());
EXPECT_EQ(3u, elements.size());
EXPECT_EQ(a, elements[0].get());
EXPECT_EQ(c, elements[1].get());
EXPECT_EQ(d, elements[2].get());
}
示例7: didAddUserAgentShadowRoot
void HTMLMarqueeElement::didAddUserAgentShadowRoot(ShadowRoot& shadowRoot) {
Element* style = HTMLStyleElement::create(document(), false);
style->setTextContent(
":host { display: inline-block; overflow: hidden;"
"text-align: initial; white-space: nowrap; }"
":host([direction=\"up\"]), :host([direction=\"down\"]) { overflow: "
"initial; overflow-y: hidden; white-space: initial; }"
":host > div { will-change: transform; }");
shadowRoot.appendChild(style);
Element* mover = HTMLDivElement::create(document());
shadowRoot.appendChild(mover);
mover->appendChild(HTMLContentElement::create(document()));
m_mover = mover;
}
示例8: buildShadowAndInstanceTree
void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target)
{
ASSERT(!m_targetElementInstance);
ASSERT(!m_needsShadowTreeRecreation);
// <use> creates a "user agent" shadow root. Do not build the shadow/instance tree for <use>
// elements living in a user agent shadow tree because they will get expanded in a second
// pass -- see expandUseElementsInShadowTree().
if (inUseShadowTree())
return;
// Do not allow self-referencing.
// 'target' may be null, if it's a non SVG namespaced element.
if (!target || target == this || isDisallowedElement(target))
return;
// Set up root SVG element in shadow tree.
RefPtrWillBeRawPtr<Element> newChild = target->cloneElementWithoutChildren();
m_targetElementInstance = toSVGElement(newChild.get());
ShadowRoot* shadowTreeRootElement = userAgentShadowRoot();
shadowTreeRootElement->appendChild(newChild.release());
// Clone the target subtree into the shadow tree, not handling <use> and <symbol> yet.
// SVG specification does not say a word about <use> & cycles. My view on this is: just ignore it!
// Non-appearing <use> content is easier to debug, then half-appearing content.
if (!buildShadowTree(target, m_targetElementInstance.get(), false)) {
clearShadowTree();
return;
}
if (instanceTreeIsLoading(m_targetElementInstance.get()))
return;
// Assure shadow tree building was successfull
ASSERT(m_targetElementInstance);
ASSERT(m_targetElementInstance->correspondingUseElement() == this);
ASSERT(m_targetElementInstance->correspondingElement() == target);
// Expand all <use> elements in the shadow tree.
// Expand means: replace the actual <use> element by what it references.
if (!expandUseElementsInShadowTree(m_targetElementInstance.get())) {
clearShadowTree();
return;
}
// Expand all <symbol> elements in the shadow tree.
// Expand means: replace the actual <symbol> element by the <svg> element.
expandSymbolElementsInShadowTree(toSVGElement(shadowTreeRootElement->firstChild()));
m_targetElementInstance = toSVGElement(shadowTreeRootElement->firstChild());
transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get(), *m_targetElementInstance->correspondingElement());
ASSERT(m_targetElementInstance->parentNode() == shadowTreeRootElement);
// Update relative length information.
updateRelativeLengthsInformation();
}
示例9: didAddUserAgentShadowRoot
void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot& root)
{
DEFINE_STATIC_LOCAL(const AtomicString, summarySelector, ("summary:first-of-type", AtomicString::ConstructFromLiteral));
RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(document());
defaultSummary->appendChild(Text::create(document(), locale().queryString(blink::WebLocalizedString::DetailsLabel)));
RefPtr<HTMLContentElement> summary = HTMLContentElement::create(document());
summary->setIdAttribute(ShadowElementNames::detailsSummary());
summary->setAttribute(selectAttr, summarySelector);
summary->appendChild(defaultSummary);
root.appendChild(summary.release());
RefPtr<HTMLDivElement> content = HTMLDivElement::create(document());
content->setIdAttribute(ShadowElementNames::detailsContent());
content->appendChild(HTMLContentElement::create(document()));
content->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
root.appendChild(content.release());
}
示例10: updateReferencedText
void SVGTRefElement::updateReferencedText()
{
String textContent;
if (Element* target = SVGURIReference::targetElementFromIRIString(href(), document()))
textContent = target->textContent();
ASSERT(shadow());
ShadowRoot* root = shadow()->oldestShadowRoot();
if (!root->firstChild())
root->appendChild(SVGShadowText::create(document(), textContent), ASSERT_NO_EXCEPTION);
else
root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION);
}
示例11: didAddUserAgentShadowRoot
void HTMLMeterElement::didAddUserAgentShadowRoot(ShadowRoot& root)
{
ASSERT(!m_value);
RefPtrWillBeRawPtr<MeterInnerElement> inner = MeterInnerElement::create(document());
root.appendChild(inner);
RefPtrWillBeRawPtr<MeterBarElement> bar = MeterBarElement::create(document());
m_value = MeterValueElement::create(document());
m_value->setWidthPercentage(0);
m_value->updatePseudo();
bar->appendChild(m_value);
inner->appendChild(bar);
}
示例12: updateReferencedText
void SVGTRefElement::updateReferencedText(Element* target)
{
String textContent;
if (target)
textContent = target->textContent();
ASSERT(shadowRoot());
ShadowRoot* root = shadowRoot();
if (!root->firstChild())
root->appendChild(Text::create(document(), textContent), ASSERT_NO_EXCEPTION);
else {
ASSERT(root->firstChild()->isTextNode());
root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION);
}
}
示例13: destroyShadowSubtree
void InputType::destroyShadowSubtree()
{
ShadowRoot* root = element()->userAgentShadowRoot();
if (!root)
return;
root->removeAllChildren();
// It's ok to clear contents of all other ShadowRoots because they must have
// been created by TextFieldDecorationElement, and we don't allow adding
// AuthorShadowRoot to HTMLInputElement.
while ((root = root->youngerShadowRoot())) {
root->removeAllChildren();
root->appendChild(HTMLShadowElement::create(shadowTag, element()->document()));
}
}
示例14: createShadowSubtree
void TextFieldInputType::createShadowSubtree()
{
ASSERT(element()->hasShadowRoot());
ASSERT(!m_innerText);
ASSERT(!m_innerBlock);
ASSERT(!m_innerSpinButton);
Document* document = element()->document();
ChromeClient* chromeClient = document->page() ? document->page()->chrome()->client() : 0;
bool shouldAddDecorations = chromeClient && chromeClient->willAddTextFieldDecorationsTo(element());
bool shouldHaveSpinButton = this->shouldHaveSpinButton();
bool createsContainer = shouldHaveSpinButton || needsContainer() || shouldAddDecorations;
ExceptionCode ec = 0;
m_innerText = TextControlInnerTextElement::create(document);
if (!createsContainer) {
element()->shadowTree()->oldestShadowRoot()->appendChild(m_innerText, ec);
return;
}
ShadowRoot* shadowRoot = element()->shadowTree()->oldestShadowRoot();
m_container = HTMLDivElement::create(document);
m_container->setShadowPseudoId("-webkit-textfield-decoration-container");
shadowRoot->appendChild(m_container, ec);
m_innerBlock = TextControlInnerElement::create(document);
m_innerBlock->appendChild(m_innerText, ec);
m_container->appendChild(m_innerBlock, ec);
#if ENABLE(INPUT_SPEECH)
ASSERT(!m_speechButton);
if (element()->isSpeechEnabled()) {
m_speechButton = InputFieldSpeechButtonElement::create(document);
m_container->appendChild(m_speechButton, ec);
}
#endif
if (shouldHaveSpinButton) {
m_innerSpinButton = SpinButtonElement::create(document);
m_container->appendChild(m_innerSpinButton, ec);
}
if (shouldAddDecorations)
chromeClient->addTextFieldDecorationsTo(element());
}
示例15: didAddUserAgentShadowRoot
void HTMLKeygenElement::didAddUserAgentShadowRoot(ShadowRoot& root)
{
DEFINE_STATIC_LOCAL(AtomicString, keygenSelectPseudoId, ("-webkit-keygen-select", AtomicString::ConstructFromLiteral));
Vector<String> keys;
getSupportedKeySizes(locale(), keys);
// Create a select element with one option element for each key size.
RefPtr<HTMLSelectElement> select = HTMLSelectElement::create(document());
select->setPseudo(keygenSelectPseudoId);
for (size_t i = 0; i < keys.size(); ++i) {
RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document());
option->appendChild(Text::create(document(), keys[i]));
select->appendChild(option);
}
root.appendChild(select);
}