Commit 6dfa2fbc authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-04-27 François Sausset <sausset@gmail.com>

        Reviewed by Kenneth Rohde Christiansen.

        Additional MathML mroot & msqrt tests.
        https://bugs.webkit.org/show_bug.cgi?id=37044

        * mathml/presentation/roots.xhtml: Added.
        * platform/mac/mathml/presentation/roots-expected.checksum: Added.
        * platform/mac/mathml/presentation/roots-expected.png: Added.
        * platform/mac/mathml/presentation/roots-expected.txt: Added.
2010-04-27  François Sausset  <sausset@gmail.com>

        Reviewed by Kenneth Rohde Christiansen.

        Implementation of the MathML mroot & msqrt elements.
        https://bugs.webkit.org/show_bug.cgi?id=37044

        Test: mathml/presentation/roots.xhtml

        * WebCore.xcodeproj/project.pbxproj:
        * css/mathml.css:
        (mroot):
        (mroot > * + *):
        (mroot > * + mrow, mroot > * + mfenced):
        * mathml/MathMLInlineContainerElement.cpp:
        (WebCore::MathMLInlineContainerElement::createRenderer):
        * mathml/RenderMathMLRoot.cpp: Added.
        (WebCore::RenderMathMLRoot::RenderMathMLRoot):
        (WebCore::RenderMathMLRoot::addChild):
        (WebCore::RenderMathMLRoot::paint):
        (WebCore::RenderMathMLRoot::layout):
        * mathml/RenderMathMLRoot.h: Added.
        * mathml/RenderMathMLSquareRoot.cpp: Added.
        (WebCore::RenderMathMLSquareRoot::RenderMathMLSquareRoot):
        (WebCore::RenderMathMLSquareRoot::paint):
        (WebCore::RenderMathMLSquareRoot::layout):
        * mathml/RenderMathMLSquareRoot.h: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 14feb458
2010-04-27 François Sausset <sausset@gmail.com>
Reviewed by Kenneth Rohde Christiansen.
Additional MathML mroot & msqrt tests.
https://bugs.webkit.org/show_bug.cgi?id=37044
* mathml/presentation/roots.xhtml: Added.
* platform/mac/mathml/presentation/roots-expected.checksum: Added.
* platform/mac/mathml/presentation/roots-expected.png: Added.
* platform/mac/mathml/presentation/roots-expected.txt: Added.
2010-04-27 Jeremy Orlow <jorlow@chromium.org>
 
Reviewed by Dimitri Glazkov.
......
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Roots</title>
<style type='text/css'>
</style>
</head>
<body>
<p id='t1'>square root:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<msqrt><mn>2</mn></msqrt>
</math></p>
<p id='t2'>long square root:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<msqrt><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></msqrt>
</math></p>
<p id='t3'>long square root with implied row:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<msqrt><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></msqrt>
</math></p>
<p id='t4'>root of a fraction:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<msqrt>
<mfrac>
<mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow>
<mrow><mi>x</mi><mo>+</mo><mn>2</mn></mrow>
</mfrac>
</msqrt>
</math></p>
<p id='t5'>cube root:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mroot><mn>2</mn><mn>3</mn></mroot>
</math></p>
<p id='t6'>long index:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mroot><mn>2</mn><mrow><mi>x</mi><mo>+</mo><mi>y</mi><mo>+</mo><mi>z</mi></mrow></mroot>
</math></p>
<p id='t7'>long index w/ complex base:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mroot>
<mfrac>
<mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow>
<mrow><mi>x</mi><mo>+</mo><mn>2</mn></mrow>
</mfrac>
<mrow><mi>x</mi><mo>+</mo><mi>y</mi><mo>+</mo><mi>z</mi></mrow>
</mroot>
</math></p>
<p id='t8'>high index:
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mroot>
<mn>2</mn>
<mfrac>
<mfrac>
<mi>x</mi>
<mi>y</mi>
</mfrac>
<mi>z</mi>
</mfrac>
</mroot>
</math></p>
<p id='t9'>Imbricated square roots:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msqrt>
<mn>1</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>2</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>3</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>4</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>5</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>6</mn>
<mo>+</mo>
<msqrt>
<mrow>
<mn>7</mn>
<mo>+</mo>
<msqrt>
<mi>A</mi>
</msqrt>
</mrow>
</msqrt>
</mrow>
</msqrt>
</mrow>
</msqrt>
</mrow>
</msqrt>
</mrow>
</msqrt>
</mrow>
</msqrt>
</msqrt>
</math>
</p>
<p id='t9'>Imbricated roots:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mroot>
<mrow>
<mn>1</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>2</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>3</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>4</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>5</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>6</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>7</mn>
<mo>+</mo>
<mroot>
<mi>A</mi>
<mfrac>
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
<mi>z</mi>
</mfrac>
</mroot>
</mrow>
<mn>9</mn>
</mroot>
</mrow>
<mn>8</mn>
</mroot>
</mrow>
<mn>7</mn>
</mroot>
</mrow>
<mn>6</mn>
</mroot>
</mrow>
<mn>5</mn>
</mroot>
</mrow>
<mn>4</mn>
</mroot>
</mrow>
<mn>3</mn>
</mroot>
</math>
</p>
</body>
</html>
\ No newline at end of file
3cf839abbf65041f5d303d08f88836f3
\ No newline at end of file
2010-04-27 François Sausset <sausset@gmail.com>
Reviewed by Kenneth Rohde Christiansen.
Implementation of the MathML mroot & msqrt elements.
https://bugs.webkit.org/show_bug.cgi?id=37044
Test: mathml/presentation/roots.xhtml
* WebCore.xcodeproj/project.pbxproj:
* css/mathml.css:
(mroot):
(mroot > * + *):
(mroot > * + mrow, mroot > * + mfenced):
* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::createRenderer):
* mathml/RenderMathMLRoot.cpp: Added.
(WebCore::RenderMathMLRoot::RenderMathMLRoot):
(WebCore::RenderMathMLRoot::addChild):
(WebCore::RenderMathMLRoot::paint):
(WebCore::RenderMathMLRoot::layout):
* mathml/RenderMathMLRoot.h: Added.
* mathml/RenderMathMLSquareRoot.cpp: Added.
(WebCore::RenderMathMLSquareRoot::RenderMathMLSquareRoot):
(WebCore::RenderMathMLSquareRoot::paint):
(WebCore::RenderMathMLSquareRoot::layout):
* mathml/RenderMathMLSquareRoot.h: Added.
2010-04-27 Darin Adler <darin@apple.com>
 
Reviewed by Maciej Stachowiak.
......@@ -220,6 +220,10 @@
0FD308D6117D168500A791F7 /* RenderIFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD308D4117D168400A791F7 /* RenderIFrame.h */; };
0FD723820EC8BD9300CA5DD7 /* FloatQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FD723830EC8BD9300CA5DD7 /* FloatQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD723810EC8BD9300CA5DD7 /* FloatQuad.cpp */; };
0FF2859011864052007B7CD6 /* RenderMathMLRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2813211821CB6007B7CD6 /* RenderMathMLRoot.cpp */; };
0FF2859111864053007B7CD6 /* RenderMathMLRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF2813311821CB6007B7CD6 /* RenderMathMLRoot.h */; };
0FF2859211864054007B7CD6 /* RenderMathMLSquareRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2813411821CB6007B7CD6 /* RenderMathMLSquareRoot.cpp */; };
0FF2859311864055007B7CD6 /* RenderMathMLSquareRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF2813511821CB6007B7CD6 /* RenderMathMLSquareRoot.h */; };
0FF5025B102BA9010066F39A /* DOMStyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF50259102BA9010066F39A /* DOMStyleMedia.h */; };
0FF5025C102BA9010066F39A /* DOMStyleMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FF5025A102BA9010066F39A /* DOMStyleMedia.mm */; };
0FF50263102BA92C0066F39A /* DOMStyleMediaInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF50262102BA92B0066F39A /* DOMStyleMediaInternal.h */; };
......@@ -5597,6 +5601,10 @@
0FD308D4117D168400A791F7 /* RenderIFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderIFrame.h; sourceTree = "<group>"; };
0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatQuad.h; sourceTree = "<group>"; };
0FD723810EC8BD9300CA5DD7 /* FloatQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatQuad.cpp; sourceTree = "<group>"; };
0FF2813211821CB6007B7CD6 /* RenderMathMLRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLRoot.cpp; sourceTree = "<group>"; };
0FF2813311821CB6007B7CD6 /* RenderMathMLRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLRoot.h; sourceTree = "<group>"; };
0FF2813411821CB6007B7CD6 /* RenderMathMLSquareRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLSquareRoot.cpp; sourceTree = "<group>"; };
0FF2813511821CB6007B7CD6 /* RenderMathMLSquareRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSquareRoot.h; sourceTree = "<group>"; };
0FF50259102BA9010066F39A /* DOMStyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMStyleMedia.h; sourceTree = "<group>"; };
0FF5025A102BA9010066F39A /* DOMStyleMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMStyleMedia.mm; sourceTree = "<group>"; };
0FF50262102BA92B0066F39A /* DOMStyleMediaInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMStyleMediaInternal.h; sourceTree = "<group>"; };
......@@ -16349,8 +16357,12 @@
FA0B1F8311125CEE007F9839 /* RenderMathMLMath.h */,
FA5FAE4011126A5D00D3750F /* RenderMathMLOperator.cpp */,
FA5FAE4111126A5D00D3750F /* RenderMathMLOperator.h */,
0FF2813211821CB6007B7CD6 /* RenderMathMLRoot.cpp */,
0FF2813311821CB6007B7CD6 /* RenderMathMLRoot.h */,
FA0B1F8411125CEE007F9839 /* RenderMathMLRow.cpp */,
FA0B1F8511125CEE007F9839 /* RenderMathMLRow.h */,
0FF2813411821CB6007B7CD6 /* RenderMathMLSquareRoot.cpp */,
0FF2813511821CB6007B7CD6 /* RenderMathMLSquareRoot.h */,
FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */,
FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */,
FA7EFB031120D25400CF79C7 /* RenderMathMLUnderOver.cpp */,
......@@ -18883,6 +18895,8 @@
2E3BC108117D479800B9409A /* DOMFileError.h in Headers */,
2E3BC10B117D47C800B9409A /* DOMFileErrorInternal.h in Headers */,
37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */,
0FF2859111864053007B7CD6 /* RenderMathMLRoot.h in Headers */,
0FF2859311864055007B7CD6 /* RenderMathMLSquareRoot.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -21119,6 +21133,8 @@
973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */,
2E3BC0CA117D3E0800B9409A /* JSFileError.cpp in Sources */,
2E3BC109117D479800B9409A /* DOMFileError.mm in Sources */,
0FF2859011864052007B7CD6 /* RenderMathMLRoot.cpp in Sources */,
0FF2859211864054007B7CD6 /* RenderMathMLSquareRoot.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -132,14 +132,23 @@ msqrt {
mroot {
display: inline-block;
position: relative;
padding-top: 0.2em;
padding-left: 0.2em;
}
mroot > * + * {
font-size: 0.75em;
vertical-align: top;
padding-right: 0.3em;
vertical-align: bottom;
position: absolute;
left: 0px;
padding-right: 0.4em;
padding-left: 0.2em;
padding-bottom: 0.2em;
}
mroot > * + mrow, mroot > * + mfenced {
padding-bottom: 0.4em;
}
mtable {
......
......@@ -33,7 +33,9 @@
#include "RenderMathMLBlock.h"
#include "RenderMathMLFraction.h"
#include "RenderMathMLMath.h"
#include "RenderMathMLRoot.h"
#include "RenderMathMLRow.h"
#include "RenderMathMLSquareRoot.h"
#include "RenderMathMLSubSup.h"
#include "RenderMathMLUnderOver.h"
......@@ -72,6 +74,10 @@ RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena *arena, R
object = new (arena) RenderMathMLUnderOver(this);
else if (hasLocalName(MathMLNames::mfracTag))
object = new (arena) RenderMathMLFraction(this);
else if (hasLocalName(MathMLNames::msqrtTag))
object = new (arena) RenderMathMLSquareRoot(this);
else if (hasLocalName(MathMLNames::mrootTag))
object = new (arena) RenderMathMLRoot(this);
else
object = new (arena) RenderMathMLBlock(this);
object->setStyle(style);
......
/*
* Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
* Copyright (C) 2010 François Sausset (sausset@gmail.com). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(MATHML)
#include "RenderMathMLRoot.h"
#include "GraphicsContext.h"
#include "MathMLNames.h"
namespace WebCore {
using namespace MathMLNames;
// Left margin of the radical (px)
const int gRadicalLeftMargin = 3;
// Bottom padding of the radical (px)
const int gRadicalBasePad = 3;
// Threshold above which the radical shape is modified to look nice with big bases (%)
const float gThresholdBaseHeight = 1.5;
// Radical width (%)
const float gRadicalWidth = 0.75;
// Horizontal position of the bottom point of the radical (%)
const float gRadicalBottomPointXPos= 0.5;
// Horizontal position of the top left point of the radical (%)
const float gRadicalTopLeftPointXPos = 0.8;
// Vertical position of the top left point of the radical (%)
const float gRadicalTopLeftPointYPos = 0.625;
// Vertical shift of the left end point of the radical (%)
const float gRadicalLeftEndYShift = 0.05;
// Root padding around the base (%)
const float gRootPadding = 0.2;
// Additional bottom root padding (%)
const float gRootBottomPadding = 0.2;
// Radical line thickness (%)
const float gRadicalLineThickness = 0.02;
// Radical thick line thickness (%)
const float gRadicalThickLineThickness = 0.1;
RenderMathMLRoot::RenderMathMLRoot(Node *expression)
: RenderMathMLBlock(expression)
{
}
void RenderMathMLRoot::addChild(RenderObject* child, RenderObject* )
{
if (isEmpty()) {
// Add a block for the index
RenderBlock* block = new (renderArena()) RenderBlock(node());
RefPtr<RenderStyle> indexStyle = makeBlockStyle();
indexStyle->setDisplay(INLINE_BLOCK);
block->setStyle(indexStyle.release());
RenderBlock::addChild(block);
// FIXME: the wrapping does not seem to be needed anymore.
// this is the base, so wrap it so we can pad it
block = new (renderArena()) RenderBlock(node());
RefPtr<RenderStyle> baseStyle = makeBlockStyle();
baseStyle->setDisplay(INLINE_BLOCK);
baseStyle->setPaddingLeft(Length(5 * gRadicalWidth , Percent));
block->setStyle(baseStyle.release());
RenderBlock::addChild(block);
block->addChild(child);
} else {
// always add to the index
firstChild()->addChild(child);
}
}
void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty)
{
RenderMathMLBlock::paint(info , tx , ty);
tx += x();
ty += y();
RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild());
int maxHeight = indexBox->offsetHeight();
// default to the font size in pixels if we're empty
if (!maxHeight)
maxHeight = style()->fontSize();
int width = indexBox->offsetWidth();
int indexWidth = 0;
RenderObject* current = firstChild();
while (current != lastChild()) {
if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
indexWidth += box->offsetWidth();
}
current = current->nextSibling();
}
int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
int topStartShift = 0;
// Base height above which the shape of the root changes
int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.;
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
}
width += topStartShift;
int rootPad = static_cast<int>(gRootPadding * style()->fontSize());
int start = tx + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
ty += style()->paddingTop().value() - rootPad;
FloatPoint topStart(start - topStartShift, ty);
FloatPoint bottomLeft(start - gRadicalBottomPointXPos * frontWidth , ty + maxHeight + gRadicalBasePad);
FloatPoint topLeft(start - gRadicalTopLeftPointXPos * frontWidth , ty + gRadicalTopLeftPointYPos * maxHeight);
FloatPoint leftEnd(start - frontWidth , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize());
info.context->save();
info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize());
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(style()->color(), sRGBColorSpace);
info.context->setLineJoin(MiterJoin);
info.context->setMiterLimit(style()->fontSize());
Path root;
root.moveTo(FloatPoint(topStart.x() + width, ty));
// draw top
root.addLineTo(topStart);
// draw from top left corner to bottom point of radical
root.addLineTo(bottomLeft);
// draw from bottom point to top of left part of radical base "pocket"
root.addLineTo(topLeft);
// draw to end
root.addLineTo(leftEnd);
info.context->beginPath();
info.context->addPath(root);
info.context->strokePath();
info.context->save();
// Build a mask to draw the thick part of the root.
Path mask;
mask.moveTo(topStart);
mask.addLineTo(bottomLeft);
mask.addLineTo(topLeft);
mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
info.context->beginPath();
info.context->addPath(mask);
info.context->clip(mask);
// Draw the thick part of the root.
info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize());
info.context->setLineCap(SquareCap);
Path line;
line = line.createLine(bottomLeft, topLeft);
info.context->beginPath();
info.context->addPath(line);
info.context->strokePath();
info.context->restore();
info.context->restore();
}
void RenderMathMLRoot::layout()
{
RenderBlock::layout();
int maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();
RenderObject* current = lastChild()->firstChild();
toRenderMathMLBlock(current)->style()->setVerticalAlign(BASELINE);
if (!maxHeight)
maxHeight = style()->fontSize();
// Base height above which the shape of the root changes
int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
int topStartShift = 0;
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.;
int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
}
// Positioning of the index
RenderBoxModelObject* indexBox = toRenderBoxModelObject(firstChild()->firstChild());
int indexShift = indexBox->offsetWidth() + topStartShift;
int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight() - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
style()->setPaddingLeft(Length(indexShift, Fixed));
if (rootMarginTop > 0)
style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
setNeedsLayoutAndPrefWidthsRecalc();
markContainingBlocksForLayout();
RenderBlock::layout();
indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed));
indexBox->layout();
}
}
#endif // ENABLE(MATHML)
/*
* Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RenderMathMLRoot_h
#define RenderMathMLRoot_h
#if ENABLE(MATHML)