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

Side by Side Diff: sky/engine/core/rendering/RenderFlexibleBox.cpp

Issue 944073006: Remove the concept of staticly positioned absolutes. (Closed) Base URL: git@github.com:domokit/mojo.git@position
Patch Set: Created 5 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 } 875 }
876 876
877 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize) 877 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize)
878 { 878 {
879 if (hasOrthogonalFlow(child)) 879 if (hasOrthogonalFlow(child))
880 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight()); 880 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight());
881 else 881 else
882 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth()); 882 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth());
883 } 883 }
884 884
885 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode )
886 {
887 ASSERT(child->isOutOfFlowPositioned());
888 child->containingBlock()->insertPositionedObject(child);
889 RenderLayer* childLayer = child->layer();
890 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t;
891 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse)
892 inlinePosition = mainAxisExtent() - mainAxisOffset;
893 childLayer->setStaticInlinePosition(inlinePosition);
894
895 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis Offset;
896 if (childLayer->staticBlockPosition() != staticBlockPosition) {
897 childLayer->setStaticBlockPosition(staticBlockPosition);
898 if (child->style()->hasStaticBlockPosition())
899 child->setChildNeedsLayout(MarkOnlyThis);
900 }
901 }
902
903 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox* child) const 885 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox* child) const
904 { 886 {
905 ItemPosition align = resolveAlignment(style(), child->style()); 887 ItemPosition align = resolveAlignment(style(), child->style());
906 888
907 if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) 889 if (align == ItemPositionBaseline && hasOrthogonalFlow(child))
908 align = ItemPositionFlexStart; 890 align = ItemPositionFlexStart;
909 891
910 if (style()->flexWrap() == FlexWrapReverse) { 892 if (style()->flexWrap() == FlexWrapReverse) {
911 if (align == ItemPositionFlexStart) 893 if (align == ItemPositionFlexStart)
912 align = ItemPositionFlexEnd; 894 align = ItemPositionFlexEnd;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 947
966 LayoutUnit totalMainExtent = mainAxisExtent(); 948 LayoutUnit totalMainExtent = mainAxisExtent();
967 LayoutUnit maxAscent = 0, maxDescent = 0; // Used when align-items: baseline . 949 LayoutUnit maxAscent = 0, maxDescent = 0; // Used when align-items: baseline .
968 LayoutUnit maxChildCrossAxisExtent = 0; 950 LayoutUnit maxChildCrossAxisExtent = 0;
969 size_t seenInFlowPositionedChildren = 0; 951 size_t seenInFlowPositionedChildren = 0;
970 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); 952 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow();
971 for (size_t i = 0; i < children.size(); ++i) { 953 for (size_t i = 0; i < children.size(); ++i) {
972 RenderBox* child = children[i]; 954 RenderBox* child = children[i];
973 955
974 if (child->isOutOfFlowPositioned()) { 956 if (child->isOutOfFlowPositioned()) {
975 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs et, FlipForRowReverse); 957 child->containingBlock()->insertPositionedObject(child);
976 continue; 958 continue;
977 } 959 }
978 960
979 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding ExtentForChild(child); 961 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding ExtentForChild(child);
980 setLogicalOverrideSize(child, childPreferredSize); 962 setLogicalOverrideSize(child, childPreferredSize);
981 if (childPreferredSize != mainAxisExtentForChild(child)) { 963 if (childPreferredSize != mainAxisExtentForChild(child)) {
982 child->setChildNeedsLayout(MarkOnlyThis); 964 child->setChildNeedsLayout(MarkOnlyThis);
983 } else { 965 } else {
984 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here. 966 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here.
985 resetAutoMarginsAndLogicalTopInCrossAxis(child); 967 resetAutoMarginsAndLogicalTopInCrossAxis(child);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 // starting from the end of the flexbox. We also don't need to layout anythi ng since we're 1028 // starting from the end of the flexbox. We also don't need to layout anythi ng since we're
1047 // just moving the children to a new position. 1029 // just moving the children to a new position.
1048 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children); 1030 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children);
1049 LayoutUnit mainAxisOffset = logicalHeight() - flowAwareBorderEnd() - flowAwa rePaddingEnd(); 1031 LayoutUnit mainAxisOffset = logicalHeight() - flowAwareBorderEnd() - flowAwa rePaddingEnd();
1050 mainAxisOffset -= initialJustifyContentOffset(availableFreeSpace, style()->j ustifyContent(), numberOfChildrenForJustifyContent); 1032 mainAxisOffset -= initialJustifyContentOffset(availableFreeSpace, style()->j ustifyContent(), numberOfChildrenForJustifyContent);
1051 1033
1052 size_t seenInFlowPositionedChildren = 0; 1034 size_t seenInFlowPositionedChildren = 0;
1053 for (size_t i = 0; i < children.size(); ++i) { 1035 for (size_t i = 0; i < children.size(); ++i) {
1054 RenderBox* child = children[i]; 1036 RenderBox* child = children[i];
1055 1037
1056 if (child->isOutOfFlowPositioned()) { 1038 if (child->isOutOfFlowPositioned())
1057 child->layer()->setStaticBlockPosition(mainAxisOffset);
1058 continue; 1039 continue;
1059 } 1040
1060 mainAxisOffset -= mainAxisExtentForChild(child) + flowAwareMarginEndForC hild(child); 1041 mainAxisOffset -= mainAxisExtentForChild(child) + flowAwareMarginEndForC hild(child);
1061 1042
1062 setFlowAwareLocationForChild(child, LayoutPoint(mainAxisOffset, crossAxi sOffset + flowAwareMarginBeforeForChild(child))); 1043 setFlowAwareLocationForChild(child, LayoutPoint(mainAxisOffset, crossAxi sOffset + flowAwareMarginBeforeForChild(child)));
1063 1044
1064 mainAxisOffset -= flowAwareMarginStartForChild(child); 1045 mainAxisOffset -= flowAwareMarginStartForChild(child);
1065 1046
1066 ++seenInFlowPositionedChildren; 1047 ++seenInFlowPositionedChildren;
1067 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) 1048 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent)
1068 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp ace, style()->justifyContent(), numberOfChildrenForJustifyContent); 1049 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp ace, style()->justifyContent(), numberOfChildrenForJustifyContent);
1069 } 1050 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 if (style()->alignContent() == AlignContentStretch && availableCrossAxis Space > 0) 1105 if (style()->alignContent() == AlignContentStretch && availableCrossAxis Space > 0)
1125 lineContexts[lineNumber].crossAxisExtent += availableCrossAxisSpace / static_cast<unsigned>(lineContexts.size()); 1106 lineContexts[lineNumber].crossAxisExtent += availableCrossAxisSpace / static_cast<unsigned>(lineContexts.size());
1126 1107
1127 lineOffset += alignContentSpaceBetweenChildren(availableCrossAxisSpace, style()->alignContent(), lineContexts.size()); 1108 lineOffset += alignContentSpaceBetweenChildren(availableCrossAxisSpace, style()->alignContent(), lineContexts.size());
1128 } 1109 }
1129 } 1110 }
1130 1111
1131 void RenderFlexibleBox::adjustAlignmentForChild(RenderBox* child, LayoutUnit del ta) 1112 void RenderFlexibleBox::adjustAlignmentForChild(RenderBox* child, LayoutUnit del ta)
1132 { 1113 {
1133 if (child->isOutOfFlowPositioned()) { 1114 if (child->isOutOfFlowPositioned()) {
1134 LayoutUnit staticInlinePosition = child->layer()->staticInlinePosition() ;
1135 LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition();
1136 LayoutUnit mainAxis = isColumnFlow() ? staticBlockPosition : staticInlin ePosition;
1137 LayoutUnit crossAxis = isColumnFlow() ? staticInlinePosition : staticBlo ckPosition;
1138 crossAxis += delta;
1139 prepareChildForPositionedLayout(child, mainAxis, crossAxis, NoFlipForRow Reverse);
1140 return; 1115 return;
1141 } 1116 }
1142 1117
1143 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + Layou tSize(0, delta)); 1118 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + Layou tSize(0, delta));
1144 } 1119 }
1145 1120
1146 void RenderFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) 1121 void RenderFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts)
1147 { 1122 {
1148 // Keep track of the space between the baseline edge and the after edge of t he box for each line. 1123 // Keep track of the space between the baseline edge and the after edge of t he box for each line.
1149 Vector<LayoutUnit> minMarginAfterBaselines; 1124 Vector<LayoutUnit> minMarginAfterBaselines;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 ASSERT(child); 1259 ASSERT(child);
1285 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1260 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1286 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1261 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1287 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1262 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1288 adjustAlignmentForChild(child, newOffset - originalOffset); 1263 adjustAlignmentForChild(child, newOffset - originalOffset);
1289 } 1264 }
1290 } 1265 }
1291 } 1266 }
1292 1267
1293 } 1268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698