Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.cpp (213057 => 213058)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-02-27 14:29:02 UTC (rev 213057)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-02-27 14:34:03 UTC (rev 213058)
@@ -914,7 +914,7 @@
};
using PaginatedLines = Vector<PaginatedLine, 20>;
-static PaginatedLine computeLineTopAndBottomWithOverflow(const RenderBlockFlow& flow, unsigned lineIndex, Layout::SimplePaginationStruts& struts)
+static PaginatedLine computeLineTopAndBottomWithOverflow(const RenderBlockFlow& flow, unsigned lineIndex, Layout::SimpleLineStruts& struts)
{
// FIXME: Add visualOverflowForDecorations.
auto& fontMetrics = flow.style().fontCascade().fontMetrics();
@@ -937,7 +937,7 @@
return { topPosition, bottomPosition, bottomPosition - topPosition };
}
-static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimplePaginationStruts& struts)
+static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimpleLineStruts& struts)
{
// First line does not fit the current page.
if (!breakCandidate)
@@ -956,19 +956,6 @@
return std::max<unsigned>(struts.last().lineBreak + 1, lineBreak);
}
-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);
-}
-
static LayoutUnit computeOffsetAfterLineBreak(LayoutUnit lineBreakPosition, bool isFirstLine, bool atTheTopOfColumnOrPage, const RenderBlockFlow& flow)
{
// No offset for top of the page lines unless widows pushed the line break.
@@ -978,6 +965,23 @@
return offset + flow.pageRemainingLogicalHeightForOffset(lineBreakPosition, RenderBlockFlow::ExcludePageBoundary);
}
+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) });
+}
+
static void updateMinimumPageHeight(RenderBlockFlow& flow, unsigned lineCount)
{
auto& style = flow.style();
@@ -987,7 +991,7 @@
flow.updateMinimumPageHeight(0, minimumLineCount * lineHeightFromFlow(flow));
}
-static void adjustLinePositionsForPagination(Layout::RunVector& runs, Layout::SimplePaginationStruts& struts,
+static void adjustLinePositionsForPagination(Layout::RunVector& runs, Layout::SimpleLineStruts& struts,
RenderBlockFlow& flow, unsigned lineCount)
{
updateMinimumPageHeight(flow, lineCount);
@@ -1009,8 +1013,7 @@
auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, widows, struts);
// Are we still at the top of the column/page?
atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false;
- setPageBreakForLine(lineBreakIndex, lines, flow);
- struts.append({ lineBreakIndex, computeOffsetAfterLineBreak(lines[lineBreakIndex].top, !lineBreakIndex, atTheTopOfColumnOrPage, flow) });
+ setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage);
// Recompute line positions that we already visited but window break pushed them to a new page.
for (auto i = lineBreakIndex; i < lines.size(); ++i)
lines.at(i) = computeLineTopAndBottomWithOverflow(flow, i, struts);
@@ -1044,7 +1047,7 @@
unsigned lineCount = 0;
Layout::RunVector runs;
createTextRuns(runs, flow, lineCount);
- Layout::SimplePaginationStruts struts;
+ Layout::SimpleLineStruts struts;
auto isPaginated = flow.view().layoutState() && flow.view().layoutState()->isPaginated();
if (isPaginated)
adjustLinePositionsForPagination(runs, struts, flow, lineCount);
@@ -1051,17 +1054,17 @@
return Layout::create(runs, struts, lineCount, isPaginated);
}
-std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount, bool isPaginated)
+std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimpleLineStruts& struts, unsigned lineCount, bool isPaginated)
{
void* slot = WTF::fastMalloc(sizeof(Layout) + sizeof(Run) * runVector.size());
return std::unique_ptr<Layout>(new (NotNull, slot) Layout(runVector, struts, lineCount, isPaginated));
}
-Layout::Layout(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount, bool isPaginated)
+Layout::Layout(const RunVector& runVector, SimpleLineStruts& struts, unsigned lineCount, bool isPaginated)
: m_lineCount(lineCount)
, m_runCount(runVector.size())
, m_isPaginated(isPaginated)
- , m_paginationStruts(WTFMove(struts))
+ , m_lineStruts(WTFMove(struts))
{
memcpy(m_runs, runVector.data(), m_runCount * sizeof(Run));
}
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.h (213057 => 213058)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.h 2017-02-27 14:29:02 UTC (rev 213057)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayout.h 2017-02-27 14:34:03 UTC (rev 213058)
@@ -66,7 +66,7 @@
ExpansionBehavior expansionBehavior { ForbidLeadingExpansion | ForbidTrailingExpansion };
};
-struct SimplePaginationStrut {
+struct SimpleLineStrut {
unsigned lineBreak;
float offset;
};
@@ -75,8 +75,8 @@
WTF_MAKE_FAST_ALLOCATED;
public:
using RunVector = Vector<Run, 10>;
- using SimplePaginationStruts = Vector<SimplePaginationStrut, 4>;
- static std::unique_ptr<Layout> create(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
+ using SimpleLineStruts = Vector<SimpleLineStrut, 4>;
+ static std::unique_ptr<Layout> create(const RunVector&, SimpleLineStruts&, unsigned lineCount, bool isPaginated);
unsigned lineCount() const { return m_lineCount; }
@@ -84,15 +84,15 @@
const Run& runAt(unsigned i) const { return m_runs[i]; }
bool isPaginated() const { return m_isPaginated; }
- bool hasPaginationStruts() const { return !m_paginationStruts.isEmpty(); }
- const SimplePaginationStruts& struts() const { return m_paginationStruts; }
+ bool hasLineStruts() const { return !m_lineStruts.isEmpty(); }
+ const SimpleLineStruts& struts() const { return m_lineStruts; }
private:
- Layout(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
+ Layout(const RunVector&, SimpleLineStruts&, unsigned lineCount, bool isPaginated);
unsigned m_lineCount;
unsigned m_runCount;
bool m_isPaginated;
- SimplePaginationStruts m_paginationStruts;
+ SimpleLineStruts m_lineStruts;
Run m_runs[0];
};