本文整理汇总了C++中ShadowRoot::firstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot::firstChild方法的具体用法?C++ ShadowRoot::firstChild怎么用?C++ ShadowRoot::firstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadowRoot
的用法示例。
在下文中一共展示了ShadowRoot::firstChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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);
}
}
示例4: recalcShadowTreeStyle
void ShadowTree::recalcShadowTreeStyle(Node::StyleChange change)
{
ShadowRoot* youngest = youngestShadowRoot();
if (!youngest)
return;
if (needsReattachHostChildrenAndShadow())
reattachHostChildrenAndShadow();
else {
StyleResolver* styleResolver = youngest->document()->styleResolver();
styleResolver->pushParentShadowRoot(youngest);
for (Node* n = youngest->firstChild(); n; n = n->nextSibling()) {
if (n->isElementNode())
static_cast<Element*>(n)->recalcStyle(change);
else if (n->isTextNode())
toText(n)->recalcTextStyle(change);
}
styleResolver->popParentShadowRoot(youngest);
}
clearNeedsReattachHostChildrenAndShadow();
for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
root->clearNeedsStyleRecalc();
root->clearChildNeedsStyleRecalc();
}
}
示例5: getDecorationRootAndDecoratedRoot
static inline void getDecorationRootAndDecoratedRoot(HTMLInputElement* input, ShadowRoot*& decorationRoot, ShadowRoot*& decoratedRoot)
{
ShadowRoot* existingRoot = input->youngestShadowRoot();
ShadowRoot* newRoot = 0;
while (existingRoot->childNodeCount() == 1 && existingRoot->firstChild()->hasTagName(shadowTag)) {
newRoot = existingRoot;
existingRoot = existingRoot->olderShadowRoot();
ASSERT(existingRoot);
}
if (newRoot)
newRoot->removeChild(newRoot->firstChild());
else
newRoot = ShadowRoot::create(input, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
decorationRoot = newRoot;
decoratedRoot = existingRoot;
}
示例6: sliderThumbElementOf
SliderThumbElement* sliderThumbElementOf(Node* node)
{
ASSERT(node);
ShadowRoot* shadow = node->toInputElement()->shadowTree()->oldestShadowRoot();
ASSERT(shadow);
Node* thumb = shadow->firstChild()->firstChild()->firstChild();
ASSERT(thumb);
return toSliderThumbElement(thumb);
}
示例7: updateSnapshotInfo
void HTMLPlugInImageElement::updateSnapshotInfo()
{
ShadowRoot* root = userAgentShadowRoot();
if (!root)
return;
Element* shadowContainer = toElement(root->firstChild());
shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this, m_isPrimarySnapshottedPlugIn));
}
示例8: sliderTrackElementOf
HTMLElement* sliderTrackElementOf(Node* node)
{
RELEASE_ASSERT(node->hasTagName(inputTag));
ShadowRoot* shadow = toHTMLInputElement(node)->userAgentShadowRoot();
ASSERT(shadow);
Node* track = shadow->firstChild()->firstChild();
ASSERT(track);
return toHTMLElement(track);
}
示例9: trackLimiterElementOf
TrackLimiterElement* trackLimiterElementOf(Node* node)
{
ASSERT(node);
ShadowRoot* shadow = node->toInputElement()->shadowRoot();
ASSERT(shadow);
Node* limiter = shadow->firstChild()->lastChild();
ASSERT(limiter);
return static_cast<TrackLimiterElement*>(limiter);
}
示例10: sliderTrackElementOf
HTMLElement* sliderTrackElementOf(Node* node)
{
ASSERT(node);
ShadowRoot* shadow = node->toInputElement()->userAgentShadowRoot();
ASSERT(shadow);
Node* track = shadow->firstChild()->firstChild();
ASSERT(track);
return toHTMLElement(track);
}
示例11: getDecorationRootAndDecoratedRoot
static inline void getDecorationRootAndDecoratedRoot(HTMLInputElement* input, ShadowRoot*& decorationRoot, ShadowRoot*& decoratedRoot)
{
ShadowRoot* existingRoot = input->youngestShadowRoot();
ShadowRoot* newRoot = 0;
while (existingRoot->childNodeCount() == 1 && existingRoot->firstChild()->hasTagName(shadowTag)) {
newRoot = existingRoot;
existingRoot = existingRoot->olderShadowRoot();
ASSERT(existingRoot);
}
if (newRoot)
newRoot->removeChild(newRoot->firstChild());
else {
// FIXME: This interacts really badly with author shadow roots because now
// we can interleave user agent and author shadow roots on the element meaning
// input.shadowRoot may be inaccessible if the browser has decided to decorate
// the input.
newRoot = input->ensureShadow()->addShadowRoot(input, ShadowRoot::UserAgentShadowRoot);
}
decorationRoot = newRoot;
decoratedRoot = existingRoot;
}
示例12: checkSnapshotStatus
void HTMLPlugInImageElement::checkSnapshotStatus()
{
if (!renderer()->isSnapshottedPlugIn()) {
if (displayState() == Playing)
checkSizeChangeForSnapshotting();
return;
}
ShadowRoot* root = userAgentShadowRoot();
if (!root)
return;
Element* shadowContainer = toElement(root->firstChild());
shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this));
}
示例13: destroyImageControls
void HTMLImageElement::destroyImageControls()
{
ShadowRoot* shadowRoot = userAgentShadowRoot();
if (!shadowRoot)
return;
if (Node* node = shadowRoot->firstChild()) {
ASSERT_WITH_SECURITY_IMPLICATION(node->isImageControlsRootElement());
shadowRoot->removeChild(*node);
}
auto* renderObject = renderer();
if (!renderObject)
return;
downcast<RenderImage>(*renderObject).setHasShadowControls(false);
}
示例14: decorate
void TextFieldDecorationElement::decorate(HTMLInputElement* input, bool visible)
{
ASSERT(input);
ShadowRoot* existingRoot;
ShadowRoot* decorationRoot;
getDecorationRootAndDecoratedRoot(input, decorationRoot, existingRoot);
ASSERT(decorationRoot);
ASSERT(existingRoot);
RefPtr<HTMLDivElement> box = HTMLDivElement::create(input->document());
decorationRoot->appendChild(box);
box->setInlineStyleProperty(CSSPropertyDisplay, CSSValueWebkitBox);
box->setInlineStyleProperty(CSSPropertyWebkitBoxAlign, CSSValueCenter);
ASSERT(existingRoot->childNodeCount() == 1);
toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropertyWebkitBoxFlex, 1.0, CSSPrimitiveValue::CSS_NUMBER);
box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->document()));
setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValueNone);
box->appendChild(this);
}
示例15: invalidateStyleForClassChangeOnChildren
bool RuleFeatureSet::invalidateStyleForClassChangeOnChildren(Element* element, Vector<AtomicString>& invalidationClasses, bool foundInvalidationSet)
{
bool someChildrenNeedStyleRecalc = false;
for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root->olderShadowRoot()) {
for (Node* child = root->firstChild(); child; child = child->nextSibling()) {
if (child->isElementNode()) {
Element* childElement = toElement(child);
bool childRecalced = invalidateStyleForClassChange(childElement, invalidationClasses, foundInvalidationSet);
someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRecalced;
}
}
}
for (Node* child = element->firstChild(); child; child = child->nextSibling()) {
if (child->isElementNode()) {
Element* childElement = toElement(child);
bool childRecalced = invalidateStyleForClassChange(childElement, invalidationClasses, foundInvalidationSet);
someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRecalced;
}
}
return someChildrenNeedStyleRecalc;
}