| OLD | NEW |
| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return previousMaxContentFlexFraction; | 157 return previousMaxContentFlexFraction; |
| 158 flexGrow = std::max(1.0f, flexGrow); | 158 flexGrow = std::max(1.0f, flexGrow); |
| 159 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow; | 159 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow; |
| 160 if (previousMaxContentFlexFraction != -1 && | 160 if (previousMaxContentFlexFraction != -1 && |
| 161 maxContentFlexFraction != previousMaxContentFlexFraction) | 161 maxContentFlexFraction != previousMaxContentFlexFraction) |
| 162 UseCounter::count(document(), | 162 UseCounter::count(document(), |
| 163 UseCounter::FlexboxIntrinsicSizeAlgorithmIsDifferent); | 163 UseCounter::FlexboxIntrinsicSizeAlgorithmIsDifferent); |
| 164 return maxContentFlexFraction; | 164 return maxContentFlexFraction; |
| 165 } | 165 } |
| 166 | 166 |
| 167 static int synthesizedBaselineFromContentBox(const LayoutBox& box, | 167 int LayoutFlexibleBox::synthesizedBaselineFromContentBox( |
| 168 LineDirectionMode direction) { | 168 const LayoutBox& box, |
| 169 LineDirectionMode direction) { |
| 169 if (direction == HorizontalLine) { | 170 if (direction == HorizontalLine) { |
| 170 return (box.size().height() - box.borderBottom() - box.paddingBottom() - | 171 return (box.size().height() - box.borderBottom() - box.paddingBottom() - |
| 171 box.verticalScrollbarWidth()) | 172 box.verticalScrollbarWidth()) |
| 172 .toInt(); | 173 .toInt(); |
| 173 } | 174 } |
| 174 return (box.size().width() - box.borderLeft() - box.paddingLeft() - | 175 return (box.size().width() - box.borderLeft() - box.paddingLeft() - |
| 175 box.horizontalScrollbarHeight()) | 176 box.horizontalScrollbarHeight()) |
| 176 .toInt(); | 177 .toInt(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 int LayoutFlexibleBox::baselinePosition(FontBaseline, | 180 int LayoutFlexibleBox::baselinePosition(FontBaseline, |
| 180 bool, | 181 bool, |
| 181 LineDirectionMode direction, | 182 LineDirectionMode direction, |
| 182 LinePositionMode mode) const { | 183 LinePositionMode mode) const { |
| 183 DCHECK_EQ(mode, PositionOnContainingLine); | 184 DCHECK_EQ(mode, PositionOnContainingLine); |
| 184 int baseline = firstLineBoxBaseline(); | 185 int baseline = firstLineBoxBaseline(); |
| 185 if (baseline == -1) | 186 if (baseline == -1) |
| 186 baseline = synthesizedBaselineFromContentBox(*this, direction); | 187 baseline = synthesizedBaselineFromContentBox(*this, direction); |
| 187 | 188 |
| 188 return beforeMarginInLineDirection(direction) + baseline; | 189 return beforeMarginInLineDirection(direction) + baseline; |
| 189 } | 190 } |
| 190 | 191 |
| 191 static const StyleContentAlignmentData& contentAlignmentNormalBehavior() { | 192 const StyleContentAlignmentData& |
| 193 LayoutFlexibleBox::contentAlignmentNormalBehavior() { |
| 192 // The justify-content property applies along the main axis, but since | 194 // The justify-content property applies along the main axis, but since |
| 193 // flexing in the main axis is controlled by flex, stretch behaves as | 195 // flexing in the main axis is controlled by flex, stretch behaves as |
| 194 // flex-start (ignoring the specified fallback alignment, if any). | 196 // flex-start (ignoring the specified fallback alignment, if any). |
| 195 // https://drafts.csswg.org/css-align/#distribution-flex | 197 // https://drafts.csswg.org/css-align/#distribution-flex |
| 196 static const StyleContentAlignmentData normalBehavior = { | 198 static const StyleContentAlignmentData normalBehavior = { |
| 197 ContentPositionNormal, ContentDistributionStretch}; | 199 ContentPositionNormal, ContentDistributionStretch}; |
| 198 return normalBehavior; | 200 return normalBehavior; |
| 199 } | 201 } |
| 200 | 202 |
| 201 int LayoutFlexibleBox::firstLineBoxBaseline() const { | 203 int LayoutFlexibleBox::firstLineBoxBaseline() const { |
| (...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 LayoutUnit originalOffset = | 2168 LayoutUnit originalOffset = |
| 2167 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 2169 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 2168 LayoutUnit newOffset = | 2170 LayoutUnit newOffset = |
| 2169 contentExtent - originalOffset - lineCrossAxisExtent; | 2171 contentExtent - originalOffset - lineCrossAxisExtent; |
| 2170 adjustAlignmentForChild(*flexItem.box, newOffset - originalOffset); | 2172 adjustAlignmentForChild(*flexItem.box, newOffset - originalOffset); |
| 2171 } | 2173 } |
| 2172 } | 2174 } |
| 2173 } | 2175 } |
| 2174 | 2176 |
| 2175 } // namespace blink | 2177 } // namespace blink |
| OLD | NEW |