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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 1807603002: Move the grid-column/grid-row shorthands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 // 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 "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSBasicShapeValues.h" 8 #include "core/css/CSSBasicShapeValues.h"
9 #include "core/css/CSSBorderImage.h" 9 #include "core/css/CSSBorderImage.h"
10 #include "core/css/CSSContentDistributionValue.h" 10 #include "core/css/CSSContentDistributionValue.h"
(...skipping 4431 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 4442
4443 for (size_t i = 0; i < longhandCount; ++i) { 4443 for (size_t i = 0; i < longhandCount; ++i) {
4444 CSSPropertyID property = shorthand.properties()[i]; 4444 CSSPropertyID property = shorthand.properties()[i];
4445 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u seLegacyBackgroundSizeShorthandBehavior()) 4445 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u seLegacyBackgroundSizeShorthandBehavior())
4446 continue; 4446 continue;
4447 addProperty(property, longhands[i].release(), important, implicit); 4447 addProperty(property, longhands[i].release(), important, implicit);
4448 } 4448 }
4449 return true; 4449 return true;
4450 } 4450 }
4451 4451
4452 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthand Id, bool important)
4453 {
4454 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4455 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
4456 ASSERT(shorthand.length() == 2);
4457 RefPtrWillBeRawPtr<CSSValue> startValue = consumeGridLine(m_range);
4458 if (!startValue)
4459 return false;
4460
4461 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr;
4462 if (!m_range.atEnd()) {
Timothy Loh 2016/03/17 23:14:55 I think more regular to do if (consumeSlash..) {
4463 if (!consumeSlashIncludingWhitespace(m_range))
4464 return false;
4465 endValue = consumeGridLine(m_range);
4466 if (!endValue || !m_range.atEnd())
4467 return false;
4468 } else {
4469 endValue = startValue->isCustomIdentValue() ? startValue : cssValuePool( ).createIdentifierValue(CSSValueAuto);
4470 }
4471 addProperty(shorthand.properties()[0], startValue, important);
4472 addProperty(shorthand.properties()[1], endValue, important);
4473 return true;
4474 }
4475
4452 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im portant) 4476 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im portant)
4453 { 4477 {
4454 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 4478 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
4455 4479
4456 CSSPropertyID oldShorthand = m_currentShorthand; 4480 CSSPropertyID oldShorthand = m_currentShorthand;
4457 // TODO(rob.buis): Remove this when the legacy property parser is gone 4481 // TODO(rob.buis): Remove this when the legacy property parser is gone
4458 m_currentShorthand = property; 4482 m_currentShorthand = property;
4459 switch (property) { 4483 switch (property) {
4460 case CSSPropertyWebkitMarginCollapse: { 4484 case CSSPropertyWebkitMarginCollapse: {
4461 CSSValueID id = m_range.consumeIncludingWhitespace().id(); 4485 CSSValueID id = m_range.consumeIncludingWhitespace().id();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 RefPtrWillBeRawPtr<CSSValue> rowGap = consumeLength(m_range, m_context.m ode(), ValueRangeNonNegative); 4643 RefPtrWillBeRawPtr<CSSValue> rowGap = consumeLength(m_range, m_context.m ode(), ValueRangeNonNegative);
4620 RefPtrWillBeRawPtr<CSSValue> columnGap = consumeLength(m_range, m_contex t.mode(), ValueRangeNonNegative); 4644 RefPtrWillBeRawPtr<CSSValue> columnGap = consumeLength(m_range, m_contex t.mode(), ValueRangeNonNegative);
4621 if (!rowGap || !m_range.atEnd()) 4645 if (!rowGap || !m_range.atEnd())
4622 return false; 4646 return false;
4623 if (!columnGap) 4647 if (!columnGap)
4624 columnGap = rowGap; 4648 columnGap = rowGap;
4625 addProperty(CSSPropertyGridRowGap, rowGap.release(), important); 4649 addProperty(CSSPropertyGridRowGap, rowGap.release(), important);
4626 addProperty(CSSPropertyGridColumnGap, columnGap.release(), important); 4650 addProperty(CSSPropertyGridColumnGap, columnGap.release(), important);
4627 return true; 4651 return true;
4628 } 4652 }
4653 case CSSPropertyGridColumn:
4654 case CSSPropertyGridRow:
4655 return consumeGridItemPositionShorthand(property, important);
4629 default: 4656 default:
4630 m_currentShorthand = oldShorthand; 4657 m_currentShorthand = oldShorthand;
4631 CSSParserValueList valueList(m_range); 4658 CSSParserValueList valueList(m_range);
4632 if (!valueList.size()) 4659 if (!valueList.size())
4633 return false; 4660 return false;
4634 m_valueList = &valueList; 4661 m_valueList = &valueList;
4635 return legacyParseShorthand(unresolvedProperty, important); 4662 return legacyParseShorthand(unresolvedProperty, important);
4636 } 4663 }
4637 } 4664 }
4638 4665
4639 } // namespace blink 4666 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698