Title: [219291] trunk
Revision
219291
Author
[email protected]
Date
2017-07-10 09:03:03 -0700 (Mon, 10 Jul 2017)

Log Message

Block of text is missing in iBooks sample books.
https://bugs.webkit.org/show_bug.cgi?id=174295
<rdar://problem/32955620>

Reviewed by Antti Koivisto.

Source/WebCore:

In the simple line layout context, translating y coordinate to a line index is
normally just a (y / line height) operation. However in case of strut offsets (pagination)
we need to take these extra paddings into account while resolving the line index.
This patch fixes the boundary checking for a given line by using the font size only
when the font is taller than the line.

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

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219290 => 219291)


--- trunk/LayoutTests/ChangeLog	2017-07-10 13:21:35 UTC (rev 219290)
+++ trunk/LayoutTests/ChangeLog	2017-07-10 16:03:03 UTC (rev 219291)
@@ -1,3 +1,14 @@
+2017-07-10  Zalan Bujtas  <[email protected]>
+
+        Block of text is missing in iBooks sample books.
+        https://bugs.webkit.org/show_bug.cgi?id=174295
+        <rdar://problem/32955620>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/multicol/simple-line-layout-line-index-after-strut-2-expected.html: Added.
+        * fast/multicol/simple-line-layout-line-index-after-strut-2.html: Added.
+
 2017-07-08  John Wilander  <[email protected]>
 
         Resource Load Statistics: User interaction should always go to top document

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


--- trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-2-expected.html	2017-07-10 16:03:03 UTC (rev 219291)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that paginated lines are painting properly when line is taller than the font.</title>
+<style>
+html {
+	overflow: hidden;
+}
+div {
+  font-size: 20px;
+  line-height: 50px;
+  width: 50px;
+  margin-top: -8px;
+}
+</style>
+</head>
+<body>
+<div>
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+</div>
+<script>
+if (window.internals)
+    internals.setPagination("LeftToRightPaginated", 0);
+</script>
+</body>
+</html>

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


--- trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-line-index-after-strut-2.html	2017-07-10 16:03:03 UTC (rev 219291)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that paginated lines are painting properly when line is taller than the font.</title>
+<style>
+html {
+	overflow: hidden;
+}
+div {
+  column-fill: auto;
+  font-size: 20px;
+  line-height: 50px;
+  width: 50px;
+}
+</style>
+</head>
+<body>
+<div>
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+</div>
+<script>
+if (window.internals)
+    internals.setPagination("LeftToRightPaginated", 0);
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+setTimeout(function() {
+    window.scrollTo(1600, 0);
+    document.body.offsetHeight;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 0);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (219290 => 219291)


--- trunk/Source/WebCore/ChangeLog	2017-07-10 13:21:35 UTC (rev 219290)
+++ trunk/Source/WebCore/ChangeLog	2017-07-10 16:03:03 UTC (rev 219291)
@@ -1,3 +1,20 @@
+2017-07-10  Zalan Bujtas  <[email protected]>
+
+        Block of text is missing in iBooks sample books.
+        https://bugs.webkit.org/show_bug.cgi?id=174295
+        <rdar://problem/32955620>
+
+        Reviewed by Antti Koivisto.
+
+        In the simple line layout context, translating y coordinate to a line index is
+        normally just a (y / line height) operation. However in case of strut offsets (pagination)
+        we need to take these extra paddings into account while resolving the line index.
+        This patch fixes the boundary checking for a given line by using the font size only
+        when the font is taller than the line.
+
+        * rendering/SimpleLineLayoutResolver.cpp:
+        (WebCore::SimpleLineLayout::RunResolver::adjustLineIndexForStruts):
+
 2017-07-10  Carlos Garcia Campos  <[email protected]>
 
         [SOUP] SoupCookieJar is never released (resulting in sqlite temp files lying around)

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (219290 => 219291)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-07-10 13:21:35 UTC (rev 219290)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-07-10 16:03:03 UTC (rev 219291)
@@ -141,20 +141,32 @@
         return lineIndexCandidate;
     unsigned strutIndex = 0;
     std::optional<unsigned> lastIndexCandidate;
-    float topPosition = strut.lineBreak * m_lineHeight + (m_baseline - m_ascent);
+    auto top = strut.lineBreak * m_lineHeight;
+    auto lineHeightWithOverflow = m_lineHeight;
+    // If font is larger than the line height (glyphs overflow), use the font size when checking line boundaries.
+    if (m_ascent + m_descent > m_lineHeight) {
+        lineHeightWithOverflow = m_ascent + m_descent;
+        top += m_baseline - m_ascent;
+    }
+    auto bottom = top + lineHeightWithOverflow;
     for (auto lineIndex = strut.lineBreak; lineIndex < m_layout.lineCount(); ++lineIndex) {
         float strutOffset = 0;
         if (strutIndex < struts.size() && struts.at(strutIndex).lineBreak == lineIndex)
             strutOffset = struts.at(strutIndex++).offset;
-        if (y >= topPosition && y < (topPosition + m_ascent + m_descent + strutOffset)) {
+        bottom = top + strutOffset + lineHeightWithOverflow;
+        if (y >= top && y < bottom) {
             if (type == IndexType::First)
                 return lineIndex;
             lastIndexCandidate = lineIndex;
         } else if (lastIndexCandidate)
             return *lastIndexCandidate;
-        topPosition += m_lineHeight + strutOffset;
+        top += m_lineHeight + strutOffset;
     }
-    return m_layout.lineCount() - 1;
+    if (lastIndexCandidate || y >= bottom)
+        return m_layout.lineCount() - 1;
+    // We missed the line.
+    ASSERT_NOT_REACHED();
+    return lineIndexCandidate;
 }
 
 unsigned RunResolver::lineIndexForHeight(LayoutUnit height, IndexType type) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to