OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the layout object implementation for KHTML. | 2 * This file is part of the layout object implementation for KHTML. |
3 * | 3 * |
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
5 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
6 * Copyright (C) 2003 Apple Computer, Inc. | 6 * Copyright (C) 2003 Apple Computer, Inc. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Helper methods for obtaining the last line, computing line counts and heights
for line counts | 124 // Helper methods for obtaining the last line, computing line counts and heights
for line counts |
125 // (crawling into blocks). | 125 // (crawling into blocks). |
126 static bool shouldCheckLines(LayoutBlockFlow* blockFlow) | 126 static bool shouldCheckLines(LayoutBlockFlow* blockFlow) |
127 { | 127 { |
128 return !blockFlow->isFloatingOrOutOfFlowPositioned() && blockFlow->style()->
height().isAuto(); | 128 return !blockFlow->isFloatingOrOutOfFlowPositioned() && blockFlow->style()->
height().isAuto(); |
129 } | 129 } |
130 | 130 |
131 static int getHeightForLineCount(const LayoutBlockFlow* blockFlow, int lineCount
, bool includeBottom, int& count) | 131 static int getHeightForLineCount(const LayoutBlockFlow* blockFlow, int lineCount
, bool includeBottom, int& count) |
132 { | 132 { |
133 if (blockFlow->style()->visibility() != VISIBLE) | 133 if (blockFlow->style()->visibility() != EVisibility::Visible) |
134 return -1; | 134 return -1; |
135 if (blockFlow->childrenInline()) { | 135 if (blockFlow->childrenInline()) { |
136 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { | 136 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { |
137 if (++count == lineCount) | 137 if (++count == lineCount) |
138 return box->lineBottom() + (includeBottom ? (blockFlow->borderBo
ttom() + blockFlow->paddingBottom()) : LayoutUnit()); | 138 return box->lineBottom() + (includeBottom ? (blockFlow->borderBo
ttom() + blockFlow->paddingBottom()) : LayoutUnit()); |
139 } | 139 } |
140 return -1; | 140 return -1; |
141 } | 141 } |
142 | 142 |
143 LayoutBox* normalFlowChildWithoutLines = nullptr; | 143 LayoutBox* normalFlowChildWithoutLines = nullptr; |
144 for (LayoutBox* obj = blockFlow->firstChildBox(); obj; obj = obj->nextSiblin
gBox()) { | 144 for (LayoutBox* obj = blockFlow->firstChildBox(); obj; obj = obj->nextSiblin
gBox()) { |
145 if (obj->isLayoutBlockFlow() && shouldCheckLines(toLayoutBlockFlow(obj))
) { | 145 if (obj->isLayoutBlockFlow() && shouldCheckLines(toLayoutBlockFlow(obj))
) { |
146 int result = getHeightForLineCount(toLayoutBlockFlow(obj), lineCount
, false, count); | 146 int result = getHeightForLineCount(toLayoutBlockFlow(obj), lineCount
, false, count); |
147 if (result != -1) | 147 if (result != -1) |
148 return result + obj->location().y() + (includeBottom ? (blockFlo
w->borderBottom() + blockFlow->paddingBottom()) : LayoutUnit()); | 148 return result + obj->location().y() + (includeBottom ? (blockFlo
w->borderBottom() + blockFlow->paddingBottom()) : LayoutUnit()); |
149 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { | 149 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { |
150 normalFlowChildWithoutLines = obj; | 150 normalFlowChildWithoutLines = obj; |
151 } | 151 } |
152 } | 152 } |
153 if (normalFlowChildWithoutLines && lineCount == 0) | 153 if (normalFlowChildWithoutLines && lineCount == 0) |
154 return normalFlowChildWithoutLines->location().y() + normalFlowChildWith
outLines->size().height(); | 154 return normalFlowChildWithoutLines->location().y() + normalFlowChildWith
outLines->size().height(); |
155 | 155 |
156 return -1; | 156 return -1; |
157 } | 157 } |
158 | 158 |
159 static RootInlineBox* lineAtIndex(const LayoutBlockFlow* blockFlow, int i) | 159 static RootInlineBox* lineAtIndex(const LayoutBlockFlow* blockFlow, int i) |
160 { | 160 { |
161 ASSERT(i >= 0); | 161 ASSERT(i >= 0); |
162 | 162 |
163 if (blockFlow->style()->visibility() != VISIBLE) | 163 if (blockFlow->style()->visibility() != EVisibility::Visible) |
164 return nullptr; | 164 return nullptr; |
165 | 165 |
166 if (blockFlow->childrenInline()) { | 166 if (blockFlow->childrenInline()) { |
167 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { | 167 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { |
168 if (!i--) | 168 if (!i--) |
169 return box; | 169 return box; |
170 } | 170 } |
171 return nullptr; | 171 return nullptr; |
172 } | 172 } |
173 for (LayoutObject* child = blockFlow->firstChild(); child; child = child->ne
xtSibling()) { | 173 for (LayoutObject* child = blockFlow->firstChild(); child; child = child->ne
xtSibling()) { |
174 if (!child->isLayoutBlockFlow()) | 174 if (!child->isLayoutBlockFlow()) |
175 continue; | 175 continue; |
176 LayoutBlockFlow* childBlockFlow = toLayoutBlockFlow(child); | 176 LayoutBlockFlow* childBlockFlow = toLayoutBlockFlow(child); |
177 if (!shouldCheckLines(childBlockFlow)) | 177 if (!shouldCheckLines(childBlockFlow)) |
178 continue; | 178 continue; |
179 if (RootInlineBox* box = lineAtIndex(childBlockFlow, i)) | 179 if (RootInlineBox* box = lineAtIndex(childBlockFlow, i)) |
180 return box; | 180 return box; |
181 } | 181 } |
182 | 182 |
183 return nullptr; | 183 return nullptr; |
184 } | 184 } |
185 | 185 |
186 static int lineCount(const LayoutBlockFlow* blockFlow, const RootInlineBox* stop
RootInlineBox = nullptr, bool* found = nullptr) | 186 static int lineCount(const LayoutBlockFlow* blockFlow, const RootInlineBox* stop
RootInlineBox = nullptr, bool* found = nullptr) |
187 { | 187 { |
188 if (blockFlow->style()->visibility() != VISIBLE) | 188 if (blockFlow->style()->visibility() != EVisibility::Visible) |
189 return 0; | 189 return 0; |
190 int count = 0; | 190 int count = 0; |
191 if (blockFlow->childrenInline()) { | 191 if (blockFlow->childrenInline()) { |
192 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { | 192 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) { |
193 count++; | 193 count++; |
194 if (box == stopRootInlineBox) { | 194 if (box == stopRootInlineBox) { |
195 if (found) | 195 if (found) |
196 *found = true; | 196 *found = true; |
197 break; | 197 break; |
198 } | 198 } |
(...skipping 12 matching lines...) Expand all Loading... |
211 if (found) | 211 if (found) |
212 *found = true; | 212 *found = true; |
213 break; | 213 break; |
214 } | 214 } |
215 } | 215 } |
216 return count; | 216 return count; |
217 } | 217 } |
218 | 218 |
219 static void clearTruncation(LayoutBlockFlow* blockFlow) | 219 static void clearTruncation(LayoutBlockFlow* blockFlow) |
220 { | 220 { |
221 if (blockFlow->style()->visibility() != VISIBLE) | 221 if (blockFlow->style()->visibility() != EVisibility::Visible) |
222 return; | 222 return; |
223 if (blockFlow->childrenInline() && blockFlow->hasMarkupTruncation()) { | 223 if (blockFlow->childrenInline() && blockFlow->hasMarkupTruncation()) { |
224 blockFlow->setHasMarkupTruncation(false); | 224 blockFlow->setHasMarkupTruncation(false); |
225 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) | 225 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex
tRootBox()) |
226 box->clearTruncation(); | 226 box->clearTruncation(); |
227 return; | 227 return; |
228 } | 228 } |
229 for (LayoutObject* obj = blockFlow->firstChild(); obj; obj = obj->nextSiblin
g()) { | 229 for (LayoutObject* obj = blockFlow->firstChild(); obj; obj = obj->nextSiblin
g()) { |
230 if (!obj->isLayoutBlockFlow()) | 230 if (!obj->isLayoutBlockFlow()) |
231 continue; | 231 continue; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (marginLeft.isFixed()) | 266 if (marginLeft.isFixed()) |
267 margin += marginLeft.value(); | 267 margin += marginLeft.value(); |
268 if (marginRight.isFixed()) | 268 if (marginRight.isFixed()) |
269 margin += marginRight.value(); | 269 margin += marginRight.value(); |
270 return margin; | 270 return margin; |
271 } | 271 } |
272 | 272 |
273 static bool childDoesNotAffectWidthOrFlexing(LayoutObject* child) | 273 static bool childDoesNotAffectWidthOrFlexing(LayoutObject* child) |
274 { | 274 { |
275 // Positioned children and collapsed children don't affect the min/max width
. | 275 // Positioned children and collapsed children don't affect the min/max width
. |
276 return child->isOutOfFlowPositioned() || child->style()->visibility() == COL
LAPSE; | 276 return child->isOutOfFlowPositioned() || child->style()->visibility() == EVi
sibility::Collapse; |
277 } | 277 } |
278 | 278 |
279 static LayoutUnit contentWidthForChild(LayoutBox* child) | 279 static LayoutUnit contentWidthForChild(LayoutBox* child) |
280 { | 280 { |
281 if (child->hasOverrideLogicalContentWidth()) | 281 if (child->hasOverrideLogicalContentWidth()) |
282 return child->overrideLogicalContentWidth(); | 282 return child->overrideLogicalContentWidth(); |
283 return child->logicalWidth() - child->borderAndPaddingLogicalWidth(); | 283 return child->logicalWidth() - child->borderAndPaddingLogicalWidth(); |
284 } | 284 } |
285 | 285 |
286 static LayoutUnit contentHeightForChild(LayoutBox* child) | 286 static LayoutUnit contentHeightForChild(LayoutBox* child) |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 PaintLayer* childLayer = child->layer(); | 498 PaintLayer* childLayer = child->layer(); |
499 childLayer->setStaticInlinePosition(xPos); | 499 childLayer->setStaticInlinePosition(xPos); |
500 if (childLayer->staticBlockPosition() != yPos) { | 500 if (childLayer->staticBlockPosition() != yPos) { |
501 childLayer->setStaticBlockPosition(yPos); | 501 childLayer->setStaticBlockPosition(yPos); |
502 if (child->style()->hasStaticBlockPosition(style()->isHorizo
ntalWritingMode())) | 502 if (child->style()->hasStaticBlockPosition(style()->isHorizo
ntalWritingMode())) |
503 child->setChildNeedsLayout(MarkOnlyThis); | 503 child->setChildNeedsLayout(MarkOnlyThis); |
504 } | 504 } |
505 continue; | 505 continue; |
506 } | 506 } |
507 | 507 |
508 if (child->style()->visibility() == COLLAPSE) { | 508 if (child->style()->visibility() == EVisibility::Collapse) { |
509 // visibility: collapsed children do not participate in our posi
tioning. | 509 // visibility: collapsed children do not participate in our posi
tioning. |
510 // But we need to lay them down. | 510 // But we need to lay them down. |
511 child->layoutIfNeeded(); | 511 child->layoutIfNeeded(); |
512 continue; | 512 continue; |
513 } | 513 } |
514 | 514 |
515 SubtreeLayoutScope layoutScope(*child); | 515 SubtreeLayoutScope layoutScope(*child); |
516 | 516 |
517 // We need to see if this child's height will change, since we make
block elements fill | 517 // We need to see if this child's height will change, since we make
block elements fill |
518 // the height of a containing box by default. We cannot actually *se
t* the new height | 518 // the height of a containing box by default. We cannot actually *se
t* the new height |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 599 |
600 // The flex groups may not have any flexible objects this ti
me around. | 600 // The flex groups may not have any flexible objects this ti
me around. |
601 if (!spaceAvailableThisPass || totalFlex == 0.0f) { | 601 if (!spaceAvailableThisPass || totalFlex == 0.0f) { |
602 // If we just couldn't grow/shrink any more, then it's t
ime to transition to the next flex group. | 602 // If we just couldn't grow/shrink any more, then it's t
ime to transition to the next flex group. |
603 groupRemainingSpace = LayoutUnit(); | 603 groupRemainingSpace = LayoutUnit(); |
604 continue; | 604 continue; |
605 } | 605 } |
606 | 606 |
607 // Now distribute the space to objects. | 607 // Now distribute the space to objects. |
608 for (LayoutBox* child = iterator.first(); child && spaceAvai
lableThisPass && totalFlex; child = iterator.next()) { | 608 for (LayoutBox* child = iterator.first(); child && spaceAvai
lableThisPass && totalFlex; child = iterator.next()) { |
609 if (child->style()->visibility() == COLLAPSE) | 609 if (child->style()->visibility() == EVisibility::Collaps
e) |
610 continue; | 610 continue; |
611 | 611 |
612 if (allowedChildFlex(child, expanding, i)) { | 612 if (allowedChildFlex(child, expanding, i)) { |
613 LayoutUnit spaceAdd = LayoutUnit(spaceAvailableThisP
ass * (child->style()->boxFlex() / totalFlex)); | 613 LayoutUnit spaceAdd = LayoutUnit(spaceAvailableThisP
ass * (child->style()->boxFlex() / totalFlex)); |
614 if (spaceAdd) { | 614 if (spaceAdd) { |
615 child->setOverrideLogicalContentWidth(contentWid
thForChild(child) + spaceAdd); | 615 child->setOverrideLogicalContentWidth(contentWid
thForChild(child) + spaceAdd); |
616 flexingChildren = true; | 616 flexingChildren = true; |
617 relayoutChildren = true; | 617 relayoutChildren = true; |
618 } | 618 } |
619 | 619 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 if (child->style()->hasStaticBlockPosition(style()->isHorizo
ntalWritingMode())) | 741 if (child->style()->hasStaticBlockPosition(style()->isHorizo
ntalWritingMode())) |
742 child->setChildNeedsLayout(MarkOnlyThis); | 742 child->setChildNeedsLayout(MarkOnlyThis); |
743 } | 743 } |
744 continue; | 744 continue; |
745 } | 745 } |
746 | 746 |
747 SubtreeLayoutScope layoutScope(*child); | 747 SubtreeLayoutScope layoutScope(*child); |
748 if (!haveLineClamp && (relayoutChildren || (child->isAtomicInlineLev
el() && (child->style()->width().hasPercent() || child->style()->height().hasPer
cent())))) | 748 if (!haveLineClamp && (relayoutChildren || (child->isAtomicInlineLev
el() && (child->style()->width().hasPercent() || child->style()->height().hasPer
cent())))) |
749 layoutScope.setChildNeedsLayout(child); | 749 layoutScope.setChildNeedsLayout(child); |
750 | 750 |
751 if (child->style()->visibility() == COLLAPSE) { | 751 if (child->style()->visibility() == EVisibility::Collapse) { |
752 // visibility: collapsed children do not participate in our posi
tioning. | 752 // visibility: collapsed children do not participate in our posi
tioning. |
753 // But we need to lay them down. | 753 // But we need to lay them down. |
754 child->layoutIfNeeded(); | 754 child->layoutIfNeeded(); |
755 continue; | 755 continue; |
756 } | 756 } |
757 | 757 |
758 // Compute the child's vertical margins. | 758 // Compute the child's vertical margins. |
759 child->computeAndSetBlockDirectionMargins(this); | 759 child->computeAndSetBlockDirectionMargins(this); |
760 | 760 |
761 // Add in the child's marginTop to our height. | 761 // Add in the child's marginTop to our height. |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 if (minHeight.isFixed() || minHeight.isAuto()) { | 1108 if (minHeight.isFixed() || minHeight.isAuto()) { |
1109 LayoutUnit minHeight(child->style()->minHeight().value()); | 1109 LayoutUnit minHeight(child->style()->minHeight().value()); |
1110 LayoutUnit height = contentHeightForChild(child); | 1110 LayoutUnit height = contentHeightForChild(child); |
1111 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero()
; | 1111 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero()
; |
1112 return allowedShrinkage; | 1112 return allowedShrinkage; |
1113 } | 1113 } |
1114 return LayoutUnit(); | 1114 return LayoutUnit(); |
1115 } | 1115 } |
1116 | 1116 |
1117 } // namespace blink | 1117 } // namespace blink |
OLD | NEW |