Ref<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode) { if (!contentNode) return StaticElementList::createEmpty(); if (m_flowManager->document()) m_flowManager->document()->updateLayoutIgnorePendingStylesheets(); // The renderer may be destroyed or created after the style update. // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary. if (!m_parentFlowThread) return StaticElementList::createEmpty(); Vector<Ref<Element>> regionElements; if (inFlowThread(contentNode->renderer(), m_parentFlowThread)) { const RenderRegionList& regionList = m_parentFlowThread->renderRegionList(); for (const auto& renderRegion : regionList) { const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion); // FIXME: Pseudo-elements are not included in the list. // They will be included when we will properly support the Region interface // http://dev.w3.org/csswg/css-regions/#the-region-interface if (namedFlowFragment.isPseudoElementRegion()) continue; if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), &namedFlowFragment)) { ASSERT(namedFlowFragment.generatingElement()); regionElements.append(*namedFlowFragment.generatingElement()); } } } return StaticElementList::adopt(regionElements); }
PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode) { Vector<RefPtr<Node> > regionNodes; if (!contentNode) return StaticNodeList::adopt(regionNodes); if (m_flowManager->document()) m_flowManager->document()->updateLayoutIgnorePendingStylesheets(); // The renderer may be destroyed or created after the style update. // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary. if (!m_parentFlowThread) return StaticNodeList::adopt(regionNodes); if (inFlowThread(contentNode->renderer(), m_parentFlowThread)) { const RenderRegionList& regionList = m_parentFlowThread->renderRegionList(); for (RenderRegionList::const_iterator iter = regionList.begin(); iter != regionList.end(); ++iter) { const RenderRegion* renderRegion = *iter; // FIXME: Pseudo-elements are not included in the list. if (!renderRegion->node()) continue; if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), renderRegion)) regionNodes.append(renderRegion->node()); } } return StaticNodeList::adopt(regionNodes); }
static inline bool inFlowThread(RenderObject* renderer, RenderNamedFlowThread* flowThread) { if (!renderer) return false; RenderFlowThread* currentFlowThread = renderer->flowThreadContainingBlock(); if (flowThread == currentFlowThread) return true; if (renderer->flowThreadState() != RenderObject::InsideInFlowThread) return false; // An in-flow flow thread can be nested inside an out-of-flow one, so we have to recur up to check. return inFlowThread(currentFlowThread->containingBlock(), flowThread); }