Title: [117659] trunk/Source/WebCore
Revision
117659
Author
[email protected]
Date
2012-05-18 16:58:21 -0700 (Fri, 18 May 2012)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117658 => 117659)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 23:47:08 UTC (rev 117658)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 23:58:21 UTC (rev 117659)
@@ -1,3 +1,30 @@
+2012-05-18  Levi Weintraub  <[email protected]>
+
+        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.
+
 2012-05-18  Eric Seidel  <[email protected]>
 
         Assertion failure in BidiResolver::commitExplicitEmbedding() (!inIsolate() || m_currentExplicitEmbeddingSequence.isEmpty()) at wikipedia.org

Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (117658 => 117659)


--- trunk/Source/WebCore/rendering/EllipsisBox.cpp	2012-05-18 23:47:08 UTC (rev 117658)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp	2012-05-18 23:58:21 UTC (rev 117659)
@@ -97,7 +97,7 @@
     GraphicsContextStateSaver stateSaver(*context);
     LayoutUnit top = root()->selectionTop();
     LayoutUnit h = root()->selectionHeight();
-    LayoutRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
+    FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
     alignSelectionRectToDevicePixels(clipRect);
     context->clip(clipRect);
     // FIXME: Why is this always LTR? Fix by passing correct text run flags below.

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (117658 => 117659)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2012-05-18 23:47:08 UTC (rev 117658)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2012-05-18 23:58:21 UTC (rev 117659)
@@ -807,21 +807,12 @@
     ePos = min(endPos - m_start, (int)m_len);
 }
 
-void alignSelectionRectToDevicePixels(LayoutRect& rect)
-{
-    LayoutUnit maxX = floorToInt(rect.maxX());
-    rect.setX(floorToInt(rect.x()));
-    rect.setWidth(maxX - rect.x());
-}
-
-#if !ENABLE(SUBPIXEL_LAYOUT)
 void alignSelectionRectToDevicePixels(FloatRect& rect)
 {
     float maxX = floorf(rect.maxX());
     rect.setX(floorf(rect.x()));
     rect.setWidth(roundf(maxX - rect.x()));
 }
-#endif
 
 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, Color textColor)
 {
@@ -861,17 +852,12 @@
     LayoutUnit selectionTop = root()->selectionTopAdjustedForPrecedingBlock();
 
     LayoutUnit deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop;
-    LayoutUnit selHeight = max<LayoutUnit>(0, selectionBottom - selectionTop);
+    LayoutUnit selHeight = max<LayoutUnit>(ZERO_LAYOUT_UNIT, selectionBottom - selectionTop);
 
-#if ENABLE(SUBPIXEL_LAYOUT)
-    LayoutPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
-    LayoutRect clipRect(localOrigin, LayoutSize(m_logicalWidth, selHeight));
-    alignSelectionRectToDevicePixels(clipRect);
-#else
     FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
     FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight));
     alignSelectionRectToDevicePixels(clipRect);
-#endif
+
     context->clip(clipRect);
 
     context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (117658 => 117659)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2012-05-18 23:47:08 UTC (rev 117658)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2012-05-18 23:58:21 UTC (rev 117659)
@@ -213,10 +213,7 @@
     return toRenderText(renderer());
 }
 
-void alignSelectionRectToDevicePixels(LayoutRect&);
-#if !ENABLE(SUBPIXEL_LAYOUT)
 void alignSelectionRectToDevicePixels(FloatRect&);
-#endif
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (117658 => 117659)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-18 23:47:08 UTC (rev 117658)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-18 23:58:21 UTC (rev 117659)
@@ -3346,6 +3346,13 @@
     return gapRect;
 }
 
+static inline void alignSelectionRectToDevicePixels(LayoutRect& rect)
+{
+    LayoutUnit maxX = floorToInt(rect.maxX());
+    rect.setX(floorToInt(rect.x()));
+    rect.setWidth((maxX - rect.x()).round());
+}
+
 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
                                                 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to