Example #1
0
// 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();
}