Changeset 112238 in webkit


Ignore:
Timestamp:
Mar 27, 2012 3:08:50 AM (12 years ago)
Author:
leviw@chromium.org
Message:

Update usage of LayoutUnits in RenderListMarker
https://bugs.webkit.org/show_bug.cgi?id=81921

Reviewed by Eric Seidel.

Implementing proper pixel snapping in list marker painting, and correcting usage of integers
for local coordinates/margins that should be sub-pixel.

No new tests. No change in behavior.

  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::localSelectionRect): Changed to LayoutUnits since this represents
a rect in local coordinates.
(WebCore::RenderListMarker::paint): Doing proper pixel snapping, and using integers for
results from text measurement.
(WebCore::RenderListMarker::computePreferredLogicalWidths): Using integers for results
from text measurement.
(WebCore::RenderListMarker::updateMargins): Fixing to be LayoutUnits.

  • rendering/RenderListMarker.h:

(RenderListMarker):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112237 r112238  
     12012-03-27  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update usage of LayoutUnits in RenderListMarker
     4        https://bugs.webkit.org/show_bug.cgi?id=81921
     5
     6        Reviewed by Eric Seidel.
     7
     8        Implementing proper pixel snapping in list marker painting, and correcting usage of integers
     9        for local coordinates/margins that should be sub-pixel.
     10
     11        No new tests. No change in behavior.
     12
     13        * rendering/RenderListMarker.cpp:
     14        (WebCore::RenderListMarker::localSelectionRect): Changed to LayoutUnits since this represents
     15        a rect in local coordinates.
     16        (WebCore::RenderListMarker::paint): Doing proper pixel snapping, and using integers for
     17        results from text measurement.
     18        (WebCore::RenderListMarker::computePreferredLogicalWidths): Using integers for results
     19        from text measurement.
     20        (WebCore::RenderListMarker::updateMargins): Fixing to be LayoutUnits.
     21        * rendering/RenderListMarker.h:
     22        (RenderListMarker):
     23
    1242012-03-27  Levi Weintraub  <leviw@chromium.org>
    225
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r110323 r112238  
    10911091}
    10921092
    1093 IntRect RenderListMarker::localSelectionRect()
     1093LayoutRect RenderListMarker::localSelectionRect()
    10941094{
    10951095    InlineBox* box = inlineBoxWrapper();
    10961096    if (!box)
    1097         return IntRect(IntPoint(), size());
     1097        return LayoutRect(LayoutPoint(), size());
    10981098    RootInlineBox* root = m_inlineBoxWrapper->root();
    1099     int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
     1099    LayoutUnit newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
    11001100    if (root->block()->style()->isHorizontalWritingMode())
    1101         return IntRect(0, newLogicalTop, width(), root->selectionHeight());
    1102     return IntRect(newLogicalTop, 0, root->selectionHeight(), height());
     1101        return LayoutRect(0, newLogicalTop, width(), root->selectionHeight());
     1102    return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height());
    11031103}
    11041104
     
    11111111        return;
    11121112
    1113     IntPoint boxOrigin(paintOffset + location());
     1113    LayoutPoint boxOrigin(paintOffset + location());
    11141114    LayoutRect overflowRect(visualOverflowRect());
    11151115    overflowRect.moveBy(boxOrigin);
    11161116    overflowRect.inflate(maximalOutlineSize(paintInfo.phase));
    11171117
    1118     if (!paintInfo.rect.intersects(overflowRect))
     1118    if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect)))
    11191119        return;
    11201120
    1121     LayoutRect box(boxOrigin, LayoutSize(width(), height()));
     1121    LayoutRect box(boxOrigin, size());
    11221122   
    1123     LayoutRect marker = getRelativeMarkerRect();
    1124     marker.moveBy(boxOrigin);
     1123    IntRect marker = getRelativeMarkerRect();
     1124    marker.moveBy(roundedIntPoint(boxOrigin));
    11251125
    11261126    GraphicsContext* context = paintInfo.context;
     
    11351135            LayoutRect selRect = localSelectionRect();
    11361136            selRect.moveBy(boxOrigin);
    1137             context->fillRect(selRect, selectionBackgroundColor(), style()->colorSpace());
     1137            context->fillRect(pixelSnappedIntRect(selRect), selectionBackgroundColor(), style()->colorSpace());
    11381138        }
    11391139        return;
     
    11491149        LayoutRect selRect = localSelectionRect();
    11501150        selRect.moveBy(boxOrigin);
    1151         context->fillRect(selRect, selectionBackgroundColor(), style()->colorSpace());
     1151        context->fillRect(pixelSnappedIntRect(selRect), selectionBackgroundColor(), style()->colorSpace());
    11521152    }
    11531153
     
    12591259    GraphicsContextStateSaver stateSaver(*context, false);
    12601260    if (!style()->isHorizontalWritingMode()) {
    1261         marker.moveBy(-boxOrigin);
     1261        marker.moveBy(roundedIntPoint(-boxOrigin));
    12621262        marker = marker.transposedRect();
    1263         marker.move(box.x(), box.y() - logicalHeight());
     1263        marker.moveBy(IntPoint(roundToInt(box.x()), roundToInt(box.y() - logicalHeight())));
    12641264        stateSaver.save();
    12651265        context->translate(marker.x(), marker.maxY());
     
    12681268    }
    12691269
    1270     LayoutPoint textOrigin = LayoutPoint(marker.x(), marker.y() + style()->fontMetrics().ascent());
     1270    IntPoint textOrigin = IntPoint(marker.x(), marker.y() + style()->fontMetrics().ascent());
    12711271
    12721272    if (type == Asterisks || type == Footnotes)
     
    12871287        const UChar suffix = listMarkerSuffix(type, m_listItem->value());
    12881288        if (style()->isLeftToRightDirection()) {
    1289             LayoutUnit width = font.width(textRun);
     1289            int width = font.width(textRun);
    12901290            context->drawText(font, textRun, textOrigin);
    12911291            UChar suffixSpace[2] = { suffix, ' ' };
     
    12941294            UChar spaceSuffix[2] = { ' ', suffix };
    12951295            TextRun spaceSuffixRun = RenderBlock::constructTextRun(this, font, spaceSuffix, 2, style());
    1296             LayoutUnit width = font.width(spaceSuffixRun);
     1296            int width = font.width(spaceSuffixRun);
    12971297            context->drawText(font, spaceSuffixRun, textOrigin);
    12981298            context->drawText(font, textRun, textOrigin + IntSize(width, 0));
     
    13501350        // FIXME: This is a somewhat arbitrary width.  Generated images for markers really won't become particularly useful
    13511351        // until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box.
    1352         LayoutUnit bulletWidth = fontMetrics.ascent() / 2;
    1353         m_image->setContainerSizeForRenderer(this, LayoutSize(bulletWidth, bulletWidth), style()->effectiveZoom());
     1352        int bulletWidth = fontMetrics.ascent() / 2;
     1353        m_image->setContainerSizeForRenderer(this, IntSize(bulletWidth, bulletWidth), style()->effectiveZoom());
    13541354        LayoutSize imageSize = m_image->imageSize(this, style()->effectiveZoom());
    13551355        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height();
     
    14741474    const FontMetrics& fontMetrics = style()->fontMetrics();
    14751475
    1476     int marginStart = 0;
    1477     int marginEnd = 0;
     1476    LayoutUnit marginStart = 0;
     1477    LayoutUnit marginEnd = 0;
    14781478
    14791479    if (isInside()) {
     
    15051505                        break;
    15061506                    default:
    1507                         marginStart = m_text.isEmpty() ? 0 : -minPreferredLogicalWidth() - offset / 2;
     1507                        marginStart = m_text.isEmpty() ? zeroLayoutUnit : -minPreferredLogicalWidth() - offset / 2;
    15081508                }
    15091509            }
  • trunk/Source/WebCore/rendering/RenderListMarker.h

    r106900 r112238  
    7575
    7676    IntRect getRelativeMarkerRect();
    77     IntRect localSelectionRect();
     77    LayoutRect localSelectionRect();
    7878
    7979    String m_text;
Note: See TracChangeset for help on using the changeset viewer.