本文整理汇总了C++中RenderMathMLBlock类的典型用法代码示例。如果您正苦于以下问题:C++ RenderMathMLBlock类的具体用法?C++ RenderMathMLBlock怎么用?C++ RenderMathMLBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderMathMLBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: element
// FIXME: It's cleaner to only call updateFromElement when an attribute has changed. The body of
// this method should probably be moved to a private stretchHeightChanged or checkStretchHeight
// method. Probably at the same time, addChild/removeChild methods should be made to work for
// dynamic DOM changes.
void RenderMathMLOperator::updateFromElement()
{
RenderElement* savedRenderer = element().renderer();
// Destroy our current children
destroyLeftoverChildren();
// Since we share a node with our children, destroying our children may set our node's
// renderer to 0, so we need to restore it.
element().setRenderer(savedRenderer);
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(style());
newStyle->setDisplay(FLEX);
RenderMathMLBlock* container = new RenderMathMLBlock(element());
// This container doesn't offer any useful information to accessibility.
container->setIgnoreInAccessibilityTree(true);
container->setStyle(newStyle.release());
addChild(container);
RenderText* text;
if (m_operator)
text = new RenderText(document(), String(&m_operator, 1));
else
text = new RenderText(document(), element().textContent().replace(hyphenMinus, minusSign).impl());
// If we can't figure out the text, leave it blank.
if (text)
container->addChild(text);
updateStyle();
setNeedsLayoutAndPrefWidthsRecalc();
}
示例2: firstChild
void RenderMathMLUnderOver::stretchToHeight(int height)
{
RenderObject* base = firstChild();
if (!base)
return;
// For over or underover, the base is the sibling of the first child
if (m_kind != Under)
base = base->nextSibling();
if (!base)
return;
// use the child of the row which is the actual base
base = base->firstChild();
if (base && base->isRenderMathMLBlock()) {
RenderMathMLBlock* block = toRenderMathMLBlock(base);
block->stretchToHeight(height);
updateBoxModelInfoFromStyle();
setNeedsLayoutAndPrefWidthsRecalc();
markContainingBlocksForLayout();
}
}
示例3: int
void RenderMathMLFraction::paint(PaintInfo& info, const LayoutPoint& paintOffset)
{
RenderMathMLBlock::paint(info, paintOffset);
if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground)
return;
if (!firstChild() ||!m_lineThickness)
return;
LayoutUnit verticalOffset = 0;
// The children are always RenderMathMLBlock instances
if (firstChild()->isRenderMathMLBlock()) {
int adjustForThickness = m_lineThickness > 1 ? int(m_lineThickness / 2) : 1;
if (int(m_lineThickness) % 2 == 1)
adjustForThickness++;
RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild());
if (numerator->isRenderMathMLRow())
verticalOffset = numerator->offsetHeight() + adjustForThickness;
else
verticalOffset = numerator->offsetHeight();
}
LayoutPoint adjustedPaintOffset = paintOffset + location();
adjustedPaintOffset.setY(adjustedPaintOffset.y() + verticalOffset);
GraphicsContextStateSaver stateSaver(*info.context);
info.context->setStrokeThickness(m_lineThickness);
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB);
info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
}
示例4: firstChild
void RenderMathMLSubSup::stretchToHeight(int height)
{
RenderObject* base = firstChild();
if (!base)
return;
if (base->isRenderMathMLBlock()) {
RenderMathMLBlock* block = toRenderMathMLBlock(base);
block->stretchToHeight(static_cast<int>(gSubSupStretch * height));
}
if (height > 0 && m_kind == SubSup && m_scripts) {
RenderObject* script = m_scripts->firstChild();
if (script) {
// Calculate the script height without the container margins.
RenderObject* top = script;
int topHeight = getBoxModelObjectHeight(top->firstChild());
int topAdjust = topHeight / gTopAdjustDivisor;
top->style()->setMarginTop(Length(-topAdjust, Fixed));
top->style()->setMarginBottom(Length(height - topHeight + topAdjust, Fixed));
if (top->isBoxModelObject()) {
RenderBoxModelObject* topBox = toRenderBoxModelObject(top);
topBox->updateBoxModelInfoFromStyle();
}
m_scripts->setNeedsLayoutAndPrefWidthsRecalc();
m_scripts->markContainingBlocksForLayout();
}
}
updateBoxModelInfoFromStyle();
setNeedsLayoutAndPrefWidthsRecalc();
markContainingBlocksForLayout();
}
示例5: new
RenderMathMLBlock* RenderMathMLBlock::createAnonymousMathMLBlock(EDisplay display)
{
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(style(), display);
RenderMathMLBlock* newBlock = new (renderArena()) RenderMathMLBlock(0);
newBlock->setDocumentForAnonymous(document());
newBlock->setStyle(newStyle.release());
return newBlock;
}
示例6: toRenderMathMLBlock
void RenderMathMLBlock::stretchToHeight(int height)
{
for (RenderObject* current = firstChild(); current; current = current->nextSibling())
if (current->isRenderMathMLBlock()) {
RenderMathMLBlock* block = toRenderMathMLBlock(current);
block->stretchToHeight(height);
}
}
示例7: toRenderMathMLBlock
void RenderMathMLUnderOver::stretchToHeight(int height)
{
RenderBoxModelObject* base = this->base();
if (base && base->isRenderMathMLBlock()) {
RenderMathMLBlock* block = toRenderMathMLBlock(base);
block->stretchToHeight(height);
setNeedsLayout(true);
}
}
示例8: createAnonymousMathMLBlock
void RenderMathMLFraction::addChild(RenderObject* child, RenderObject* beforeChild)
{
RenderMathMLBlock* row = createAnonymousMathMLBlock();
RenderMathMLBlock::addChild(row, beforeChild);
row->addChild(child);
fixChildStyle(row);
updateFromElement();
}
示例9: toRenderMathMLBlock
int RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
{
if (firstChild() && firstChild()->isRenderMathMLBlock()) {
RenderMathMLBlock* block = toRenderMathMLBlock(firstChild());
if (block->isRenderMathMLOperator())
return block->y() + block->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode);
}
return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode);
}
示例10: toElement
void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
{
// Note: The RenderMathMLBlock only allows element children to be added.
Element* childElement = toElement(child->node());
if (childElement && !childElement->previousElementSibling()) {
// Position 1 is always the base of the msub/msup/msubsup.
RenderMathMLBlock* wrapper = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> wrapperStyle = RenderStyle::create();
wrapperStyle->inheritFrom(style());
wrapperStyle->setDisplay(INLINE_BLOCK);
wrapperStyle->setVerticalAlign(BASELINE);
wrapper->setStyle(wrapperStyle.release());
RenderMathMLBlock::addChild(wrapper, firstChild());
wrapper->addChild(child);
// Make sure we have a script block for rendering.
if (m_kind == SubSup && !m_scripts) {
m_scripts = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> scriptsStyle = RenderStyle::create();
scriptsStyle->inheritFrom(style());
scriptsStyle->setDisplay(INLINE_BLOCK);
scriptsStyle->setVerticalAlign(TOP);
scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed));
scriptsStyle->setTextAlign(LEFT);
// Set this wrapper's font-size for its line-height & baseline position.
scriptsStyle->setBlendedFontSize(static_cast<int>(0.75 * style()->fontSize()));
m_scripts->setStyle(scriptsStyle.release());
RenderMathMLBlock::addChild(m_scripts, beforeChild);
}
} else {
if (m_kind == SubSup) {
ASSERT(childElement);
if (!childElement)
return;
RenderBlock* script = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> scriptStyle = RenderStyle::create();
scriptStyle->inheritFrom(m_scripts->style());
scriptStyle->setDisplay(BLOCK);
script->setStyle(scriptStyle.release());
// The order is always backwards so the first script is the subscript and the superscript
// is last. That means the superscript is the first to render vertically.
Element* previousSibling = childElement->previousElementSibling();
if (previousSibling && !previousSibling->previousElementSibling())
m_scripts->addChild(script);
else
m_scripts->addChild(script, m_scripts->firstChild());
script->addChild(child);
} else
RenderMathMLBlock::addChild(child, beforeChild);
}
}
示例11: new
void RenderMathMLUnderOver::addChild(RenderObject* child, RenderObject* beforeChild)
{
RenderMathMLBlock* row = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> rowStyle = makeBlockStyle();
row->setStyle(rowStyle.release());
// look through the children for rendered elements counting the blocks so we know what child
// we are adding
int blocks = 0;
RenderObject* current = this->firstChild();
while (current) {
blocks++;
current = current->nextSibling();
}
switch (blocks) {
case 0:
// this is the base so just append it
RenderBlock::addChild(row, beforeChild);
break;
case 1:
// the under or over
// FIXME: text-align: center does not work
row->style()->setTextAlign(CENTER);
if (m_kind == Over) {
// add the over as first
RenderBlock::addChild(row, firstChild());
} else {
// add the under as last
RenderBlock::addChild(row, beforeChild);
}
break;
case 2:
// the under or over
// FIXME: text-align: center does not work
row->style()->setTextAlign(CENTER);
if (m_kind == UnderOver) {
// add the over as first
RenderBlock::addChild(row, firstChild());
} else {
// we really shouldn't get here as only munderover should have three children
RenderBlock::addChild(row, beforeChild);
}
break;
default:
// munderover shouldn't have more than three children. In theory we shouldn't
// get here if the MathML is correctly formed, but that isn't a guarantee.
// We will treat this as another under element and they'll get something funky.
RenderBlock::addChild(row, beforeChild);
}
row->addChild(child);
}
示例12: toRenderMathMLBlock
LayoutUnit RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const
{
if (firstChild() && firstChild()->isRenderMathMLBlock()) {
RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild());
RenderStyle* refStyle = style();
if (previousSibling())
refStyle = previousSibling()->style();
else if (nextSibling())
refStyle = nextSibling()->style();
int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2));
return numerator->offsetHeight() + shift;
}
return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode);
}
示例13: toRenderElement
void RenderMathMLRow::layout()
{
int stretchHeightAboveBaseline = 0, stretchDepthBelowBaseline = 0;
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->needsLayout())
toRenderElement(child)->layout();
if (child->isRenderMathMLBlock()) {
// We skip the stretchy operators as they must not be included in the computation of the stretch size.
auto renderOperator = toRenderMathMLBlock(child)->unembellishedOperator();
if (renderOperator && renderOperator->hasOperatorFlag(MathMLOperatorDictionary::Stretchy))
continue;
}
LayoutUnit childHeightAboveBaseline = 0, childDepthBelowBaseline = 0;
if (child->isRenderMathMLBlock()) {
RenderMathMLBlock* mathmlChild = toRenderMathMLBlock(child);
childHeightAboveBaseline = mathmlChild->firstLineBaseline();
if (childHeightAboveBaseline == -1)
childHeightAboveBaseline = mathmlChild->logicalHeight();
childDepthBelowBaseline = mathmlChild->logicalHeight() - childHeightAboveBaseline;
} else if (child->isRenderMathMLTable()) {
RenderMathMLTable* tableChild = toRenderMathMLTable(child);
childHeightAboveBaseline = tableChild->firstLineBaseline();
childDepthBelowBaseline = tableChild->logicalHeight() - childHeightAboveBaseline;
} else if (child->isBox()) {
childHeightAboveBaseline = toRenderBox(child)->logicalHeight();
childDepthBelowBaseline = 0;
}
stretchHeightAboveBaseline = std::max<LayoutUnit>(stretchHeightAboveBaseline, childHeightAboveBaseline);
stretchDepthBelowBaseline = std::max<LayoutUnit>(stretchDepthBelowBaseline, childDepthBelowBaseline);
}
if (stretchHeightAboveBaseline + stretchDepthBelowBaseline <= 0)
stretchHeightAboveBaseline = style().fontSize();
// Set the sizes of (possibly embellished) stretchy operator children.
for (auto& child : childrenOfType<RenderMathMLBlock>(*this)) {
if (auto renderOperator = child.unembellishedOperator())
renderOperator->stretchTo(stretchHeightAboveBaseline, stretchDepthBelowBaseline);
}
RenderMathMLBlock::layout();
}
示例14: ASSERT
void RenderMathMLBlock::computeChildrenPreferredLogicalHeights()
{
ASSERT(needsLayout());
// This is ugly, but disable fragmentation when computing the preferred heights.
FragmentationDisabler fragmentationDisabler(this);
// Ensure a full repaint will happen after layout finishes.
setNeedsLayout(true, MarkOnlyThis);
RenderView* renderView = view();
bool hadLayoutState = renderView->layoutState();
if (!hadLayoutState)
renderView->pushLayoutState(this);
{
LayoutStateDisabler layoutStateDisabler(renderView);
LayoutUnit oldAvailableLogicalWidth = availableLogicalWidth();
setLogicalWidth(cLargeLogicalWidth);
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (!child->isBox())
continue;
// Because our width changed, |child| may need layout.
if (child->maxPreferredLogicalWidth() > oldAvailableLogicalWidth)
child->setNeedsLayout(true, MarkOnlyThis);
RenderMathMLBlock* childMathMLBlock = child->isRenderMathMLBlock() ? toRenderMathMLBlock(child) : 0;
if (childMathMLBlock && !childMathMLBlock->isPreferredLogicalHeightDirty())
continue;
// Layout our child to compute its preferred logical height.
child->layoutIfNeeded();
if (childMathMLBlock)
childMathMLBlock->setPreferredLogicalHeight(childMathMLBlock->logicalHeight());
}
}
if (!hadLayoutState)
renderView->popLayoutState(this);
}
示例15: new
void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
{
if (firstChild()) {
// We already have a base, so this is the super/subscripts being added.
if (m_kind == SubSup) {
if (!m_scripts) {
m_scripts = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> scriptsStyle = RenderStyle::create();
scriptsStyle->inheritFrom(style());
scriptsStyle->setDisplay(INLINE_BLOCK);
scriptsStyle->setVerticalAlign(MIDDLE);
scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed));
scriptsStyle->setTextAlign(LEFT);
m_scripts->setStyle(scriptsStyle.release());
RenderMathMLBlock::addChild(m_scripts, beforeChild);
}
RenderBlock* script = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> scriptStyle = RenderStyle::create();
scriptStyle->inheritFrom(m_scripts->style());
scriptStyle->setDisplay(BLOCK);
script->setStyle(scriptStyle.release());
m_scripts->addChild(script, m_scripts->firstChild());
script->addChild(child);
} else
RenderMathMLBlock::addChild(child, beforeChild);
} else {
RenderMathMLBlock* wrapper = new (renderArena()) RenderMathMLBlock(node());
RefPtr<RenderStyle> wrapperStyle = RenderStyle::create();
wrapperStyle->inheritFrom(style());
wrapperStyle->setDisplay(INLINE_BLOCK);
wrapperStyle->setVerticalAlign(MIDDLE);
wrapper->setStyle(wrapperStyle.release());
RenderMathMLBlock::addChild(wrapper, beforeChild);
wrapper->addChild(child);
}
}