OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | |
5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. | |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
7 * Copyright (C) 2013 Google Inc. All rights reserved. | |
8 * | |
9 * Redistribution and use in source and binary forms, with or without | |
10 * modification, are permitted provided that the following conditions are | |
11 * met: | |
12 * | |
13 * * Redistributions of source code must retain the above copyright | |
14 * notice, this list of conditions and the following disclaimer. | |
15 * * Redistributions in binary form must reproduce the above | |
16 * copyright notice, this list of conditions and the following disclaimer | |
17 * in the documentation and/or other materials provided with the | |
18 * distribution. | |
19 * * Neither the name of Google Inc. nor the names of its | |
20 * contributors may be used to endorse or promote products derived from | |
21 * this software without specific prior written permission. | |
22 * | |
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 */ | |
35 | |
36 #ifndef SKY_ENGINE_CORE_RENDERING_RENDERBLOCKFLOW_H_ | |
37 #define SKY_ENGINE_CORE_RENDERING_RENDERBLOCKFLOW_H_ | |
38 | |
39 #include "sky/engine/core/rendering/RenderBlock.h" | |
40 #include "sky/engine/core/rendering/line/TrailingObjects.h" | |
41 #include "sky/engine/core/rendering/style/RenderStyleConstants.h" | |
42 | |
43 namespace blink { | |
44 | |
45 class LineBreaker; | |
46 class LineWidth; | |
47 class FloatingObject; | |
48 | |
49 class RenderBlockFlow : public RenderBlock { | |
50 public: | |
51 explicit RenderBlockFlow(ContainerNode*); | |
52 virtual ~RenderBlockFlow(); | |
53 | |
54 static RenderBlockFlow* createAnonymous(Document*); | |
55 | |
56 virtual bool isRenderBlockFlow() const override final { return true; } | |
57 | |
58 void layout() override; | |
59 | |
60 virtual void deleteLineBoxTree() override final; | |
61 | |
62 LayoutUnit availableLogicalWidthForLine(bool shouldIndentText) const | |
63 { | |
64 return max<LayoutUnit>(0, logicalRightOffsetForLine(shouldIndentText) -
logicalLeftOffsetForLine(shouldIndentText)); | |
65 } | |
66 LayoutUnit logicalRightOffsetForLine(bool shouldIndentText) const | |
67 { | |
68 LayoutUnit right = logicalRightOffsetForContent(); | |
69 if (shouldIndentText && !style()->isLeftToRightDirection()) | |
70 right -= textIndentOffset(); | |
71 return right; | |
72 } | |
73 LayoutUnit logicalLeftOffsetForLine(bool shouldIndentText) const | |
74 { | |
75 LayoutUnit left = logicalLeftOffsetForContent(); | |
76 if (shouldIndentText && style()->isLeftToRightDirection()) | |
77 left += textIndentOffset(); | |
78 return left; | |
79 } | |
80 LayoutUnit startOffsetForLine(bool shouldIndentText) const | |
81 { | |
82 return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(shou
ldIndentText) | |
83 : logicalWidth() - logicalRightOffsetForLine(shouldIndentText); | |
84 } | |
85 LayoutUnit endOffsetForLine(bool shouldIndentText) const | |
86 { | |
87 return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(sho
uldIndentText) | |
88 : logicalWidth() - logicalRightOffsetForLine(shouldIndentText); | |
89 } | |
90 | |
91 // FIXME-BLOCKFLOW: Move this into RenderBlockFlow once there are no calls | |
92 // in RenderBlock. http://crbug.com/393945, http://crbug.com/302024 | |
93 using RenderBlock::lineBoxes; | |
94 using RenderBlock::firstLineBox; | |
95 using RenderBlock::lastLineBox; | |
96 using RenderBlock::firstRootBox; | |
97 using RenderBlock::lastRootBox; | |
98 | |
99 virtual LayoutUnit logicalLeftSelectionOffset(RenderBlock* rootBlock, Layout
Unit position) override; | |
100 virtual LayoutUnit logicalRightSelectionOffset(RenderBlock* rootBlock, Layou
tUnit position) override; | |
101 | |
102 RootInlineBox* createAndAppendRootInlineBox(); | |
103 | |
104 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0)
override; | |
105 | |
106 LayoutUnit startAlignedOffsetForLine(bool shouldIndentText); | |
107 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*,
BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float&
availableLogicalWidth, unsigned expansionOpportunityCount); | |
108 | |
109 static bool shouldSkipCreatingRunsForObject(RenderObject* obj) | |
110 { | |
111 return obj->isOutOfFlowPositioned() && !obj->style()->isOriginalDisplayI
nlineType() && !obj->container()->isRenderInline(); | |
112 } | |
113 | |
114 protected: | |
115 virtual void layoutChildren(bool relayoutChildren, SubtreeLayoutScope&, Layo
utUnit beforeEdge, LayoutUnit afterEdge); | |
116 | |
117 void determineLogicalLeftPositionForChild(RenderBox* child); | |
118 | |
119 private: | |
120 void layoutBlockFlow(SubtreeLayoutScope&); | |
121 void layoutBlockChild(RenderBox* child); | |
122 | |
123 RootInlineBox* createRootInlineBox(); | |
124 | |
125 public: | |
126 struct FloatWithRect { | |
127 FloatWithRect(RenderBox* f) | |
128 : object(f) | |
129 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(),
f->width() + f->marginWidth(), f->height() + f->marginHeight())) | |
130 , everHadLayout(f->everHadLayout()) | |
131 { | |
132 } | |
133 | |
134 RenderBox* object; | |
135 LayoutRect rect; | |
136 bool everHadLayout; | |
137 }; | |
138 | |
139 protected: | |
140 friend class BreakingContext; // FIXME: It uses insertFloatingObject and pos
itionNewFloatOnLine, if we move those out from the private scope/add a helper to
LineBreaker, we can remove this friend | |
141 friend class LineBreaker; | |
142 }; | |
143 | |
144 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); | |
145 | |
146 } // namespace blink | |
147 | |
148 #endif // SKY_ENGINE_CORE_RENDERING_RENDERBLOCKFLOW_H_ | |
OLD | NEW |