2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All right reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef LineLayoutState_h
25 #define LineLayoutState_h
27 #include "core/rendering/RenderBlockFlow.h"
28 #include "platform/geometry/LayoutRect.h"
32 // Like LayoutState for layout(), LineLayoutState keeps track of global information
33 // during an entire linebox tree layout pass (aka layoutInlineChildren).
34 class LineLayoutState {
36 LineLayoutState(bool fullLayout, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom, RenderFlowThread* flowThread)
40 , m_endLineLogicalTop(0)
41 , m_endLineMatched(false)
42 , m_checkForFloatsFromLastLine(false)
43 , m_hasInlineChild(false)
44 , m_isFullLayout(fullLayout)
45 , m_repaintLogicalTop(repaintLogicalTop)
46 , m_repaintLogicalBottom(repaintLogicalBottom)
47 , m_adjustedLogicalLineTop(0)
48 , m_usesRepaintBounds(false)
49 , m_flowThread(flowThread)
52 void markForFullLayout() { m_isFullLayout = true; }
53 bool isFullLayout() const { return m_isFullLayout; }
55 bool usesRepaintBounds() const { return m_usesRepaintBounds; }
57 void setRepaintRange(LayoutUnit logicalHeight)
59 m_usesRepaintBounds = true;
60 m_repaintLogicalTop = m_repaintLogicalBottom = logicalHeight;
63 void updateRepaintRangeFromBox(RootInlineBox* box, LayoutUnit paginationDelta = 0)
65 m_usesRepaintBounds = true;
66 m_repaintLogicalTop = std::min(m_repaintLogicalTop, box->logicalTopVisualOverflow() + std::min<LayoutUnit>(paginationDelta, 0));
67 m_repaintLogicalBottom = std::max(m_repaintLogicalBottom, box->logicalBottomVisualOverflow() + std::max<LayoutUnit>(paginationDelta, 0));
70 bool endLineMatched() const { return m_endLineMatched; }
71 void setEndLineMatched(bool endLineMatched) { m_endLineMatched = endLineMatched; }
73 bool checkForFloatsFromLastLine() const { return m_checkForFloatsFromLastLine; }
74 void setCheckForFloatsFromLastLine(bool check) { m_checkForFloatsFromLastLine = check; }
76 bool hasInlineChild() const { return m_hasInlineChild; }
77 void setHasInlineChild(bool hasInlineChild) { m_hasInlineChild = hasInlineChild; }
79 LineInfo& lineInfo() { return m_lineInfo; }
80 const LineInfo& lineInfo() const { return m_lineInfo; }
82 LayoutUnit endLineLogicalTop() const { return m_endLineLogicalTop; }
83 void setEndLineLogicalTop(LayoutUnit logicalTop) { m_endLineLogicalTop = logicalTop; }
85 RootInlineBox* endLine() const { return m_endLine; }
86 void setEndLine(RootInlineBox* line) { m_endLine = line; }
88 FloatingObject* lastFloat() const { return m_lastFloat; }
89 void setLastFloat(FloatingObject* lastFloat) { m_lastFloat = lastFloat; }
91 Vector<RenderBlockFlow::FloatWithRect>& floats() { return m_floats; }
93 unsigned floatIndex() const { return m_floatIndex; }
94 void setFloatIndex(unsigned floatIndex) { m_floatIndex = floatIndex; }
96 LayoutUnit adjustedLogicalLineTop() const { return m_adjustedLogicalLineTop; }
97 void setAdjustedLogicalLineTop(LayoutUnit value) { m_adjustedLogicalLineTop = value; }
99 RenderFlowThread* flowThread() const { return m_flowThread; }
100 void setFlowThread(RenderFlowThread* thread) { m_flowThread = thread; }
103 Vector<RenderBlockFlow::FloatWithRect> m_floats;
104 FloatingObject* m_lastFloat;
105 RootInlineBox* m_endLine;
107 unsigned m_floatIndex;
108 LayoutUnit m_endLineLogicalTop;
109 bool m_endLineMatched;
110 bool m_checkForFloatsFromLastLine;
111 // Used as a performance optimization to avoid doing a full repaint when our floats
112 // change but we don't have any inline children.
113 bool m_hasInlineChild;
117 // FIXME: Should this be a range object instead of two ints?
118 LayoutUnit& m_repaintLogicalTop;
119 LayoutUnit& m_repaintLogicalBottom;
121 LayoutUnit m_adjustedLogicalLineTop;
123 bool m_usesRepaintBounds;
125 RenderFlowThread* m_flowThread;
130 #endif // LineLayoutState_h