本文整理汇总了C++中ContainerNode::isShadowRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode::isShadowRoot方法的具体用法?C++ ContainerNode::isShadowRoot怎么用?C++ ContainerNode::isShadowRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerNode
的用法示例。
在下文中一共展示了ContainerNode::isShadowRoot方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerWithScopingNode
void HTMLStyleElement::registerWithScopingNode(bool scoped)
{
// Note: We cannot rely on the 'scoped' element already being present when this method is invoked.
// Therefore we cannot rely on scoped()!
ASSERT(m_scopedStyleRegistrationState == NotRegistered);
ASSERT(inDocument());
if (m_scopedStyleRegistrationState != NotRegistered)
return;
ContainerNode* scope = scoped ? parentNode() : containingShadowRoot();
if (!scope)
return;
if (!scope->isElementNode() && !scope->isShadowRoot()) {
// DocumentFragment nodes should never be inDocument,
// <style> should not be a child of Document, PI or some such.
ASSERT_NOT_REACHED();
return;
}
scope->registerScopedHTMLStyleChild();
if (scope->isShadowRoot())
scope->shadowHost()->setNeedsStyleRecalc();
else
scope->setNeedsStyleRecalc();
if (inDocument() && !document()->parsing() && document()->renderer())
document()->styleResolverChanged(DeferRecalcStyle);
m_scopedStyleRegistrationState = scoped ? RegisteredAsScoped : RegisteredInShadowRoot;
}
示例2: isAtShadowBoundary
// FIXME: This is duplicated with StyleResolver.cpp
// Perhaps this should move onto ElementResolveContext or even Element?
static inline bool isAtShadowBoundary(const Element* element)
{
if (!element)
return false;
ContainerNode* parentNode = element->parentNode();
return parentNode && parentNode->isShadowRoot();
}
示例3: traverseParent
static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadowRootCrossing)
{
if (node->isPseudoElement())
return toPseudoElement(node)->hostElement();
if (shadowRootCrossing == DontCrossShadowRoot && node->isShadowRoot())
return 0;
if (nodeCanBeDistributed(node)) {
if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
return traverseParent(insertionPoint, shadowRootCrossing);
return nullptr;
}
ContainerNode* parent = node->parentNode();
if (!parent)
return nullptr;
if (parent->isShadowRoot())
return shadowRootCrossing == CrossShadowRoot ? toShadowRoot(parent)->hostElement() : parent;
if (parent->isInsertionPoint()) {
const InsertionPoint* insertionPoint = toInsertionPoint(parent);
if (insertionPoint->hasDistribution())
return nullptr;
if (insertionPoint->isActive())
return traverseParent(parent, shadowRootCrossing);
}
return parent;
}
示例4: childAttachedAllowedWhenAttachingChildren
static bool childAttachedAllowedWhenAttachingChildren(ContainerNode& node)
{
if (node.isShadowRoot())
return true;
if (node.isInsertionPoint())
return true;
if (node.isElementNode() && toElement(&node)->shadowRoot())
return true;
return false;
}
示例5: traverseParentOrHost
ContainerNode* FlatTreeTraversal::traverseParentOrHost(const Node& node)
{
ContainerNode* parent = node.parentNode();
if (!parent)
return nullptr;
if (!parent->isShadowRoot())
return parent;
ShadowRoot* shadowRoot = toShadowRoot(parent);
DCHECK(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
if (!shadowRoot->isYoungest())
return nullptr;
return &shadowRoot->host();
}
示例6: toElement
NodeRenderingContext::NodeRenderingContext(Node* node)
: m_location(LocationNotInTree)
, m_phase(AttachStraight)
, m_node(node)
, m_parentNodeForRenderingAndStyle(0)
, m_visualParentShadowRoot(0)
, m_includer(0)
, m_style(0)
, m_parentFlowRenderer(0)
{
ContainerNode* parent = m_node->parentOrHostNode();
if (!parent)
return;
if (parent->isShadowRoot()) {
m_location = LocationShadowChild;
m_parentNodeForRenderingAndStyle = parent->shadowHost();
return;
}
m_location = LocationLightChild;
if (parent->isElementNode()) {
m_visualParentShadowRoot = toElement(parent)->shadowRoot();
if (m_visualParentShadowRoot) {
if ((m_includer = m_visualParentShadowRoot->includerFor(m_node))
&& m_visualParentShadowRoot->isInclusionSelectorActive()) {
m_phase = AttachContentForwarded;
m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_includer).parentNodeForRenderingAndStyle();
return;
}
m_phase = AttachContentLight;
m_parentNodeForRenderingAndStyle = parent;
return;
}
if (parent->isContentElement()) {
HTMLContentElement* shadowContentElement = toHTMLContentElement(parent);
if (!shadowContentElement->hasInclusion()) {
m_phase = AttachContentFallback;
m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
return;
}
}
}
m_parentNodeForRenderingAndStyle = parent;
}
示例7: scopingNodeFor
const ContainerNode* ScopedStyleResolver::scopingNodeFor(const CSSStyleSheet* sheet)
{
ASSERT(sheet);
Document* document = sheet->ownerDocument();
if (!document)
return 0;
Node* ownerNode = sheet->ownerNode();
if (!ownerNode || !ownerNode->isHTMLElement() || !ownerNode->hasTagName(HTMLNames::styleTag))
return 0;
HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(ownerNode);
if (!styleElement->scoped())
return styleElement->isInShadowTree() ? styleElement->containingShadowRoot() : 0;
ContainerNode* parent = styleElement->parentNode();
if (!parent)
return 0;
return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0;
}
示例8: scopingNodeFor
ContainerNode* ScopedStyleResolver::scopingNodeFor(Document& document, const CSSStyleSheet* sheet)
{
ASSERT(sheet);
Document* sheetDocument = sheet->ownerDocument();
if (!sheetDocument)
return 0;
Node* ownerNode = sheet->ownerNode();
if (!isHTMLStyleElement(ownerNode))
return &document;
HTMLStyleElement& styleElement = toHTMLStyleElement(*ownerNode);
if (!styleElement.scoped()) {
if (styleElement.isInShadowTree())
return styleElement.containingShadowRoot();
return &document;
}
ContainerNode* parent = styleElement.parentNode();
if (!parent)
return 0;
return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0;
}
示例9: if
NodeRenderingContext::NodeRenderingContext(Node* node)
: m_phase(AttachingNotInTree)
, m_node(node)
, m_parentNodeForRenderingAndStyle(0)
, m_visualParentShadow(0)
, m_insertionPoint(0)
, m_style(0)
, m_parentFlowRenderer(0)
{
ContainerNode* parent = m_node->parentOrHostNode();
if (!parent)
return;
if (parent->isShadowRoot() && toShadowRoot(parent)->isYoungest()) {
m_phase = AttachingShadowChild;
m_parentNodeForRenderingAndStyle = toShadowRoot(parent)->host();
return;
}
if (parent->isElementNode() || parent->isShadowRoot()) {
if (parent->isElementNode())
m_visualParentShadow = toElement(parent)->shadow();
else if (parent->isShadowRoot())
m_visualParentShadow = toShadowRoot(parent)->owner();
if (m_visualParentShadow) {
if ((m_insertionPoint = m_visualParentShadow->insertionPointFor(m_node))) {
if (m_insertionPoint->shadowRoot()->isUsedForRendering()) {
m_phase = AttachingDistributed;
m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_insertionPoint).parentNodeForRenderingAndStyle();
return;
}
}
m_phase = AttachingNotDistributed;
m_parentNodeForRenderingAndStyle = parent;
return;
}
if (isShadowBoundary(parent)) {
if (!parent->shadowRoot()->isUsedForRendering()) {
m_phase = AttachingNotDistributed;
m_parentNodeForRenderingAndStyle = parent;
return;
}
if (toInsertionPoint(parent)->hasDistribution())
m_phase = AttachingNotFallbacked;
else
m_phase = AttachingFallbacked;
if (toInsertionPoint(parent)->isActive())
m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
else
m_parentNodeForRenderingAndStyle = parent;
return;
}
}
m_phase = AttachingStraight;
m_parentNodeForRenderingAndStyle = parent;
}
示例10: isTreeScopeRoot
static inline bool isTreeScopeRoot(const ContainerNode& node)
{
return node.isDocumentNode() || node.isShadowRoot();
}
示例11: buildShadowAndInstanceTree
void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowRoot)
{
struct ShadowTreeUpdateBlocker {
ShadowTreeUpdateBlocker(SVGUseElement* currentUseElement)
: useElement(currentUseElement)
{
useElement->setUpdatesBlocked(true);
}
~ShadowTreeUpdateBlocker()
{
useElement->setUpdatesBlocked(false);
}
SVGUseElement* useElement;
};
// When cloning the target nodes, they may decide to synchronize style and/or animated SVG attributes.
// That causes calls to SVGElementInstance::updateAllInstancesOfElement(), which mark the shadow tree for recreation.
// Solution: block any updates to the shadow tree while we're building it.
ShadowTreeUpdateBlocker blocker(this);
String id = SVGURIReference::getTarget(href());
Element* targetElement = document()->getElementById(id);
if (!targetElement) {
// The only time we should get here is when the use element has not been
// given a resource to target.
ASSERT(m_resourceId.isEmpty());
return;
}
// Do not build the shadow/instance tree for <use> elements living in a shadow tree.
// The will be expanded soon anyway - see expandUseElementsInShadowTree().
ContainerNode* parent = parentNode();
while (parent) {
if (parent->isShadowRoot())
return;
parent = parent->parentNodeGuaranteedHostFree();
}
SVGElement* target = 0;
if (targetElement && targetElement->isSVGElement())
target = static_cast<SVGElement*>(targetElement);
detachInstance();
// Do not allow self-referencing.
// 'target' may be null, if it's a non SVG namespaced element.
if (!target || target == this)
return;
// Why a seperated instance/shadow tree? SVG demands it:
// The instance tree is accesable from JavaScript, and has to
// expose a 1:1 copy of the referenced tree, whereas internally we need
// to alter the tree for correct "use-on-symbol", "use-on-svg" support.
// Build instance tree. Create root SVGElementInstance object for the first sub-tree node.
//
// Spec: If the 'use' element references a simple graphics element such as a 'rect', then there is only a
// single SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object
// is the SVGRectElement that corresponds to the referenced 'rect' element.
m_targetElementInstance = SVGElementInstance::create(this, target);
// Eventually enter recursion to build SVGElementInstance objects for the sub-tree children
bool foundProblem = false;
buildInstanceTree(target, m_targetElementInstance.get(), foundProblem);
// 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 (foundProblem) {
detachInstance();
return;
}
// Assure instance tree building was successfull
ASSERT(m_targetElementInstance);
ASSERT(!m_targetElementInstance->shadowTreeElement());
ASSERT(m_targetElementInstance->correspondingUseElement() == this);
ASSERT(m_targetElementInstance->correspondingElement() == target);
// Build shadow tree from instance tree
// This also handles the special cases: <use> on <symbol>, <use> on <svg>.
buildShadowTree(shadowRoot, target, m_targetElementInstance.get());
#if ENABLE(SVG) && ENABLE(SVG_USE)
// Expand all <use> elements in the shadow tree.
// Expand means: replace the actual <use> element by what it references.
expandUseElementsInShadowTree(shadowRoot, shadowRoot);
// Expand all <symbol> elements in the shadow tree.
// Expand means: replace the actual <symbol> element by the <svg> element.
expandSymbolElementsInShadowTree(shadowRoot, shadowRoot);
#endif
// Now that the shadow tree is completly expanded, we can associate
// shadow tree elements <-> instances in the instance tree.
associateInstancesWithShadowTreeElements(shadowRoot->firstChild(), m_targetElementInstance.get());
// If no shadow tree element is present, this means that the reference root
//.........这里部分代码省略.........