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

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

Issue 1162383003: C++11: Replace 0 with nullptr where applicable in layout code. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add one more file. Created 5 years, 6 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
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutBoxModelObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 namespace blink { 72 namespace blink {
73 73
74 using namespace HTMLNames; 74 using namespace HTMLNames;
75 75
76 // Used by flexible boxes when flexing this element and by table cells. 76 // Used by flexible boxes when flexing this element and by table cells.
77 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; 77 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap;
78 78
79 // Used by grid elements to properly size their grid items. 79 // Used by grid elements to properly size their grid items.
80 // FIXME: Move these into LayoutBoxRareData. 80 // FIXME: Move these into LayoutBoxRareData.
81 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; 81 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = nullptr;
82 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; 82 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = nullptr;
83 static OverrideSizeMap* gExtraInlineOffsetMap = 0; 83 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr;
84 static OverrideSizeMap* gExtraBlockOffsetMap = 0; 84 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr;
85 85
86 86
87 // Size of border belt for autoscroll. When mouse pointer in border belt, 87 // Size of border belt for autoscroll. When mouse pointer in border belt,
88 // autoscroll is started. 88 // autoscroll is started.
89 static const int autoscrollBeltSize = 20; 89 static const int autoscrollBeltSize = 20;
90 static const unsigned backgroundObscurationTestMaxDepth = 4; 90 static const unsigned backgroundObscurationTestMaxDepth = 4;
91 91
92 static bool skipBodyBackground(const LayoutBox* bodyElementLayoutObject) 92 static bool skipBodyBackground(const LayoutBox* bodyElementLayoutObject)
93 { 93 {
94 ASSERT(bodyElementLayoutObject->isBody()); 94 ASSERT(bodyElementLayoutObject->isBody());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() 149 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists()
150 { 150 {
151 ASSERT(isFloatingOrOutOfFlowPositioned()); 151 ASSERT(isFloatingOrOutOfFlowPositioned());
152 152
153 if (documentBeingDestroyed()) 153 if (documentBeingDestroyed())
154 return; 154 return;
155 155
156 if (isFloating()) { 156 if (isFloating()) {
157 LayoutBlockFlow* parentBlockFlow = 0; 157 LayoutBlockFlow* parentBlockFlow = nullptr;
158 for (LayoutObject* curr = parent(); curr && !curr->isLayoutView(); curr = curr->parent()) { 158 for (LayoutObject* curr = parent(); curr && !curr->isLayoutView(); curr = curr->parent()) {
159 if (curr->isLayoutBlockFlow()) { 159 if (curr->isLayoutBlockFlow()) {
160 LayoutBlockFlow* currBlockFlow = toLayoutBlockFlow(curr); 160 LayoutBlockFlow* currBlockFlow = toLayoutBlockFlow(curr);
161 if (!parentBlockFlow || currBlockFlow->containsFloat(this)) 161 if (!parentBlockFlow || currBlockFlow->containsFloat(this))
162 parentBlockFlow = currBlockFlow; 162 parentBlockFlow = currBlockFlow;
163 } 163 }
164 } 164 }
165 165
166 if (parentBlockFlow) { 166 if (parentBlockFlow) {
167 parentBlockFlow->markSiblingsWithFloatsForLayout(this); 167 parentBlockFlow->markSiblingsWithFloatsForLayout(this);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 471 }
472 } 472 }
473 return false; 473 return false;
474 } 474 }
475 475
476 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY) 476 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY)
477 { 477 {
478 // Presumably the same issue as in setScrollTop. See crbug.com/343132. 478 // Presumably the same issue as in setScrollTop. See crbug.com/343132.
479 DisableCompositingQueryAsserts disabler; 479 DisableCompositingQueryAsserts disabler;
480 480
481 LayoutBox* parentBox = 0; 481 LayoutBox* parentBox = nullptr;
482 LayoutRect newRect = rect; 482 LayoutRect newRect = rect;
483 483
484 bool restrictedByLineClamp = false; 484 bool restrictedByLineClamp = false;
485 if (parent()) { 485 if (parent()) {
486 parentBox = parent()->enclosingBox(); 486 parentBox = parent()->enclosingBox();
487 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); 487 restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
488 } 488 }
489 489
490 if (hasOverflowClip() && !restrictedByLineClamp) { 490 if (hasOverflowClip() && !restrictedByLineClamp) {
491 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 491 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
492 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 492 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
493 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY ); 493 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY );
494 } else if (!parentBox && canBeProgramaticallyScrolled()) { 494 } else if (!parentBox && canBeProgramaticallyScrolled()) {
495 if (FrameView* frameView = this->frameView()) { 495 if (FrameView* frameView = this->frameView()) {
496 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); 496 HTMLFrameOwnerElement* ownerElement = document().ownerElement();
497 if (!isDisallowedAutoscroll(ownerElement, frameView)) { 497 if (!isDisallowedAutoscroll(ownerElement, frameView)) {
498 frameView->scrollableArea()->scrollIntoView(rect, alignX, alignY ); 498 frameView->scrollableArea()->scrollIntoView(rect, alignX, alignY );
499 499
500 if (ownerElement && ownerElement->layoutObject()) { 500 if (ownerElement && ownerElement->layoutObject()) {
501 if (frameView->safeToPropagateScrollToParent()) { 501 if (frameView->safeToPropagateScrollToParent()) {
502 parentBox = ownerElement->layoutObject()->enclosingBox() ; 502 parentBox = ownerElement->layoutObject()->enclosingBox() ;
503 // FIXME: This doesn't correctly convert the rect to 503 // FIXME: This doesn't correctly convert the rect to
504 // absolute coordinates in the parent. 504 // absolute coordinates in the parent.
505 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x()); 505 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x());
506 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y()); 506 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y());
507 } else { 507 } else {
508 parentBox = 0; 508 parentBox = nullptr;
509 } 509 }
510 } 510 }
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 // If we are fixed-position, it is useless to scroll the parent. 515 // If we are fixed-position, it is useless to scroll the parent.
516 if (hasLayer() && layer()->scrollsWithViewport()) 516 if (hasLayer() && layer()->scrollsWithViewport())
517 return; 517 return;
518 518
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 { 1690 {
1691 return new InlineBox(*this); 1691 return new InlineBox(*this);
1692 } 1692 }
1693 1693
1694 void LayoutBox::dirtyLineBoxes(bool fullLayout) 1694 void LayoutBox::dirtyLineBoxes(bool fullLayout)
1695 { 1695 {
1696 if (inlineBoxWrapper()) { 1696 if (inlineBoxWrapper()) {
1697 if (fullLayout) { 1697 if (fullLayout) {
1698 inlineBoxWrapper()->destroy(); 1698 inlineBoxWrapper()->destroy();
1699 ASSERT(m_rareData); 1699 ASSERT(m_rareData);
1700 m_rareData->m_inlineBoxWrapper = 0; 1700 m_rareData->m_inlineBoxWrapper = nullptr;
1701 } else { 1701 } else {
1702 inlineBoxWrapper()->dirtyLineBoxes(); 1702 inlineBoxWrapper()->dirtyLineBoxes();
1703 } 1703 }
1704 } 1704 }
1705 } 1705 }
1706 1706
1707 void LayoutBox::positionLineBox(InlineBox* box) 1707 void LayoutBox::positionLineBox(InlineBox* box)
1708 { 1708 {
1709 if (isOutOfFlowPositioned()) { 1709 if (isOutOfFlowPositioned()) {
1710 // Cache the x position only if we were an INLINE type originally. 1710 // Cache the x position only if we were an INLINE type originally.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 setChildNeedsLayout(MarkOnlyThis); 1748 setChildNeedsLayout(MarkOnlyThis);
1749 } 1749 }
1750 1750
1751 void LayoutBox::deleteLineBoxWrapper() 1751 void LayoutBox::deleteLineBoxWrapper()
1752 { 1752 {
1753 if (inlineBoxWrapper()) { 1753 if (inlineBoxWrapper()) {
1754 if (!documentBeingDestroyed()) 1754 if (!documentBeingDestroyed())
1755 inlineBoxWrapper()->remove(); 1755 inlineBoxWrapper()->remove();
1756 inlineBoxWrapper()->destroy(); 1756 inlineBoxWrapper()->destroy();
1757 ASSERT(m_rareData); 1757 ASSERT(m_rareData);
1758 m_rareData->m_inlineBoxWrapper = 0; 1758 m_rareData->m_inlineBoxWrapper = nullptr;
1759 } 1759 }
1760 } 1760 }
1761 1761
1762 void LayoutBox::setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder& place holder) 1762 void LayoutBox::setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder& place holder)
1763 { 1763 {
1764 RELEASE_ASSERT(!m_rareData || !m_rareData->m_spannerPlaceholder); // not exp ected to change directly from one spanner to another. 1764 RELEASE_ASSERT(!m_rareData || !m_rareData->m_spannerPlaceholder); // not exp ected to change directly from one spanner to another.
1765 ensureRareData().m_spannerPlaceholder = &placeholder; 1765 ensureRareData().m_spannerPlaceholder = &placeholder;
1766 } 1766 }
1767 1767
1768 void LayoutBox::clearSpannerPlaceholder() 1768 void LayoutBox::clearSpannerPlaceholder()
1769 { 1769 {
1770 if (!m_rareData) 1770 if (!m_rareData)
1771 return; 1771 return;
1772 m_rareData->m_spannerPlaceholder = 0; 1772 m_rareData->m_spannerPlaceholder = nullptr;
1773 } 1773 }
1774 1774
1775 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid ationState) const 1775 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid ationState) const
1776 { 1776 {
1777 if (style()->visibility() != VISIBLE) { 1777 if (style()->visibility() != VISIBLE) {
1778 DeprecatedPaintLayer* layer = enclosingLayer(); 1778 DeprecatedPaintLayer* layer = enclosingLayer();
1779 layer->updateDescendantDependentFlags(); 1779 layer->updateDescendantDependentFlags();
1780 if (layer->subtreeIsInvisible()) 1780 if (layer->subtreeIsInvisible())
1781 return LayoutRect(); 1781 return LayoutRect();
1782 } 1782 }
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
3834 3834
3835 if (point.x() < 0 || point.x() > right || point.y() < 0 || point.y() > b ottom) { 3835 if (point.x() < 0 || point.x() > right || point.y() < 0 || point.y() > b ottom) {
3836 if (point.x() <= right / 2) 3836 if (point.x() <= right / 2)
3837 return createPositionWithAffinity(firstPositionInOrBeforeNode(no nPseudoNode())); 3837 return createPositionWithAffinity(firstPositionInOrBeforeNode(no nPseudoNode()));
3838 return createPositionWithAffinity(lastPositionInOrAfterNode(nonPseud oNode())); 3838 return createPositionWithAffinity(lastPositionInOrAfterNode(nonPseud oNode()));
3839 } 3839 }
3840 } 3840 }
3841 3841
3842 // Pass off to the closest child. 3842 // Pass off to the closest child.
3843 LayoutUnit minDist = LayoutUnit::max(); 3843 LayoutUnit minDist = LayoutUnit::max();
3844 LayoutBox* closestLayoutObject = 0; 3844 LayoutBox* closestLayoutObject = nullptr;
3845 LayoutPoint adjustedPoint = point; 3845 LayoutPoint adjustedPoint = point;
3846 if (isTableRow()) 3846 if (isTableRow())
3847 adjustedPoint.moveBy(location()); 3847 adjustedPoint.moveBy(location());
3848 3848
3849 for (LayoutObject* layoutObject = firstChild; layoutObject; layoutObject = l ayoutObject->nextSibling()) { 3849 for (LayoutObject* layoutObject = firstChild; layoutObject; layoutObject = l ayoutObject->nextSibling()) {
3850 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && !la youtObject->isLayoutBlockFlow() ) 3850 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && !la youtObject->isLayoutBlockFlow() )
3851 || layoutObject->style()->visibility() != VISIBLE) 3851 || layoutObject->style()->visibility() != VISIBLE)
3852 continue; 3852 continue;
3853 3853
3854 if (!layoutObject->isBox()) 3854 if (!layoutObject->isBox())
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
4392 4392
4393 DeprecatedPaintLayer* LayoutBox::enclosingFloatPaintingLayer() const 4393 DeprecatedPaintLayer* LayoutBox::enclosingFloatPaintingLayer() const
4394 { 4394 {
4395 const LayoutObject* curr = this; 4395 const LayoutObject* curr = this;
4396 while (curr) { 4396 while (curr) {
4397 DeprecatedPaintLayer* layer = curr->hasLayer() && curr->isBox() ? toLayo utBox(curr)->layer() : 0; 4397 DeprecatedPaintLayer* layer = curr->hasLayer() && curr->isBox() ? toLayo utBox(curr)->layer() : 0;
4398 if (layer && layer->isSelfPaintingLayer()) 4398 if (layer && layer->isSelfPaintingLayer())
4399 return layer; 4399 return layer;
4400 curr = curr->parent(); 4400 curr = curr->parent();
4401 } 4401 }
4402 return 0; 4402 return nullptr;
4403 } 4403 }
4404 4404
4405 LayoutRect LayoutBox::logicalVisualOverflowRectForPropagation(const ComputedStyl e& parentStyle) const 4405 LayoutRect LayoutBox::logicalVisualOverflowRectForPropagation(const ComputedStyl e& parentStyle) const
4406 { 4406 {
4407 LayoutRect rect = visualOverflowRectForPropagation(parentStyle); 4407 LayoutRect rect = visualOverflowRectForPropagation(parentStyle);
4408 if (!parentStyle.isHorizontalWritingMode()) 4408 if (!parentStyle.isHorizontalWritingMode())
4409 return rect.transposedRect(); 4409 return rect.transposedRect();
4410 return rect; 4410 return rect;
4411 } 4411 }
4412 4412
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
4793 bool LayoutBox::canRenderBorderImage() const 4793 bool LayoutBox::canRenderBorderImage() const
4794 { 4794 {
4795 if (!style()->hasBorderDecoration()) 4795 if (!style()->hasBorderDecoration())
4796 return false; 4796 return false;
4797 4797
4798 StyleImage* borderImage = style()->borderImage().image(); 4798 StyleImage* borderImage = style()->borderImage().image();
4799 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4799 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4800 } 4800 }
4801 4801
4802 } // namespace blink 4802 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698