Skip to content

Commit

Permalink
Revert of Layout children if the width available to them has changed …
Browse files Browse the repository at this point in the history
…(patchset #3 id:40001 of https://codereview.chromium.org/390633004/)

Reason for revert:
The CL was landed with unrelated changes. Reverting so that the corrected CL can be landed cleanly.

Original issue's description:
> Layout children if the width available to them has changed
> 
> Currently we let a style change to border or padding trigger a layout to
> children, even if the parent's width hasn't changed. This is because the
> change in border/padding alters the amount of space available to the children.
> 
> Likewise if a box has percent padding and uses border-box sizing then the
> space available to children can reduce/increase even when the box itself
> doesn't change size (e.g. because it has a max-width). When that happens we
> still need to relayout its children so they fit to the changed available width.
> 
> If we cached content width or even padding we could watch for changes to this
> available width for children but unfortunately we do neither so both of the
> above cases have to be identified specifically at layout time.
> 
> BUG=391820
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=178864

[email protected]
BUG=391820

Review URL: https://codereview.chromium.org/529803002

git-svn-id: svn://svn.chromium.org/blink/trunk@181199 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
mwenge committed Sep 1, 2014
1 parent 2ebba60 commit 8071f99
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 194 deletions.
3 changes: 0 additions & 3 deletions LayoutTests/fast/block/borderbox-percent-padding-expected.txt

This file was deleted.

21 changes: 0 additions & 21 deletions LayoutTests/fast/block/borderbox-percent-padding.html

This file was deleted.

This file was deleted.

56 changes: 0 additions & 56 deletions LayoutTests/fast/overflow/abs-rel-pos-invalidation-ancestor.html

This file was deleted.

15 changes: 0 additions & 15 deletions LayoutTests/fast/overflow/abs-rel-pos-invalidation-expected.txt

This file was deleted.

39 changes: 0 additions & 39 deletions LayoutTests/fast/overflow/abs-rel-pos-invalidation.html

This file was deleted.

7 changes: 2 additions & 5 deletions Source/core/rendering/LayoutState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace blink {
LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, RenderView& view)
: m_isPaginated(pageLogicalHeight)
, m_pageLogicalHeightChanged(pageLogicalHeightChanged)
, m_containingBlockLogicalWidthChanged(false)
, m_columnInfo(0)
, m_next(0)
, m_pageLogicalHeight(pageLogicalHeight)
Expand All @@ -46,9 +45,8 @@ LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightCha
view.pushLayoutState(*this);
}

LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo, bool containingBlockLogicalWidthChanged)
: m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged)
, m_columnInfo(columnInfo)
LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo)
: m_columnInfo(columnInfo)
, m_next(renderer.view()->layoutState())
, m_renderer(renderer)
{
Expand Down Expand Up @@ -102,7 +100,6 @@ LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUn
LayoutState::LayoutState(RenderObject& root)
: m_isPaginated(false)
, m_pageLogicalHeightChanged(false)
, m_containingBlockLogicalWidthChanged(false)
, m_columnInfo(0)
, m_next(root.view()->layoutState())
, m_pageLogicalHeight(0)
Expand Down
4 changes: 1 addition & 3 deletions Source/core/rendering/LayoutState.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LayoutState {
// Constructor for sub-tree Layout and RenderTableSections
explicit LayoutState(RenderObject& root);

LayoutState(RenderBox&, const LayoutSize& offset, LayoutUnit pageLogicalHeight = 0, bool pageHeightLogicalChanged = false, ColumnInfo* = 0, bool containingBlockLogicalWidthChanged = false);
LayoutState(RenderBox&, const LayoutSize& offset, LayoutUnit pageLogicalHeight = 0, bool pageHeightLogicalChanged = false, ColumnInfo* = 0);
LayoutState(RenderInline&);

~LayoutState();
Expand All @@ -68,7 +68,6 @@ class LayoutState {
const LayoutSize& pageOffset() const { return m_pageOffset; }
LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
bool containingBlockLogicalWidthChanged() const { return m_containingBlockLogicalWidthChanged; }

LayoutState* next() const { return m_next; }

Expand All @@ -85,7 +84,6 @@ class LayoutState {
bool m_isPaginated : 1;
// If our page height has changed, this will force all blocks to relayout.
bool m_pageLogicalHeightChanged : 1;
bool m_containingBlockLogicalWidthChanged : 1;

// If the enclosing pagination model is a column model, then this will store column information for easy retrieval/manipulation.
ColumnInfo* m_columnInfo;
Expand Down
31 changes: 4 additions & 27 deletions Source/core/rendering/RenderBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,18 +1411,6 @@ void RenderBlock::computeRegionRangeForBlock(RenderFlowThread* flowThread)
flowThread->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage());
}

bool RenderBlock::widthAvailableToChildrenHasChanged()
{
bool widthAvailableToChildrenHasChanged = m_hasBorderOrPaddingLogicalWidthChanged;
m_hasBorderOrPaddingLogicalWidthChanged = false;

// If we use border-box sizing, have percentage padding, and our parent has changed width then the width available to our children has changed even
// though our own width has remained the same.
widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX && needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLogicalWidthChanged();

return widthAvailableToChildrenHasChanged;
}

bool RenderBlock::updateLogicalWidthAndColumnWidth()
{
LayoutUnit oldWidth = logicalWidth();
Expand All @@ -1431,7 +1419,10 @@ bool RenderBlock::updateLogicalWidthAndColumnWidth()
updateLogicalWidth();
calcColumnWidth();

return oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth() || widthAvailableToChildrenHasChanged();
bool hasBorderOrPaddingLogicalWidthChanged = m_hasBorderOrPaddingLogicalWidthChanged;
m_hasBorderOrPaddingLogicalWidthChanged = false;

return oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth() || hasBorderOrPaddingLogicalWidthChanged;
}

void RenderBlock::layoutBlock(bool)
Expand Down Expand Up @@ -1669,20 +1660,6 @@ LayoutUnit RenderBlock::marginIntrinsicLogicalWidthForChild(RenderBox* child) co
return margin;
}

void RenderBlock::invalidatePositionedObjectsAffectedByOverflowClip()
{
TrackedRendererListHashSet* positionedDescendants = positionedObjects();
if (!positionedDescendants)
return;

RenderBox* r;
TrackedRendererListHashSet::iterator end = positionedDescendants->end();
for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(); it != end; ++it) {
r = *it;
r->setShouldDoFullPaintInvalidationIfSelfPaintingLayer(true);
}
}

void RenderBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior info)
{
TrackedRendererListHashSet* positionedDescendants = positionedObjects();
Expand Down
3 changes: 0 additions & 3 deletions Source/core/rendering/RenderBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ class RenderBlock : public RenderBox {
bool recalcChildOverflowAfterStyleChange();
bool recalcOverflowAfterStyleChange();

void invalidatePositionedObjectsAffectedByOverflowClip();

protected:
virtual void willBeDestroyed() OVERRIDE;

Expand Down Expand Up @@ -442,7 +440,6 @@ class RenderBlock : public RenderBox {

// End helper functions and structs used by layoutBlockChildren.

bool widthAvailableToChildrenHasChanged();
void removeFromGlobalMaps();

protected:
Expand Down
6 changes: 3 additions & 3 deletions Source/core/rendering/RenderBlockFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren)
inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit &pageLogicalHeight, SubtreeLayoutScope& layoutScope)
{
LayoutUnit oldLeft = logicalLeft();
bool logicalWidthChanged = updateLogicalWidthAndColumnWidth();
relayoutChildren |= logicalWidthChanged;
if (updateLogicalWidthAndColumnWidth())
relayoutChildren = true;

rebuildFloatsFromIntruding();

Expand All @@ -399,7 +399,7 @@ inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit &
if (pageLogicalHeightChanged)
relayoutChildren = true;

LayoutState state(*this, locationOffset(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo(), logicalWidthChanged);
LayoutState state(*this, locationOffset(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo());

// We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
// our current maximal positive and negative margins. These values are used when we
Expand Down
5 changes: 1 addition & 4 deletions Source/core/rendering/RenderBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ void RenderBox::updateFromStyle()
// generated by positioned children or self painting layers. crbug.com/345403
for (RenderObject* child = slowFirstChild(); child; child = child->nextSibling())
child->setShouldDoFullPaintInvalidationIfSelfPaintingLayer(true);

if (isRenderBlock())
toRenderBlock(this)->invalidatePositionedObjectsAffectedByOverflowClip();
}

setHasOverflowClip(boxHasOverflowClip);
Expand Down Expand Up @@ -2018,7 +2015,7 @@ void RenderBox::mapRectToPaintInvalidationBacking(const RenderLayerModelObject*
// FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout,
// its controlClipRect will be wrong. For overflow clip we use the values cached by the layer.
rect.setLocation(topLeft);
if (o->hasOverflowClip() && !shouldDoFullPaintInvalidationIfSelfPaintingLayer()) {
if (o->hasOverflowClip()) {
RenderBox* containerBox = toRenderBox(o);
containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect);
if (rect.isEmpty())
Expand Down

0 comments on commit 8071f99

Please sign in to comment.