Modified: trunk/Source/WebCore/ChangeLog (203394 => 203395)
--- trunk/Source/WebCore/ChangeLog 2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/ChangeLog 2016-07-19 05:36:16 UTC (rev 203395)
@@ -1,3 +1,27 @@
+2016-07-18 Frederic Wang <[email protected]>
+
+ Do not store gap and shift parameters on RenderMathMLFraction
+ https://bugs.webkit.org/show_bug.cgi?id=159876
+
+ Reviewed by Darin Adler.
+
+ After r203285, the stack and fraction layout parameters are only used in layoutBlock so we
+ do not need to store them on the class. We remove them and split updateLayoutParameters into
+ three functions: one to update the linethickness and two others to retrieve the fraction and
+ stack respectively.
+
+ No new tests, rendering is unchanged.
+
+ * rendering/mathml/RenderMathMLFraction.cpp:
+ (WebCore::RenderMathMLFraction::updateLineThickness): Move code to update thickness members here.
+ (WebCore::RenderMathMLFraction::getFractionParameters): Move code to retrieve fraction parameters here.
+ (WebCore::RenderMathMLFraction::getStackParameters): Move code to retrieve stack parameters here.
+ (WebCore::RenderMathMLFraction::layoutBlock): Use the new helper functions and local variables
+ for fraction and stack parameters.
+ (WebCore::RenderMathMLFraction::updateLayoutParameters): Deleted.
+ * rendering/mathml/RenderMathMLFraction.h: Declare new helper functions and remove members
+ for stack and fraction parameters.
+
2016-07-18 Chris Dumez <[email protected]>
input.formEnctype / formMethod and button.formEnctype / formMethod / type should treat null as "null"
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (203394 => 203395)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2016-07-19 05:36:16 UTC (rev 203395)
@@ -67,11 +67,8 @@
return *firstChildBox()->nextSiblingBox();
}
-void RenderMathMLFraction::updateLayoutParameters()
+void RenderMathMLFraction::updateLineThickness()
{
- // We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise.
- // We also parse presentation attributes of the <mfrac> element.
-
// We first determine the default line thickness.
const auto& primaryFont = style().fontCascade().primaryFont();
const auto* mathData = style().fontCascade().primaryFont().mathData();
@@ -80,38 +77,55 @@
else
m_defaultLineThickness = ruleThicknessFallback();
- // Resolve the thickness using m_defaultLineThickness as the default value.
+ // Next we resolve the thickness using m_defaultLineThickness as the default value.
m_lineThickness = toUserUnits(element().lineThickness(), style(), m_defaultLineThickness);
if (m_lineThickness < 0)
m_lineThickness = 0;
+}
- // We now know whether we should layout as a normal fraction or as a stack (fraction without bar) and so determine the relevant constants.
+void RenderMathMLFraction::getFractionParameters(LayoutUnit& numeratorGapMin, LayoutUnit& denominatorGapMin, LayoutUnit& numeratorMinShiftUp, LayoutUnit& denominatorMinShiftDown)
+{
+ ASSERT(!isStack());
+
+ // We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise.
+ const auto& primaryFont = style().fontCascade().primaryFont();
+ const auto* mathData = style().fontCascade().primaryFont().mathData();
bool display = mathMLStyle()->displayStyle();
- if (isStack()) {
- if (mathData) {
- m_gapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackDisplayStyleGapMin : OpenTypeMathData::StackGapMin);
- m_topShiftUp = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackTopDisplayStyleShiftUp : OpenTypeMathData::StackTopShiftUp);
- m_bottomShiftDown = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackBottomDisplayStyleShiftDown : OpenTypeMathData::StackBottomShiftDown);
- } else {
- // We use the values suggested in the MATH table specification.
- m_gapMin = m_denominatorGapMin = display ? 7 * ruleThicknessFallback() : 3 * ruleThicknessFallback();
+ if (mathData) {
+ numeratorGapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumDisplayStyleGapMin : OpenTypeMathData::FractionNumeratorGapMin);
+ denominatorGapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenomDisplayStyleGapMin : OpenTypeMathData::FractionDenominatorGapMin);
+ numeratorMinShiftUp = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumeratorDisplayStyleShiftUp : OpenTypeMathData::FractionNumeratorShiftUp);
+ denominatorMinShiftDown = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenominatorDisplayStyleShiftDown : OpenTypeMathData::FractionDenominatorShiftDown);
+ } else {
+ // The MATH table specification suggests default rule thickness or (in displaystyle) 3 times default rule thickness for the gaps.
+ numeratorGapMin = display ? 3 * ruleThicknessFallback() : ruleThicknessFallback();
+ denominatorGapMin = numeratorGapMin;
- // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
- m_topShiftUp = m_bottomShiftDown = 0;
- }
+ // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
+ numeratorMinShiftUp = 0;
+ denominatorMinShiftDown = 0;
+ }
+}
+
+void RenderMathMLFraction::getStackParameters(LayoutUnit& gapMin, LayoutUnit& topShiftUp, LayoutUnit& bottomShiftDown)
+{
+ ASSERT(isStack());
+
+ // We try and read constants to draw the stack from the OpenType MATH and use fallback values otherwise.
+ const auto& primaryFont = style().fontCascade().primaryFont();
+ const auto* mathData = style().fontCascade().primaryFont().mathData();
+ bool display = mathMLStyle()->displayStyle();
+ if (mathData) {
+ gapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackDisplayStyleGapMin : OpenTypeMathData::StackGapMin);
+ topShiftUp = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackTopDisplayStyleShiftUp : OpenTypeMathData::StackTopShiftUp);
+ bottomShiftDown = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::StackBottomDisplayStyleShiftDown : OpenTypeMathData::StackBottomShiftDown);
} else {
- if (mathData) {
- m_numeratorGapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumDisplayStyleGapMin : OpenTypeMathData::FractionNumeratorGapMin);
- m_denominatorGapMin = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenomDisplayStyleGapMin : OpenTypeMathData::FractionDenominatorGapMin);
- m_numeratorMinShiftUp = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumeratorDisplayStyleShiftUp : OpenTypeMathData::FractionNumeratorShiftUp);
- m_denominatorMinShiftDown = mathData->getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenominatorDisplayStyleShiftDown : OpenTypeMathData::FractionDenominatorShiftDown);
- } else {
- // The MATH table specification suggests default rule thickness or (in displaystyle) 3 times default rule thickness for the gaps.
- m_numeratorGapMin = m_denominatorGapMin = display ? 3 * ruleThicknessFallback() : ruleThicknessFallback();
+ // We use the values suggested in the MATH table specification.
+ gapMin = display ? 7 * ruleThicknessFallback() : 3 * ruleThicknessFallback();
- // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
- m_numeratorMinShiftUp = m_denominatorMinShiftDown = 0;
- }
+ // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
+ topShiftUp = 0;
+ bottomShiftDown = 0;
}
}
@@ -127,7 +141,8 @@
{
ASSERT(preferredLogicalWidthsDirty());
- m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
+ m_minPreferredLogicalWidth = 0;
+ m_maxPreferredLogicalWidth = 0;
if (isValid()) {
LayoutUnit numeratorWidth = numerator().maxPreferredLogicalWidth();
@@ -172,7 +187,7 @@
setLogicalWidth(std::max(numerator().logicalWidth(), denominator().logicalWidth()));
- updateLayoutParameters();
+ updateLineThickness();
LayoutUnit verticalOffset = 0; // This is the top of the renderer.
LayoutPoint numeratorLocation(horizontalOffset(numerator(), element().numeratorAlignment()), verticalOffset);
numerator().setLocation(numeratorLocation);
@@ -182,12 +197,12 @@
LayoutUnit denominatorAscent = ascentForChild(denominator());
LayoutUnit denominatorDescent = denominator().logicalHeight() - denominatorAscent;
if (isStack()) {
- LayoutUnit topShiftUp = m_topShiftUp;
- LayoutUnit bottomShiftDown = m_bottomShiftDown;
+ LayoutUnit gapMin, topShiftUp, bottomShiftDown;
+ getStackParameters(gapMin, topShiftUp, bottomShiftDown);
LayoutUnit gap = topShiftUp - numeratorDescent + bottomShiftDown - denominatorAscent;
- if (gap < m_gapMin) {
+ if (gap < gapMin) {
// If the gap is not large enough, we increase the shifts by the same value.
- LayoutUnit delta = (m_gapMin - gap) / 2;
+ LayoutUnit delta = (gapMin - gap) / 2;
topShiftUp += delta;
bottomShiftDown += delta;
}
@@ -195,9 +210,11 @@
m_ascent = verticalOffset + mathAxisHeight();
verticalOffset += bottomShiftDown - denominatorAscent;
} else {
- verticalOffset += std::max(numerator().logicalHeight() + m_numeratorGapMin + m_lineThickness / 2, numeratorAscent + m_numeratorMinShiftUp); // This is the middle of the fraction bar.
+ LayoutUnit numeratorGapMin, denominatorGapMin, numeratorMinShiftUp, denominatorMinShiftDown;
+ getFractionParameters(numeratorGapMin, denominatorGapMin, numeratorMinShiftUp, denominatorMinShiftDown);
+ verticalOffset += std::max(numerator().logicalHeight() + numeratorGapMin + m_lineThickness / 2, numeratorAscent + numeratorMinShiftUp); // This is the middle of the fraction bar.
m_ascent = verticalOffset + mathAxisHeight();
- verticalOffset += std::max(m_lineThickness / 2 + m_denominatorGapMin, m_denominatorMinShiftDown - denominatorAscent);
+ verticalOffset += std::max(m_lineThickness / 2 + denominatorGapMin, denominatorMinShiftDown - denominatorAscent);
}
LayoutPoint denominatorLocation(horizontalOffset(denominator(), element().denominatorAlignment()), verticalOffset);
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h (203394 => 203395)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2016-07-19 05:36:16 UTC (rev 203395)
@@ -58,24 +58,13 @@
RenderBox& numerator() const;
RenderBox& denominator() const;
LayoutUnit horizontalOffset(RenderBox&, MathMLFractionElement::FractionAlignment);
- void updateLayoutParameters();
+ void updateLineThickness();
+ void getFractionParameters(LayoutUnit& numeratorGapMin, LayoutUnit& denominatorGapMin, LayoutUnit& numeratorMinShiftUp, LayoutUnit& denominatorMinShiftDown);
+ void getStackParameters(LayoutUnit& gapMin, LayoutUnit& topShiftUp, LayoutUnit& bottomShiftDown);
LayoutUnit m_ascent;
LayoutUnit m_defaultLineThickness { 1 };
LayoutUnit m_lineThickness;
- union {
- LayoutUnit m_numeratorGapMin;
- LayoutUnit m_gapMin;
- };
- LayoutUnit m_denominatorGapMin;
- union {
- LayoutUnit m_numeratorMinShiftUp;
- LayoutUnit m_topShiftUp;
- };
- union {
- LayoutUnit m_denominatorMinShiftDown;
- LayoutUnit m_bottomShiftDown;
- };
};
} // namespace WebCore