本文整理汇总了C++中RenderRubyBase类的典型用法代码示例。如果您正苦于以下问题:C++ RenderRubyBase类的具体用法?C++ RenderRubyBase怎么用?C++ RenderRubyBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderRubyBase类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldOverhang
static bool shouldOverhang(bool firstLine, const RenderObject* renderer, const RenderRubyBase& rubyBase)
{
if (!renderer || !renderer->isText())
return false;
const RenderStyle& rubyBaseStyle = firstLine ? rubyBase.firstLineStyle() : rubyBase.style();
const RenderStyle& style = firstLine ? renderer->firstLineStyle() : renderer->style();
return style.fontSize() <= rubyBaseStyle.fontSize();
}
示例2: createRubyBase
RenderRubyBase* RenderRubyRun::createRubyBase() const
{
RenderRubyBase* renderer = RenderRubyBase::createAnonymous(&document());
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK);
newStyle->setTextAlign(CENTER); // FIXME: use WEBKIT_CENTER?
renderer->setStyle(newStyle.release());
return renderer;
}
示例3: new
RenderRubyBase* RenderRubyRun::createRubyBase() const
{
RenderRubyBase* rb = new (renderArena()) RenderRubyBase(document() /* anonymous */);
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK);
newStyle->setTextAlign(CENTER); // FIXME: use WEBKIT_CENTER?
rb->setStyle(newStyle.release());
return rb;
}
示例4: ASSERT
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);
RenderObject* 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.
RenderObject* 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)
RenderRubyBase* base = rubyBaseSafe();
if (beforeChild == base)
beforeChild = base->firstChild();
if (beforeChild && beforeChild->isRubyText())
beforeChild = 0;
ASSERT(!beforeChild || beforeChild->isDescendantOf(base));
base->addChild(child, beforeChild);
}
}
示例5: rubyBase
RenderObject* RenderRubyRun::removeChild(RenderObject& child)
{
// If the child is a ruby text, then merge the ruby base with the base of
// the right sibling run, if possible.
if (!beingDestroyed() && !documentBeingDestroyed() && child.isRubyText()) {
RenderRubyBase* base = rubyBase();
RenderObject* rightNeighbour = nextSibling();
if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
// Ruby run without a base can happen only at the first run.
RenderRubyRun* rightRun = toRenderRubyRun(rightNeighbour);
if (rightRun->hasRubyBase()) {
RenderRubyBase* rightBase = rightRun->rubyBaseSafe();
// Collect all children in a single base, then swap the bases.
rightBase->mergeChildrenWithBase(base);
moveChildTo(rightRun, base);
rightRun->moveChildTo(this, rightBase);
// The now empty ruby base will be removed below.
ASSERT(!rubyBase()->firstChild());
}
}
}
RenderObject* next = RenderBlockFlow::removeChild(child);
if (!beingDestroyed() && !documentBeingDestroyed()) {
// Check if our base (if any) is now empty. If so, destroy it.
RenderBlock* base = rubyBase();
if (base && !base->firstChild()) {
next = RenderBlockFlow::removeChild(*base);
base->deleteLines();
base->destroy();
}
// If any of the above leaves the run empty, destroy it as well.
if (isEmpty()) {
parent()->removeChild(*this);
deleteLines();
destroy();
next = nullptr;
}
}
return next;
}
示例6: ASSERT
void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, int& startOverhang, int& endOverhang) const
{
ASSERT(!needsLayout());
startOverhang = 0;
endOverhang = 0;
RenderRubyBase* rubyBase = this->rubyBase();
RenderRubyText* rubyText = this->rubyText();
if (!rubyBase || !rubyText)
return;
if (!rubyBase->firstRootBox())
return;
int logicalWidth = this->logicalWidth();
int logicalLeftOverhang = numeric_limits<int>::max();
int logicalRightOverhang = numeric_limits<int>::max();
for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox; rootInlineBox = rootInlineBox->nextRootBox()) {
logicalLeftOverhang = min<int>(logicalLeftOverhang, rootInlineBox->logicalLeft());
logicalRightOverhang = min<int>(logicalRightOverhang, logicalWidth - rootInlineBox->logicalRight());
}
startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : logicalRightOverhang;
endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : logicalLeftOverhang;
if (!startRenderer || !startRenderer->isText() || startRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
startOverhang = 0;
if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
endOverhang = 0;
// We overhang a ruby only if the neighboring render object is a text.
// We can overhang the ruby by no more than half the width of the neighboring text
// and no more than half the font size.
int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2;
if (startOverhang)
startOverhang = min<int>(startOverhang, min<int>(toRenderText(startRenderer)->minLogicalWidth(), halfWidthOfFontSize));
if (endOverhang)
endOverhang = min<int>(endOverhang, min<int>(toRenderText(endRenderer)->minLogicalWidth(), halfWidthOfFontSize));
}
示例7: rubyBase
void RenderRubyRun::removeChild(RenderObject* child)
{
// If the child is a ruby text, then merge the ruby base with the base of
// the right sibling run, if possible.
if (!m_beingDestroyed && !documentBeingDestroyed() && child->isRubyText()) {
RenderRubyBase* base = rubyBase();
RenderObject* rightNeighbour = nextSibling();
if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
// Ruby run without a base can happen only at the first run.
RenderRubyRun* rightRun = static_cast<RenderRubyRun*>(rightNeighbour);
if (rightRun->hasRubyBase()) {
RenderRubyBase* rightBase = rightRun->rubyBaseSafe();
// Collect all children in a single base, then swap the bases.
rightBase->moveChildren(base);
moveChildTo(rightRun, base);
rightRun->moveChildTo(this, rightBase);
// The now empty ruby base will be removed below.
}
}
}
RenderBlock::removeChild(child);
if (!m_beingDestroyed && !documentBeingDestroyed()) {
// Check if our base (if any) is now empty. If so, destroy it.
RenderBlock* base = rubyBase();
if (base && !base->firstChild()) {
RenderBlock::removeChild(base);
base->deleteLineBoxTree();
base->destroy();
}
// If any of the above leaves the run empty, destroy it as well.
if (isEmpty()) {
parent()->removeChild(this);
deleteLineBoxTree();
destroy();
}
}
}
示例8: ASSERT
void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, int& startOverhang, int& endOverhang) const
{
ASSERT(!needsLayout());
startOverhang = 0;
endOverhang = 0;
RenderRubyBase* rubyBase = this->rubyBase();
RenderRubyText* rubyText = this->rubyText();
if (!rubyBase || !rubyText)
return;
if (!rubyBase->firstRootBox())
return;
int logicalWidth = this->logicalWidth();
// No more than half a ruby is allowed to overhang.
int logicalLeftOverhang = rubyText->style(firstLine)->fontSize() / 2;
int logicalRightOverhang = logicalLeftOverhang;
for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox; rootInlineBox = rootInlineBox->nextRootBox()) {
logicalLeftOverhang = min<int>(logicalLeftOverhang, rootInlineBox->logicalLeft());
logicalRightOverhang = min<int>(logicalRightOverhang, logicalWidth - rootInlineBox->logicalRight());
}
startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : logicalRightOverhang;
endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : logicalLeftOverhang;
if (!startRenderer || !startRenderer->isText() || startRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
startOverhang = 0;
if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
endOverhang = 0;
}
示例9: RenderRubyBase
RenderRubyBase* RenderRubyBase::createAnonymous(Document* document)
{
RenderRubyBase* renderer = new RenderRubyBase();
renderer->setDocumentForAnonymous(document);
return renderer;
}