Diff
Modified: trunk/Source/WebCore/ChangeLog (110495 => 110496)
--- trunk/Source/WebCore/ChangeLog 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/ChangeLog 2012-03-12 22:59:44 UTC (rev 110496)
@@ -1,3 +1,41 @@
+2012-03-12 Levi Weintraub <[email protected]>
+
+ Update LayoutUnit usage in RenderMathML* classes
+ https://bugs.webkit.org/show_bug.cgi?id=77916
+
+ Reviewed by Eric Seidel.
+
+ The purpose of this patch is to ensure MathML rendering does not regress when
+ we switch to sub-pixel layout. A subsequent patch can likely improve MathML's
+ rendering when zoom is applied.
+
+ To accomplish this without changing the current heuristics for positioning,
+ we continue to use integers for sizes and locations, using pixel snapping
+ when communicating with other Rendering classes.
+
+ No new tests. No change in behavior.
+
+ * rendering/mathml/RenderMathMLBlock.cpp:
+ (WebCore::RenderMathMLBlock::paint): Cleaning up debug painting to be on
+ pixel boundaries instead of subpixel.
+ * rendering/mathml/RenderMathMLFraction.cpp:
+ (WebCore::RenderMathMLFraction::paint): Reverting to integers for determining
+ the vertical offset.
+ (WebCore::RenderMathMLFraction::baselinePosition):
+ * rendering/mathml/RenderMathMLRoot.cpp:
+ (WebCore::RenderMathMLRoot::paint): Using integers for height and width
+ and only accumulating pixel snapped values.
+ (WebCore::RenderMathMLRoot::layout): Setting padding with integers to
+ avoid inconsistent rounding based on the root's location.
+ * rendering/mathml/RenderMathMLRow.cpp:
+ (WebCore::RenderMathMLRow::layout):
+ * rendering/mathml/RenderMathMLSquareRoot.cpp:
+ (WebCore::RenderMathMLSquareRoot::paint): See RenderMathMLRoot.
+ (WebCore::RenderMathMLSquareRoot::layout): Ditto.
+ * rendering/mathml/RenderMathMLUnderOver.cpp:
+ (WebCore::getOffsetHeight):
+ (WebCore::RenderMathMLUnderOver::layout):
+
2012-03-12 Anders Carlsson <[email protected]>
Use smaller tiles for right and bottom edges
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -82,22 +82,22 @@
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB);
- info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
- info.context->drawLine(LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
- info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
- info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()));
+ info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()));
+ info.context->drawLine(IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
+ info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
+ info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
int topStart = paddingTop();
info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB);
- info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + topStart));
+ info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + topStart));
- int baseline = baselinePosition(AlphabeticBaseline, true, HorizontalLine);
+ int baseline = roundToInt(baselinePosition(AlphabeticBaseline, true, HorizontalLine));
info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB);
- info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + baseline));
+ info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + baseline));
}
#endif // ENABLE(DEBUG_MATH_LAYOUT)
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -151,7 +151,7 @@
if (!firstChild() ||!m_lineThickness)
return;
- LayoutUnit verticalOffset = 0;
+ int verticalOffset = 0;
// The children are always RenderMathMLBlock instances
if (firstChild()->isRenderMathMLBlock()) {
int adjustForThickness = m_lineThickness > 1 ? int(m_lineThickness / 2) : 1;
@@ -159,9 +159,9 @@
adjustForThickness++;
RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild());
if (numerator->isRenderMathMLRow())
- verticalOffset = numerator->offsetHeight() + adjustForThickness;
+ verticalOffset = numerator->pixelSnappedOffsetHeight() + adjustForThickness;
else
- verticalOffset = numerator->offsetHeight();
+ verticalOffset = numerator->pixelSnappedOffsetHeight();
}
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
@@ -173,7 +173,7 @@
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB);
- info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
+ info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()));
}
LayoutUnit RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const
@@ -186,7 +186,7 @@
else if (nextSibling())
refStyle = nextSibling()->style();
int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2));
- return numerator->offsetHeight() + shift;
+ return numerator->pixelSnappedOffsetHeight() + shift;
}
return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode);
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -108,18 +108,18 @@
RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild());
- LayoutUnit maxHeight = indexBox->offsetHeight();
+ int maxHeight = indexBox->pixelSnappedOffsetHeight();
// default to the font size in pixels if we're empty
if (!maxHeight)
maxHeight = style()->fontSize();
- LayoutUnit width = indexBox->offsetWidth();
+ int width = indexBox->pixelSnappedOffsetWidth();
- LayoutUnit indexWidth = 0;
+ int indexWidth = 0;
RenderObject* current = firstChild();
while (current != lastChild()) {
if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
- indexWidth += box->offsetWidth();
+ indexWidth += box->pixelSnappedOffsetWidth();
}
current = current->nextSibling();
}
@@ -139,7 +139,7 @@
width += topStartShift;
int rootPad = static_cast<int>(gRootPadding * style()->fontSize());
- LayoutUnit start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
+ int start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
FloatPoint topStart(start - topStartShift, adjustedPaintOffset.y());
@@ -199,7 +199,7 @@
if (!firstChild() || !lastChild())
return;
- LayoutUnit maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();
+ int maxHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
RenderObject* current = lastChild()->firstChild();
if (current)
@@ -209,17 +209,17 @@
maxHeight = style()->fontSize();
// Base height above which the shape of the root changes
- LayoutUnit thresholdHeight = static_cast<LayoutUnit>(gThresholdBaseHeight * style()->fontSize());
- LayoutUnit topStartShift = 0;
+ 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.0f;
- LayoutUnit frontWidth = static_cast<LayoutUnit>(style()->fontSize() * gRadicalWidth);
- topStartShift = static_cast<LayoutUnit>(gRadicalBottomPointXPos * frontWidth * shift);
+ int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
+ topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
- style()->setPaddingBottom(Length(static_cast<LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));
+ style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
}
// Positioning of the index
@@ -230,14 +230,14 @@
if (!indexBox)
return;
- LayoutUnit indexShift = indexBox->offsetWidth() + topStartShift;
- LayoutUnit radicalHeight = static_cast<LayoutUnit>((1 - gRadicalTopLeftPointYPos) * maxHeight);
- LayoutUnit rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight()
- - (maxHeight + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()));
+ 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()));
style()->setPaddingLeft(Length(indexShift, Fixed));
if (rootMarginTop > 0)
- style()->setPaddingTop(Length(rootMarginTop + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()), Fixed));
+ style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
setNeedsLayout(true);
setPreferredLogicalWidthsDirty(true, false);
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -45,7 +45,7 @@
{
RenderBlock::layout();
- LayoutUnit maxHeight = 0;
+ int maxHeight = 0;
// Calculate the non-operator max height of the row.
for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
@@ -56,8 +56,8 @@
} else if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
// Check to see if this box has a larger height.
- if (box->offsetHeight() > maxHeight)
- maxHeight = box->offsetHeight();
+ if (box->pixelSnappedOffsetHeight() > maxHeight)
+ maxHeight = box->pixelSnappedOffsetHeight();
}
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -75,8 +75,8 @@
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
- LayoutUnit maxHeight = 0;
- LayoutUnit width = 0;
+ int maxHeight = 0;
+ int width = 0;
RenderObject* current = firstChild();
while (current) {
if (current->isBoxModelObject()) {
@@ -84,9 +84,9 @@
RenderBoxModelObject* box = toRenderBoxModelObject(current);
// Check to see if this box has a larger height
- if (box->offsetHeight() > maxHeight)
- maxHeight = box->offsetHeight();
- width += box->offsetWidth();
+ if (box->pixelSnappedOffsetHeight() > maxHeight)
+ maxHeight = box->pixelSnappedOffsetHeight();
+ width += box->pixelSnappedOffsetWidth();
}
current = current->nextSibling();
}
@@ -160,15 +160,15 @@
void RenderMathMLSquareRoot::layout()
{
- LayoutUnit maxHeight = 0;
+ int maxHeight = 0;
RenderObject* current = firstChild();
while (current) {
if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
- if (box->offsetHeight() > maxHeight)
- maxHeight = box->offsetHeight();
+ if (box->pixelSnappedOffsetHeight() > maxHeight)
+ maxHeight = box->pixelSnappedOffsetHeight();
box->style()->setVerticalAlign(BASELINE);
}
@@ -179,8 +179,8 @@
maxHeight = style()->fontSize();
- if (maxHeight > static_cast<LayoutUnit>(gThresholdBaseHeight * style()->fontSize()))
- style()->setPaddingBottom(Length(static_cast<LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));
+ if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
+ style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
RenderBlock::layout();
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp (110495 => 110496)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp 2012-03-12 22:48:42 UTC (rev 110495)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp 2012-03-12 22:59:44 UTC (rev 110496)
@@ -131,7 +131,7 @@
{
if (obj->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(obj);
- return box->offsetHeight();
+ return box->pixelSnappedOffsetHeight();
}
return 0;
@@ -185,7 +185,7 @@
// base row wrapper
base = firstChild();
if (base) {
- LayoutUnit baseHeight = getOffsetHeight(base);
+ int baseHeight = getOffsetHeight(base);
// actual base
base = base->firstChild();
if (!base || !base->isBoxModelObject())
@@ -226,7 +226,7 @@
// We need to calculate the baseline of the base versus the start of the under block and
// adjust the placement of the under block.
- LayoutUnit baseHeight = getOffsetHeight(base);
+ int baseHeight = getOffsetHeight(base);
// actual base
base = base->firstChild();
if (!base || !base->isBoxModelObject())