Changeset 110496 in webkit


Ignore:
Timestamp:
Mar 12, 2012 3:59:44 PM (12 years ago)
Author:
leviw@chromium.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110495 r110496  
     12012-03-12  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update LayoutUnit usage in RenderMathML* classes
     4        https://bugs.webkit.org/show_bug.cgi?id=77916
     5
     6        Reviewed by Eric Seidel.
     7
     8        The purpose of this patch is to ensure MathML rendering does not regress when
     9        we switch to sub-pixel layout. A subsequent patch can likely improve MathML's
     10        rendering when zoom is applied.
     11
     12        To accomplish this without changing the current heuristics for positioning,
     13        we continue to use integers for sizes and locations, using pixel snapping
     14        when communicating with other Rendering classes.
     15
     16        No new tests. No change in behavior.
     17
     18        * rendering/mathml/RenderMathMLBlock.cpp:
     19        (WebCore::RenderMathMLBlock::paint): Cleaning up debug painting to be on
     20        pixel boundaries instead of subpixel.
     21        * rendering/mathml/RenderMathMLFraction.cpp:
     22        (WebCore::RenderMathMLFraction::paint): Reverting to integers for determining
     23        the vertical offset.
     24        (WebCore::RenderMathMLFraction::baselinePosition):
     25        * rendering/mathml/RenderMathMLRoot.cpp:
     26        (WebCore::RenderMathMLRoot::paint): Using integers for height and width
     27        and only accumulating pixel snapped values.
     28        (WebCore::RenderMathMLRoot::layout): Setting padding with integers to
     29        avoid inconsistent rounding based on the root's location.
     30        * rendering/mathml/RenderMathMLRow.cpp:
     31        (WebCore::RenderMathMLRow::layout):
     32        * rendering/mathml/RenderMathMLSquareRoot.cpp:
     33        (WebCore::RenderMathMLSquareRoot::paint): See RenderMathMLRoot.
     34        (WebCore::RenderMathMLSquareRoot::layout): Ditto.
     35        * rendering/mathml/RenderMathMLUnderOver.cpp:
     36        (WebCore::getOffsetHeight):
     37        (WebCore::RenderMathMLUnderOver::layout):
     38
    1392012-03-12  Anders Carlsson  <andersca@apple.com>
    240
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp

    r108249 r110496  
    8383    info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB);
    8484   
    85     info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
    86     info.context->drawLine(LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
    87     info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
    88     info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()));
     85    info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()));
     86    info.context->drawLine(IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
     87    info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
     88    info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
    8989   
    9090    int topStart = paddingTop();
     
    9292    info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB);
    9393   
    94     info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + topStart));
     94    info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + topStart));
    9595   
    96     int baseline = baselinePosition(AlphabeticBaseline, true, HorizontalLine);
     96    int baseline = roundToInt(baselinePosition(AlphabeticBaseline, true, HorizontalLine));
    9797   
    9898    info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB);
    9999   
    100     info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + baseline));
     100    info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + baseline));
    101101}
    102102#endif // ENABLE(DEBUG_MATH_LAYOUT)
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp

    r108136 r110496  
    152152        return;
    153153
    154     LayoutUnit verticalOffset = 0;
     154    int verticalOffset = 0;
    155155    // The children are always RenderMathMLBlock instances
    156156    if (firstChild()->isRenderMathMLBlock()) {
     
    160160        RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild());
    161161        if (numerator->isRenderMathMLRow())
    162             verticalOffset = numerator->offsetHeight() + adjustForThickness;
     162            verticalOffset = numerator->pixelSnappedOffsetHeight() + adjustForThickness;
    163163        else
    164             verticalOffset = numerator->offsetHeight();       
     164            verticalOffset = numerator->pixelSnappedOffsetHeight();       
    165165    }
    166166   
     
    174174    info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB);
    175175   
    176     info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
     176    info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()));
    177177}
    178178
     
    187187            refStyle = nextSibling()->style();
    188188        int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2));
    189         return numerator->offsetHeight() + shift;
     189        return numerator->pixelSnappedOffsetHeight() + shift;
    190190    }
    191191    return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp

    r107473 r110496  
    109109    RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild());
    110110   
    111     LayoutUnit maxHeight = indexBox->offsetHeight();
     111    int maxHeight = indexBox->pixelSnappedOffsetHeight();
    112112    // default to the font size in pixels if we're empty
    113113    if (!maxHeight)
    114114        maxHeight = style()->fontSize();
    115     LayoutUnit width = indexBox->offsetWidth();
    116    
    117     LayoutUnit indexWidth = 0;
     115    int width = indexBox->pixelSnappedOffsetWidth();
     116   
     117    int indexWidth = 0;
    118118    RenderObject* current = firstChild();
    119119    while (current != lastChild()) {
    120120        if (current->isBoxModelObject()) {
    121121            RenderBoxModelObject* box = toRenderBoxModelObject(current);
    122             indexWidth += box->offsetWidth();
     122            indexWidth += box->pixelSnappedOffsetWidth();
    123123        }
    124124        current = current->nextSibling();
     
    140140   
    141141    int rootPad = static_cast<int>(gRootPadding * style()->fontSize());
    142     LayoutUnit start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
     142    int start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
    143143    adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
    144144   
     
    200200        return;
    201201
    202     LayoutUnit maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();
     202    int maxHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
    203203   
    204204    RenderObject* current = lastChild()->firstChild();
     
    210210   
    211211    // Base height above which the shape of the root changes
    212     LayoutUnit thresholdHeight = static_cast<LayoutUnit>(gThresholdBaseHeight * style()->fontSize());
    213     LayoutUnit topStartShift = 0;
     212    int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
     213    int topStartShift = 0;
    214214   
    215215    if (maxHeight > thresholdHeight && thresholdHeight) {
     
    217217        if (shift > 1.)
    218218            shift = 1.0f;
    219         LayoutUnit frontWidth = static_cast<LayoutUnit>(style()->fontSize() * gRadicalWidth);
    220         topStartShift = static_cast<LayoutUnit>(gRadicalBottomPointXPos * frontWidth * shift);
     219        int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
     220        topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
    221221       
    222         style()->setPaddingBottom(Length(static_cast<LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));
     222        style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
    223223    }
    224224   
     
    231231        return;
    232232   
    233     LayoutUnit indexShift = indexBox->offsetWidth() + topStartShift;
    234     LayoutUnit radicalHeight = static_cast<LayoutUnit>((1 - gRadicalTopLeftPointYPos) * maxHeight);
    235     LayoutUnit rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight()
    236         - (maxHeight + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()));
     233    int indexShift = indexBox->pixelSnappedOffsetWidth() + topStartShift;
     234    int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
     235    int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
     236        - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
    237237   
    238238    style()->setPaddingLeft(Length(indexShift, Fixed));
    239239    if (rootMarginTop > 0)
    240         style()->setPaddingTop(Length(rootMarginTop + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()), Fixed));
     240        style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
    241241   
    242242    setNeedsLayout(true);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp

    r108302 r110496  
    4646    RenderBlock::layout();
    4747   
    48     LayoutUnit maxHeight = 0;
     48    int maxHeight = 0;
    4949
    5050    // Calculate the non-operator max height of the row.
     
    5757            RenderBoxModelObject* box = toRenderBoxModelObject(current);
    5858            // Check to see if this box has a larger height.
    59             if (box->offsetHeight() > maxHeight)
    60                 maxHeight = box->offsetHeight();
     59            if (box->pixelSnappedOffsetHeight() > maxHeight)
     60                maxHeight = box->pixelSnappedOffsetHeight();
    6161        }
    6262    }
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp

    r107296 r110496  
    7676    IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
    7777
    78     LayoutUnit maxHeight = 0;
    79     LayoutUnit width = 0;
     78    int maxHeight = 0;
     79    int width = 0;
    8080    RenderObject* current = firstChild();
    8181    while (current) {
     
    8585           
    8686            // Check to see if this box has a larger height
    87             if (box->offsetHeight() > maxHeight)
    88                 maxHeight = box->offsetHeight();
    89             width += box->offsetWidth();
     87            if (box->pixelSnappedOffsetHeight() > maxHeight)
     88                maxHeight = box->pixelSnappedOffsetHeight();
     89            width += box->pixelSnappedOffsetWidth();
    9090        }
    9191        current = current->nextSibling();
     
    161161void RenderMathMLSquareRoot::layout()
    162162{
    163     LayoutUnit maxHeight = 0;
     163    int maxHeight = 0;
    164164   
    165165    RenderObject* current = firstChild();
     
    168168            RenderBoxModelObject* box = toRenderBoxModelObject(current);
    169169           
    170             if (box->offsetHeight() > maxHeight)
    171                 maxHeight = box->offsetHeight();
     170            if (box->pixelSnappedOffsetHeight() > maxHeight)
     171                maxHeight = box->pixelSnappedOffsetHeight();
    172172           
    173173            box->style()->setVerticalAlign(BASELINE);
     
    180180
    181181   
    182     if (maxHeight > static_cast<LayoutUnit>(gThresholdBaseHeight * style()->fontSize()))
    183         style()->setPaddingBottom(Length(static_cast<LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));
     182    if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
     183        style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
    184184
    185185   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp

    r108249 r110496  
    132132    if (obj->isBoxModelObject()) {
    133133        RenderBoxModelObject* box = toRenderBoxModelObject(obj);
    134         return box->offsetHeight();
     134        return box->pixelSnappedOffsetHeight();
    135135    }
    136136   
     
    186186        base = firstChild();
    187187        if (base) {
    188             LayoutUnit baseHeight = getOffsetHeight(base);
     188            int baseHeight = getOffsetHeight(base);
    189189            // actual base
    190190            base = base->firstChild();
     
    227227                // adjust the placement of the under block.
    228228               
    229                 LayoutUnit baseHeight = getOffsetHeight(base);
     229                int baseHeight = getOffsetHeight(base);
    230230                // actual base
    231231                base = base->firstChild();
Note: See TracChangeset for help on using the changeset viewer.