Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: Source/core/layout/LayoutBlock.cpp

Issue 1128713004: Don't mark a positioned object for layout when we've just laid it out. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 Length marginLeft = child.style()->marginStartUsing(style()); 1674 Length marginLeft = child.style()->marginStartUsing(style());
1675 Length marginRight = child.style()->marginEndUsing(style()); 1675 Length marginRight = child.style()->marginEndUsing(style());
1676 LayoutUnit margin = 0; 1676 LayoutUnit margin = 0;
1677 if (marginLeft.isFixed()) 1677 if (marginLeft.isFixed())
1678 margin += marginLeft.value(); 1678 margin += marginLeft.value();
1679 if (marginRight.isFixed()) 1679 if (marginRight.isFixed())
1680 margin += marginRight.value(); 1680 margin += marginRight.value();
1681 return margin; 1681 return margin;
1682 } 1682 }
1683 1683
1684 static bool needsLayoutDueToStaticPosition(LayoutObject* child)
1685 {
1686 // When a non-positioned block element moves, it may have positioned childre n that are implicitly positioned relative to the
1687 // non-positioned block. In block flow we can detect these when we layout th e non-positioned block (by noticing the change
1688 // in the immediate parent's logical top in |adjustPositionedBlock|). In lin e layout we always need to mark the positioned
1689 // child for layout if its statically positioned in the direction in which t he object lays out.
1690 // crbug.com/490322(rhogan): We probably need to move the block layout case in here too, as marking a positioned object for
1691 // layout while laying out an object's children invalidly assumes that our p ositionedObjects list is in DOM order and that
1692 // we could never mark a positioned object for layout *after* we've laid it out in layoutPositionedObjects.
1693 if (!child->parent()->childrenInline())
1694 return false;
1695 const ComputedStyle* style = child->style();
1696 bool isHorizontal = style->isHorizontalWritingMode();
1697 return style->isDisplayInlineType() ? style->hasStaticInlinePosition(isHoriz ontal) : style->hasStaticBlockPosition(isHorizontal);
1698 }
1699
1684 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info) 1700 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info)
1685 { 1701 {
1686 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); 1702 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects();
1687 if (!positionedDescendants) 1703 if (!positionedDescendants)
1688 return; 1704 return;
1689 1705
1690 if (hasColumns()) 1706 if (hasColumns())
1691 view()->layoutState()->clearPaginationInformation(); // Positioned objec ts are not part of the column flow, so they don't paginate with the columns. 1707 view()->layoutState()->clearPaginationInformation(); // Positioned objec ts are not part of the column flow, so they don't paginate with the columns.
1692 1708
1693 for (auto* positionedObject : *positionedDescendants) { 1709 for (auto* positionedObject : *positionedDescendants) {
1694 positionedObject->setMayNeedPaintInvalidation(); 1710 positionedObject->setMayNeedPaintInvalidation();
1695 1711
1696 SubtreeLayoutScope layoutScope(*positionedObject); 1712 SubtreeLayoutScope layoutScope(*positionedObject);
1697 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So 1713 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So
1698 // 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. 1714 // 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.
1699 // it has static position. 1715 // it has static position.
1700 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); 1716 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope);
1701 if (info == LayoutOnlyFixedPositionedObjects) { 1717 if (info == LayoutOnlyFixedPositionedObjects) {
1702 positionedObject->layoutIfNeeded(); 1718 positionedObject->layoutIfNeeded();
1703 continue; 1719 continue;
1704 } 1720 }
1705 1721
1706 // When a non-positioned block element moves, it may have positioned chi ldren that are implicitly positioned relative to the 1722 if (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject) )
1707 // non-positioned block. Rather than trying to detect all of these move ment cases, we just always lay out positioned
1708 // objects that are positioned implicitly like this. Such objects are r are, and so in typical DHTML menu usage (where everything is
1709 // positioned explicitly) this should not incur a performance penalty.
1710 if (relayoutChildren || (positionedObject->style()->hasStaticBlockPositi on(isHorizontalWritingMode()) && positionedObject->parent() != this))
1711 layoutScope.setChildNeedsLayout(positionedObject); 1723 layoutScope.setChildNeedsLayout(positionedObject);
1712 1724
1713 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. 1725 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
1714 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) 1726 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion())
1715 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); 1727 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
1716 1728
1717 if (!positionedObject->needsLayout()) 1729 if (!positionedObject->needsLayout())
1718 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope); 1730 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope);
1719 1731
1720 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now. 1732 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now.
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 3933 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
3922 { 3934 {
3923 showLayoutObject(); 3935 showLayoutObject();
3924 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3936 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3925 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3937 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3926 } 3938 }
3927 3939
3928 #endif 3940 #endif
3929 3941
3930 } // namespace blink 3942 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698