Changeset 117659 in webkit


Ignore:
Timestamp:
May 18, 2012 4:58:21 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Revert to float method of selection rect alignment for line box tree
https://bugs.webkit.org/show_bug.cgi?id=86904

Reviewed by Eric Seidel.

In r117491, we introduced a new method of alignment for the selection rect in the sub-pixel case.
It turns out there is at least one case on Mac where this leaves a gap when painting selection rects
originating in the line box tree. This patch reverts us to the float method for the line box tree,
but retains the LayoutRect snapping for gap rects.

No new tests. Covered by existing tests with sub-pixel layout enabled.

  • rendering/EllipsisBox.cpp:

(WebCore::EllipsisBox::paintSelection): Re-enabling the FloatRect flavor of
alignSelectionRectToDevicePixels for the line box tree.

  • rendering/InlineTextBox.cpp:

(WebCore::alignSelectionRectToDevicePixels): Moving LayoutRect flavor to RenderBlock.
(WebCore::InlineTextBox::paintSelection): Happily clearing up the bifurcation of algorithms for
sub-pixel layout.

  • rendering/InlineTextBox.h: Re-enabling the FloatRect flavor of alignSelectionRectToDevicePixels

for the line box tree.

  • rendering/RenderBlock.cpp:

(WebCore::alignSelectionRectToDevicePixels): Re-seating the LayoutRect version of
alignSelectionRectToDevicePixels for use with GapRects.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117658 r117659  
     12012-05-18  Levi Weintraub  <leviw@chromium.org>
     2
     3        Revert to float method of selection rect alignment for line box tree
     4        https://bugs.webkit.org/show_bug.cgi?id=86904
     5
     6        Reviewed by Eric Seidel.
     7
     8        In r117491, we introduced a new method of alignment for the selection rect in the sub-pixel case.
     9        It turns out there is at least one case on Mac where this leaves a gap when painting selection rects
     10        originating in the line box tree. This patch reverts us to the float method for the line box tree,
     11        but retains the LayoutRect snapping for gap rects.
     12
     13        No new tests. Covered by existing tests with sub-pixel layout enabled.
     14
     15        * rendering/EllipsisBox.cpp:
     16        (WebCore::EllipsisBox::paintSelection): Re-enabling the FloatRect flavor of
     17        alignSelectionRectToDevicePixels for the line box tree.
     18        * rendering/InlineTextBox.cpp:
     19        (WebCore::alignSelectionRectToDevicePixels): Moving LayoutRect flavor to RenderBlock.
     20        (WebCore::InlineTextBox::paintSelection): Happily clearing up the bifurcation of algorithms for
     21        sub-pixel layout.
     22        * rendering/InlineTextBox.h: Re-enabling the FloatRect flavor of alignSelectionRectToDevicePixels
     23        for the line box tree.
     24        * rendering/RenderBlock.cpp:
     25        (WebCore::alignSelectionRectToDevicePixels): Re-seating the LayoutRect version of
     26        alignSelectionRectToDevicePixels for use with GapRects.
     27
    1282012-05-18  Eric Seidel  <eric@webkit.org>
    229
  • trunk/Source/WebCore/rendering/EllipsisBox.cpp

    r117491 r117659  
    9898    LayoutUnit top = root()->selectionTop();
    9999    LayoutUnit h = root()->selectionHeight();
    100     LayoutRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
     100    FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
    101101    alignSelectionRectToDevicePixels(clipRect);
    102102    context->clip(clipRect);
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r117491 r117659  
    808808}
    809809
    810 void alignSelectionRectToDevicePixels(LayoutRect& rect)
    811 {
    812     LayoutUnit maxX = floorToInt(rect.maxX());
    813     rect.setX(floorToInt(rect.x()));
    814     rect.setWidth(maxX - rect.x());
    815 }
    816 
    817 #if !ENABLE(SUBPIXEL_LAYOUT)
    818810void alignSelectionRectToDevicePixels(FloatRect& rect)
    819811{
     
    822814    rect.setWidth(roundf(maxX - rect.x()));
    823815}
    824 #endif
    825816
    826817void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, Color textColor)
     
    862853
    863854    LayoutUnit deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop;
    864     LayoutUnit selHeight = max<LayoutUnit>(0, selectionBottom - selectionTop);
    865 
    866 #if ENABLE(SUBPIXEL_LAYOUT)
    867     LayoutPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
    868     LayoutRect clipRect(localOrigin, LayoutSize(m_logicalWidth, selHeight));
    869     alignSelectionRectToDevicePixels(clipRect);
    870 #else
     855    LayoutUnit selHeight = max<LayoutUnit>(ZERO_LAYOUT_UNIT, selectionBottom - selectionTop);
     856
    871857    FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
    872858    FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight));
    873859    alignSelectionRectToDevicePixels(clipRect);
    874 #endif
     860
    875861    context->clip(clipRect);
    876862
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r117491 r117659  
    214214}
    215215
    216 void alignSelectionRectToDevicePixels(LayoutRect&);
    217 #if !ENABLE(SUBPIXEL_LAYOUT)
    218216void alignSelectionRectToDevicePixels(FloatRect&);
    219 #endif
    220217
    221218} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r117491 r117659  
    33473347}
    33483348
     3349static inline void alignSelectionRectToDevicePixels(LayoutRect& rect)
     3350{
     3351    LayoutUnit maxX = floorToInt(rect.maxX());
     3352    rect.setX(floorToInt(rect.x()));
     3353    rect.setWidth((maxX - rect.x()).round());
     3354}
     3355
    33493356LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    33503357                                                RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo)
Note: See TracChangeset for help on using the changeset viewer.