OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 : LayoutBox(node) | 127 : LayoutBox(node) |
128 , m_hasMarginBeforeQuirk(false) | 128 , m_hasMarginBeforeQuirk(false) |
129 , m_hasMarginAfterQuirk(false) | 129 , m_hasMarginAfterQuirk(false) |
130 , m_beingDestroyed(false) | 130 , m_beingDestroyed(false) |
131 , m_hasMarkupTruncation(false) | 131 , m_hasMarkupTruncation(false) |
132 , m_widthAvailableToChildrenChanged(false) | 132 , m_widthAvailableToChildrenChanged(false) |
133 , m_hasOnlySelfCollapsingChildren(false) | 133 , m_hasOnlySelfCollapsingChildren(false) |
134 , m_descendantsWithFloatsMarkedForLayout(false) | 134 , m_descendantsWithFloatsMarkedForLayout(false) |
135 , m_hasPositionedObjects(false) | 135 , m_hasPositionedObjects(false) |
136 , m_hasPercentHeightDescendants(false) | 136 , m_hasPercentHeightDescendants(false) |
137 , m_heightAvailableToChildrenChanged(false) | |
137 { | 138 { |
138 // LayoutBlockFlow calls setChildrenInline(true). | 139 // LayoutBlockFlow calls setChildrenInline(true). |
139 // By default, subclasses do not have inline children. | 140 // By default, subclasses do not have inline children. |
140 } | 141 } |
141 | 142 |
142 void LayoutBlock::removeFromGlobalMaps() | 143 void LayoutBlock::removeFromGlobalMaps() |
143 { | 144 { |
144 if (hasPositionedObjects()) { | 145 if (hasPositionedObjects()) { |
145 OwnPtr<TrackedLayoutBoxListHashSet> descendants = gPositionedDescendants Map->take(this); | 146 OwnPtr<TrackedLayoutBoxListHashSet> descendants = gPositionedDescendants Map->take(this); |
146 ASSERT(!descendants->isEmpty()); | 147 ASSERT(!descendants->isEmpty()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 // Remove our fixed positioned descendants from their current contai ning block. | 242 // Remove our fixed positioned descendants from their current contai ning block. |
242 // They will be inserted into our positioned objects list during lay out. | 243 // They will be inserted into our positioned objects list during lay out. |
243 if (LayoutBlock* cb = containerForFixedPosition()) | 244 if (LayoutBlock* cb = containerForFixedPosition()) |
244 cb->removePositionedObjects(this, NewContainingBlock); | 245 cb->removePositionedObjects(this, NewContainingBlock); |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 LayoutBox::styleWillChange(diff, newStyle); | 249 LayoutBox::styleWillChange(diff, newStyle); |
249 } | 250 } |
250 | 251 |
251 static bool borderOrPaddingLogicalWidthChanged(const ComputedStyle& oldStyle, co nst ComputedStyle& newStyle) | 252 enum LogicalExtent { LogicalWidth, LogicalHeight }; |
253 static bool borderOrPaddingLogicalDimensionChanged(const ComputedStyle& oldStyle , const ComputedStyle& newStyle, LogicalExtent logicalExtent) | |
252 { | 254 { |
253 if (newStyle.isHorizontalWritingMode()) { | 255 if (newStyle.isHorizontalWritingMode() && logicalExtent == LogicalWidth) { |
mstensho (USE GERRIT)
2016/02/17 10:19:42
I think "if (newStyle.isHorizontalWritingMode() ==
| |
254 return oldStyle.borderLeftWidth() != newStyle.borderLeftWidth() | 256 return oldStyle.borderLeftWidth() != newStyle.borderLeftWidth() |
255 || oldStyle.borderRightWidth() != newStyle.borderRightWidth() | 257 || oldStyle.borderRightWidth() != newStyle.borderRightWidth() |
256 || oldStyle.paddingLeft() != newStyle.paddingLeft() | 258 || oldStyle.paddingLeft() != newStyle.paddingLeft() |
257 || oldStyle.paddingRight() != newStyle.paddingRight(); | 259 || oldStyle.paddingRight() != newStyle.paddingRight(); |
258 } | 260 } |
259 | 261 |
260 return oldStyle.borderTopWidth() != newStyle.borderTopWidth() | 262 return oldStyle.borderTopWidth() != newStyle.borderTopWidth() |
261 || oldStyle.borderBottomWidth() != newStyle.borderBottomWidth() | 263 || oldStyle.borderBottomWidth() != newStyle.borderBottomWidth() |
262 || oldStyle.paddingTop() != newStyle.paddingTop() | 264 || oldStyle.paddingTop() != newStyle.paddingTop() |
263 || oldStyle.paddingBottom() != newStyle.paddingBottom(); | 265 || oldStyle.paddingBottom() != newStyle.paddingBottom(); |
(...skipping 23 matching lines...) Expand all Loading... | |
287 cb->removePositionedObjects(this, NewContainingBlock); | 289 cb->removePositionedObjects(this, NewContainingBlock); |
288 } | 290 } |
289 } | 291 } |
290 | 292 |
291 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 293 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
292 textAutosizer->record(this); | 294 textAutosizer->record(this); |
293 | 295 |
294 propagateStyleToAnonymousChildren(true); | 296 propagateStyleToAnonymousChildren(true); |
295 | 297 |
296 // It's possible for our border/padding to change, but for the overall logic al width of the block to | 298 // It's possible for our border/padding to change, but for the overall logic al width of the block to |
297 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true. | 299 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true. |
mstensho (USE GERRIT)
2016/02/17 10:19:42
Should probably update this comment.
| |
298 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); | 300 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n eedsLayout() && borderOrPaddingLogicalDimensionChanged(*oldStyle, newStyle, Logi calWidth); |
301 m_heightAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalDimensionChanged(*oldStyle, newStyle, Log icalHeight); | |
299 } | 302 } |
300 | 303 |
301 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil dPaintInvalidationState) | 304 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil dPaintInvalidationState) |
302 { | 305 { |
303 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); | 306 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); |
304 | 307 |
305 // Take care of positioned objects. This is required as PaintInvalidationSta te keeps a single clip rect. | 308 // Take care of positioned objects. This is required as PaintInvalidationSta te keeps a single clip rect. |
306 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects ()) { | 309 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects ()) { |
307 for (auto* box : *positionedObjects) { | 310 for (auto* box : *positionedObjects) { |
308 | 311 |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 addVisualOverflow(LayoutRect(inflatedRect)); | 1013 addVisualOverflow(LayoutRect(inflatedRect)); |
1011 } | 1014 } |
1012 | 1015 |
1013 bool LayoutBlock::createsNewFormattingContext() const | 1016 bool LayoutBlock::createsNewFormattingContext() const |
1014 { | 1017 { |
1015 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() | 1018 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() |
1016 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() | 1019 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() |
1017 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint(); | 1020 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint(); |
1018 } | 1021 } |
1019 | 1022 |
1023 bool static changeInAvailableLogicalHeightAffectsChild(LayoutBlock* parent, Layo utBox& child) | |
1024 { | |
1025 if (parent->style()->boxSizing() != BORDER_BOX) | |
1026 return false; | |
1027 return parent->style()->isHorizontalWritingMode() && !child.style()->isHoriz ontalWritingMode(); | |
1028 } | |
1029 | |
1020 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child) | 1030 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child) |
1021 { | 1031 { |
1022 if (child.isOutOfFlowPositioned()) { | 1032 if (child.isOutOfFlowPositioned()) { |
1023 // It's rather useless to mark out-of-flow children at this point. We ma y not be their | 1033 // It's rather useless to mark out-of-flow children at this point. We ma y not be their |
1024 // containing block (and if we are, it's just pure luck), so this would be the wrong place | 1034 // containing block (and if we are, it's just pure luck), so this would be the wrong place |
1025 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column | 1035 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column |
1026 // spanners, if the containing block is outside the spanner but inside t he multicol container. | 1036 // spanners, if the containing block is outside the spanner but inside t he multicol container. |
1027 return; | 1037 return; |
1028 } | 1038 } |
1029 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into | 1039 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into |
1030 // an auto value. Add a method to determine this, so that we can avoid the r elayout. | 1040 // an auto value. Add a method to determine this, so that we can avoid the r elayout. |
1031 bool hasRelativeLogicalHeight = child.hasRelativeLogicalHeight() | 1041 bool hasRelativeLogicalHeight = child.hasRelativeLogicalHeight() |
1032 || (child.isAnonymous() && this->hasRelativeLogicalHeight()) | 1042 || (child.isAnonymous() && this->hasRelativeLogicalHeight()) |
1033 || child.stretchesToViewport(); | 1043 || child.stretchesToViewport(); |
1034 if (relayoutChildren || (hasRelativeLogicalHeight && !isLayoutView())) { | 1044 if (relayoutChildren || (hasRelativeLogicalHeight && !isLayoutView()) |
1045 || (m_heightAvailableToChildrenChanged && changeInAvailableLogicalHeight AffectsChild(this, child))) { | |
1035 child.setChildNeedsLayout(MarkOnlyThis); | 1046 child.setChildNeedsLayout(MarkOnlyThis); |
1036 | 1047 |
1037 // If the child has percentage padding or an embedded content box, we al so need to invalidate the childs pref widths. | 1048 // If the child has percentage padding or an embedded content box, we al so need to invalidate the childs pref widths. |
1038 if (child.needsPreferredWidthsRecalculation()) | 1049 if (child.needsPreferredWidthsRecalculation()) |
1039 child.setPreferredLogicalWidthsDirty(MarkOnlyThis); | 1050 child.setPreferredLogicalWidthsDirty(MarkOnlyThis); |
1040 } | 1051 } |
1041 } | 1052 } |
1042 | 1053 |
1043 void LayoutBlock::simplifiedNormalFlowLayout() | 1054 void LayoutBlock::simplifiedNormalFlowLayout() |
1044 { | 1055 { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 SubtreeLayoutScope layoutScope(*positionedObject); | 1227 SubtreeLayoutScope layoutScope(*positionedObject); |
1217 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So | 1228 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So |
1218 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e. | 1229 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e. |
1219 // it has static position. | 1230 // it has static position. |
1220 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); | 1231 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); |
1221 if (info == LayoutOnlyFixedPositionedObjects) { | 1232 if (info == LayoutOnlyFixedPositionedObjects) { |
1222 positionedObject->layoutIfNeeded(); | 1233 positionedObject->layoutIfNeeded(); |
1223 continue; | 1234 continue; |
1224 } | 1235 } |
1225 | 1236 |
1226 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject))) | 1237 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || m_heightAvailableToChildrenChanged || needsLayoutDueToStaticPosition(positionedO bject))) |
1227 layoutScope.setChildNeedsLayout(positionedObject); | 1238 layoutScope.setChildNeedsLayout(positionedObject); |
1228 | 1239 |
1229 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. | 1240 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. |
1230 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) | 1241 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) |
1231 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 1242 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
1232 | 1243 |
1233 LayoutUnit logicalTopEstimate; | 1244 LayoutUnit logicalTopEstimate; |
1234 bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && positio nedObject->paginationBreakability() != ForbidBreaks; | 1245 bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && positio nedObject->paginationBreakability() != ForbidBreaks; |
1235 if (needsBlockDirectionLocationSetBeforeLayout) { | 1246 if (needsBlockDirectionLocationSetBeforeLayout) { |
1236 // Out-of-flow objects are normally positioned after layout (while i n-flow objects are | 1247 // Out-of-flow objects are normally positioned after layout (while i n-flow objects are |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2865 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 2876 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
2866 { | 2877 { |
2867 showLayoutObject(); | 2878 showLayoutObject(); |
2868 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2879 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
2869 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2880 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
2870 } | 2881 } |
2871 | 2882 |
2872 #endif | 2883 #endif |
2873 | 2884 |
2874 } // namespace blink | 2885 } // namespace blink |
OLD | NEW |