Changeset 117491 in webkit
- Timestamp:
- May 17, 2012 1:57:38 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117485 r117491 1 2012-05-17 Emil A Eklund <eae@chromium.org> 2 3 Fix rounding in paintSelection 4 https://bugs.webkit.org/show_bug.cgi?id=86693 5 6 Reviewed by Eric Seidel. 7 8 Break out rounding logic from InlineTextBox::paintSelection into separate 9 function and use it for all the EllipsisBox paintSelection implementation 10 and selection gap calculation. This ensures that selections are painted 11 without gaps and overlaps once we turn on subpixel layout. 12 13 No new tests, covered by existing tests in editing/selection and 14 editing/style. 15 16 * rendering/EllipsisBox.cpp: 17 (WebCore::EllipsisBox::paintSelection): 18 * rendering/InlineTextBox.cpp: 19 (WebCore::alignSelectionRectToDevicePixels): 20 (WebCore): 21 (WebCore::InlineTextBox::paintSelection): 22 * rendering/InlineTextBox.h: 23 (WebCore): 24 * rendering/RenderBlock.cpp: 25 (WebCore::RenderBlock::logicalLeftSelectionGap): 26 (WebCore::RenderBlock::logicalRightSelectionGap): 27 1 28 2012-05-17 Michal Mocny <mmocny@google.com> 2 29 -
trunk/Source/WebCore/rendering/EllipsisBox.cpp
r114784 r117491 24 24 #include "GraphicsContext.h" 25 25 #include "HitTestResult.h" 26 #include "InlineTextBox.h" 26 27 #include "PaintInfo.h" 27 28 #include "RenderBlock.h" … … 97 98 LayoutUnit top = root()->selectionTop(); 98 99 LayoutUnit h = root()->selectionHeight(); 99 // FIXME: We'll need to apply the correct clip rounding here: https://bugs.webkit.org/show_bug.cgi?id=63656 100 context->clip(IntRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h)); 100 LayoutRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h); 101 alignSelectionRectToDevicePixels(clipRect); 102 context->clip(clipRect); 101 103 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 102 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x() + paintOffset.x(), y() + paintOffset.y() + top), h, c, style->colorSpace());104 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style->colorSpace()); 103 105 } 104 106 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r116723 r117491 808 808 } 809 809 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) 818 void alignSelectionRectToDevicePixels(FloatRect& rect) 819 { 820 float maxX = floorf(rect.maxX()); 821 rect.setX(floorf(rect.x())); 822 rect.setWidth(roundf(maxX - rect.x())); 823 } 824 #endif 825 810 826 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, Color textColor) 811 827 { … … 845 861 LayoutUnit selectionTop = root()->selectionTopAdjustedForPrecedingBlock(); 846 862 847 int deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop; 848 int selHeight = max<LayoutUnit>(0, selectionBottom - selectionTop); 849 863 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 850 871 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); 851 852 872 FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight)); 853 float maxX = floorf(clipRect.maxX()); 854 clipRect.setX(floorf(clipRect.x())); 855 clipRect.setWidth(maxX - clipRect.x()); 873 alignSelectionRectToDevicePixels(clipRect); 874 #endif 856 875 context->clip(clipRect); 857 876 -
trunk/Source/WebCore/rendering/InlineTextBox.h
r116353 r117491 214 214 } 215 215 216 void alignSelectionRectToDevicePixels(LayoutRect&); 217 #if !ENABLE(SUBPIXEL_LAYOUT) 218 void alignSelectionRectToDevicePixels(FloatRect&); 219 #endif 220 216 221 } // namespace WebCore 217 222 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r117484 r117491 3358 3358 3359 3359 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight)); 3360 alignSelectionRectToDevicePixels(gapRect); 3360 3361 if (paintInfo) 3361 3362 paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace()); … … 3374 3375 3375 3376 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight)); 3377 alignSelectionRectToDevicePixels(gapRect); 3376 3378 if (paintInfo) 3377 3379 paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
Note: See TracChangeset
for help on using the changeset viewer.