本文整理汇总了C++中ContainerNode::childShouldCreateRenderer方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode::childShouldCreateRenderer方法的具体用法?C++ ContainerNode::childShouldCreateRenderer怎么用?C++ ContainerNode::childShouldCreateRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerNode
的用法示例。
在下文中一共展示了ContainerNode::childShouldCreateRenderer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTextRendererIfNeeded
static void createTextRendererIfNeeded(Text& textNode)
{
ASSERT(!textNode.renderer());
ContainerNode* renderingParentNode = NodeRenderingTraversal::parent(&textNode);
if (!renderingParentNode)
return;
RenderObject* parentRenderer = renderingParentNode->renderer();
if (!parentRenderer || !parentRenderer->canHaveChildren())
return;
if (!renderingParentNode->childShouldCreateRenderer(&textNode))
return;
Document& document = textNode.document();
RefPtr<RenderStyle> style;
bool resetStyleInheritance = textNode.parentNode()->isShadowRoot() && toShadowRoot(textNode.parentNode())->resetStyleInheritance();
if (resetStyleInheritance)
style = document.ensureStyleResolver().defaultStyleForElement();
else
style = parentRenderer->style();
if (!textRendererIsNeeded(textNode, *parentRenderer, *style))
return;
RenderText* newRenderer = textNode.createTextRenderer(document.renderArena(), style.get());
if (!newRenderer)
return;
if (!parentRenderer->isChildAllowed(newRenderer, style.get())) {
newRenderer->destroy();
return;
}
// Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
// for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
RenderObject* nextRenderer = nextSiblingRenderer(textNode);
textNode.setRenderer(newRenderer);
// Parent takes care of the animations, no need to call setAnimatableStyle.
newRenderer->setStyle(style.release());
parentRenderer->addChild(newRenderer, nextRenderer);
Node* sibling = textNode.nextSibling();
if (sibling && !sibling->renderer() && sibling->attached())
createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
}