<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212854] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212854">212854</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2017-02-22 14:37:41 -0800 (Wed, 22 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simple line layout: Set the pagination strut on the flow when the first line does not fit the page.
https://bugs.webkit.org/show_bug.cgi?id=168738
<rdar://problem/30659469>
Reviewed by Antti Koivisto.
The pagination strut for the first line is tracked by the parent RenderBlockFlow and not by
the line itself (see RenderBlockFlow::adjustLinePositionForPagination()). Also renamed *PaginationStrut* to
*LineStrut* to make sure we don't confuse it with the block level strut.
Not enabled yet.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::computeLineTopAndBottomWithOverflow):
(WebCore::SimpleLineLayout::computeLineBreakIndex):
(WebCore::SimpleLineLayout::setPageBreakForLine):
(WebCore::SimpleLineLayout::adjustLinePositionsForPagination):
(WebCore::SimpleLineLayout::create):
(WebCore::SimpleLineLayout::Layout::create):
(WebCore::SimpleLineLayout::Layout::Layout):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Layout::hasLineStruts):
(WebCore::SimpleLineLayout::Layout::struts):
(WebCore::SimpleLineLayout::Layout::hasPaginationStruts): Deleted.
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
* rendering/SimpleLineLayoutFunctions.h:
(WebCore::SimpleLineLayout::computeFlowHeight):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::computeBaselinePosition):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutcpp">trunk/Source/WebCore/rendering/SimpleLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayouth">trunk/Source/WebCore/rendering/SimpleLineLayout.h</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFunctionsh">trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutResolverh">trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212853 => 212854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-22 22:07:39 UTC (rev 212853)
+++ trunk/Source/WebCore/ChangeLog        2017-02-22 22:37:41 UTC (rev 212854)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2017-02-22 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Set the pagination strut on the flow when the first line does not fit the page.
+ https://bugs.webkit.org/show_bug.cgi?id=168738
+ <rdar://problem/30659469>
+
+ Reviewed by Antti Koivisto.
+
+ The pagination strut for the first line is tracked by the parent RenderBlockFlow and not by
+ the line itself (see RenderBlockFlow::adjustLinePositionForPagination()). Also renamed *PaginationStrut* to
+ *LineStrut* to make sure we don't confuse it with the block level strut.
+
+ Not enabled yet.
+
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::computeLineTopAndBottomWithOverflow):
+ (WebCore::SimpleLineLayout::computeLineBreakIndex):
+ (WebCore::SimpleLineLayout::setPageBreakForLine):
+ (WebCore::SimpleLineLayout::adjustLinePositionsForPagination):
+ (WebCore::SimpleLineLayout::create):
+ (WebCore::SimpleLineLayout::Layout::create):
+ (WebCore::SimpleLineLayout::Layout::Layout):
+ * rendering/SimpleLineLayout.h:
+ (WebCore::SimpleLineLayout::Layout::hasLineStruts):
+ (WebCore::SimpleLineLayout::Layout::struts):
+ (WebCore::SimpleLineLayout::Layout::hasPaginationStruts): Deleted.
+ * rendering/SimpleLineLayoutFunctions.cpp:
+ (WebCore::SimpleLineLayout::paintFlow):
+ * rendering/SimpleLineLayoutFunctions.h:
+ (WebCore::SimpleLineLayout::computeFlowHeight):
+ * rendering/SimpleLineLayoutResolver.h:
+ (WebCore::SimpleLineLayout::RunResolver::Run::computeBaselinePosition):
+
</ins><span class="cx"> 2017-02-22 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><span class="cx"> [WebRTC] Disable libwebrtc stderr logging in release mode
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (212853 => 212854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2017-02-22 22:07:39 UTC (rev 212853)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2017-02-22 22:37:41 UTC (rev 212854)
</span><span class="lines">@@ -914,7 +914,7 @@
</span><span class="cx"> };
</span><span class="cx"> using PaginatedLines = Vector<PaginatedLine, 20>;
</span><span class="cx">
</span><del>-static PaginatedLine computeLineTopAndBottomWithOverflow(const RenderBlockFlow& flow, unsigned lineIndex, Layout::SimplePaginationStruts& struts)
</del><ins>+static PaginatedLine computeLineTopAndBottomWithOverflow(const RenderBlockFlow& flow, unsigned lineIndex, Layout::SimpleLineStruts& struts)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: Add visualOverflowForDecorations.
</span><span class="cx"> auto& fontMetrics = flow.style().fontCascade().fontMetrics();
</span><span class="lines">@@ -937,7 +937,7 @@
</span><span class="cx"> return { topPosition, bottomPosition, bottomPosition - topPosition };
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimplePaginationStruts& struts)
</del><ins>+static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimpleLineStruts& struts)
</ins><span class="cx"> {
</span><span class="cx"> // First line does not fit the current page.
</span><span class="cx"> if (!breakCandidate)
</span><span class="lines">@@ -956,19 +956,6 @@
</span><span class="cx"> return std::max<unsigned>(struts.last().lineBreak + 1, lineBreak);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void setPageBreakForLine(unsigned lineBreak, PaginatedLines& lines, RenderBlockFlow& flow)
-{
- if (!lineBreak) {
- // When the line does not fit the current page, just add a page break in front.
- auto line = lines.first();
- flow.setPageBreak(line.top, flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary));
- return;
- }
- auto beforeLineBreak = lines.at(lineBreak - 1);
- auto spaceShortage = flow.pageRemainingLogicalHeightForOffset(beforeLineBreak.top, RenderBlockFlow::ExcludePageBoundary) - beforeLineBreak.height;
- flow.setPageBreak(beforeLineBreak.bottom, spaceShortage);
-}
-
</del><span class="cx"> static LayoutUnit computeOffsetAfterLineBreak(LayoutUnit lineBreakPosition, bool isFirstLine, bool atTheTopOfColumnOrPage, const RenderBlockFlow& flow)
</span><span class="cx"> {
</span><span class="cx"> // No offset for top of the page lines unless widows pushed the line break.
</span><span class="lines">@@ -978,6 +965,23 @@
</span><span class="cx"> return offset + flow.pageRemainingLogicalHeightForOffset(lineBreakPosition, RenderBlockFlow::ExcludePageBoundary);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void setPageBreakForLine(unsigned lineBreakIndex, PaginatedLines& lines, RenderBlockFlow& flow, Layout::SimpleLineStruts& struts,
+ bool atTheTopOfColumnOrPage)
+{
+ if (!lineBreakIndex) {
+ // When the first line does not fit the current page, just add a page break in front and set the strut on the block.
+ auto line = lines.first();
+ auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
+ flow.setPageBreak(line.top, line.height - remainingLogicalHeight);
+ flow.setPaginationStrut(remainingLogicalHeight);
+ return;
+ }
+ auto beforeLineBreak = lines.at(lineBreakIndex - 1);
+ auto spaceShortage = flow.pageRemainingLogicalHeightForOffset(beforeLineBreak.top, RenderBlockFlow::ExcludePageBoundary) - beforeLineBreak.height;
+ flow.setPageBreak(beforeLineBreak.bottom, spaceShortage);
+ struts.append({ lineBreakIndex, computeOffsetAfterLineBreak(lines[lineBreakIndex].top, !lineBreakIndex, atTheTopOfColumnOrPage, flow) });
+}
+
</ins><span class="cx"> static void updateMinimumPageHeight(RenderBlockFlow& flow, unsigned lineCount)
</span><span class="cx"> {
</span><span class="cx"> auto& style = flow.style();
</span><span class="lines">@@ -987,7 +991,7 @@
</span><span class="cx"> flow.updateMinimumPageHeight(0, minimumLineCount * lineHeightFromFlow(flow));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void adjustLinePositionsForPagination(Layout::RunVector& runs, Layout::SimplePaginationStruts& struts,
</del><ins>+static void adjustLinePositionsForPagination(Layout::RunVector& runs, Layout::SimpleLineStruts& struts,
</ins><span class="cx"> RenderBlockFlow& flow, unsigned lineCount)
</span><span class="cx"> {
</span><span class="cx"> updateMinimumPageHeight(flow, lineCount);
</span><span class="lines">@@ -1009,8 +1013,7 @@
</span><span class="cx"> auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, widows, struts);
</span><span class="cx"> // Are we still at the top of the column/page?
</span><span class="cx"> atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false;
</span><del>- setPageBreakForLine(lineBreakIndex, lines, flow);
- struts.append({ lineBreakIndex, computeOffsetAfterLineBreak(lines[lineBreakIndex].top, !lineBreakIndex, atTheTopOfColumnOrPage, flow) });
</del><ins>+ setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage);
</ins><span class="cx"> // Recompute line positions that we already visited but window break pushed them to a new page.
</span><span class="cx"> for (auto i = lineBreakIndex; i < lines.size(); ++i)
</span><span class="cx"> lines.at(i) = computeLineTopAndBottomWithOverflow(flow, i, struts);
</span><span class="lines">@@ -1044,7 +1047,7 @@
</span><span class="cx"> unsigned lineCount = 0;
</span><span class="cx"> Layout::RunVector runs;
</span><span class="cx"> createTextRuns(runs, flow, lineCount);
</span><del>- Layout::SimplePaginationStruts struts;
</del><ins>+ Layout::SimpleLineStruts struts;
</ins><span class="cx"> auto isPaginated = flow.view().layoutState() && flow.view().layoutState()->isPaginated();
</span><span class="cx"> if (isPaginated)
</span><span class="cx"> adjustLinePositionsForPagination(runs, struts, flow, lineCount);
</span><span class="lines">@@ -1051,17 +1054,17 @@
</span><span class="cx"> return Layout::create(runs, struts, lineCount, isPaginated);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount, bool isPaginated)
</del><ins>+std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimpleLineStruts& struts, unsigned lineCount, bool isPaginated)
</ins><span class="cx"> {
</span><span class="cx"> void* slot = WTF::fastMalloc(sizeof(Layout) + sizeof(Run) * runVector.size());
</span><span class="cx"> return std::unique_ptr<Layout>(new (NotNull, slot) Layout(runVector, struts, lineCount, isPaginated));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Layout::Layout(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount, bool isPaginated)
</del><ins>+Layout::Layout(const RunVector& runVector, SimpleLineStruts& struts, unsigned lineCount, bool isPaginated)
</ins><span class="cx"> : m_lineCount(lineCount)
</span><span class="cx"> , m_runCount(runVector.size())
</span><span class="cx"> , m_isPaginated(isPaginated)
</span><del>- , m_paginationStruts(WTFMove(struts))
</del><ins>+ , m_lineStruts(WTFMove(struts))
</ins><span class="cx"> {
</span><span class="cx"> memcpy(m_runs, runVector.data(), m_runCount * sizeof(Run));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayouth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (212853 => 212854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.h        2017-02-22 22:07:39 UTC (rev 212853)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h        2017-02-22 22:37:41 UTC (rev 212854)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> ExpansionBehavior expansionBehavior { ForbidLeadingExpansion | ForbidTrailingExpansion };
</span><span class="cx"> };
</span><span class="cx">
</span><del>-struct SimplePaginationStrut {
</del><ins>+struct SimpleLineStrut {
</ins><span class="cx"> unsigned lineBreak;
</span><span class="cx"> float offset;
</span><span class="cx"> };
</span><span class="lines">@@ -75,8 +75,8 @@
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx"> using RunVector = Vector<Run, 10>;
</span><del>- using SimplePaginationStruts = Vector<SimplePaginationStrut, 4>;
- static std::unique_ptr<Layout> create(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
</del><ins>+ using SimpleLineStruts = Vector<SimpleLineStrut, 4>;
+ static std::unique_ptr<Layout> create(const RunVector&, SimpleLineStruts&, unsigned lineCount, bool isPaginated);
</ins><span class="cx">
</span><span class="cx"> unsigned lineCount() const { return m_lineCount; }
</span><span class="cx">
</span><span class="lines">@@ -84,15 +84,15 @@
</span><span class="cx"> const Run& runAt(unsigned i) const { return m_runs[i]; }
</span><span class="cx">
</span><span class="cx"> bool isPaginated() const { return m_isPaginated; }
</span><del>- bool hasPaginationStruts() const { return !m_paginationStruts.isEmpty(); }
- const SimplePaginationStruts& struts() const { return m_paginationStruts; }
</del><ins>+ bool hasLineStruts() const { return !m_lineStruts.isEmpty(); }
+ const SimpleLineStruts& struts() const { return m_lineStruts; }
</ins><span class="cx"> private:
</span><del>- Layout(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
</del><ins>+ Layout(const RunVector&, SimpleLineStruts&, unsigned lineCount, bool isPaginated);
</ins><span class="cx">
</span><span class="cx"> unsigned m_lineCount;
</span><span class="cx"> unsigned m_runCount;
</span><span class="cx"> bool m_isPaginated;
</span><del>- SimplePaginationStruts m_paginationStruts;
</del><ins>+ SimpleLineStruts m_lineStruts;
</ins><span class="cx"> Run m_runs[0];
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFunctionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (212853 => 212854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h        2017-02-22 22:07:39 UTC (rev 212853)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h        2017-02-22 22:37:41 UTC (rev 212854)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Layout& layout)
</span><span class="cx"> {
</span><span class="cx"> auto flowHeight = lineHeightFromFlow(flow) * layout.lineCount();
</span><del>- if (!layout.hasPaginationStruts())
</del><ins>+ if (!layout.hasLineStruts())
</ins><span class="cx"> return flowHeight;
</span><span class="cx"> for (auto& strutEntry : layout.struts())
</span><span class="cx"> flowHeight += strutEntry.offset;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (212853 => 212854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-02-22 22:07:39 UTC (rev 212853)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-02-22 22:37:41 UTC (rev 212854)
</span><span class="lines">@@ -221,7 +221,7 @@
</span><span class="cx"> {
</span><span class="cx"> auto& resolver = m_iterator.resolver();
</span><span class="cx"> auto offset = resolver.m_borderAndPaddingBefore + resolver.m_lineHeight * lineIndex();
</span><del>- if (!resolver.m_layout.hasPaginationStruts())
</del><ins>+ if (!resolver.m_layout.hasLineStruts())
</ins><span class="cx"> return offset + resolver.m_baseline;
</span><span class="cx"> for (auto& strutEntry : resolver.m_layout.struts()) {
</span><span class="cx"> if (strutEntry.lineBreak > lineIndex())
</span></span></pre>
</div>
</div>
</body>
</html>