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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 LayoutBox& child, 890 LayoutBox& child,
891 LayoutUnit mainAxisBorderAndPadding, 891 LayoutUnit mainAxisBorderAndPadding,
892 ChildLayoutType childLayoutType) { 892 ChildLayoutType childLayoutType) {
893 child.clearOverrideSize(); 893 child.clearOverrideSize();
894 894
895 if (child.isImage() || child.isVideo() || child.isCanvas()) 895 if (child.isImage() || child.isVideo() || child.isCanvas())
896 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); 896 UseCounter::count(document(), UseCounter::AspectRatioFlexItem);
897 897
898 Length flexBasis = flexBasisForChild(child); 898 Length flexBasis = flexBasisForChild(child);
899 if (mainAxisLengthIsDefinite(child, flexBasis)) 899 if (mainAxisLengthIsDefinite(child, flexBasis))
900 return std::max(LayoutUnit(), computeMainAxisExtentForChild( 900 return std::max(
901 child, MainOrPreferredSize, flexBasis)); 901 LayoutUnit(),
902 computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis));
902 903
903 if (child.styleRef().containsSize()) 904 if (child.styleRef().containsSize())
904 return LayoutUnit(); 905 return LayoutUnit();
905 906
906 // The flex basis is indefinite (=auto), so we need to compute the actual 907 // The flex basis is indefinite (=auto), so we need to compute the actual
907 // width of the child. For the logical width axis we just use the preferred 908 // width of the child. For the logical width axis we just use the preferred
908 // width; for the height we need to lay out the child. 909 // width; for the height we need to lay out the child.
909 LayoutUnit mainAxisExtent; 910 LayoutUnit mainAxisExtent;
910 if (hasOrthogonalFlow(child)) { 911 if (hasOrthogonalFlow(child)) {
911 if (childLayoutType == NeverLayout) 912 if (childLayoutType == NeverLayout)
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 // The last item does not get extra space added. 1857 // The last item does not get extra space added.
1857 mainAxisOffset += justifyContentSpaceBetweenChildren( 1858 mainAxisOffset += justifyContentSpaceBetweenChildren(
1858 availableFreeSpace, distribution, children.size()); 1859 availableFreeSpace, distribution, children.size());
1859 } 1860 }
1860 1861
1861 if (isPaginated) 1862 if (isPaginated)
1862 updateFragmentationInfoForChild(*child); 1863 updateFragmentationInfoForChild(*child);
1863 } 1864 }
1864 1865
1865 if (isColumnFlow()) 1866 if (isColumnFlow())
1866 setLogicalHeight(std::max( 1867 setLogicalHeight(std::max(logicalHeight(),
1867 logicalHeight(), mainAxisOffset + flowAwareBorderEnd() + 1868 mainAxisOffset + flowAwareBorderEnd() +
1868 flowAwarePaddingEnd() + scrollbarLogicalHeight())); 1869 flowAwarePaddingEnd() +
1870 scrollbarLogicalHeight()));
1869 1871
1870 if (style()->flexDirection() == FlowColumnReverse) { 1872 if (style()->flexDirection() == FlowColumnReverse) {
1871 // We have to do an extra pass for column-reverse to reposition the flex 1873 // We have to do an extra pass for column-reverse to reposition the flex
1872 // items since the start depends on the height of the flexbox, which we 1874 // items since the start depends on the height of the flexbox, which we
1873 // only know after we've positioned all the flex items. 1875 // only know after we've positioned all the flex items.
1874 updateLogicalHeight(); 1876 updateLogicalHeight();
1875 layoutColumnReverse(children, crossAxisOffset, availableFreeSpace); 1877 layoutColumnReverse(children, crossAxisOffset, availableFreeSpace);
1876 } 1878 }
1877 1879
1878 if (m_numberOfInFlowChildrenOnFirstLine == -1) 1880 if (m_numberOfInFlowChildrenOnFirstLine == -1)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 1999
1998 lineOffset += alignContentSpaceBetweenChildren( 2000 lineOffset += alignContentSpaceBetweenChildren(
1999 availableCrossAxisSpace, distribution, lineContexts.size()); 2001 availableCrossAxisSpace, distribution, lineContexts.size());
2000 } 2002 }
2001 } 2003 }
2002 2004
2003 void LayoutFlexibleBox::adjustAlignmentForChild(LayoutBox& child, 2005 void LayoutFlexibleBox::adjustAlignmentForChild(LayoutBox& child,
2004 LayoutUnit delta) { 2006 LayoutUnit delta) {
2005 DCHECK(!child.isOutOfFlowPositioned()); 2007 DCHECK(!child.isOutOfFlowPositioned());
2006 2008
2007 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + 2009 setFlowAwareLocationForChild(
2008 LayoutSize(LayoutUnit(), delta)); 2010 child,
2011 flowAwareLocationForChild(child) + LayoutSize(LayoutUnit(), delta));
2009 } 2012 }
2010 2013
2011 void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) { 2014 void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) {
2012 // Keep track of the space between the baseline edge and the after edge of 2015 // Keep track of the space between the baseline edge and the after edge of
2013 // the box for each line. 2016 // the box for each line.
2014 Vector<LayoutUnit> minMarginAfterBaselines; 2017 Vector<LayoutUnit> minMarginAfterBaselines;
2015 2018
2016 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) { 2019 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) {
2017 const LineContext& lineContext = lineContexts[lineNumber]; 2020 const LineContext& lineContext = lineContexts[lineNumber];
2018 2021
2019 LayoutUnit minMarginAfterBaseline = LayoutUnit::max(); 2022 LayoutUnit minMarginAfterBaseline = LayoutUnit::max();
2020 LayoutUnit lineCrossAxisExtent = lineContext.crossAxisExtent; 2023 LayoutUnit lineCrossAxisExtent = lineContext.crossAxisExtent;
2021 LayoutUnit maxAscent = lineContext.maxAscent; 2024 LayoutUnit maxAscent = lineContext.maxAscent;
2022 2025
2023 for (size_t childNumber = 0; childNumber < lineContext.flexItems.size(); 2026 for (size_t childNumber = 0; childNumber < lineContext.flexItems.size();
2024 ++childNumber) { 2027 ++childNumber) {
2025 const FlexItem& flexItem = lineContext.flexItems[childNumber]; 2028 const FlexItem& flexItem = lineContext.flexItems[childNumber];
2026 DCHECK(!flexItem.box->isOutOfFlowPositioned()); 2029 DCHECK(!flexItem.box->isOutOfFlowPositioned());
2027 2030
2028 if (updateAutoMarginsInCrossAxis( 2031 if (updateAutoMarginsInCrossAxis(
2029 *flexItem.box, 2032 *flexItem.box,
2030 std::max(LayoutUnit(), availableAlignmentSpaceForChild( 2033 std::max(LayoutUnit(),
2031 lineCrossAxisExtent, *flexItem.box)))) 2034 availableAlignmentSpaceForChild(lineCrossAxisExtent,
2035 *flexItem.box))))
2032 continue; 2036 continue;
2033 2037
2034 ItemPosition position = alignmentForChild(*flexItem.box); 2038 ItemPosition position = alignmentForChild(*flexItem.box);
2035 if (position == ItemPositionStretch) 2039 if (position == ItemPositionStretch)
2036 applyStretchAlignmentToChild(*flexItem.box, lineCrossAxisExtent); 2040 applyStretchAlignmentToChild(*flexItem.box, lineCrossAxisExtent);
2037 LayoutUnit availableSpace = 2041 LayoutUnit availableSpace =
2038 availableAlignmentSpaceForChild(lineCrossAxisExtent, *flexItem.box); 2042 availableAlignmentSpaceForChild(lineCrossAxisExtent, *flexItem.box);
2039 LayoutUnit offset = alignmentOffset( 2043 LayoutUnit offset = alignmentOffset(
2040 availableSpace, position, marginBoxAscentForChild(*flexItem.box), 2044 availableSpace, position, marginBoxAscentForChild(*flexItem.box),
2041 maxAscent, styleRef().flexWrap() == FlexWrapReverse); 2045 maxAscent, styleRef().flexWrap() == FlexWrapReverse);
2042 adjustAlignmentForChild(*flexItem.box, offset); 2046 adjustAlignmentForChild(*flexItem.box, offset);
2043 if (position == ItemPositionBaseline && 2047 if (position == ItemPositionBaseline &&
2044 styleRef().flexWrap() == FlexWrapReverse) { 2048 styleRef().flexWrap() == FlexWrapReverse) {
2045 minMarginAfterBaseline = std::min( 2049 minMarginAfterBaseline =
2046 minMarginAfterBaseline, availableAlignmentSpaceForChild( 2050 std::min(minMarginAfterBaseline,
2047 lineCrossAxisExtent, *flexItem.box) - 2051 availableAlignmentSpaceForChild(lineCrossAxisExtent,
2048 offset); 2052 *flexItem.box) -
2053 offset);
2049 } 2054 }
2050 } 2055 }
2051 minMarginAfterBaselines.push_back(minMarginAfterBaseline); 2056 minMarginAfterBaselines.push_back(minMarginAfterBaseline);
2052 } 2057 }
2053 2058
2054 if (style()->flexWrap() != FlexWrapReverse) 2059 if (style()->flexWrap() != FlexWrapReverse)
2055 return; 2060 return;
2056 2061
2057 // wrap-reverse flips the cross axis start and end. For baseline alignment, 2062 // wrap-reverse flips the cross axis start and end. For baseline alignment,
2058 // this means we need to align the after edge of baseline elements with the 2063 // this means we need to align the after edge of baseline elements with the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 LayoutUnit originalOffset = 2169 LayoutUnit originalOffset =
2165 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 2170 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
2166 LayoutUnit newOffset = 2171 LayoutUnit newOffset =
2167 contentExtent - originalOffset - lineCrossAxisExtent; 2172 contentExtent - originalOffset - lineCrossAxisExtent;
2168 adjustAlignmentForChild(*flexItem.box, newOffset - originalOffset); 2173 adjustAlignmentForChild(*flexItem.box, newOffset - originalOffset);
2169 } 2174 }
2170 } 2175 }
2171 } 2176 }
2172 2177
2173 } // namespace blink 2178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698