This source file includes following definitions.
- createAnonymous
- isChildAllowed
- moveChildren
- moveInlineChildren
- moveBlockChildren
- rubyRun
- textAlignmentForLine
- adjustInlineDirectionLineBounds
#include "config.h"
#include "core/rendering/RenderRubyBase.h"
#include "core/rendering/RenderRubyRun.h"
using namespace std;
namespace WebCore {
RenderRubyBase::RenderRubyBase()
: RenderBlockFlow(0)
{
setInline(false);
}
RenderRubyBase::~RenderRubyBase()
{
}
RenderRubyBase* RenderRubyBase::createAnonymous(Document* document)
{
RenderRubyBase* renderer = new RenderRubyBase();
renderer->setDocumentForAnonymous(document);
return renderer;
}
bool RenderRubyBase::isChildAllowed(RenderObject* child, RenderStyle*) const
{
return child->isInline();
}
void RenderRubyBase::moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
ASSERT_ARG(toBase, toBase);
if (beforeChild && beforeChild->parent() != this)
beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
if (childrenInline())
moveInlineChildren(toBase, beforeChild);
else
moveBlockChildren(toBase, beforeChild);
setNeedsLayoutAndPrefWidthsRecalc();
toBase->setNeedsLayoutAndPrefWidthsRecalc();
}
void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
ASSERT(childrenInline());
ASSERT_ARG(toBase, toBase);
if (!firstChild())
return;
RenderBlock* toBlock;
if (toBase->childrenInline()) {
toBlock = toBase;
} else {
RenderObject* lastChild = toBase->lastChild();
if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
toBlock = toRenderBlock(lastChild);
else {
toBlock = toBase->createAnonymousBlock();
toBase->children()->appendChildNode(toBase, toBlock);
}
}
moveChildrenTo(toBlock, firstChild(), beforeChild);
}
void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
ASSERT(!childrenInline());
ASSERT_ARG(toBase, toBase);
if (!firstChild())
return;
if (toBase->childrenInline())
toBase->makeChildrenNonInline();
RenderObject* firstChildHere = firstChild();
RenderObject* lastChildThere = toBase->lastChild();
if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline()
&& lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {
RenderBlock* anonBlockHere = toRenderBlock(firstChildHere);
RenderBlock* anonBlockThere = toRenderBlock(lastChildThere);
anonBlockHere->moveAllChildrenTo(anonBlockThere, anonBlockThere->children());
anonBlockHere->deleteLineBoxTree();
anonBlockHere->destroy();
}
moveChildrenTo(toBase, firstChild(), beforeChild);
}
RenderRubyRun* RenderRubyBase::rubyRun() const
{
ASSERT(parent());
ASSERT(parent()->isRubyRun());
return toRenderRubyRun(parent());
}
ETextAlign RenderRubyBase::textAlignmentForLine(bool ) const
{
return JUSTIFY;
}
void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
{
int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth();
if (maxPreferredLogicalWidth >= logicalWidth)
return;
float inset = (logicalWidth - maxPreferredLogicalWidth) / (expansionOpportunityCount + 1);
logicalLeft += inset / 2;
logicalWidth -= inset;
}
}