Diff
Modified: trunk/Source/WebCore/ChangeLog (111635 => 111636)
--- trunk/Source/WebCore/ChangeLog 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/ChangeLog 2012-03-22 01:33:34 UTC (rev 111636)
@@ -1,3 +1,34 @@
+2012-03-21 David Barton <[email protected]>
+
+ MathML internals - improve naming in RenderMathMLSquareRoot.cpp and RenderMathMLRoot.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=81850
+
+ Reviewed by Eric Seidel.
+
+ This prepares these files for bug fixes, and eventually combining their common code. To
+ understand this patch, I suggest you start with RenderMathMLSquareRoot.cpp, as it's
+ simpler than RenderMathMLRoot.cpp.
+
+ No new tests. LayoutTests/mathml/presentation/roots.xhtml is thorough enough for this.
+
+ * rendering/mathml/RenderMathMLRoot.cpp:
+ (WebCore):
+ (WebCore::RenderMathMLRoot::addChild):
+ (WebCore::RenderMathMLRoot::paint):
+ (WebCore::RenderMathMLRoot::layout):
+ * rendering/mathml/RenderMathMLRoot.h:
+ (WebCore):
+ (RenderMathMLRoot):
+ * rendering/mathml/RenderMathMLSquareRoot.cpp:
+ (WebCore):
+ (WebCore::RenderMathMLSquareRoot::paint):
+ (WebCore::RenderMathMLSquareRoot::layout):
+ * rendering/mathml/RenderMathMLSquareRoot.h:
+ (WebCore):
+ (RenderMathMLSquareRoot):
+ * rendering/mathml/RenderMathMLSubSup.h:
+ (WebCore):
+
2012-03-21 Tony Chang <[email protected]>
refactor flexbox in preparation for flex-line-pack
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp (111635 => 111636)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2012-03-22 01:33:34 UTC (rev 111636)
@@ -38,32 +38,32 @@
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.5f;
-// Radical width (%)
-const float gRadicalWidth = 0.75f;
-// Horizontal position of the bottom point of the radical (%)
-const float gRadicalBottomPointXPos= 0.5f;
-// Horizontal position of the top left point of the radical (%)
-const float gRadicalTopLeftPointXPos = 0.8f;
-// Vertical position of the top left point of the radical (%)
-const float gRadicalTopLeftPointYPos = 0.625f;
-// Vertical shift of the left end point of the radical (%)
-const float gRadicalLeftEndYShift = 0.05f;
-// Root padding around the base (%)
-const float gRootPadding = 0.2f;
-// Additional bottom root padding (%)
-const float gRootBottomPadding = 0.2f;
+// Extra space on the left for the radical sign (px)
+const int gRadicalLeftExtra = 3;
+// Lower the radical sign's bottom point (px)
+const int gRadicalBottomPointLower = 3;
+// Threshold above which the radical shape is modified to look nice with big bases (em)
+const float gThresholdBaseHeightEms = 1.5f;
+// Front width (em)
+const float gFrontWidthEms = 0.75f;
+// Horizontal position of the bottom point of the radical (* frontWidth)
+const float gRadicalBottomPointXFront = 0.5f;
+// Horizontal position of the top left point of the radical "dip" (* frontWidth)
+const float gRadicalDipLeftPointXFront = 0.8f;
+// Vertical position of the top left point of the radical "dip" (* baseHeight)
+const float gRadicalDipLeftPointYPos = 0.625f;
+// Vertical shift of the left end point of the radical (em)
+const float gRadicalLeftEndYShiftEms = 0.05f;
+// Root padding around the base (em) (mroot padding-top/left from mathml.css)
+const float gRootPaddingEms = 0.2f;
+// Additional bottom root padding if baseHeight > threshold (em)
+const float gBigRootBottomPaddingEms = 0.2f;
+
+// Radical line thickness (em)
+const float gRadicalLineThicknessEms = 0.02f;
+// Radical thick line thickness (em)
+const float gRadicalThickLineThicknessEms = 0.1f;
-// Radical line thickness (%)
-const float gRadicalLineThickness = 0.02f;
-// Radical thick line thickness (%)
-const float gRadicalThickLineThickness = 0.1f;
-
RenderMathMLRoot::RenderMathMLRoot(Element* element)
: RenderMathMLBlock(element)
{
@@ -79,7 +79,7 @@
// FIXME: the wrapping does not seem to be needed anymore.
// this is the base, so wrap it so we can pad it
RenderBlock* baseWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
- baseWrapper->style()->setPaddingLeft(Length(5 * gRadicalWidth, Percent));
+ baseWrapper->style()->setPaddingLeft(Length(5 * gFrontWidthEms, Percent));
RenderBlock::addChild(baseWrapper);
baseWrapper->addChild(child);
} else {
@@ -94,19 +94,19 @@
if (info.context->paintingDisabled())
return;
-
+
if (!firstChild() || !lastChild())
return;
-
+
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
- RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild());
+ RenderBoxModelObject* baseWrapper = toRenderBoxModelObject(lastChild());
- int maxHeight = indexBox->pixelSnappedOffsetHeight();
+ int baseHeight = baseWrapper->pixelSnappedOffsetHeight();
// default to the font size in pixels if we're empty
- if (!maxHeight)
- maxHeight = style()->fontSize();
- int width = indexBox->pixelSnappedOffsetWidth();
+ if (!baseHeight)
+ baseHeight = style()->fontSize();
+ int overbarWidth = baseWrapper->pixelSnappedOffsetWidth();
int indexWidth = 0;
RenderObject* current = firstChild();
@@ -118,32 +118,32 @@
current = current->nextSibling();
}
- int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
- int topStartShift = 0;
+ int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
+ int overbarLeftPointShift = 0;
// Base height above which the shape of the root changes
- int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
+ int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
- if (maxHeight > thresholdHeight && thresholdHeight) {
- float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
+ if (baseHeight > thresholdHeight && thresholdHeight) {
+ float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.0f;
- topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
+ overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
}
- width += topStartShift;
+ overbarWidth += overbarLeftPointShift;
- int rootPad = static_cast<int>(gRootPadding * style()->fontSize());
- int start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
+ int rootPad = static_cast<int>(gRootPaddingEms * style()->fontSize());
+ int startX = adjustedPaintOffset.x() + indexWidth + gRadicalLeftExtra + style()->paddingLeft().value() - rootPad;
adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
- FloatPoint topStart(start - topStartShift, adjustedPaintOffset.y());
- FloatPoint bottomLeft(start - gRadicalBottomPointXPos * frontWidth , adjustedPaintOffset.y() + maxHeight + gRadicalBasePad);
- FloatPoint topLeft(start - gRadicalTopLeftPointXPos * frontWidth , adjustedPaintOffset.y() + gRadicalTopLeftPointYPos * maxHeight);
- FloatPoint leftEnd(start - frontWidth , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize());
+ FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
+ FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
+ FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
+ FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
GraphicsContextStateSaver stateSaver(*info.context);
- info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize());
+ info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
info.context->setLineJoin(MiterJoin);
@@ -151,13 +151,13 @@
Path root;
- root.moveTo(FloatPoint(topStart.x() + width, adjustedPaintOffset.y()));
+ root.moveTo(FloatPoint(overbarLeftPoint.x() + overbarWidth, adjustedPaintOffset.y()));
// draw top
- root.addLineTo(topStart);
+ root.addLineTo(overbarLeftPoint);
// 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);
+ root.addLineTo(bottomPoint);
+ // draw from bottom point to top of left part of radical base "dip"
+ root.addLineTo(dipLeftPoint);
// draw to end
root.addLineTo(leftEnd);
@@ -168,21 +168,21 @@
// 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()));
+ mask.moveTo(overbarLeftPoint);
+ mask.addLineTo(bottomPoint);
+ mask.addLineTo(dipLeftPoint);
+ mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
info.context->clip(mask);
// Draw the thick part of the root.
- info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize());
+ info.context->setStrokeThickness(gRadicalThickLineThicknessEms * style()->fontSize());
info.context->setLineCap(SquareCap);
Path line;
- line.moveTo(bottomLeft);
- line.addLineTo(topLeft);
-
+ line.moveTo(bottomPoint);
+ line.addLineTo(dipLeftPoint);
+
info.context->strokePath(line);
}
@@ -193,27 +193,27 @@
if (!firstChild() || !lastChild())
return;
- int maxHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
+ int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
+ if (!baseHeight)
+ baseHeight = style()->fontSize();
- RenderObject* current = lastChild()->firstChild();
- if (current)
- current->style()->setVerticalAlign(BASELINE);
+ RenderObject* base = lastChild()->firstChild();
+ if (base)
+ base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
- 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;
+ int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
+ int overbarLeftPointShift = 0;
- if (maxHeight > thresholdHeight && thresholdHeight) {
- float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
+ // FIXME: Can style() and indexBox->style() be modified (4 times below)?
+ if (baseHeight > thresholdHeight && thresholdHeight) {
+ float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.0f;
- int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
- topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
+ int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
+ overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
- style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
+ style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
}
// Positioning of the index
@@ -224,20 +224,20 @@
if (!indexBox)
return;
- int indexShift = indexBox->pixelSnappedOffsetWidth() + topStartShift;
- int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
- int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
- - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
+ int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
+ int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
+ int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
+ - (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
- style()->setPaddingLeft(Length(indexShift, Fixed));
- if (rootMarginTop > 0)
- style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
+ style()->setPaddingLeft(Length(shiftForIndex, Fixed));
+ if (rootExtraTop > 0)
+ style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
setNeedsLayout(true);
- setPreferredLogicalWidthsDirty(true, false);
+ setPreferredLogicalWidthsDirty(true, false); // FIXME: Can this really be right?
RenderBlock::layout();
- indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed));
+ indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));
// Now that we've potentially changed its position, we need layout the index again.
indexBox->setNeedsLayout(true);
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h (111635 => 111636)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h 2012-03-22 01:33:34 UTC (rev 111636)
@@ -32,11 +32,14 @@
namespace WebCore {
+// Render base^(1/index), using radical notation.
class RenderMathMLRoot : public RenderMathMLBlock {
public:
RenderMathMLRoot(Element*);
virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
+
virtual void paint(PaintInfo&, const LayoutPoint&);
+
protected:
virtual void layout();
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp (111635 => 111636)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp 2012-03-22 01:33:34 UTC (rev 111636)
@@ -33,33 +33,32 @@
#include "GraphicsContext.h"
#include "MathMLNames.h"
#include "PaintInfo.h"
-#include "Path.h"
namespace WebCore {
using namespace MathMLNames;
-// 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.5f;
-// Radical width (%)
-const float gRadicalWidth = 0.75f;
-// Horizontal position of the bottom point of the radical (%)
-const float gRadicalBottomPointXPos= 0.5f;
-// Horizontal position of the top left point of the radical (%)
-const float gRadicalTopLeftPointXPos = 0.2f;
-// Vertical position of the top left point of the radical (%)
-const float gRadicalTopLeftPointYPos = 0.5f;
-// Vertical shift of the left end point of the radical (%)
-const float gRadicalLeftEndYShift = 0.05f;
-// Additional bottom root padding (%)
-const float gRootBottomPadding = 0.2f;
+// Lower the radical sign's bottom point (px)
+const int gRadicalBottomPointLower = 3;
+// Threshold above which the radical shape is modified to look nice with big bases (em)
+const float gThresholdBaseHeightEms = 1.5f;
+// Front width (em)
+const float gFrontWidthEms = 0.75f;
+// Horizontal position of the bottom point of the radical (* frontWidth)
+const float gRadicalBottomPointXFront = 0.5f;
+// Horizontal position of the top left point of the radical "dip" (* frontWidth)
+const float gRadicalDipLeftPointXFront = 0.2f;
+// Vertical position of the top left point of the radical "dip" (* baseHeight)
+const float gRadicalDipLeftPointYPos = 0.5f;
+// Vertical shift of the left end point of the radical (em)
+const float gRadicalLeftEndYShiftEms = 0.05f;
+// Additional bottom root padding if baseHeight > threshold (em)
+const float gBigRootBottomPaddingEms = 0.2f;
-// Radical line thickness (%)
-const float gRadicalLineThickness = 0.02f;
-// Radical thick line thickness (%)
-const float gRadicalThickLineThickness = 0.1f;
+// Radical line thickness (em)
+const float gRadicalLineThicknessEms = 0.02f;
+// Radical thick line thickness (em)
+const float gRadicalThickLineThicknessEms = 0.1f;
RenderMathMLSquareRoot::RenderMathMLSquareRoot(Element* element)
: RenderMathMLBlock(element)
@@ -69,53 +68,54 @@
void RenderMathMLSquareRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
{
RenderMathMLBlock::paint(info, paintOffset);
-
+
if (info.context->paintingDisabled())
return;
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
-
- int maxHeight = 0;
- int width = 0;
+
+ int baseHeight = 0;
+ int overbarWidth = 0;
RenderObject* current = firstChild();
while (current) {
if (current->isBoxModelObject()) {
-
RenderBoxModelObject* box = toRenderBoxModelObject(current);
// Check to see if this box has a larger height
- if (box->pixelSnappedOffsetHeight() > maxHeight)
- maxHeight = box->pixelSnappedOffsetHeight();
- width += box->pixelSnappedOffsetWidth();
+ // FIXME: We should consider the height above & below the baseline separately. This will be
+ // fixed by an <mrow> base wrapper, which is required anyway by the MathML spec.
+ if (box->pixelSnappedOffsetHeight() > baseHeight)
+ baseHeight = box->pixelSnappedOffsetHeight();
+ overbarWidth += box->pixelSnappedOffsetWidth();
}
current = current->nextSibling();
}
// default to the font size in pixels if we're empty
- if (!maxHeight)
- maxHeight = style()->fontSize();
+ if (!baseHeight)
+ baseHeight = style()->fontSize();
- int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
- int topStartShift = 0;
+ int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
+ int overbarLeftPointShift = 0;
// Base height above which the shape of the root changes
- int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
+ int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
- if (maxHeight > thresholdHeight && thresholdHeight) {
- float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
+ if (baseHeight > thresholdHeight && thresholdHeight) {
+ float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.0f;
- topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
+ overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
}
- width += topStartShift;
+ overbarWidth += overbarLeftPointShift;
- FloatPoint topStart(adjustedPaintOffset.x() + frontWidth - topStartShift, adjustedPaintOffset.y());
- FloatPoint bottomLeft(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXPos , adjustedPaintOffset.y() + maxHeight + gRadicalBasePad);
- FloatPoint topLeft(adjustedPaintOffset.x() + frontWidth * gRadicalTopLeftPointXPos , adjustedPaintOffset.y() + gRadicalTopLeftPointYPos * maxHeight);
- FloatPoint leftEnd(adjustedPaintOffset.x() , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize());
+ FloatPoint overbarLeftPoint(adjustedPaintOffset.x() + frontWidth - overbarLeftPointShift, adjustedPaintOffset.y());
+ FloatPoint bottomPoint(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXFront, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
+ FloatPoint dipLeftPoint(adjustedPaintOffset.x() + frontWidth * gRadicalDipLeftPointXFront, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
+ FloatPoint leftEnd(adjustedPaintOffset.x(), dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
GraphicsContextStateSaver stateSaver(*info.context);
- info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize());
+ info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
info.context->setLineJoin(MiterJoin);
@@ -123,16 +123,16 @@
Path root;
- root.moveTo(FloatPoint(topStart.x() + width , adjustedPaintOffset.y()));
+ root.moveTo(FloatPoint(overbarLeftPoint.x() + overbarWidth, adjustedPaintOffset.y()));
// draw top
- root.addLineTo(topStart);
+ root.addLineTo(overbarLeftPoint);
// 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);
+ root.addLineTo(bottomPoint);
+ // draw from bottom point to top of left part of radical base "dip"
+ root.addLineTo(dipLeftPoint);
// draw to end
root.addLineTo(leftEnd);
-
+
info.context->strokePath(root);
GraphicsContextStateSaver maskStateSaver(*info.context);
@@ -140,48 +140,48 @@
// 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()));
+ mask.moveTo(overbarLeftPoint);
+ mask.addLineTo(bottomPoint);
+ mask.addLineTo(dipLeftPoint);
+ mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
info.context->clip(mask);
// Draw the thick part of the root.
- info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize());
+ info.context->setStrokeThickness(gRadicalThickLineThicknessEms * style()->fontSize());
info.context->setLineCap(SquareCap);
Path line;
- line.moveTo(bottomLeft);
- line.addLineTo(topLeft);
+ line.moveTo(bottomPoint);
+ line.addLineTo(dipLeftPoint);
info.context->strokePath(line);
}
void RenderMathMLSquareRoot::layout()
{
- int maxHeight = 0;
+ int baseHeight = 0;
RenderObject* current = firstChild();
while (current) {
if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
- if (box->pixelSnappedOffsetHeight() > maxHeight)
- maxHeight = box->pixelSnappedOffsetHeight();
+ if (box->pixelSnappedOffsetHeight() > baseHeight)
+ baseHeight = box->pixelSnappedOffsetHeight();
+ // FIXME: Can box->style() be modified?
box->style()->setVerticalAlign(BASELINE);
}
current = current->nextSibling();
}
- if (!maxHeight)
- maxHeight = style()->fontSize();
-
+ if (!baseHeight)
+ baseHeight = style()->fontSize();
- if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
- style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
-
+ // FIXME: Can style() be modified? And don't we need styleDidChange()?
+ if (baseHeight > static_cast<int>(gThresholdBaseHeightEms * style()->fontSize()))
+ style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
RenderBlock::layout();
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h (111635 => 111636)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h 2012-03-22 01:33:34 UTC (rev 111636)
@@ -32,10 +32,13 @@
namespace WebCore {
+// Render sqrt(base), using radical notation.
class RenderMathMLSquareRoot : public RenderMathMLBlock {
public:
RenderMathMLSquareRoot(Element*);
+
virtual void paint(PaintInfo&, const LayoutPoint&);
+
protected:
virtual void layout();
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h (111635 => 111636)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h 2012-03-22 01:29:04 UTC (rev 111635)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h 2012-03-22 01:33:34 UTC (rev 111636)
@@ -32,6 +32,7 @@
namespace WebCore {
+// Render a base with a subscript and/or a superscript.
class RenderMathMLSubSup : public RenderMathMLBlock {
public:
RenderMathMLSubSup(Element*);