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

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 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 FillAvailableMeasure(available_logical_width, margin_start, margin_end); 2743 FillAvailableMeasure(available_logical_width, margin_start, margin_end);
2744 2744
2745 if (ShrinkToAvoidFloats() && cb->IsLayoutBlockFlow() && 2745 if (ShrinkToAvoidFloats() && cb->IsLayoutBlockFlow() &&
2746 ToLayoutBlockFlow(cb)->ContainsFloats()) 2746 ToLayoutBlockFlow(cb)->ContainsFloats())
2747 logical_width_result = 2747 logical_width_result =
2748 std::min(logical_width_result, 2748 std::min(logical_width_result,
2749 ShrinkLogicalWidthToAvoidFloats(margin_start, margin_end, 2749 ShrinkLogicalWidthToAvoidFloats(margin_start, margin_end,
2750 ToLayoutBlockFlow(cb))); 2750 ToLayoutBlockFlow(cb)));
2751 2751
2752 if (width_type == kMainOrPreferredSize && 2752 if (width_type == kMainOrPreferredSize &&
2753 SizesLogicalWidthToFitContent(logical_width)) 2753 SizesLogicalWidthToFitContent(logical_width)) {
2754 // Reset width so that any percent margins on inline children do not
2755 // use it when calculating min/max preferred width.
2756 // TODO(crbug.com/710026): Remove const_cast
2757 const_cast<LayoutBox*>(this)->SetLogicalWidth(LayoutUnit());
2754 return std::max(MinPreferredLogicalWidth(), 2758 return std::max(MinPreferredLogicalWidth(),
2755 std::min(MaxPreferredLogicalWidth(), logical_width_result)); 2759 std::min(MaxPreferredLogicalWidth(), logical_width_result));
2760 }
2756 return logical_width_result; 2761 return logical_width_result;
2757 } 2762 }
2758 2763
2759 bool LayoutBox::ColumnFlexItemHasStretchAlignment() const { 2764 bool LayoutBox::ColumnFlexItemHasStretchAlignment() const {
2760 // auto margins mean we don't stretch. Note that this function will only be 2765 // auto margins mean we don't stretch. Note that this function will only be
2761 // used for widths, so we don't have to check marginBefore/marginAfter. 2766 // used for widths, so we don't have to check marginBefore/marginAfter.
2762 const auto& parent_style = Parent()->StyleRef(); 2767 const auto& parent_style = Parent()->StyleRef();
2763 DCHECK(parent_style.IsColumnFlexDirection()); 2768 DCHECK(parent_style.IsColumnFlexDirection());
2764 if (StyleRef().MarginStart().IsAuto() || StyleRef().MarginEnd().IsAuto()) 2769 if (StyleRef().MarginStart().IsAuto() || StyleRef().MarginEnd().IsAuto())
2765 return false; 2770 return false;
(...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after
5819 void LayoutBox::MutableForPainting:: 5824 void LayoutBox::MutableForPainting::
5820 SavePreviousContentBoxSizeAndLayoutOverflowRect() { 5825 SavePreviousContentBoxSizeAndLayoutOverflowRect() {
5821 auto& rare_data = GetLayoutBox().EnsureRareData(); 5826 auto& rare_data = GetLayoutBox().EnsureRareData();
5822 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; 5827 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true;
5823 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().size(); 5828 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().size();
5824 rare_data.previous_layout_overflow_rect_ = 5829 rare_data.previous_layout_overflow_rect_ =
5825 GetLayoutBox().LayoutOverflowRect(); 5830 GetLayoutBox().LayoutOverflowRect();
5826 } 5831 }
5827 5832
5828 } // namespace blink 5833 } // 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