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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
7 | 7 |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/CSSCustomIdentValue.h" | 10 #include "core/css/CSSCustomIdentValue.h" |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 int i = defaultValue; | 656 int i = defaultValue; |
657 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> counterValue = consumeInteger( range, cssParserMode)) | 657 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> counterValue = consumeInteger( range, cssParserMode)) |
658 i = clampTo<int>(counterValue->getDoubleValue()); | 658 i = clampTo<int>(counterValue->getDoubleValue()); |
659 list->append(CSSValuePair::create(counterName.release(), | 659 list->append(CSSValuePair::create(counterName.release(), |
660 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number), | 660 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number), |
661 CSSValuePair::DropIdenticalValues)); | 661 CSSValuePair::DropIdenticalValues)); |
662 } while (!range.atEnd()); | 662 } while (!range.atEnd()); |
663 return list.release(); | 663 return list.release(); |
664 } | 664 } |
665 | 665 |
666 static PassRefPtrWillBeRawPtr<CSSValue> consumeTextIndent(CSSParserTokenRange& r ange, CSSParserMode cssParserMode) | |
667 { | |
668 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; | |
669 | |
670 bool hasLengthOrPercentage = false; | |
671 bool hasEachLine = false; | |
672 bool hasHanging = false; | |
673 | |
674 do { | |
675 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false | |
Timothy Loh
2015/10/13 05:32:09
Probably better at the top of the function. Maybe
| |
676 if (!hasLengthOrPercentage) { | |
677 if (RefPtrWillBeRawPtr<CSSValue> textIndent = consumeLengthOrPercent (range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) { | |
678 list->append(textIndent.release()); | |
679 hasLengthOrPercentage = true; | |
680 continue; | |
681 } | |
682 } | |
683 | |
684 // [ <length> | <percentage> ] && hanging? && each-line? | inherit | |
685 // when RuntimeEnabledFeatures::css3TextEnabled() returns true. | |
686 if (RuntimeEnabledFeatures::css3TextEnabled()) { | |
687 CSSValueID id = range.peek().id(); | |
688 if (!hasEachLine && id == CSSValueEachLine) { | |
689 list->append(consumeIdent(range)); | |
690 hasEachLine = true; | |
691 continue; | |
692 } | |
693 if (!hasHanging && id == CSSValueHanging) { | |
694 list->append(consumeIdent(range)); | |
695 hasHanging = true; | |
696 continue; | |
697 } | |
698 } | |
699 return nullptr; | |
700 } while (!range.atEnd()); | |
701 | |
702 if (!hasLengthOrPercentage) | |
703 return nullptr; | |
704 | |
705 return list.release(); | |
706 } | |
707 | |
666 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId) | 708 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId) |
667 { | 709 { |
668 m_range.consumeWhitespace(); | 710 m_range.consumeWhitespace(); |
669 switch (propId) { | 711 switch (propId) { |
670 case CSSPropertyWillChange: | 712 case CSSPropertyWillChange: |
671 return consumeWillChange(m_range); | 713 return consumeWillChange(m_range); |
672 case CSSPropertyPage: | 714 case CSSPropertyPage: |
673 return consumePage(m_range); | 715 return consumePage(m_range); |
674 case CSSPropertyQuotes: | 716 case CSSPropertyQuotes: |
675 return consumeQuotes(m_range); | 717 return consumeQuotes(m_range); |
(...skipping 19 matching lines...) Expand all Loading... | |
695 case CSSPropertyLineHeight: | 737 case CSSPropertyLineHeight: |
696 return consumeLineHeight(m_range, m_context.mode()); | 738 return consumeLineHeight(m_range, m_context.mode()); |
697 case CSSPropertyRotate: | 739 case CSSPropertyRotate: |
698 return consumeRotation(m_range); | 740 return consumeRotation(m_range); |
699 case CSSPropertyWebkitBorderHorizontalSpacing: | 741 case CSSPropertyWebkitBorderHorizontalSpacing: |
700 case CSSPropertyWebkitBorderVerticalSpacing: | 742 case CSSPropertyWebkitBorderVerticalSpacing: |
701 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); | 743 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); |
702 case CSSPropertyCounterIncrement: | 744 case CSSPropertyCounterIncrement: |
703 case CSSPropertyCounterReset: | 745 case CSSPropertyCounterReset: |
704 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0); | 746 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0); |
747 case CSSPropertyTextIndent: | |
748 return consumeTextIndent(m_range, m_context.mode()); | |
705 default: | 749 default: |
706 return nullptr; | 750 return nullptr; |
707 } | 751 } |
708 } | 752 } |
709 | 753 |
710 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) | 754 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) |
711 { | 755 { |
712 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); | 756 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); |
713 | 757 |
714 do { | 758 do { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 } | 1133 } |
1090 case CSSPropertyBorderSpacing: | 1134 case CSSPropertyBorderSpacing: |
1091 return consumeBorderSpacing(important); | 1135 return consumeBorderSpacing(important); |
1092 default: | 1136 default: |
1093 m_currentShorthand = oldShorthand; | 1137 m_currentShorthand = oldShorthand; |
1094 return false; | 1138 return false; |
1095 } | 1139 } |
1096 } | 1140 } |
1097 | 1141 |
1098 } // namespace blink | 1142 } // namespace blink |
OLD | NEW |