Changeset 113221 in webkit


Ignore:
Timestamp:
Apr 4, 2012 11:54:38 AM (12 years ago)
Author:
eae@chromium.org
Message:

Convert RootInlineBox to LayoutUnits in preparation for turning on subpixel layout
https://bugs.webkit.org/show_bug.cgi?id=83054

Reviewed by Eric Seidel.

Convert RootInlineBox over to LayoutUnits, this mostly involves updating
the alignment and adjustment code to be subpixel aware.

No new tests, no change in functionality.

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::alignBoxesInBlockDirection):
Change beforeAnnotationsAdjustment to LayoutUnit.

(WebCore::RootInlineBox::beforeAnnotationsAdjustment):
Change method to return LayoutUnit as it is computed from values with
subpixel precision.

(WebCore::RootInlineBox::lineSnapAdjustment):
Round values before computing remainder.

(WebCore::RootInlineBox::ascentAndDescentForBox):
Change ascent and decent calculation to use LayoutUnits as they are
computed from values with subpixel precision.

(WebCore::RootInlineBox::verticalPositionForBox):
Change verticalPosition to LayoutUnit.

  • rendering/RootInlineBox.h:

(RootInlineBox):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r113220 r113221  
     12012-04-04  Emil A Eklund  <eae@chromium.org>
     2
     3        Convert RootInlineBox to LayoutUnits in preparation for turning on subpixel layout
     4        https://bugs.webkit.org/show_bug.cgi?id=83054
     5
     6        Reviewed by Eric Seidel.
     7
     8        Convert RootInlineBox over to LayoutUnits, this mostly involves updating
     9        the alignment and adjustment code to be subpixel aware.
     10
     11        No new tests, no change in functionality.
     12
     13        * rendering/RootInlineBox.cpp:
     14        (WebCore::RootInlineBox::alignBoxesInBlockDirection):
     15        Change beforeAnnotationsAdjustment to LayoutUnit.
     16       
     17        (WebCore::RootInlineBox::beforeAnnotationsAdjustment):
     18        Change method to return LayoutUnit as it is computed from values with
     19        subpixel precision.
     20       
     21        (WebCore::RootInlineBox::lineSnapAdjustment):
     22        Round values before computing remainder.
     23
     24        (WebCore::RootInlineBox::ascentAndDescentForBox):
     25        Change ascent and decent calculation to use LayoutUnits as they are
     26        computed from values with subpixel precision.
     27       
     28        (WebCore::RootInlineBox::verticalPositionForBox):
     29        Change verticalPosition to LayoutUnit.
     30       
     31        * rendering/RootInlineBox.h:
     32        (RootInlineBox):
     33
    1342012-04-05  Joseph Pecoraro  <pecoraro@apple.com>
    235
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r112512 r113221  
    289289    setPaginatedLineWidth(block()->availableLogicalWidthForContent(heightOfBlock));
    290290
    291     int annotationsAdjustment = beforeAnnotationsAdjustment();
     291    LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment();
    292292    if (annotationsAdjustment) {
    293293        // FIXME: Need to handle pagination here. We might have to move to the next page/column as a result of the
     
    306306}
    307307
    308 int RootInlineBox::beforeAnnotationsAdjustment() const
    309 {
    310     int result = 0;
     308LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const
     309{
     310    LayoutUnit result = 0;
    311311
    312312    if (!renderer()->style()->isFlippedLinesWritingMode()) {
     
    319319
    320320        // Annotations over this line may push us further down.
    321         int highestAllowedPosition = prevRootBox() ? min(prevRootBox()->lineBottom(), lineTop()) + result : block()->borderBefore();
     321        LayoutUnit highestAllowedPosition = prevRootBox() ? min(prevRootBox()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block()->borderBefore());
    322322        result = computeOverAnnotationAdjustment(highestAllowedPosition);
    323323    } else {
    324324        // Annotations under this line may push us up.
    325325        if (hasAnnotationsBefore())
    326             result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBox()->lineBottom() : block()->borderBefore());
     326            result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBox()->lineBottom() : static_cast<LayoutUnit>(block()->borderBefore()));
    327327
    328328        if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter())
     
    330330
    331331        // We have to compute the expansion for annotations over the previous line to see how much we should move.
    332         int lowestAllowedPosition = max(prevRootBox()->lineBottom(), lineTop()) - result;
     332        LayoutUnit lowestAllowedPosition = max(prevRootBox()->lineBottom(), lineTop()) - result;
    333333        result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPosition);
    334334    }
     
    410410    // Otherwise we're in the middle of the grid somewhere. Just push to the next line.
    411411    LayoutUnit baselineOffset = currentBaselinePosition - firstBaselinePosition;
    412     LayoutUnit remainder = baselineOffset % gridLineHeight;
     412    LayoutUnit remainder = roundToInt(baselineOffset) % roundToInt(gridLineHeight);
    413413    LayoutUnit result = delta;
    414414    if (remainder)
     
    757757    // If leading is included for the box, then we compute that box.
    758758    if (includeLeading && !setUsedFontWithLeading) {
    759         int ascentWithLeading = box->baselinePosition(baselineType());
    760         int descentWithLeading = box->lineHeight() - ascentWithLeading;
     759        LayoutUnit ascentWithLeading = box->baselinePosition(baselineType());
     760        LayoutUnit descentWithLeading = box->lineHeight() - ascentWithLeading;
    761761        setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeading, ascentDescentSet);
    762762       
     
    770770   
    771771    if (includeFontForBox(box) && !setUsedFont) {
    772         int fontAscent = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent();
    773         int fontDescent = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent();
     772        LayoutUnit fontAscent = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent();
     773        LayoutUnit fontDescent = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent();
    774774        setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDescentSet);
    775775        affectsAscent = fontAscent - box->logicalTop() > 0;
     
    786786
    787787    if (includeMarginForBox(box)) {
    788         int ascentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent();
    789         int descentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent();
     788        LayoutUnit ascentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent();
     789        LayoutUnit descentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent();
    790790        if (box->parent() && !box->renderer()->isText()) {
    791791            ascentWithMargin += box->boxModelObject()->borderBefore() + box->boxModelObject()->paddingBefore() + box->boxModelObject()->marginBefore();
     
    823823    }
    824824
    825     int verticalPosition = 0;
     825    LayoutUnit verticalPosition = 0;
    826826    EVerticalAlign verticalAlign = renderer->style()->verticalAlign();
    827827    if (verticalAlign == TOP || verticalAlign == BOTTOM)
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r112512 r113221  
    185185    LayoutUnit lineSnapAdjustment(LayoutUnit delta = 0) const;
    186186
    187     int beforeAnnotationsAdjustment() const;
     187    LayoutUnit beforeAnnotationsAdjustment() const;
    188188
    189189    // This folds into the padding at the end of InlineFlowBox on 64-bit.
Note: See TracChangeset for help on using the changeset viewer.