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

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

Issue 2802413002: Don't let current width affect preferred width on shrink-to-fit containers (Closed)
Patch Set: bug 598711 Created 3 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/inline/percentage-margins-shrink-to-fit-expected.html ('k') | no next file » | 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. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 LayoutUnit logicalWidthResult = 2717 LayoutUnit logicalWidthResult =
2718 fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); 2718 fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd);
2719 2719
2720 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && 2720 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() &&
2721 toLayoutBlockFlow(cb)->containsFloats()) 2721 toLayoutBlockFlow(cb)->containsFloats())
2722 logicalWidthResult = std::min( 2722 logicalWidthResult = std::min(
2723 logicalWidthResult, shrinkLogicalWidthToAvoidFloats( 2723 logicalWidthResult, shrinkLogicalWidthToAvoidFloats(
2724 marginStart, marginEnd, toLayoutBlockFlow(cb))); 2724 marginStart, marginEnd, toLayoutBlockFlow(cb)));
2725 2725
2726 if (widthType == MainOrPreferredSize && 2726 if (widthType == MainOrPreferredSize &&
2727 sizesLogicalWidthToFitContent(logicalWidth)) 2727 sizesLogicalWidthToFitContent(logicalWidth)) {
2728 // Reset width so that any percent margins on inline children do not
2729 // use it when calculating min/max preferred width.
eae 2017/04/10 05:17:57 Would you mind filing a bug about this const_cast
2730 const_cast<LayoutBox*>(this)->setLogicalWidth(LayoutUnit());
2728 return std::max(minPreferredLogicalWidth(), 2731 return std::max(minPreferredLogicalWidth(),
2729 std::min(maxPreferredLogicalWidth(), logicalWidthResult)); 2732 std::min(maxPreferredLogicalWidth(), logicalWidthResult));
2733 }
2730 return logicalWidthResult; 2734 return logicalWidthResult;
2731 } 2735 }
2732 2736
2733 bool LayoutBox::columnFlexItemHasStretchAlignment() const { 2737 bool LayoutBox::columnFlexItemHasStretchAlignment() const {
2734 // auto margins mean we don't stretch. Note that this function will only be 2738 // auto margins mean we don't stretch. Note that this function will only be
2735 // used for widths, so we don't have to check marginBefore/marginAfter. 2739 // used for widths, so we don't have to check marginBefore/marginAfter.
2736 const auto& parentStyle = parent()->styleRef(); 2740 const auto& parentStyle = parent()->styleRef();
2737 DCHECK(parentStyle.isColumnFlexDirection()); 2741 DCHECK(parentStyle.isColumnFlexDirection());
2738 if (styleRef().marginStart().isAuto() || styleRef().marginEnd().isAuto()) 2742 if (styleRef().marginStart().isAuto() || styleRef().marginEnd().isAuto())
2739 return false; 2743 return false;
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after
5756 5760
5757 void LayoutBox::MutableForPainting:: 5761 void LayoutBox::MutableForPainting::
5758 savePreviousContentBoxSizeAndLayoutOverflowRect() { 5762 savePreviousContentBoxSizeAndLayoutOverflowRect() {
5759 auto& rareData = layoutBox().ensureRareData(); 5763 auto& rareData = layoutBox().ensureRareData();
5760 rareData.m_hasPreviousContentBoxSizeAndLayoutOverflowRect = true; 5764 rareData.m_hasPreviousContentBoxSizeAndLayoutOverflowRect = true;
5761 rareData.m_previousContentBoxSize = layoutBox().contentBoxRect().size(); 5765 rareData.m_previousContentBoxSize = layoutBox().contentBoxRect().size();
5762 rareData.m_previousLayoutOverflowRect = layoutBox().layoutOverflowRect(); 5766 rareData.m_previousLayoutOverflowRect = layoutBox().layoutOverflowRect();
5763 } 5767 }
5764 5768
5765 } // namespace blink 5769 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/inline/percentage-margins-shrink-to-fit-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698