Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / layout / LayoutPagedFlowThread.cpp
blob413f2701af476bbd8f4a6d4882d1159c02311772
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/layout/LayoutPagedFlowThread.h"
8 #include "core/layout/LayoutMultiColumnSet.h"
10 namespace blink {
12 LayoutPagedFlowThread* LayoutPagedFlowThread::createAnonymous(Document& document, const ComputedStyle& parentStyle)
14 LayoutPagedFlowThread* pagedFlowThread = new LayoutPagedFlowThread();
15 pagedFlowThread->setDocumentForAnonymous(&document);
16 pagedFlowThread->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parentStyle, BLOCK));
17 return pagedFlowThread;
20 int LayoutPagedFlowThread::pageCount()
22 if (LayoutMultiColumnSet* columnSet = firstMultiColumnSet())
23 return columnSet->actualColumnCount();
24 return 1;
27 bool LayoutPagedFlowThread::needsNewWidth() const
29 return progressionIsInline() != pagedBlockFlow()->style()->hasInlinePaginationAxis();
32 void LayoutPagedFlowThread::updateLogicalWidth()
34 // As long as we inherit from LayoutMultiColumnFlowThread, we need to bypass its implementation
35 // here. We're not split into columns, so the flow thread width will just be whatever is
36 // available in the containing block.
37 LayoutFlowThread::updateLogicalWidth();
40 void LayoutPagedFlowThread::layout()
42 ASSERT(firstMultiColumnBox() == lastMultiColumnBox()); // There should either be zero or one of those for paged layout.
43 setProgressionIsInline(pagedBlockFlow()->style()->hasInlinePaginationAxis());
44 LayoutMultiColumnFlowThread::layout();
46 LayoutMultiColumnSet* columnSet = firstMultiColumnSet();
47 if (!columnSet)
48 return;
49 LayoutUnit pageLogicalHeight = columnSet->pageLogicalHeightForOffset(LayoutUnit());
50 if (!pageLogicalHeight)
51 return; // Page height not calculated yet. Happens in the first layout pass when height is auto.
52 // Ensure uniform page height. We don't want the last page to be shorter than the others,
53 // or it'll be impossible to scroll that whole page into view.
54 LayoutUnit paddedLogicalBottomInFlowThread = pageLogicalHeight * pageCount();
55 ASSERT(paddedLogicalBottomInFlowThread >= columnSet->logicalBottomInFlowThread());
56 columnSet->endFlow(paddedLogicalBottomInFlowThread);
59 } // namespace blink