[Regression] text-overflow ellipsis clips content when zoomed
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 23:07:55 +0000 (23:07 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 23:07:55 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105456

Reviewed by Levi Weintraub.

Source/WebCore:

At certain zoom levels text-overflow ellipsis incorrectly clips
content and displays the ellipsis even though the full content
would fit.

Test: fast/sub-pixel/ellipsis-zoom.html

* rendering/RenderBlock.h:
(WebCore::RenderBlock::pixelSnappedLogicalRightOffsetForLine):
Add bug url to FIXME.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::checkLinesForTextOverflow):
Pixel snap the content edge before comparing with the line box
edge as the line box edge is aligned to a pixel boundary.

LayoutTests:

Add test for text-overflow: ellipsis.

* fast/sub-pixel/ellipsis-zoom-expected.html: Added.
* fast/sub-pixel/ellipsis-zoom.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138196 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/sub-pixel/ellipsis-zoom-expected.html [new file with mode: 0644]
LayoutTests/fast/sub-pixel/ellipsis-zoom.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 1708d94..10a384f 100644 (file)
@@ -1,3 +1,15 @@
+2012-12-19  Emil A Eklund  <eae@chromium.org>
+
+        [Regression] text-overflow ellipsis clips content when zoomed
+        https://bugs.webkit.org/show_bug.cgi?id=105456
+
+        Reviewed by Levi Weintraub.
+
+        Add test for text-overflow: ellipsis.
+
+        * fast/sub-pixel/ellipsis-zoom-expected.html: Added.
+        * fast/sub-pixel/ellipsis-zoom.html: Added.
+
 2012-12-19  Levi Weintraub  <leviw@chromium.org>
 
         Re-skipping touch-input-element-chang-documents.html since it's still
diff --git a/LayoutTests/fast/sub-pixel/ellipsis-zoom-expected.html b/LayoutTests/fast/sub-pixel/ellipsis-zoom-expected.html
new file mode 100644 (file)
index 0000000..506ea4f
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .test > div { display: inline-block; white-space: nowrap; padding: 0 1px; }
+        </style>
+    </head>
+    <body>
+        <div class="test" style="zoom: 0.5;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.66;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.75;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.9;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.0;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.1;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.25;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.33;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <p>
+            None of the lines above should be truncated.
+        </p>
+    </body>
+</html>
diff --git a/LayoutTests/fast/sub-pixel/ellipsis-zoom.html b/LayoutTests/fast/sub-pixel/ellipsis-zoom.html
new file mode 100644 (file)
index 0000000..3b8ca3d
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .test > div { display: inline-block; overflow: hidden; white-space: nowrap; padding: 0 1px; }
+            .test > .ellipsis { text-overflow: ellipsis; }
+        </style>
+    </head>
+    <body>
+        <div class="test" style="zoom: 0.5;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.66;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.75;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 0.9;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.0;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.1;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.25;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <div class="test" style="zoom: 1.33;">
+            <div class="ellipsis">Should not be truncated</div><br>
+            <div class="expected">Should not be truncated</div>
+        </div>
+        <p>
+            None of the lines above should be truncated.
+        </p>
+    </body>
+</html>
index edafc4f..dbdbe1b 100644 (file)
@@ -1,3 +1,25 @@
+2012-12-19  Emil A Eklund  <eae@chromium.org>
+
+        [Regression] text-overflow ellipsis clips content when zoomed
+        https://bugs.webkit.org/show_bug.cgi?id=105456
+
+        Reviewed by Levi Weintraub.
+
+        At certain zoom levels text-overflow ellipsis incorrectly clips
+        content and displays the ellipsis even though the full content
+        would fit.
+
+        Test: fast/sub-pixel/ellipsis-zoom.html
+        
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::pixelSnappedLogicalRightOffsetForLine):
+        Add bug url to FIXME.
+        
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::checkLinesForTextOverflow):
+        Pixel snap the content edge before comparing with the line box
+        edge as the line box edge is aligned to a pixel boundary.
+
 2012-12-19  Antti Koivisto  <antti@apple.com>
 
         Use ElementTraversal in LiveNodeListBase
index 87bcdcd..3c93cbb 100644 (file)
@@ -199,6 +199,7 @@ public:
         // FIXME: Multicolumn layouts break carrying over subpixel values to the logical right offset because the lines may be shifted
         // by a subpixel value for all but the first column. This can lead to the actual pixel snapped width of the column being off
         // by one pixel when rendered versus layed out, which can result in the line being clipped. For now, we have to floor.
+        // https://bugs.webkit.org/show_bug.cgi?id=105461
         return floorToInt(logicalRightOffsetForLine(position, firstLine, logicalHeight));
     }
     LayoutUnit startOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const
index 0d4b6f7..4389636 100644 (file)
@@ -3199,8 +3199,10 @@ void RenderBlock::checkLinesForTextOverflow()
     ETextAlign textAlign = style()->textAlign();
     bool firstLine = true;
     for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
-        LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), firstLine);
-        LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), firstLine);
+        // FIXME: Use pixelSnappedLogicalRightOffsetForLine instead of snapping it ourselves once the column workaround in said method has been fixed.
+        // https://bugs.webkit.org/show_bug.cgi?id=105461
+        int blockRightEdge = snapSizeToPixel(logicalRightOffsetForLine(curr->lineTop(), firstLine), curr->x());
+        int blockLeftEdge = pixelSnappedLogicalLeftOffsetForLine(curr->lineTop(), firstLine);
         LayoutUnit lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x();
         if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < blockLeftEdge)) {
             // This line spills out of our box in the appropriate direction.  Now we need to see if the line