| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 kForRows, LogicalHeight() - track_based_logical_height); | 324 kForRows, LogicalHeight() - track_based_logical_height); |
| 325 } | 325 } |
| 326 | 326 |
| 327 // TODO (lajava): We need to compute baselines after step 2 so | 327 // TODO (lajava): We need to compute baselines after step 2 so |
| 328 // items with a relative size (percentages) can resolve it before | 328 // items with a relative size (percentages) can resolve it before |
| 329 // determining its baseline. However, we only set item's grid area | 329 // determining its baseline. However, we only set item's grid area |
| 330 // (via override sizes) as part of the content-sized tracks sizing | 330 // (via override sizes) as part of the content-sized tracks sizing |
| 331 // logic. Hence, items located at fixed or flexible tracks can't | 331 // logic. Hence, items located at fixed or flexible tracks can't |
| 332 // resolve correctly their size at this stage, which may lead to | 332 // resolve correctly their size at this stage, which may lead to |
| 333 // an incorrect computation of their shared context's baseline. | 333 // an incorrect computation of their shared context's baseline. |
| 334 ComputeBaselineAlignmentContext(); | 334 // ComputeBaselineAlignmentContext(); |
| 335 | 335 |
| 336 // 3- If the min-content contribution of any grid items have changed based | 336 // 3- If the min-content contribution of any grid items have changed based |
| 337 // on the row sizes calculated in step 2, steps 1 and 2 are repeated with | 337 // on the row sizes calculated in step 2, steps 1 and 2 are repeated with |
| 338 // the new min-content contribution (once only). | 338 // the new min-content contribution (once only). |
| 339 RepeatTracksSizingIfNeeded(available_space_for_columns, | 339 RepeatTracksSizingIfNeeded(available_space_for_columns, |
| 340 ContentLogicalHeight()); | 340 ContentLogicalHeight()); |
| 341 | 341 |
| 342 // Grid container should have the minimum height of a line if it's editable. | 342 // Grid container should have the minimum height of a line if it's editable. |
| 343 // That doesn't affect track sizing though. | 343 // That doesn't affect track sizing though. |
| 344 if (HasLineIfEmpty()) | 344 if (HasLineIfEmpty()) |
| (...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 } | 2126 } |
| 2127 | 2127 |
| 2128 LayoutUnit LayoutGrid::ColumnAxisOffsetForChild(const LayoutBox& child) const { | 2128 LayoutUnit LayoutGrid::ColumnAxisOffsetForChild(const LayoutBox& child) const { |
| 2129 const GridSpan& rows_span = | 2129 const GridSpan& rows_span = |
| 2130 track_sizing_algorithm_.GetGrid().GridItemSpan(child, kForRows); | 2130 track_sizing_algorithm_.GetGrid().GridItemSpan(child, kForRows); |
| 2131 size_t child_start_line = rows_span.StartLine(); | 2131 size_t child_start_line = rows_span.StartLine(); |
| 2132 LayoutUnit start_of_row = row_positions_[child_start_line]; | 2132 LayoutUnit start_of_row = row_positions_[child_start_line]; |
| 2133 LayoutUnit start_position = start_of_row + MarginBeforeForChild(child); | 2133 LayoutUnit start_position = start_of_row + MarginBeforeForChild(child); |
| 2134 if (HasAutoMarginsInColumnAxis(child)) | 2134 if (HasAutoMarginsInColumnAxis(child)) |
| 2135 return start_position; | 2135 return start_position; |
| 2136 if (IsBaselineAlignmentForChild(child, kGridColumnAxis)) |
| 2137 start_position += ColumnAxisBaselineOffsetForChild(child); |
| 2136 GridAxisPosition axis_position = ColumnAxisPositionForChild(child); | 2138 GridAxisPosition axis_position = ColumnAxisPositionForChild(child); |
| 2137 switch (axis_position) { | 2139 switch (axis_position) { |
| 2138 case kGridAxisStart: | 2140 case kGridAxisStart: |
| 2139 return start_position + ColumnAxisBaselineOffsetForChild(child); | 2141 return start_position; |
| 2140 case kGridAxisEnd: | 2142 case kGridAxisEnd: |
| 2141 case kGridAxisCenter: { | 2143 case kGridAxisCenter: { |
| 2142 size_t child_end_line = rows_span.EndLine(); | 2144 size_t child_end_line = rows_span.EndLine(); |
| 2143 LayoutUnit end_of_row = row_positions_[child_end_line]; | 2145 LayoutUnit end_of_row = row_positions_[child_end_line]; |
| 2144 // m_rowPositions include distribution offset (because of content | 2146 // m_rowPositions include distribution offset (because of content |
| 2145 // alignment) and gutters so we need to subtract them to get the actual | 2147 // alignment) and gutters so we need to subtract them to get the actual |
| 2146 // end position for a given row (this does not have to be done for the | 2148 // end position for a given row (this does not have to be done for the |
| 2147 // last track as there are no more m_columnPositions after it). | 2149 // last track as there are no more m_columnPositions after it). |
| 2148 LayoutUnit track_gap = GridGap(kForRows); | 2150 LayoutUnit track_gap = GridGap(kForRows); |
| 2149 if (child_end_line < row_positions_.size() - 1) { | 2151 if (child_end_line < row_positions_.size() - 1) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2168 } | 2170 } |
| 2169 | 2171 |
| 2170 LayoutUnit LayoutGrid::RowAxisOffsetForChild(const LayoutBox& child) const { | 2172 LayoutUnit LayoutGrid::RowAxisOffsetForChild(const LayoutBox& child) const { |
| 2171 const GridSpan& columns_span = | 2173 const GridSpan& columns_span = |
| 2172 track_sizing_algorithm_.GetGrid().GridItemSpan(child, kForColumns); | 2174 track_sizing_algorithm_.GetGrid().GridItemSpan(child, kForColumns); |
| 2173 size_t child_start_line = columns_span.StartLine(); | 2175 size_t child_start_line = columns_span.StartLine(); |
| 2174 LayoutUnit start_of_column = column_positions_[child_start_line]; | 2176 LayoutUnit start_of_column = column_positions_[child_start_line]; |
| 2175 LayoutUnit start_position = start_of_column + MarginStartForChild(child); | 2177 LayoutUnit start_position = start_of_column + MarginStartForChild(child); |
| 2176 if (HasAutoMarginsInRowAxis(child)) | 2178 if (HasAutoMarginsInRowAxis(child)) |
| 2177 return start_position; | 2179 return start_position; |
| 2180 if (IsBaselineAlignmentForChild(child, kGridRowAxis)) |
| 2181 start_position += RowAxisBaselineOffsetForChild(child); |
| 2178 GridAxisPosition axis_position = RowAxisPositionForChild(child); | 2182 GridAxisPosition axis_position = RowAxisPositionForChild(child); |
| 2179 switch (axis_position) { | 2183 switch (axis_position) { |
| 2180 case kGridAxisStart: | 2184 case kGridAxisStart: |
| 2181 return start_position + RowAxisBaselineOffsetForChild(child); | 2185 return start_position; |
| 2182 case kGridAxisEnd: | 2186 case kGridAxisEnd: |
| 2183 case kGridAxisCenter: { | 2187 case kGridAxisCenter: { |
| 2184 size_t child_end_line = columns_span.EndLine(); | 2188 size_t child_end_line = columns_span.EndLine(); |
| 2185 LayoutUnit end_of_column = column_positions_[child_end_line]; | 2189 LayoutUnit end_of_column = column_positions_[child_end_line]; |
| 2186 // m_columnPositions include distribution offset (because of content | 2190 // m_columnPositions include distribution offset (because of content |
| 2187 // alignment) and gutters so we need to subtract them to get the actual | 2191 // alignment) and gutters so we need to subtract them to get the actual |
| 2188 // end position for a given column (this does not have to be done for the | 2192 // end position for a given column (this does not have to be done for the |
| 2189 // last track as there are no more m_columnPositions after it). | 2193 // last track as there are no more m_columnPositions after it). |
| 2190 LayoutUnit track_gap = GridGap(kForColumns); | 2194 LayoutUnit track_gap = GridGap(kForColumns); |
| 2191 if (child_end_line < column_positions_.size() - 1) { | 2195 if (child_end_line < column_positions_.size() - 1) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 if (direction == kForRows) | 2408 if (direction == kForRows) |
| 2405 return grid.NumTracks(kForRows); | 2409 return grid.NumTracks(kForRows); |
| 2406 | 2410 |
| 2407 return grid.NumTracks(kForRows) | 2411 return grid.NumTracks(kForRows) |
| 2408 ? grid.NumTracks(kForColumns) | 2412 ? grid.NumTracks(kForColumns) |
| 2409 : GridPositionsResolver::ExplicitGridColumnCount( | 2413 : GridPositionsResolver::ExplicitGridColumnCount( |
| 2410 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2414 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
| 2411 } | 2415 } |
| 2412 | 2416 |
| 2413 } // namespace blink | 2417 } // namespace blink |
| OLD | NEW |