本文整理汇总了C++中RenderElement::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderElement::addChild方法的具体用法?C++ RenderElement::addChild怎么用?C++ RenderElement::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderElement
的用法示例。
在下文中一共展示了RenderElement::addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
void RenderRubyRun::addChild(RenderObject* child, RenderObject* beforeChild)
{
ASSERT(child);
if (child->isRubyText()) {
if (!beforeChild) {
// RenderRuby has already ascertained that we can add the child here.
ASSERT(!hasRubyText());
// prepend ruby texts as first child
RenderBlockFlow::addChild(child, firstChild());
} else if (beforeChild->isRubyText()) {
// New text is inserted just before another.
// In this case the new text takes the place of the old one, and
// the old text goes into a new run that is inserted as next sibling.
ASSERT(beforeChild->parent() == this);
RenderElement* ruby = parent();
ASSERT(ruby->isRuby());
RenderBlock* newRun = staticCreateRubyRun(ruby);
ruby->addChild(newRun, nextSibling());
// Add the new ruby text and move the old one to the new run
// Note: Doing it in this order and not using RenderRubyRun's methods,
// in order to avoid automatic removal of the ruby run in case there is no
// other child besides the old ruby text.
RenderBlockFlow::addChild(child, beforeChild);
RenderBlockFlow::removeChild(*beforeChild);
newRun->addChild(beforeChild);
} else if (hasRubyBase()) {
// Insertion before a ruby base object.
// In this case we need insert a new run before the current one and split the base.
RenderElement* ruby = parent();
RenderRubyRun* newRun = staticCreateRubyRun(ruby);
ruby->addChild(newRun, this);
newRun->addChild(child);
rubyBaseSafe()->moveChildren(newRun->rubyBaseSafe(), beforeChild);
}
} else {
// child is not a text -> insert it into the base
// (append it instead if beforeChild is the ruby text)
if (beforeChild && beforeChild->isRubyText())
beforeChild = 0;
rubyBaseSafe()->addChild(child, beforeChild);
}
}
示例2: didAttachRenderers
void PseudoElement::didAttachRenderers()
{
RenderElement* renderer = this->renderer();
if (!renderer || renderer->style().hasFlowFrom())
return;
const RenderStyle& style = renderer->style();
ASSERT(style.contentData());
for (const ContentData* content = style.contentData(); content; content = content->next()) {
auto child = content->createContentRenderer(document(), style);
if (renderer->isChildAllowed(*child, style))
renderer->addChild(child.leakPtr());
}
}
示例3: addChild
void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild)
{
// Insert :before and :after content before/after the RenderRubyRun(s)
if (child->isBeforeContent()) {
if (child->isInline()) {
// Add generated inline content normally
RenderBlockFlow::addChild(child, firstChild());
} else {
// Wrap non-inline content with an anonymous inline-block.
RenderBlock* beforeBlock = rubyBeforeBlock(this);
if (!beforeBlock) {
beforeBlock = createAnonymousRubyInlineBlock(*this);
RenderBlockFlow::addChild(beforeBlock, firstChild());
}
beforeBlock->addChild(child);
}
return;
}
if (child->isAfterContent()) {
if (child->isInline()) {
// Add generated inline content normally
RenderBlockFlow::addChild(child);
} else {
// Wrap non-inline content with an anonymous inline-block.
RenderBlock* afterBlock = rubyAfterBlock(this);
if (!afterBlock) {
afterBlock = createAnonymousRubyInlineBlock(*this);
RenderBlockFlow::addChild(afterBlock);
}
afterBlock->addChild(child);
}
return;
}
// If the child is a ruby run, just add it normally.
if (child->isRubyRun()) {
RenderBlockFlow::addChild(child, beforeChild);
return;
}
if (beforeChild && !isAfterContent(beforeChild)) {
// insert child into run
ASSERT(!beforeChild->isRubyRun());
RenderElement* run = beforeChild->parent();
while (run && !run->isRubyRun())
run = run->parent();
if (run) {
run->addChild(child, beforeChild);
return;
}
ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
// Emergency fallback: fall through and just append.
}
// If the new child would be appended, try to add the child to the previous run
// if possible, or create a new run otherwise.
// (The RenderRubyRun object will handle the details)
RenderRubyRun* lastRun = lastRubyRun(this);
if (!lastRun || lastRun->hasRubyText()) {
lastRun = RenderRubyRun::staticCreateRubyRun(this);
RenderBlockFlow::addChild(lastRun, beforeChild);
}
lastRun->addChild(child);
}