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> consumePageSize(CSSParserTokenRange& ran
ge) |
| 667 { |
| 668 switch (range.peek().id()) { |
| 669 case CSSValueA3: |
| 670 case CSSValueA4: |
| 671 case CSSValueA5: |
| 672 case CSSValueB4: |
| 673 case CSSValueB5: |
| 674 case CSSValueLedger: |
| 675 case CSSValueLegal: |
| 676 case CSSValueLetter: |
| 677 return consumeIdent(range); |
| 678 default: |
| 679 return nullptr; |
| 680 } |
| 681 } |
| 682 |
| 683 static PassRefPtrWillBeRawPtr<CSSValueList> consumeSize(CSSParserTokenRange& ran
ge, CSSParserMode cssParserMode) |
| 684 { |
| 685 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 686 |
| 687 if (range.peek().id() == CSSValueAuto) { |
| 688 result->append(consumeIdent(range)); |
| 689 return result.release(); |
| 690 } |
| 691 |
| 692 if (RefPtrWillBeRawPtr<CSSValue> width = consumeLength(range, cssParserMode,
ValueRangeNonNegative)) { |
| 693 RefPtrWillBeRawPtr<CSSValue> height = consumeLength(range, cssParserMode
, ValueRangeNonNegative); |
| 694 result->append(width.release()); |
| 695 if (height) |
| 696 result->append(height.release()); |
| 697 return result.release(); |
| 698 } |
| 699 |
| 700 RefPtrWillBeRawPtr<CSSValue> pageSize = consumePageSize(range); |
| 701 RefPtrWillBeRawPtr<CSSValue> orientation = nullptr; |
| 702 if (range.peek().id() == CSSValuePortrait || range.peek().id() == CSSValueLa
ndscape) |
| 703 orientation = consumeIdent(range); |
| 704 if (!pageSize) |
| 705 pageSize = consumePageSize(range); |
| 706 |
| 707 if (!orientation && !pageSize) |
| 708 return nullptr; |
| 709 if (pageSize) |
| 710 result->append(pageSize.release()); |
| 711 if (orientation) |
| 712 result->append(orientation.release()); |
| 713 return result.release(); |
| 714 } |
| 715 |
666 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID propId) | 716 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID propId) |
667 { | 717 { |
668 m_range.consumeWhitespace(); | 718 m_range.consumeWhitespace(); |
669 switch (propId) { | 719 switch (propId) { |
670 case CSSPropertyWillChange: | 720 case CSSPropertyWillChange: |
671 return consumeWillChange(m_range); | 721 return consumeWillChange(m_range); |
672 case CSSPropertyPage: | 722 case CSSPropertyPage: |
673 return consumePage(m_range); | 723 return consumePage(m_range); |
674 case CSSPropertyQuotes: | 724 case CSSPropertyQuotes: |
675 return consumeQuotes(m_range); | 725 return consumeQuotes(m_range); |
(...skipping 19 matching lines...) Expand all Loading... |
695 case CSSPropertyLineHeight: | 745 case CSSPropertyLineHeight: |
696 return consumeLineHeight(m_range, m_context.mode()); | 746 return consumeLineHeight(m_range, m_context.mode()); |
697 case CSSPropertyRotate: | 747 case CSSPropertyRotate: |
698 return consumeRotation(m_range); | 748 return consumeRotation(m_range); |
699 case CSSPropertyWebkitBorderHorizontalSpacing: | 749 case CSSPropertyWebkitBorderHorizontalSpacing: |
700 case CSSPropertyWebkitBorderVerticalSpacing: | 750 case CSSPropertyWebkitBorderVerticalSpacing: |
701 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); | 751 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); |
702 case CSSPropertyCounterIncrement: | 752 case CSSPropertyCounterIncrement: |
703 case CSSPropertyCounterReset: | 753 case CSSPropertyCounterReset: |
704 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo
unterIncrement ? 1 : 0); | 754 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo
unterIncrement ? 1 : 0); |
| 755 case CSSPropertySize: |
| 756 return consumeSize(m_range, m_context.mode()); |
705 default: | 757 default: |
706 return nullptr; | 758 return nullptr; |
707 } | 759 } |
708 } | 760 } |
709 | 761 |
710 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 762 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
711 { | 763 { |
712 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 764 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
713 | 765 |
714 do { | 766 do { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 } | 1141 } |
1090 case CSSPropertyBorderSpacing: | 1142 case CSSPropertyBorderSpacing: |
1091 return consumeBorderSpacing(important); | 1143 return consumeBorderSpacing(important); |
1092 default: | 1144 default: |
1093 m_currentShorthand = oldShorthand; | 1145 m_currentShorthand = oldShorthand; |
1094 return false; | 1146 return false; |
1095 } | 1147 } |
1096 } | 1148 } |
1097 | 1149 |
1098 } // namespace blink | 1150 } // namespace blink |
OLD | NEW |