OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/parser/CSSPropertyParser.h" | 5 #include "core/css/parser/CSSPropertyParser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSBasicShapeValues.h" | 9 #include "core/css/CSSBasicShapeValues.h" |
10 #include "core/css/CSSBorderImage.h" | 10 #include "core/css/CSSBorderImage.h" |
(...skipping 3286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 if (!m_range.atEnd()) | 3297 if (!m_range.atEnd()) |
3298 return false; | 3298 return false; |
3299 | 3299 |
3300 addProperty(CSSPropertyAlignContent, CSSPropertyPlaceContent, | 3300 addProperty(CSSPropertyAlignContent, CSSPropertyPlaceContent, |
3301 *alignContentValue, important); | 3301 *alignContentValue, important); |
3302 addProperty(CSSPropertyJustifyContent, CSSPropertyPlaceContent, | 3302 addProperty(CSSPropertyJustifyContent, CSSPropertyPlaceContent, |
3303 *justifyContentValue, important); | 3303 *justifyContentValue, important); |
3304 return true; | 3304 return true; |
3305 } | 3305 } |
3306 | 3306 |
| 3307 bool CSSPropertyParser::consumePlaceItemsShorthand(bool important) { |
| 3308 DCHECK(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3309 DCHECK_EQ(shorthandForProperty(CSSPropertyPlaceContent).length(), |
| 3310 static_cast<unsigned>(2)); |
| 3311 |
| 3312 // align-items property does not allow the 'auto' value. |
| 3313 if (identMatches<CSSValueAuto>(m_range.peek().id())) |
| 3314 return false; |
| 3315 |
| 3316 CSSValue* alignItemsValue = |
| 3317 CSSPropertyAlignmentUtils::consumeSimplifiedItemPosition(m_range); |
| 3318 if (!alignItemsValue) |
| 3319 return false; |
| 3320 CSSValue* justifyItemsValue = |
| 3321 m_range.atEnd() |
| 3322 ? alignItemsValue |
| 3323 : CSSPropertyAlignmentUtils::consumeSimplifiedItemPosition(m_range); |
| 3324 if (!justifyItemsValue) |
| 3325 return false; |
| 3326 |
| 3327 if (!m_range.atEnd()) |
| 3328 return false; |
| 3329 |
| 3330 addProperty(CSSPropertyAlignItems, CSSPropertyPlaceItems, *alignItemsValue, |
| 3331 important); |
| 3332 addProperty(CSSPropertyJustifyItems, CSSPropertyPlaceItems, |
| 3333 *justifyItemsValue, important); |
| 3334 return true; |
| 3335 } |
| 3336 |
3307 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, | 3337 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, |
3308 bool important) { | 3338 bool important) { |
3309 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3339 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3310 | 3340 |
3311 // Gets the parsing method for our current property from the property API. | 3341 // Gets the parsing method for our current property from the property API. |
3312 // If it has been implemented, we call this method, otherwise we manually | 3342 // If it has been implemented, we call this method, otherwise we manually |
3313 // parse this value in the switch statement below. As we implement APIs for | 3343 // parse this value in the switch statement below. As we implement APIs for |
3314 // other properties, those properties will be taken out of the switch | 3344 // other properties, those properties will be taken out of the switch |
3315 // statement. | 3345 // statement. |
3316 const CSSPropertyDescriptor& cssPropertyDesc = | 3346 const CSSPropertyDescriptor& cssPropertyDesc = |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3558 case CSSPropertyGridRow: | 3588 case CSSPropertyGridRow: |
3559 return consumeGridItemPositionShorthand(property, important); | 3589 return consumeGridItemPositionShorthand(property, important); |
3560 case CSSPropertyGridArea: | 3590 case CSSPropertyGridArea: |
3561 return consumeGridAreaShorthand(important); | 3591 return consumeGridAreaShorthand(important); |
3562 case CSSPropertyGridTemplate: | 3592 case CSSPropertyGridTemplate: |
3563 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); | 3593 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); |
3564 case CSSPropertyGrid: | 3594 case CSSPropertyGrid: |
3565 return consumeGridShorthand(important); | 3595 return consumeGridShorthand(important); |
3566 case CSSPropertyPlaceContent: | 3596 case CSSPropertyPlaceContent: |
3567 return consumePlaceContentShorthand(important); | 3597 return consumePlaceContentShorthand(important); |
| 3598 case CSSPropertyPlaceItems: |
| 3599 return consumePlaceItemsShorthand(important); |
3568 default: | 3600 default: |
3569 return false; | 3601 return false; |
3570 } | 3602 } |
3571 } | 3603 } |
3572 | 3604 |
3573 } // namespace blink | 3605 } // namespace blink |
OLD | NEW |