Title: [213779] trunk
Revision
213779
Author
[email protected]
Date
2017-03-12 20:16:43 -0700 (Sun, 12 Mar 2017)

Log Message

Simple line layout: Paginated content is not painted properly when font overflows line height.
https://bugs.webkit.org/show_bug.cgi?id=169516

Reviewed by Antti Koivisto.

Source/WebCore:

adjustLineIndexForStruts should take the IndexType::First/Last into account
when searching for the line index in a paginated context.
This also changes the the computed offset height from m_lineHeight to m_ascent + m_descent
so that we can find lines with large fonts (but small line height).

Test: fast/multicol/simple-line-layout-line-index-after-strut.html

* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::adjustLineIndexForStruts):
(WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
(WebCore::SimpleLineLayout::RunResolver::rangeForRect):
* rendering/SimpleLineLayoutResolver.h:

LayoutTests:

* fast/multicol/simple-line-layout-line-index-after-strut-expected.html: Added.
* fast/multicol/simple-line-layout-line-index-after-strut.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213778 => 213779)


--- trunk/LayoutTests/ChangeLog	2017-03-13 01:54:16 UTC (rev 213778)
+++ trunk/LayoutTests/ChangeLog	2017-03-13 03:16:43 UTC (rev 213779)
@@ -1,3 +1,13 @@
+2017-03-12  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Paginated content is not painted properly when font overflows line height.
+        https://bugs.webkit.org/show_bug.cgi?id=169516
+
+        Reviewed by Antti Koivisto.
+
+        * fast/multicol/simple-line-layout-line-index-after-strut-expected.html: Added.
+        * fast/multicol/simple-line-layout-line-index-after-strut.html: Added.
+
 2017-03-12  Javier Fernandez  <[email protected]>
 
         [GTK] Unreviewed test gardening

Added: trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-expected.html (0 => 213779)


--- trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-expected.html	2017-03-13 03:16:43 UTC (rev 213779)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that paginated lines are painting properly when lines visually overflow.</title>
+<style>
+html {
+	overflow: hidden;
+}
+div {
+  font-size: 241px;
+  line-height: 0.7;
+  padding-top: 47px;
+}
+</style>
+</head>
+<body>
+<div>
+foobar
+foobar
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut.html (0 => 213779)


--- trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut.html	2017-03-13 03:16:43 UTC (rev 213779)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that paginated lines are painting properly when lines visually overflow.</title>
+<style>
+html {
+	overflow: hidden;
+}
+div {
+  column-fill: auto;
+  font-size: 241px;
+  line-height: 0.7;
+}
+</style>
+</head>
+<body>
+<div>
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+</div>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    internals.setPagination("LeftToRightPaginated", 0);
+}
+
+setTimeout(function() {
+    window.scrollTo(1600, 0);
+    document.body.offsetHeight;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 0);
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (213778 => 213779)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-03-13 01:54:16 UTC (rev 213778)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-03-13 03:16:43 UTC (rev 213779)
@@ -1531,6 +1531,7 @@
 fast/multicol/span/generated-child-split-flow-crash.html [ Failure ]
 fast/multicol/split-in-top-margin.html [ ImageOnlyFailure ]
 fast/multicol/vertical-rl/rule-style.html [ Failure ]
+fast/multicol/simple-line-layout-line-index-after-strut.html [ ImageOnlyFailure ]
 fast/overflow/horizontal-scroll-after-back.html [ Failure ]
 fast/overflow/overflow-y-scroll.html [ Failure ]
 fast/overflow/scroll-div-hide-show.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (213778 => 213779)


--- trunk/Source/WebCore/ChangeLog	2017-03-13 01:54:16 UTC (rev 213778)
+++ trunk/Source/WebCore/ChangeLog	2017-03-13 03:16:43 UTC (rev 213779)
@@ -1,3 +1,23 @@
+2017-03-12  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Paginated content is not painted properly when font overflows line height.
+        https://bugs.webkit.org/show_bug.cgi?id=169516
+
+        Reviewed by Antti Koivisto.
+
+        adjustLineIndexForStruts should take the IndexType::First/Last into account
+        when searching for the line index in a paginated context.
+        This also changes the the computed offset height from m_lineHeight to m_ascent + m_descent
+        so that we can find lines with large fonts (but small line height).
+
+        Test: fast/multicol/simple-line-layout-line-index-after-strut.html
+
+        * rendering/SimpleLineLayoutResolver.cpp:
+        (WebCore::SimpleLineLayout::RunResolver::adjustLineIndexForStruts):
+        (WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
+        (WebCore::SimpleLineLayout::RunResolver::rangeForRect):
+        * rendering/SimpleLineLayoutResolver.h:
+
 2017-03-12  Brady Eidson  <[email protected]>
 
         Add full NSHTTPCookie fidelity to WebCore::Cookie.

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (213778 => 213779)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-03-13 01:54:16 UTC (rev 213778)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-03-13 03:16:43 UTC (rev 213779)
@@ -132,7 +132,7 @@
 {
 }
 
-unsigned RunResolver::adjustLineIndexForStruts(LayoutUnit y, unsigned lineIndexCandidate) const
+unsigned RunResolver::adjustLineIndexForStruts(LayoutUnit y, IndexType type, unsigned lineIndexCandidate) const
 {
     auto& struts = m_layout.struts();
     // We need to offset the lineIndex with line struts when there's an actual strut before the candidate.
@@ -139,15 +139,20 @@
     auto& strut = struts.first();
     if (strut.lineBreak >= lineIndexCandidate)
         return lineIndexCandidate;
-    // Jump over the first strut since we know that the line we are looking for is beyond the strut.
-    unsigned strutIndex = 1;
-    float topPosition = strut.lineBreak * m_lineHeight + strut.offset;
+    unsigned strutIndex = 0;
+    std::optional<unsigned> lastIndexCandidate;
+    float topPosition = strut.lineBreak * m_lineHeight + (m_baseline - m_ascent);
     for (auto lineIndex = strut.lineBreak; lineIndex < m_layout.lineCount(); ++lineIndex) {
+        float strutOffset = 0;
         if (strutIndex < struts.size() && struts.at(strutIndex).lineBreak == lineIndex)
-            topPosition += struts.at(strutIndex++).offset;
-        if (y >= topPosition && y < (topPosition + m_lineHeight))
-            return lineIndex;
-        topPosition += m_lineHeight;
+            strutOffset = struts.at(strutIndex++).offset;
+        if (y >= topPosition && y < (topPosition + m_ascent + m_descent + strutOffset)) {
+            if (type == IndexType::First)
+                return lineIndex;
+            lastIndexCandidate = lineIndex;
+        } else if (lastIndexCandidate)
+            return *lastIndexCandidate;
+        topPosition += m_lineHeight + strutOffset;
     }
     return m_layout.lineCount() - 1;
 }
@@ -157,14 +162,15 @@
     ASSERT(m_lineHeight);
     float y = height - m_borderAndPaddingBefore;
     // Lines may overlap, adjust to get the first or last line at this height.
+    auto adjustedY = y;
     if (type == IndexType::First)
-        y += m_lineHeight - (m_baseline + m_descent);
+        adjustedY += m_lineHeight - (m_baseline + m_descent);
     else
-        y -= m_baseline - m_ascent;
-    y = std::max<float>(y, 0);
-    auto lineIndexCandidate =  std::min<unsigned>(y / m_lineHeight, m_layout.lineCount() - 1);
+        adjustedY -= m_baseline - m_ascent;
+    adjustedY = std::max<float>(adjustedY, 0);
+    auto lineIndexCandidate =  std::min<unsigned>(adjustedY / m_lineHeight, m_layout.lineCount() - 1);
     if (m_layout.hasLineStruts())
-        return adjustLineIndexForStruts(y, lineIndexCandidate);
+        return adjustLineIndexForStruts(y, type, lineIndexCandidate);
     return lineIndexCandidate;
 }
 
@@ -175,7 +181,6 @@
 
     unsigned firstLine = lineIndexForHeight(rect.y(), IndexType::First);
     unsigned lastLine = std::max(firstLine, lineIndexForHeight(rect.maxY(), IndexType::Last));
-
     auto rangeBegin = begin().advanceLines(firstLine);
     if (rangeBegin == end())
         return { end(), end() };

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (213778 => 213779)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2017-03-13 01:54:16 UTC (rev 213778)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2017-03-13 03:16:43 UTC (rev 213779)
@@ -109,7 +109,7 @@
 private:
     enum class IndexType { First, Last };
     unsigned lineIndexForHeight(LayoutUnit, IndexType) const;
-    unsigned adjustLineIndexForStruts(LayoutUnit, unsigned lineIndexCandidate) const;
+    unsigned adjustLineIndexForStruts(LayoutUnit, IndexType, unsigned lineIndexCandidate) const;
 
     const RenderBlockFlow& m_flowRenderer;
     const Layout& m_layout;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to