Diff
Modified: trunk/Source/WebCore/ChangeLog (212842 => 212843)
--- trunk/Source/WebCore/ChangeLog 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/ChangeLog 2017-02-22 19:33:02 UTC (rev 212843)
@@ -1,3 +1,34 @@
+2017-02-22 Zalan Bujtas <za...@apple.com>
+
+ Simple line layout: ensureLineBoxes for paginated content.
+ https://bugs.webkit.org/show_bug.cgi?id=168729
+ <rdar://problem/30654400>
+
+ Reviewed by Antti Koivisto.
+
+ This patch sets the layout state bits for paginated subtree layout, when we are switching
+ over from simple line runs to inline tree.
+
+ Not enabled yet.
+
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::ensureLineBoxes):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::pushLayoutStateForPagination): LayoutUnit(1) is not the real height, it's just
+ an indicator that we've got paginated content.
+ * rendering/RenderView.h:
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::create):
+ (WebCore::SimpleLineLayout::Layout::create):
+ (WebCore::SimpleLineLayout::Layout::Layout):
+ * rendering/SimpleLineLayout.h:
+ (WebCore::SimpleLineLayout::Layout::isPaginated):
+ (WebCore::SimpleLineLayout::Layout::hasPaginationStruts):
+ * rendering/SimpleLineLayoutFunctions.h:
+ (WebCore::SimpleLineLayout::computeFlowHeight):
+ * rendering/SimpleLineLayoutResolver.h:
+ (WebCore::SimpleLineLayout::RunResolver::Run::computeBaselinePosition):
+
2017-02-22 Per Arne Vollan <pvol...@apple.com>
[Win] Compile fix.
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (212842 => 212843)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-02-22 19:33:02 UTC (rev 212843)
@@ -3700,6 +3700,7 @@
setLineLayoutPath(ForceLineBoxesPath);
if (!m_simpleLineLayout)
return;
+ bool isPaginated = m_simpleLineLayout->isPaginated();
m_simpleLineLayout = nullptr;
#if !ASSERT_DISABLED
@@ -3710,7 +3711,12 @@
bool relayoutChildren = false;
LayoutUnit repaintLogicalTop;
LayoutUnit repaintLogicalBottom;
- layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
+ if (isPaginated) {
+ view().pushLayoutStateForPagination(*this);
+ layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
+ view().popLayoutState(*this);
+ } else
+ layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
updateLogicalHeight();
ASSERT(didNeedLayout || logicalHeight() == oldHeight);
@@ -3944,7 +3950,7 @@
// enabled and flow thread height is still unknown (i.e. during the first layout pass). When
// it's unknown, we need to prevent the pagination code from assuming page breaks everywhere
// and thereby eating every top margin. It should be trivial to clean up and get rid of this
- // hack once the old multicol implementation is gone.
+ // hack once the old multicol implementation is gone (see also RenderView::pushLayoutStateForPagination).
pageLogicalHeight = flowThread.isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(0);
pageLogicalHeightChanged = flowThread.pageLogicalSizeChanged();
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (212842 => 212843)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2017-02-22 19:33:02 UTC (rev 212843)
@@ -1232,6 +1232,15 @@
pushLayoutStateForCurrentFlowThread(root);
}
+void RenderView::pushLayoutStateForPagination(RenderBlockFlow& layoutRoot)
+{
+ pushLayoutState(layoutRoot);
+ ASSERT(m_layoutState);
+ m_layoutState->m_isPaginated = true;
+ // This is just a flag for known page height (see RenderBlockFlow::checkForPaginationLogicalHeightChange).
+ m_layoutState->m_pageLogicalHeight = 1;
+}
+
IntSize RenderView::viewportSizeForCSSViewportUnits() const
{
return frameView().viewportSizeForCSSViewportUnits();
Modified: trunk/Source/WebCore/rendering/RenderView.h (212842 => 212843)
--- trunk/Source/WebCore/rendering/RenderView.h 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/RenderView.h 2017-02-22 19:33:02 UTC (rev 212843)
@@ -132,6 +132,7 @@
// Subtree push/pop
void pushLayoutState(RenderObject&);
+ void pushLayoutStateForPagination(RenderBlockFlow&);
void popLayoutState(RenderObject&) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical.
// Returns true if layoutState should be used for its cached offset and clip.
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (212842 => 212843)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-02-22 19:33:02 UTC (rev 212843)
@@ -1045,20 +1045,22 @@
Layout::RunVector runs;
createTextRuns(runs, flow, lineCount);
Layout::SimplePaginationStruts struts;
- if (flow.view().layoutState() && flow.view().layoutState()->isPaginated())
+ auto isPaginated = flow.view().layoutState() && flow.view().layoutState()->isPaginated();
+ if (isPaginated)
adjustLinePositionsForPagination(runs, struts, flow, lineCount);
- return Layout::create(runs, struts, lineCount);
+ return Layout::create(runs, struts, lineCount, isPaginated);
}
-std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount)
+std::unique_ptr<Layout> Layout::create(const RunVector& runVector, SimplePaginationStruts& 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));
+ return std::unique_ptr<Layout>(new (NotNull, slot) Layout(runVector, struts, lineCount, isPaginated));
}
-Layout::Layout(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount)
+Layout::Layout(const RunVector& runVector, SimplePaginationStruts& struts, unsigned lineCount, bool isPaginated)
: m_lineCount(lineCount)
, m_runCount(runVector.size())
+ , m_isPaginated(isPaginated)
, m_paginationStruts(WTFMove(struts))
{
memcpy(m_runs, runVector.data(), m_runCount * sizeof(Run));
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (212842 => 212843)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.h 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h 2017-02-22 19:33:02 UTC (rev 212843)
@@ -76,7 +76,7 @@
public:
using RunVector = Vector<Run, 10>;
using SimplePaginationStruts = Vector<SimplePaginationStrut, 4>;
- static std::unique_ptr<Layout> create(const RunVector&, SimplePaginationStruts&, unsigned lineCount);
+ static std::unique_ptr<Layout> create(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
unsigned lineCount() const { return m_lineCount; }
@@ -83,13 +83,15 @@
unsigned runCount() const { return m_runCount; }
const Run& runAt(unsigned i) const { return m_runs[i]; }
- bool isPaginated() const { return !m_paginationStruts.isEmpty(); }
+ bool isPaginated() const { return m_isPaginated; }
+ bool hasPaginationStruts() const { return !m_paginationStruts.isEmpty(); }
const SimplePaginationStruts& struts() const { return m_paginationStruts; }
private:
- Layout(const RunVector&, SimplePaginationStruts&, unsigned lineCount);
+ Layout(const RunVector&, SimplePaginationStruts&, unsigned lineCount, bool isPaginated);
unsigned m_lineCount;
unsigned m_runCount;
+ bool m_isPaginated;
SimplePaginationStruts m_paginationStruts;
Run m_runs[0];
};
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (212842 => 212843)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2017-02-22 19:33:02 UTC (rev 212843)
@@ -74,7 +74,7 @@
inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Layout& layout)
{
auto flowHeight = lineHeightFromFlow(flow) * layout.lineCount();
- if (!layout.isPaginated())
+ if (!layout.hasPaginationStruts())
return flowHeight;
for (auto& strutEntry : layout.struts())
flowHeight += strutEntry.offset;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (212842 => 212843)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-02-22 19:26:14 UTC (rev 212842)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-02-22 19:33:02 UTC (rev 212843)
@@ -221,7 +221,7 @@
{
auto& resolver = m_iterator.resolver();
auto offset = resolver.m_borderAndPaddingBefore + resolver.m_lineHeight * lineIndex();
- if (!resolver.m_layout.isPaginated())
+ if (!resolver.m_layout.hasPaginationStruts())
return offset + resolver.m_baseline;
for (auto& strutEntry : resolver.m_layout.struts()) {
if (strutEntry.lineBreak > lineIndex())