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

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

Issue 1715513002: Move background related shorthands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unify convertOriginLength and convertPositionLength 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/CSSCalculationValue.h" 10 #include "core/css/CSSCalculationValue.h"
(...skipping 4481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4492 ASSERT_NOT_REACHED(); 4492 ASSERT_NOT_REACHED();
4493 } 4493 }
4494 if (value == CSSValueInvalid) 4494 if (value == CSSValueInvalid)
4495 return false; 4495 return false;
4496 4496
4497 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); 4497 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property);
4498 addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value ), important); 4498 addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value ), important);
4499 return true; 4499 return true;
4500 } 4500 }
4501 4501
4502 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParse rContext& context, UnitlessQuirk unitless, RefPtrWillBeRawPtr<CSSValue>& resultX , RefPtrWillBeRawPtr<CSSValue>& resultY)
4503 {
4504 do {
4505 RefPtrWillBeRawPtr<CSSValue> positionX = nullptr;
4506 RefPtrWillBeRawPtr<CSSValue> positionY = nullptr;
4507 if (!consumePosition(range, context.mode(), unitless, positionX, positio nY))
Timothy Loh 2016/02/29 05:45:25 not sure if I said this yet, but careful with the
4508 return false;
4509 addBackgroundValue(resultX, positionX);
4510 addBackgroundValue(resultY, positionY);
4511 } while (consumeCommaIncludingWhitespace(range));
4512 return true;
4513 }
4514
4515 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, RefPtrWillBe RawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, bool& implicit)
4516 {
4517 if (consumeIdent<CSSValueRepeatX>(range)) {
4518 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat);
4519 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
4520 implicit = true;
4521 return true;
4522 }
4523 if (consumeIdent<CSSValueRepeatY>(range)) {
4524 value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
4525 value2 = cssValuePool().createIdentifierValue(CSSValueRepeat);
4526 implicit = true;
4527 return true;
4528 }
4529 value1 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa lueSpace>(range);
4530 if (!value1)
4531 return false;
4532
4533 value2 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa lueSpace>(range);
4534 if (!value2) {
4535 value2 = value1;
4536 implicit = true;
4537 }
4538 return true;
4539 }
4540
4541 static bool consumeRepeatStyle(CSSParserTokenRange& range, RefPtrWillBeRawPtr<CS SValue>& resultX, RefPtrWillBeRawPtr<CSSValue>& resultY, bool& implicit)
4542 {
4543 do {
4544 RefPtrWillBeRawPtr<CSSValue> repeatX = nullptr;
4545 RefPtrWillBeRawPtr<CSSValue> repeatY = nullptr;
4546 if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit))
4547 return false;
4548 addBackgroundValue(resultX, repeatX);
4549 addBackgroundValue(resultY, repeatY);
4550 } while (consumeCommaIncludingWhitespace(range));
4551 return true;
4552 }
4553
4502 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im portant) 4554 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im portant)
4503 { 4555 {
4504 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 4556 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
4505 4557
4506 CSSPropertyID oldShorthand = m_currentShorthand; 4558 CSSPropertyID oldShorthand = m_currentShorthand;
4507 // TODO(rob.buis): Remove this when the legacy property parser is gone 4559 // TODO(rob.buis): Remove this when the legacy property parser is gone
4508 m_currentShorthand = property; 4560 m_currentShorthand = property;
4509 switch (property) { 4561 switch (property) {
4510 case CSSPropertyWebkitMarginCollapse: { 4562 case CSSPropertyWebkitMarginCollapse: {
4511 CSSValueID id = m_range.consumeIncludingWhitespace().id(); 4563 CSSValueID id = m_range.consumeIncludingWhitespace().id();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 case CSSPropertyBorderImage: 4685 case CSSPropertyBorderImage:
4634 case CSSPropertyWebkitMaskBoxImage: 4686 case CSSPropertyWebkitMaskBoxImage:
4635 return consumeBorderImage(property, important); 4687 return consumeBorderImage(property, important);
4636 case CSSPropertyPageBreakAfter: 4688 case CSSPropertyPageBreakAfter:
4637 case CSSPropertyPageBreakBefore: 4689 case CSSPropertyPageBreakBefore:
4638 case CSSPropertyPageBreakInside: 4690 case CSSPropertyPageBreakInside:
4639 case CSSPropertyWebkitColumnBreakAfter: 4691 case CSSPropertyWebkitColumnBreakAfter:
4640 case CSSPropertyWebkitColumnBreakBefore: 4692 case CSSPropertyWebkitColumnBreakBefore:
4641 case CSSPropertyWebkitColumnBreakInside: 4693 case CSSPropertyWebkitColumnBreakInside:
4642 return consumeLegacyBreakProperty(property, important); 4694 return consumeLegacyBreakProperty(property, important);
4695 case CSSPropertyWebkitMaskPosition:
4696 case CSSPropertyBackgroundPosition: {
4697 RefPtrWillBeRawPtr<CSSValue> resultX = nullptr;
4698 RefPtrWillBeRawPtr<CSSValue> resultY = nullptr;
4699 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow, resultX, resultY) || !m_range.atEnd())
4700 return false;
4701 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg roundPositionX : CSSPropertyWebkitMaskPositionX, resultX.release(), important);
4702 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg roundPositionY : CSSPropertyWebkitMaskPositionY, resultY.release(), important);
4703 return true;
4704 }
4705 case CSSPropertyBackgroundRepeat:
4706 case CSSPropertyWebkitMaskRepeat: {
4707 RefPtrWillBeRawPtr<CSSValue> resultX = nullptr;
4708 RefPtrWillBeRawPtr<CSSValue> resultY = nullptr;
4709 bool implicit = false;
4710 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range .atEnd())
4711 return false;
4712 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro undRepeatX : CSSPropertyWebkitMaskRepeatX, resultX.release(), important, implici t);
4713 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro undRepeatY : CSSPropertyWebkitMaskRepeatY, resultY.release(), important, implici t);
4714 return true;
4715 }
4643 default: 4716 default:
4644 m_currentShorthand = oldShorthand; 4717 m_currentShorthand = oldShorthand;
4645 CSSParserValueList valueList(m_range); 4718 CSSParserValueList valueList(m_range);
4646 if (!valueList.size()) 4719 if (!valueList.size())
4647 return false; 4720 return false;
4648 m_valueList = &valueList; 4721 m_valueList = &valueList;
4649 return legacyParseShorthand(unresolvedProperty, important); 4722 return legacyParseShorthand(unresolvedProperty, important);
4650 } 4723 }
4651 } 4724 }
4652 4725
4653 } // namespace blink 4726 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698