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

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

Issue 2411943002: [css-flexbox] Don't force layout for overflow: auto anymore (Closed)
Patch Set: further simplify & add comment Created 4 years, 2 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/Source/core/layout/LayoutFlexibleBox.h ('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) 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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 bool definite = child.computePercentageLogicalHeight(length) != -1; 888 bool definite = child.computePercentageLogicalHeight(length) != -1;
889 m_hasDefiniteHeight = 889 m_hasDefiniteHeight =
890 definite ? SizeDefiniteness::Definite : SizeDefiniteness::Indefinite; 890 definite ? SizeDefiniteness::Definite : SizeDefiniteness::Indefinite;
891 return definite; 891 return definite;
892 } 892 }
893 // TODO(cbiesinger): Eventually we should support other types of sizes here. 893 // TODO(cbiesinger): Eventually we should support other types of sizes here.
894 // Requires updating computeMainSizeFromAspectRatioUsing. 894 // Requires updating computeMainSizeFromAspectRatioUsing.
895 return length.isFixed(); 895 return length.isFixed();
896 } 896 }
897 897
898 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(
899 const LayoutBox& child) const {
900 return (!mainAxisLengthIsDefinite(child, flexBasisForChild(child)) &&
901 (hasOrthogonalFlow(child) ||
902 (crossAxisOverflowForChild(child) == OverflowAuto &&
903 !PaintLayerScrollableArea::FreezeScrollbarsScope::
904 scrollbarsAreFrozen())));
905 }
906
907 void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child) { 898 void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child) {
908 DCHECK(!child.needsLayout()); 899 DCHECK(!child.needsLayout());
909 LayoutUnit mainSize; 900 LayoutUnit mainSize;
910 if (hasOrthogonalFlow(child)) { 901 if (hasOrthogonalFlow(child)) {
911 mainSize = child.logicalHeight(); 902 mainSize = child.logicalHeight();
912 } else { 903 } else {
913 // The max preferred logical width includes the intrinsic scrollbar logical 904 // The max preferred logical width includes the intrinsic scrollbar logical
914 // width, which is only set for overflow: scroll. To handle overflow: auto, 905 // width, which is only set for overflow: scroll. To handle overflow: auto,
915 // we have to take scrollbarLogicalWidth() into account, and then subtract 906 // we have to take scrollbarLogicalWidth() into account, and then subtract
916 // the intrinsic width again so as to not double-count overflow: scroll 907 // the intrinsic width again so as to not double-count overflow: scroll
(...skipping 20 matching lines...) Expand all
937 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); 928 UseCounter::count(document(), UseCounter::AspectRatioFlexItem);
938 929
939 Length flexBasis = flexBasisForChild(child); 930 Length flexBasis = flexBasisForChild(child);
940 if (mainAxisLengthIsDefinite(child, flexBasis)) 931 if (mainAxisLengthIsDefinite(child, flexBasis))
941 return std::max(LayoutUnit(), computeMainAxisExtentForChild( 932 return std::max(LayoutUnit(), computeMainAxisExtentForChild(
942 child, MainOrPreferredSize, flexBasis)); 933 child, MainOrPreferredSize, flexBasis));
943 934
944 if (child.styleRef().containsSize()) 935 if (child.styleRef().containsSize())
945 return LayoutUnit(); 936 return LayoutUnit();
946 937
938 // The flex basis is indefinite (=auto), so we need to compute the actual
939 // width of the child. For the logical width axis we just use the preferred
940 // width; for the height we need to lay out the child.
947 LayoutUnit mainAxisExtent; 941 LayoutUnit mainAxisExtent;
948 if (childFlexBaseSizeRequiresLayout(child)) { 942 if (hasOrthogonalFlow(child)) {
949 if (childLayoutType == NeverLayout) 943 if (childLayoutType == NeverLayout)
950 return LayoutUnit(); 944 return LayoutUnit();
951 945
952 updateBlockChildDirtyBitsBeforeLayout(childLayoutType == ForceLayout, 946 updateBlockChildDirtyBitsBeforeLayout(childLayoutType == ForceLayout,
953 child); 947 child);
954 if (child.needsLayout() || childLayoutType == ForceLayout || 948 if (child.needsLayout() || childLayoutType == ForceLayout ||
955 !m_intrinsicSizeAlongMainAxis.contains(&child)) { 949 !m_intrinsicSizeAlongMainAxis.contains(&child)) {
956 child.forceChildLayout(); 950 child.forceChildLayout();
957 cacheChildMainSize(child); 951 cacheChildMainSize(child);
958 } 952 }
959 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); 953 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
960 } else { 954 } else {
961 // We don't need to add scrollbarLogicalWidth here. For overflow: scroll, 955 // We don't need to add scrollbarLogicalWidth here because the preferred
962 // the preferred width already includes the scrollbar size (via 956 // width includes the scrollbar, even for overflow: auto.
963 // scrollbarLogicalWidth()). For overflow: auto,
964 // childFlexBaseSizeRequiresLayout returns true and we handle that via the
965 // other branch of this if.
966 mainAxisExtent = child.maxPreferredLogicalWidth(); 957 mainAxisExtent = child.maxPreferredLogicalWidth();
967 } 958 }
968 DCHECK_GE(mainAxisExtent - mainAxisBorderAndPadding, LayoutUnit()) 959 DCHECK_GE(mainAxisExtent - mainAxisBorderAndPadding, LayoutUnit())
969 << mainAxisExtent << " - " << mainAxisBorderAndPadding; 960 << mainAxisExtent << " - " << mainAxisBorderAndPadding;
970 return mainAxisExtent - mainAxisBorderAndPadding; 961 return mainAxisExtent - mainAxisBorderAndPadding;
971 } 962 }
972 963
973 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, 964 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren,
974 SubtreeLayoutScope& layoutScope) { 965 SubtreeLayoutScope& layoutScope) {
975 Vector<LineContext> lineContexts; 966 Vector<LineContext> lineContexts;
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 LayoutUnit originalOffset = 2289 LayoutUnit originalOffset =
2299 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 2290 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
2300 LayoutUnit newOffset = 2291 LayoutUnit newOffset =
2301 contentExtent - originalOffset - lineCrossAxisExtent; 2292 contentExtent - originalOffset - lineCrossAxisExtent;
2302 adjustAlignmentForChild(*child, newOffset - originalOffset); 2293 adjustAlignmentForChild(*child, newOffset - originalOffset);
2303 } 2294 }
2304 } 2295 }
2305 } 2296 }
2306 2297
2307 } // namespace blink 2298 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698