static unsigned depthCrossingShadowBoundaries(Node* node) { unsigned depth = 0; for (ContainerNode* parent = node->parentOrShadowHostNode(); parent; parent = parent->parentOrShadowHostNode()) ++depth; return depth; }
void ScopedStyleTree::setupScopedStylesTree(ScopedStyleResolver* target) { ASSERT(target); const ContainerNode& scopingNode = target->scopingNode(); // Since StyleResolver creates RuleSets according to styles' document // order, a parent of the given ScopedRuleData has been already // prepared. for (ContainerNode* node = scopingNode.parentOrShadowHostNode(); node; node = node->parentOrShadowHostNode()) { if (ScopedStyleResolver* scopedResolver = scopedStyleResolverFor(*node)) { target->setParent(scopedResolver); break; } if (node->isDocumentNode()) { bool dummy; ScopedStyleResolver* scopedResolver = addScopedStyleResolver(*node, dummy); target->setParent(scopedResolver); setupScopedStylesTree(scopedResolver); break; } } if (m_buildInDocumentOrder) return; // Reparent all nodes whose scoping node is contained by target's one. for (HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> >::iterator it = m_authorStyles.begin(); it != m_authorStyles.end(); ++it) { if (it->value == target) continue; ASSERT(it->key->inDocument()); if (it->value->parent() == target->parent() && scopingNode.containsIncludingShadowDOM(it->key)) it->value->setParent(target); } }
bool SubframeLoadingDisabler::canLoadFrame(HTMLFrameOwnerElement& owner) { for (ContainerNode* node = &owner; node; node = node->parentOrShadowHostNode()) { if (disabledSubtreeRoots().contains(node)) return false; } return true; }
void ScopedStyleTree::popStyleCache(const ContainerNode& scopingNode) { if (!cacheIsValid(&scopingNode)) return; if (m_cache.scopedResolver && m_cache.scopedResolver->scopingNode() == scopingNode) m_cache.scopedResolver = m_cache.scopedResolver->parent(); m_cache.nodeForScopedStyles = scopingNode.parentOrShadowHostNode(); }
void HTMLFrameOwnerElement::clearContentFrame() { if (!m_contentFrame) return; m_contentFrame = 0; for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()) node->decrementConnectedSubframeCount(); }
void HTMLFrameOwnerElement::setContentFrame(Frame& frame) { // Make sure we will not end up with two frames referencing the same owner element. ASSERT(!m_contentFrame || m_contentFrame->ownerElement() != this); // Disconnected frames should not be allowed to load. ASSERT(inDocument()); m_contentFrame = &frame; for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()) node->incrementConnectedSubframeCount(); }
SVGSVGElement* SVGElement::ownerSVGElement() const { ContainerNode* n = parentOrShadowHostNode(); while (n) { if (n->hasTagName(SVGNames::svgTag)) return toSVGSVGElement(n); n = n->parentOrShadowHostNode(); } return 0; }
SVGSVGElement* SVGElement::ownerSVGElement() const { ContainerNode* n = parentOrShadowHostNode(); while (n) { if (isSVGSVGElement(*n)) return toSVGSVGElement(n); n = n->parentOrShadowHostNode(); } return nullptr; }
SVGSVGElement* SVGElement::ownerSVGElement() const { ContainerNode* node = parentOrShadowHostNode(); while (node) { if (is<SVGSVGElement>(*node)) return downcast<SVGSVGElement>(node); node = node->parentOrShadowHostNode(); } return nullptr; }
SVGElement* SVGElement::viewportElement() const { // This function needs shadow tree support - as RenderSVGContainer uses this function // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise. ContainerNode* n = parentOrShadowHostNode(); while (n) { if (n->hasTagName(SVGNames::svgTag) || isSVGImageElement(n) || n->hasTagName(SVGNames::symbolTag)) return toSVGElement(n); n = n->parentOrShadowHostNode(); } return 0; }
SVGElement* SVGElement::viewportElement() const { // This function needs shadow tree support - as LayoutSVGContainer uses this function // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise. ContainerNode* n = parentOrShadowHostNode(); while (n) { if (isSVGSVGElement(*n) || isSVGImageElement(*n) || isSVGSymbolElement(*n)) return toSVGElement(n); n = n->parentOrShadowHostNode(); } return nullptr; }
SVGElement* SVGElement::viewportElement() const { // This function needs shadow tree support - as RenderSVGContainer uses this function // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise. ContainerNode* node = parentOrShadowHostNode(); while (node) { if (is<SVGSVGElement>(*node) || is<SVGImageElement>(*node) || node->hasTagName(SVGNames::symbolTag)) return downcast<SVGElement>(node); node = node->parentOrShadowHostNode(); } return nullptr; }
void FullyClippedStateStack::setUpFullyClippedStack(Node* node) { // Put the nodes in a vector so we can iterate in reverse order. WillBeHeapVector<RawPtrWillBeMember<ContainerNode>, 100> ancestry; for (ContainerNode* parent = node->parentOrShadowHostNode(); parent; parent = parent->parentOrShadowHostNode()) ancestry.append(parent); // Call pushFullyClippedState on each node starting with the earliest ancestor. size_t ancestrySize = ancestry.size(); for (size_t i = 0; i < ancestrySize; ++i) pushFullyClippedState(ancestry[ancestrySize - i - 1]); pushFullyClippedState(node); ASSERT(size() == 1 + depthCrossingShadowBoundaries(node)); }
void EventListenerInfo::getEventListeners(EventTarget* target, WillBeHeapVector<EventListenerInfo>& eventInformation, bool includeAncestors) { // The Node's Ancestors including self. WillBeHeapVector<RawPtrWillBeMember<EventTarget>> ancestors; ancestors.append(target); if (includeAncestors) { Node* node = target->toNode(); for (ContainerNode* ancestor = node ? node->parentOrShadowHostNode() : nullptr; ancestor; ancestor = ancestor->parentOrShadowHostNode()) ancestors.append(ancestor); } // Nodes and their Listeners for the concerned event types (order is top to bottom) for (size_t i = ancestors.size(); i; --i) { EventTarget* ancestor = ancestors[i - 1]; Vector<AtomicString> eventTypes = ancestor->eventTypes(); for (size_t j = 0; j < eventTypes.size(); ++j) { AtomicString& type = eventTypes[j]; EventListenerVector* listeners = ancestor->getEventListeners(type); if (!listeners) continue; EventListenerVector filteredListeners; filteredListeners.reserveCapacity(listeners->size()); for (size_t k = 0; k < listeners->size(); ++k) { if (listeners->at(k).listener->type() == EventListener::JSEventListenerType) filteredListeners.append(listeners->at(k)); } if (!filteredListeners.isEmpty()) eventInformation.append(EventListenerInfo(ancestor, type, filteredListeners)); } } }