Chromium Code Reviews| 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 841 if (direction == ForColumns) | 841 if (direction == ForColumns) |
| 842 return child.hasRelativeLogicalWidth() || child.styleRef().logicalWidth( ).isIntrinsicOrAuto(); | 842 return child.hasRelativeLogicalWidth() || child.styleRef().logicalWidth( ).isIntrinsicOrAuto(); |
| 843 return child.hasRelativeLogicalHeight() || child.styleRef().logicalHeight(). isIntrinsicOrAuto(); | 843 return child.hasRelativeLogicalHeight() || child.styleRef().logicalHeight(). isIntrinsicOrAuto(); |
| 844 } | 844 } |
| 845 | 845 |
| 846 const GridTrackSize& LayoutGrid::rawGridTrackSize(GridTrackSizingDirection direc tion, size_t translatedIndex) const | 846 const GridTrackSize& LayoutGrid::rawGridTrackSize(GridTrackSizingDirection direc tion, size_t translatedIndex) const |
| 847 { | 847 { |
| 848 bool isRowAxis = direction == ForColumns; | 848 bool isRowAxis = direction == ForColumns; |
| 849 const Vector<GridTrackSize>& trackStyles = isRowAxis ? styleRef().gridTempla teColumns() : styleRef().gridTemplateRows(); | 849 const Vector<GridTrackSize>& trackStyles = isRowAxis ? styleRef().gridTempla teColumns() : styleRef().gridTemplateRows(); |
| 850 const Vector<GridTrackSize>& autoRepeatTrackStyles = isRowAxis ? styleRef(). gridAutoRepeatColumns() : styleRef().gridAutoRepeatRows(); | 850 const Vector<GridTrackSize>& autoRepeatTrackStyles = isRowAxis ? styleRef(). gridAutoRepeatColumns() : styleRef().gridAutoRepeatRows(); |
| 851 const GridTrackSize& autoTrackSize = isRowAxis ? styleRef().gridAutoColumns( ) : styleRef().gridAutoRows(); | 851 const Vector<GridTrackSize>& autoTrackStyles = isRowAxis ? styleRef().gridAu toColumns() : styleRef().gridAutoRows(); |
| 852 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); | 852 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); |
| 853 size_t repetitions = autoRepeatCountForDirection(direction); | 853 size_t repetitions = autoRepeatCountForDirection(direction); |
| 854 | 854 |
| 855 // We should not use GridPositionsResolver::explicitGridXXXCount() for this because the | 855 // We should not use GridPositionsResolver::explicitGridXXXCount() for this because the |
| 856 // explicit grid might be larger than the number of tracks in grid-template- rows|columns (if | 856 // explicit grid might be larger than the number of tracks in grid-template- rows|columns (if |
| 857 // grid-template-areas is specified for example). | 857 // grid-template-areas is specified for example). |
| 858 size_t explicitTracksCount = trackStyles.size() + repetitions; | 858 size_t explicitTracksCount = trackStyles.size() + repetitions; |
| 859 | 859 |
| 860 int untranslatedIndexAsInt = translatedIndex + (isRowAxis ? m_smallestColumn Start : m_smallestRowStart); | 860 int untranslatedIndexAsInt = translatedIndex + (isRowAxis ? m_smallestColumn Start : m_smallestRowStart); |
| 861 if (untranslatedIndexAsInt < 0) | 861 if (untranslatedIndexAsInt < 0) { |
| 862 return autoTrackSize; | 862 size_t autoTrackStylesSize = autoTrackStyles.size(); |
|
Manuel Rego
2016/07/22 08:24:55
What about defining it as an int to avoid the cast
svillar
2016/07/22 13:08:28
We're using it as size_t later anyway.
| |
| 863 int index = untranslatedIndexAsInt % static_cast<int>(autoTrackStylesSiz e); | |
| 864 // We need to traspose the index because the first negative implicit lin e will get the last defined auto track and so on. | |
| 865 index += index ? autoTrackStylesSize : 0; | |
| 866 return autoTrackStyles[index]; | |
| 867 } | |
| 863 | 868 |
| 864 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt); | 869 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt); |
| 865 if (untranslatedIndex >= explicitTracksCount) | 870 if (untranslatedIndex >= explicitTracksCount) |
| 866 return autoTrackSize; | 871 return autoTrackStyles[(untranslatedIndex - explicitTracksCount) % autoT rackStyles.size()]; |
| 867 | 872 |
| 868 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) | 873 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) |
| 869 return trackStyles[untranslatedIndex]; | 874 return trackStyles[untranslatedIndex]; |
| 870 | 875 |
| 871 if (untranslatedIndex < (insertionPoint + repetitions)) | 876 if (untranslatedIndex < (insertionPoint + repetitions)) |
| 872 return autoRepeatTrackStyles[0]; | 877 return autoRepeatTrackStyles[0]; |
| 873 | 878 |
| 874 return trackStyles[untranslatedIndex - repetitions]; | 879 return trackStyles[untranslatedIndex - repetitions]; |
| 875 } | 880 } |
| 876 | 881 |
| (...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2539 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2544 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
| 2540 } | 2545 } |
| 2541 | 2546 |
| 2542 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2547 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
| 2543 { | 2548 { |
| 2544 if (!m_gridItemArea.isEmpty()) | 2549 if (!m_gridItemArea.isEmpty()) |
| 2545 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2550 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2546 } | 2551 } |
| 2547 | 2552 |
| 2548 } // namespace blink | 2553 } // namespace blink |
| OLD | NEW |