Title: [213136] releases/WebKitGTK/webkit-2.16/Source/WebCore
- Revision
- 213136
- Author
- carlo...@webkit.org
- Date
- 2017-02-28 01:14:21 -0800 (Tue, 28 Feb 2017)
Log Message
Merge r212912 - Simple line layout: Adjust RunResolver::lineIndexForHeight with line struts.
https://bugs.webkit.org/show_bug.cgi?id=168783
<rdar://problem/30676449>
Reviewed by Antti Koivisto.
When there's a pagination gap between lines the simple lineIndex = y / lineHeight formula does not work anymore.
This patch takes the line gaps into account by offsetting the y position accordingly.
Not enabled yet.
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (213135 => 213136)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-02-28 09:13:08 UTC (rev 213135)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-02-28 09:14:21 UTC (rev 213136)
@@ -1,3 +1,19 @@
+2017-02-23 Zalan Bujtas <za...@apple.com>
+
+ Simple line layout: Adjust RunResolver::lineIndexForHeight with line struts.
+ https://bugs.webkit.org/show_bug.cgi?id=168783
+ <rdar://problem/30676449>
+
+ Reviewed by Antti Koivisto.
+
+ When there's a pagination gap between lines the simple lineIndex = y / lineHeight formula does not work anymore.
+ This patch takes the line gaps into account by offsetting the y position accordingly.
+
+ Not enabled yet.
+
+ * rendering/SimpleLineLayoutResolver.cpp:
+ (WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight):
+
2017-02-23 Carlos Garcia Campos <cgar...@igalia.com>
[GStreamer] Several layout tests trigger GStreamer-CRITICAL **: gst_bin_get_by_name: assertion 'GST_IS_BIN (bin)' failed
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (213135 => 213136)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2017-02-28 09:13:08 UTC (rev 213135)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2017-02-28 09:14:21 UTC (rev 213136)
@@ -132,6 +132,26 @@
{
}
+unsigned RunResolver::adjustLineIndexForStruts(LayoutUnit y, 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.
+ 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;
+ for (auto lineIndex = strut.lineBreak; lineIndex < m_layout.lineCount(); ++lineIndex) {
+ 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;
+ }
+ return m_layout.lineCount() - 1;
+}
+
unsigned RunResolver::lineIndexForHeight(LayoutUnit height, IndexType type) const
{
ASSERT(m_lineHeight);
@@ -142,7 +162,10 @@
else
y -= m_baseline - m_ascent;
y = std::max<float>(y, 0);
- return std::min<unsigned>(y / m_lineHeight, m_layout.lineCount() - 1);
+ auto lineIndexCandidate = std::min<unsigned>(y / m_lineHeight, m_layout.lineCount() - 1);
+ if (m_layout.hasLineStruts())
+ return adjustLineIndexForStruts(y, lineIndexCandidate);
+ return lineIndexCandidate;
}
WTF::IteratorRange<RunResolver::Iterator> RunResolver::rangeForRect(const LayoutRect& rect) const
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h (213135 => 213136)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-02-28 09:13:08 UTC (rev 213135)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-02-28 09:14:21 UTC (rev 213136)
@@ -109,6 +109,7 @@
private:
enum class IndexType { First, Last };
unsigned lineIndexForHeight(LayoutUnit, IndexType) const;
+ unsigned adjustLineIndexForStruts(LayoutUnit, unsigned lineIndexCandidate) const;
const RenderBlockFlow& m_flowRenderer;
const Layout& m_layout;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes