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

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

Issue 1062283002: Use C++11 range-based loop for core/layout (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix it naming Created 5 years, 8 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
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 , m_hasOnlySelfCollapsingChildren(false) 155 , m_hasOnlySelfCollapsingChildren(false)
156 , m_descendantsWithFloatsMarkedForLayout(false) 156 , m_descendantsWithFloatsMarkedForLayout(false)
157 { 157 {
158 // LayoutBlockFlow calls setChildrenInline(true). 158 // LayoutBlockFlow calls setChildrenInline(true).
159 // By default, subclasses do not have inline children. 159 // By default, subclasses do not have inline children.
160 } 160 }
161 161
162 static void removeBlockFromDescendantAndContainerMaps(LayoutBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap) 162 static void removeBlockFromDescendantAndContainerMaps(LayoutBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap)
163 { 163 {
164 if (OwnPtr<TrackedRendererListHashSet> descendantSet = descendantMap->take(b lock)) { 164 if (OwnPtr<TrackedRendererListHashSet> descendantSet = descendantMap->take(b lock)) {
165 TrackedRendererListHashSet::iterator end = descendantSet->end(); 165 for (auto& descendant : *descendantSet) {
166 for (TrackedRendererListHashSet::iterator descendant = descendantSet->be gin(); descendant != end; ++descendant) { 166 TrackedContainerMap::iterator it = containerMap->find(descendant);
167 TrackedContainerMap::iterator it = containerMap->find(*descendant);
168 ASSERT(it != containerMap->end()); 167 ASSERT(it != containerMap->end());
169 if (it == containerMap->end()) 168 if (it == containerMap->end())
170 continue; 169 continue;
171 HashSet<LayoutBlock*>* containerSet = it->value.get(); 170 HashSet<LayoutBlock*>* containerSet = it->value.get();
172 ASSERT(containerSet->contains(block)); 171 ASSERT(containerSet->contains(block));
173 containerSet->remove(block); 172 containerSet->remove(block);
174 if (containerSet->isEmpty()) 173 if (containerSet->isEmpty())
175 containerMap->remove(it); 174 containerMap->remove(it);
176 } 175 }
177 } 176 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 else 361 else
363 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayou tObject(this); 362 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayou tObject(this);
364 } 363 }
365 364
366 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil dPaintInvalidationState) 365 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil dPaintInvalidationState)
367 { 366 {
368 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); 367 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState);
369 368
370 // Take care of positioned objects. This is required as PaintInvalidationSta te keeps a single clip rect. 369 // Take care of positioned objects. This is required as PaintInvalidationSta te keeps a single clip rect.
371 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) { 370 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) {
372 TrackedRendererListHashSet::iterator end = positionedObjects->end(); 371 for (auto* box : *positionedObjects) {
373 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) {
374 LayoutBox* box = *it;
375 372
376 // One of the renderers we're skipping over here may be the child's paint invalidation container, 373 // One of the renderers we're skipping over here may be the child's paint invalidation container,
377 // so we can't pass our own paint invalidation container along. 374 // so we can't pass our own paint invalidation container along.
378 const LayoutBoxModelObject& paintInvalidationContainerForChild = *bo x->containerForPaintInvalidation(); 375 const LayoutBoxModelObject& paintInvalidationContainerForChild = *bo x->containerForPaintInvalidation();
379 376
380 // If it's a new paint invalidation container, we won't have properl y accumulated the offset into the 377 // If it's a new paint invalidation container, we won't have properl y accumulated the offset into the
381 // PaintInvalidationState. 378 // PaintInvalidationState.
382 // FIXME: Teach PaintInvalidationState to handle this case. crbug.co m/371485 379 // FIXME: Teach PaintInvalidationState to handle this case. crbug.co m/371485
383 if (paintInvalidationContainerForChild != childPaintInvalidationStat e.paintInvalidationContainer()) { 380 if (paintInvalidationContainerForChild != childPaintInvalidationStat e.paintInvalidationContainer()) {
384 ForceHorriblySlowRectMapping slowRectMapping(&childPaintInvalida tionState); 381 ForceHorriblySlowRectMapping slowRectMapping(&childPaintInvalida tionState);
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 void LayoutBlock::finishDelayUpdateScrollInfo() 1329 void LayoutBlock::finishDelayUpdateScrollInfo()
1333 { 1330 {
1334 --gDelayUpdateScrollInfo; 1331 --gDelayUpdateScrollInfo;
1335 ASSERT(gDelayUpdateScrollInfo >= 0); 1332 ASSERT(gDelayUpdateScrollInfo >= 0);
1336 if (gDelayUpdateScrollInfo == 0) { 1333 if (gDelayUpdateScrollInfo == 0) {
1337 ASSERT(gDelayedUpdateScrollInfoSet); 1334 ASSERT(gDelayedUpdateScrollInfoSet);
1338 1335
1339 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet)); 1336 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet));
1340 gDelayedUpdateScrollInfoSet = 0; 1337 gDelayedUpdateScrollInfoSet = 0;
1341 1338
1342 for (DelayedUpdateScrollInfoSet::iterator it = infoSet->begin(); it != i nfoSet->end(); ++it) { 1339 for (auto* block : *infoSet) {
1343 LayoutBlock* block = *it;
1344 if (block->hasOverflowClip()) { 1340 if (block->hasOverflowClip()) {
1345 block->layer()->scrollableArea()->updateAfterLayout(); 1341 block->layer()->scrollableArea()->updateAfterLayout();
1346 } 1342 }
1347 } 1343 }
1348 } 1344 }
1349 } 1345 }
1350 1346
1351 void LayoutBlock::updateScrollInfoAfterLayout() 1347 void LayoutBlock::updateScrollInfoAfterLayout()
1352 { 1348 {
1353 if (hasOverflowClip()) { 1349 if (hasOverflowClip()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 1400
1405 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? 1401 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
1406 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; 1402 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible;
1407 1403
1408 LayoutRect screenArea; 1404 LayoutRect screenArea;
1409 if (!objectBounds.isEmpty()) { 1405 if (!objectBounds.isEmpty()) {
1410 screenArea = viewBounds; 1406 screenArea = viewBounds;
1411 screenArea.intersect(objectBounds); 1407 screenArea.intersect(objectBounds);
1412 } 1408 }
1413 1409
1414 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it) 1410 for (auto* imageResource : images)
1415 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status, screenArea); 1411 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(imageResource, status, screenArea);
1416 1412
1417 return true; 1413 return true;
1418 } 1414 }
1419 1415
1420 bool LayoutBlock::widthAvailableToChildrenHasChanged() 1416 bool LayoutBlock::widthAvailableToChildrenHasChanged()
1421 { 1417 {
1422 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; 1418 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged;
1423 m_widthAvailableToChildrenChanged = false; 1419 m_widthAvailableToChildrenChanged = false;
1424 1420
1425 // 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 1421 // 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
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 addOverflowFromChild(child); 1496 addOverflowFromChild(child);
1501 } 1497 }
1502 } 1498 }
1503 1499
1504 void LayoutBlock::addOverflowFromPositionedObjects() 1500 void LayoutBlock::addOverflowFromPositionedObjects()
1505 { 1501 {
1506 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 1502 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
1507 if (!positionedDescendants) 1503 if (!positionedDescendants)
1508 return; 1504 return;
1509 1505
1510 LayoutBox* positionedObject; 1506 for (auto* positionedObject : *positionedDescendants) {
1511 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
1512 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
1513 positionedObject = *it;
1514
1515 // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content. 1507 // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content.
1516 if (positionedObject->style()->position() != FixedPosition) 1508 if (positionedObject->style()->position() != FixedPosition)
1517 addOverflowFromChild(positionedObject, toLayoutSize(positionedObject ->location())); 1509 addOverflowFromChild(positionedObject, toLayoutSize(positionedObject ->location()));
1518 } 1510 }
1519 } 1511 }
1520 1512
1521 void LayoutBlock::addVisualOverflowFromTheme() 1513 void LayoutBlock::addVisualOverflowFromTheme()
1522 { 1514 {
1523 if (!style()->hasAppearance()) 1515 if (!style()->hasAppearance())
1524 return; 1516 return;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 1676
1685 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info) 1677 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info)
1686 { 1678 {
1687 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 1679 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
1688 if (!positionedDescendants) 1680 if (!positionedDescendants)
1689 return; 1681 return;
1690 1682
1691 if (hasColumns()) 1683 if (hasColumns())
1692 view()->layoutState()->clearPaginationInformation(); // Positioned objec ts are not part of the column flow, so they don't paginate with the columns. 1684 view()->layoutState()->clearPaginationInformation(); // Positioned objec ts are not part of the column flow, so they don't paginate with the columns.
1693 1685
1694 LayoutBox* r; 1686 for (auto* positionedObject : *positionedDescendants) {
1695 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 1687 positionedObject->setMayNeedPaintInvalidation();
1696 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
1697 r = *it;
1698 1688
1699 r->setMayNeedPaintInvalidation(); 1689 SubtreeLayoutScope layoutScope(*positionedObject);
1700
1701 SubtreeLayoutScope layoutScope(*r);
1702 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So 1690 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So
1703 // 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. 1691 // 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.
1704 // it has static position. 1692 // it has static position.
1705 markFixedPositionObjectForLayoutIfNeeded(r, layoutScope); 1693 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope);
1706 if (info == LayoutOnlyFixedPositionedObjects) { 1694 if (info == LayoutOnlyFixedPositionedObjects) {
1707 r->layoutIfNeeded(); 1695 positionedObject->layoutIfNeeded();
1708 continue; 1696 continue;
1709 } 1697 }
1710 1698
1711 // When a non-positioned block element moves, it may have positioned chi ldren that are implicitly positioned relative to the 1699 // When a non-positioned block element moves, it may have positioned chi ldren that are implicitly positioned relative to the
1712 // non-positioned block. Rather than trying to detect all of these move ment cases, we just always lay out positioned 1700 // non-positioned block. Rather than trying to detect all of these move ment cases, we just always lay out positioned
1713 // objects that are positioned implicitly like this. Such objects are r are, and so in typical DHTML menu usage (where everything is 1701 // objects that are positioned implicitly like this. Such objects are r are, and so in typical DHTML menu usage (where everything is
1714 // positioned explicitly) this should not incur a performance penalty. 1702 // positioned explicitly) this should not incur a performance penalty.
1715 if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontal WritingMode()) && r->parent() != this)) 1703 if (relayoutChildren || (positionedObject->style()->hasStaticBlockPositi on(isHorizontalWritingMode()) && positionedObject->parent() != this))
1716 layoutScope.setChildNeedsLayout(r); 1704 layoutScope.setChildNeedsLayout(positionedObject);
1717 1705
1718 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. 1706 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
1719 if (relayoutChildren && r->needsPreferredWidthsRecalculation()) 1707 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion())
1720 r->setPreferredLogicalWidthsDirty(MarkOnlyThis); 1708 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
1721 1709
1722 if (!r->needsLayout()) 1710 if (!positionedObject->needsLayout())
1723 r->markForPaginationRelayoutIfNeeded(layoutScope); 1711 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope);
1724 1712
1725 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now. 1713 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now.
1726 // If it's wrong we'll lay out again. 1714 // If it's wrong we'll lay out again.
1727 LayoutUnit oldLogicalTop = 0; 1715 LayoutUnit oldLogicalTop = 0;
1728 bool needsBlockDirectionLocationSetBeforeLayout = r->needsLayout() && vi ew()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); 1716 bool needsBlockDirectionLocationSetBeforeLayout = positionedObject->need sLayout() && view()->layoutState()->needsBlockDirectionLocationSetBeforeLayout() ;
1729 if (needsBlockDirectionLocationSetBeforeLayout) { 1717 if (needsBlockDirectionLocationSetBeforeLayout) {
1730 if (isHorizontalWritingMode() == r->isHorizontalWritingMode()) 1718 if (isHorizontalWritingMode() == positionedObject->isHorizontalWriti ngMode())
1731 r->updateLogicalHeight(); 1719 positionedObject->updateLogicalHeight();
1732 else 1720 else
1733 r->updateLogicalWidth(); 1721 positionedObject->updateLogicalWidth();
1734 oldLogicalTop = logicalTopForChild(*r); 1722 oldLogicalTop = logicalTopForChild(*positionedObject);
1735 } 1723 }
1736 1724
1737 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need 1725 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need
1738 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756 1726 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756
1739 if (info == ForcedLayoutAfterContainingBlockMoved) 1727 if (info == ForcedLayoutAfterContainingBlockMoved)
1740 r->setNeedsLayout(LayoutInvalidationReason::AncestorMoved, MarkOnlyT his); 1728 positionedObject->setNeedsLayout(LayoutInvalidationReason::AncestorM oved, MarkOnlyThis);
1741 1729
1742 r->layoutIfNeeded(); 1730 positionedObject->layoutIfNeeded();
1743 1731
1744 // Lay out again if our estimate was wrong. 1732 // Lay out again if our estimate was wrong.
1745 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*r) != oldLogicalTop) 1733 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*po sitionedObject) != oldLogicalTop)
1746 r->forceChildLayout(); 1734 positionedObject->forceChildLayout();
1747 } 1735 }
1748 1736
1749 if (hasColumns()) 1737 if (hasColumns())
1750 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work. 1738 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work.
1751 } 1739 }
1752 1740
1753 void LayoutBlock::markPositionedObjectsForLayout() 1741 void LayoutBlock::markPositionedObjectsForLayout()
1754 { 1742 {
1755 if (TrackedRendererListHashSet* positionedDescendants = positionedObjects()) { 1743 if (TrackedRendererListHashSet* positionedDescendants = positionedObjects()) {
1756 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 1744 for (auto* descendant : *positionedDescendants)
1757 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be gin(); it != end; ++it) 1745 descendant->setChildNeedsLayout();
1758 (*it)->setChildNeedsLayout();
1759 } 1746 }
1760 } 1747 }
1761 1748
1762 void LayoutBlock::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutSc ope) 1749 void LayoutBlock::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutSc ope)
1763 { 1750 {
1764 ASSERT(!needsLayout()); 1751 ASSERT(!needsLayout());
1765 if (needsLayout()) 1752 if (needsLayout())
1766 return; 1753 return;
1767 1754
1768 if (view()->layoutState()->pageLogicalHeightChanged() || (view()->layoutStat e()->pageLogicalHeight() && view()->layoutState()->pageLogicalOffset(*this, logi calTop()) != pageLogicalOffset())) 1755 if (view()->layoutState()->pageLogicalHeightChanged() || (view()->layoutStat e()->pageLogicalHeight() && view()->layoutState()->pageLogicalOffset(*this, logi calTop()) != pageLogicalOffset()))
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 1944
1958 void LayoutBlock::removeFromTrackedRendererMaps(LayoutBox* descendant, TrackedDe scendantsMap*& descendantsMap, TrackedContainerMap*& containerMap) 1945 void LayoutBlock::removeFromTrackedRendererMaps(LayoutBox* descendant, TrackedDe scendantsMap*& descendantsMap, TrackedContainerMap*& containerMap)
1959 { 1946 {
1960 if (!descendantsMap) 1947 if (!descendantsMap)
1961 return; 1948 return;
1962 1949
1963 OwnPtr<HashSet<LayoutBlock*>> containerSet = containerMap->take(descendant); 1950 OwnPtr<HashSet<LayoutBlock*>> containerSet = containerMap->take(descendant);
1964 if (!containerSet) 1951 if (!containerSet)
1965 return; 1952 return;
1966 1953
1967 HashSet<LayoutBlock*>::iterator end = containerSet->end(); 1954 for (auto* container : *containerSet) {
1968 for (HashSet<LayoutBlock*>::iterator it = containerSet->begin(); it != end; ++it) {
1969 LayoutBlock* container = *it;
1970
1971 // FIXME: Disabling this assert temporarily until we fix the layout 1955 // FIXME: Disabling this assert temporarily until we fix the layout
1972 // bugs associated with positioned objects not properly cleared from 1956 // bugs associated with positioned objects not properly cleared from
1973 // their ancestor chain before being moved. See webkit bug 93766. 1957 // their ancestor chain before being moved. See webkit bug 93766.
1974 // ASSERT(descendant->isDescendantOf(container)); 1958 // ASSERT(descendant->isDescendantOf(container));
1975 1959
1976 TrackedDescendantsMap::iterator descendantsMapIterator = descendantsMap- >find(container); 1960 TrackedDescendantsMap::iterator descendantsMapIterator = descendantsMap- >find(container);
1977 ASSERT(descendantsMapIterator != descendantsMap->end()); 1961 ASSERT(descendantsMapIterator != descendantsMap->end());
1978 if (descendantsMapIterator == descendantsMap->end()) 1962 if (descendantsMapIterator == descendantsMap->end())
1979 continue; 1963 continue;
1980 TrackedRendererListHashSet* descendantSet = descendantsMapIterator->valu e.get(); 1964 TrackedRendererListHashSet* descendantSet = descendantsMapIterator->valu e.get();
(...skipping 21 matching lines...) Expand all
2002 { 1986 {
2003 removeFromTrackedRendererMaps(o, gPositionedDescendantsMap, gPositionedConta inerMap); 1987 removeFromTrackedRendererMaps(o, gPositionedDescendantsMap, gPositionedConta inerMap);
2004 } 1988 }
2005 1989
2006 void LayoutBlock::removePositionedObjects(LayoutBlock* o, ContainingBlockState c ontainingBlockState) 1990 void LayoutBlock::removePositionedObjects(LayoutBlock* o, ContainingBlockState c ontainingBlockState)
2007 { 1991 {
2008 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 1992 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
2009 if (!positionedDescendants) 1993 if (!positionedDescendants)
2010 return; 1994 return;
2011 1995
2012 LayoutBox* r;
2013
2014 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
2015
2016 Vector<LayoutBox*, 16> deadObjects; 1996 Vector<LayoutBox*, 16> deadObjects;
2017 1997 for (auto* positionedObject : *positionedDescendants) {
2018 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 1998 if (!o || positionedObject->isDescendantOf(o)) {
2019 r = *it;
2020 if (!o || r->isDescendantOf(o)) {
2021 if (containingBlockState == NewContainingBlock) { 1999 if (containingBlockState == NewContainingBlock) {
2022 r->setChildNeedsLayout(MarkOnlyThis); 2000 positionedObject->setChildNeedsLayout(MarkOnlyThis);
2023 if (r->needsPreferredWidthsRecalculation()) 2001 if (positionedObject->needsPreferredWidthsRecalculation())
2024 r->setPreferredLogicalWidthsDirty(MarkOnlyThis); 2002 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThi s);
2025 } 2003 }
2026 2004
2027 // It is parent blocks job to add positioned child to positioned obj ects list of its containing block 2005 // It is parent blocks job to add positioned child to positioned obj ects list of its containing block
2028 // Parent layout needs to be invalidated to ensure this happens. 2006 // Parent layout needs to be invalidated to ensure this happens.
2029 LayoutObject* p = r->parent(); 2007 LayoutObject* p = positionedObject->parent();
2030 while (p && !p->isLayoutBlock()) 2008 while (p && !p->isLayoutBlock())
2031 p = p->parent(); 2009 p = p->parent();
2032 if (p) 2010 if (p)
2033 p->setChildNeedsLayout(); 2011 p->setChildNeedsLayout();
2034 2012
2035 deadObjects.append(r); 2013 deadObjects.append(positionedObject);
2036 } 2014 }
2037 } 2015 }
2038 2016
2039 for (unsigned i = 0; i < deadObjects.size(); i++) 2017 for (unsigned i = 0; i < deadObjects.size(); i++)
2040 removePositionedObject(deadObjects.at(i)); 2018 removePositionedObject(deadObjects.at(i));
2041 } 2019 }
2042 2020
2043 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) 2021 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant)
2044 { 2022 {
2045 insertIntoTrackedRendererMaps(descendant, gPercentHeightDescendantsMap, gPer centHeightContainerMap); 2023 insertIntoTrackedRendererMaps(descendant, gPercentHeightDescendantsMap, gPer centHeightContainerMap);
(...skipping 25 matching lines...) Expand all
2071 2049
2072 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants(SubtreeLayoutSco pe& layoutScope) 2050 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants(SubtreeLayoutSco pe& layoutScope)
2073 { 2051 {
2074 if (!gPercentHeightDescendantsMap) 2052 if (!gPercentHeightDescendantsMap)
2075 return; 2053 return;
2076 2054
2077 TrackedRendererListHashSet* descendants = gPercentHeightDescendantsMap->get( this); 2055 TrackedRendererListHashSet* descendants = gPercentHeightDescendantsMap->get( this);
2078 if (!descendants) 2056 if (!descendants)
2079 return; 2057 return;
2080 2058
2081 TrackedRendererListHashSet::iterator end = descendants->end(); 2059 for (auto* box : *descendants) {
2082 for (TrackedRendererListHashSet::iterator it = descendants->begin(); it != e nd; ++it) {
2083 LayoutBox* box = *it;
2084 while (box != this) { 2060 while (box != this) {
2085 if (box->normalChildNeedsLayout()) 2061 if (box->normalChildNeedsLayout())
2086 break; 2062 break;
2087 layoutScope.setChildNeedsLayout(box); 2063 layoutScope.setChildNeedsLayout(box);
2088 box = box->containingBlock(); 2064 box = box->containingBlock();
2089 ASSERT(box); 2065 ASSERT(box);
2090 if (!box) 2066 if (!box)
2091 break; 2067 break;
2092 } 2068 }
2093 } 2069 }
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) { 3802 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) {
3827 if (recalcNormalFlowChildOverflowIfNeeded(box)) 3803 if (recalcNormalFlowChildOverflowIfNeeded(box))
3828 childrenOverflowChanged = true; 3804 childrenOverflowChanged = true;
3829 } 3805 }
3830 } 3806 }
3831 3807
3832 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 3808 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
3833 if (!positionedDescendants) 3809 if (!positionedDescendants)
3834 return childrenOverflowChanged; 3810 return childrenOverflowChanged;
3835 3811
3836 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 3812 for (auto* box : *positionedDescendants) {
3837 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
3838 LayoutBox* box = *it;
3839
3840 if (!box->needsOverflowRecalcAfterStyleChange()) 3813 if (!box->needsOverflowRecalcAfterStyleChange())
3841 continue; 3814 continue;
3842 LayoutBlock* block = toLayoutBlock(box); 3815 LayoutBlock* block = toLayoutBlock(box);
3843 if (!block->recalcOverflowAfterStyleChange() || box->style()->position() == FixedPosition) 3816 if (!block->recalcOverflowAfterStyleChange() || box->style()->position() == FixedPosition)
3844 continue; 3817 continue;
3845 3818
3846 childrenOverflowChanged = true; 3819 childrenOverflowChanged = true;
3847 } 3820 }
3848 return childrenOverflowChanged; 3821 return childrenOverflowChanged;
3849 } 3822 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 3916 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
3944 { 3917 {
3945 showLayoutObject(); 3918 showLayoutObject();
3946 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3919 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3947 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3920 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3948 } 3921 }
3949 3922
3950 #endif 3923 #endif
3951 3924
3952 } // namespace blink 3925 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/ImageQualityController.cpp ('k') | Source/core/layout/LayoutBlockFlowLine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698