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

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

Issue 1306993002: Cleanup friends of LayoutObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 void LayoutBlock::promoteAllChildrenAndInsertAfter() 556 void LayoutBlock::promoteAllChildrenAndInsertAfter()
557 { 557 {
558 LayoutObject* firstPromotee = firstChild(); 558 LayoutObject* firstPromotee = firstChild();
559 if (!firstPromotee) 559 if (!firstPromotee)
560 return; 560 return;
561 LayoutObject* lastPromotee = lastChild(); 561 LayoutObject* lastPromotee = lastChild();
562 LayoutBlock* parent = toLayoutBlock(this->parent()); 562 LayoutBlock* parent = toLayoutBlock(this->parent());
563 LayoutObject* nextSiblingOfPromotees = nextSibling(); 563 LayoutObject* nextSiblingOfPromotees = nextSibling();
564 for (LayoutObject* o = firstPromotee; o; o = o->nextSibling()) 564 for (LayoutObject* o = firstPromotee; o; o = o->nextSibling())
565 o->setParent(parent); 565 DangerousLayoutTreeMutator(*o).setParent(parent);
566 children()->setFirstChild(nullptr); 566 children()->setFirstChild(nullptr);
567 children()->setLastChild(nullptr); 567 children()->setLastChild(nullptr);
568 firstPromotee->setPreviousSibling(this); 568 DangerousLayoutTreeMutator(*firstPromotee).setPreviousSibling(this);
569 setNextSibling(firstPromotee); 569 DangerousLayoutTreeMutator(*this).setNextSibling(firstPromotee);
570 lastPromotee->setNextSibling(nextSiblingOfPromotees); 570 DangerousLayoutTreeMutator(*lastPromotee).setNextSibling(nextSiblingOfPromot ees);
571 if (nextSiblingOfPromotees) 571 if (nextSiblingOfPromotees)
572 nextSiblingOfPromotees->setPreviousSibling(lastPromotee); 572 DangerousLayoutTreeMutator(*nextSiblingOfPromotees).setPreviousSibling(l astPromotee);
esprehn 2015/08/21 21:20:32 Instead of having all methods I'd prefer it only h
Xianzhu 2015/08/21 22:52:19 Thanks for the finding. Actually I didn't look int
573 if (parent->children()->lastChild() == this) 573 if (parent->children()->lastChild() == this)
574 parent->children()->setLastChild(lastPromotee); 574 parent->children()->setLastChild(lastPromotee);
575 } 575 }
576 576
577 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child) 577 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child)
578 { 578 {
579 ASSERT(child->isAnonymousBlock()); 579 ASSERT(child->isAnonymousBlock());
580 ASSERT(!child->childrenInline()); 580 ASSERT(!child->childrenInline());
581 ASSERT(child->parent() == this); 581 ASSERT(child->parent() == this);
582 582
583 if (child->continuation()) 583 if (child->continuation())
584 return; 584 return;
585 585
586 // Promote all the leftover anonymous block's children (to become children o f this block 586 // Promote all the leftover anonymous block's children (to become children o f this block
587 // instead). We still want to keep the leftover block in the tree for a mome nt, for notification 587 // instead). We still want to keep the leftover block in the tree for a mome nt, for notification
588 // purposes done further below (flow threads and grids). 588 // purposes done further below (flow threads and grids).
589 child->promoteAllChildrenAndInsertAfter(); 589 child->promoteAllChildrenAndInsertAfter();
590 590
591 // Remove all the information in the flow thread associated with the leftove r anonymous block. 591 // Remove all the information in the flow thread associated with the leftove r anonymous block.
592 child->removeFromLayoutFlowThread(); 592 DangerousLayoutTreeMutator(*child).removeFromLayoutFlowThread();
esprehn 2015/08/21 21:20:31 I think I would just make removeFromLayoutFlowThre
Xianzhu 2015/08/21 22:52:19 Done.
593 593
594 // LayoutGrid keeps track of its children, we must notify it about changes i n the tree. 594 // LayoutGrid keeps track of its children, we must notify it about changes i n the tree.
595 if (child->parent()->isLayoutGrid()) 595 if (child->parent()->isLayoutGrid())
596 toLayoutGrid(child->parent())->dirtyGrid(); 596 toLayoutGrid(child->parent())->dirtyGrid();
597 597
598 // Now remove the leftover anonymous block from the tree, and destroy it. We 'll rip it out 598 // Now remove the leftover anonymous block from the tree, and destroy it. We 'll rip it out
599 // manually from the tree before destroying it, because we don't want to tri gger any tree 599 // manually from the tree before destroying it, because we don't want to tri gger any tree
600 // adjustments with regards to anonymous blocks (or any other kind of undesi red chain-reaction). 600 // adjustments with regards to anonymous blocks (or any other kind of undesi red chain-reaction).
601 children()->removeChildNode(this, child, false); 601 children()->removeChildNode(this, child, false);
602 child->destroy(); 602 child->destroy();
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 if (layoutObject->isOutOfFlowPositioned() || !layoutObject->needsOverflowRec alcAfterStyleChange()) 2771 if (layoutObject->isOutOfFlowPositioned() || !layoutObject->needsOverflowRec alcAfterStyleChange())
2772 return false; 2772 return false;
2773 2773
2774 ASSERT(layoutObject->isLayoutBlock()); 2774 ASSERT(layoutObject->isLayoutBlock());
2775 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange(); 2775 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange();
2776 } 2776 }
2777 2777
2778 bool LayoutBlock::recalcChildOverflowAfterStyleChange() 2778 bool LayoutBlock::recalcChildOverflowAfterStyleChange()
2779 { 2779 {
2780 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); 2780 ASSERT(childNeedsOverflowRecalcAfterStyleChange());
2781 setChildNeedsOverflowRecalcAfterStyleChange(false); 2781 clearChildNeedsOverflowRecalcAfterStyleChange();
2782 2782
2783 bool childrenOverflowChanged = false; 2783 bool childrenOverflowChanged = false;
2784 2784
2785 if (childrenInline()) { 2785 if (childrenInline()) {
2786 ListHashSet<RootInlineBox*> lineBoxes; 2786 ListHashSet<RootInlineBox*> lineBoxes;
2787 ASSERT_WITH_SECURITY_IMPLICATION(isLayoutBlockFlow()); 2787 ASSERT_WITH_SECURITY_IMPLICATION(isLayoutBlockFlow());
2788 for (InlineWalker walker(toLayoutBlockFlow(this)); !walker.atEnd(); walk er.advance()) { 2788 for (InlineWalker walker(toLayoutBlockFlow(this)); !walker.atEnd(); walk er.advance()) {
2789 LayoutObject* layoutObject = walker.current(); 2789 LayoutObject* layoutObject = walker.current();
2790 if (recalcNormalFlowChildOverflowIfNeeded(layoutObject)) { 2790 if (recalcNormalFlowChildOverflowIfNeeded(layoutObject)) {
2791 childrenOverflowChanged = true; 2791 childrenOverflowChanged = true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 { 2827 {
2828 ASSERT(needsOverflowRecalcAfterStyleChange()); 2828 ASSERT(needsOverflowRecalcAfterStyleChange());
2829 2829
2830 bool childrenOverflowChanged = false; 2830 bool childrenOverflowChanged = false;
2831 if (childNeedsOverflowRecalcAfterStyleChange()) 2831 if (childNeedsOverflowRecalcAfterStyleChange())
2832 childrenOverflowChanged = recalcChildOverflowAfterStyleChange(); 2832 childrenOverflowChanged = recalcChildOverflowAfterStyleChange();
2833 2833
2834 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged) 2834 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged)
2835 return false; 2835 return false;
2836 2836
2837 setSelfNeedsOverflowRecalcAfterStyleChange(false); 2837 clearSelfNeedsOverflowRecalcAfterStyleChange();
2838 // If the current block needs layout, overflow will be recalculated during 2838 // If the current block needs layout, overflow will be recalculated during
2839 // layout time anyway. We can safely exit here. 2839 // layout time anyway. We can safely exit here.
2840 if (needsLayout()) 2840 if (needsLayout())
2841 return false; 2841 return false;
2842 2842
2843 LayoutUnit oldClientAfterEdge = hasOverflowModel() ? m_overflow->layoutClien tAfterEdge() : clientLogicalBottom(); 2843 LayoutUnit oldClientAfterEdge = hasOverflowModel() ? m_overflow->layoutClien tAfterEdge() : clientLogicalBottom();
2844 computeOverflow(oldClientAfterEdge); 2844 computeOverflow(oldClientAfterEdge);
2845 2845
2846 if (hasOverflowClip()) 2846 if (hasOverflowClip())
2847 layer()->scrollableArea()->updateAfterOverflowRecalc(); 2847 layer()->scrollableArea()->updateAfterOverflowRecalc();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2918 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2919 { 2919 {
2920 showLayoutObject(); 2920 showLayoutObject();
2921 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2921 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2922 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2922 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2923 } 2923 }
2924 2924
2925 #endif 2925 #endif
2926 2926
2927 } // namespace blink 2927 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698