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

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

Issue 1401533005: Move clip property into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better solution Created 5 years, 2 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 "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"
11 #include "core/css/CSSFontFaceSrcValue.h" 11 #include "core/css/CSSFontFaceSrcValue.h"
12 #include "core/css/CSSFontFeatureValue.h" 12 #include "core/css/CSSFontFeatureValue.h"
13 #include "core/css/CSSPrimitiveValueMappings.h" 13 #include "core/css/CSSPrimitiveValueMappings.h"
14 #include "core/css/CSSQuadValue.h"
14 #include "core/css/CSSStringValue.h" 15 #include "core/css/CSSStringValue.h"
15 #include "core/css/CSSURIValue.h" 16 #include "core/css/CSSURIValue.h"
16 #include "core/css/CSSUnicodeRangeValue.h" 17 #include "core/css/CSSUnicodeRangeValue.h"
17 #include "core/css/CSSValuePair.h" 18 #include "core/css/CSSValuePair.h"
18 #include "core/css/CSSValuePool.h" 19 #include "core/css/CSSValuePool.h"
19 #include "core/css/FontFace.h" 20 #include "core/css/FontFace.h"
20 #include "core/css/parser/CSSParserFastPaths.h" 21 #include "core/css/parser/CSSParserFastPaths.h"
21 #include "core/css/parser/CSSParserValues.h" 22 #include "core/css/parser/CSSParserValues.h"
22 #include "core/frame/UseCounter.h" 23 #include "core/frame/UseCounter.h"
23 #include "core/layout/LayoutTheme.h" 24 #include "core/layout/LayoutTheme.h"
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 748 }
748 return nullptr; 749 return nullptr;
749 } while (!range.atEnd()); 750 } while (!range.atEnd());
750 751
751 if (!hasLengthOrPercentage) 752 if (!hasLengthOrPercentage)
752 return nullptr; 753 return nullptr;
753 754
754 return list.release(); 755 return list.release();
755 } 756 }
756 757
758 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeShape(CSSParserTokenRang e& range, CSSParserMode cssParserMode)
Timothy Loh 2015/10/13 23:43:38 consumeShape -> consumeClipComponent?
759 {
760 if (range.peek().id() == CSSValueAuto)
761 return consumeIdent(range);
762 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All ow);
763 }
764
765 static PassRefPtrWillBeRawPtr<CSSValue> consumeClip(CSSParserTokenRange& range, CSSParserMode cssParserMode)
766 {
767 if (range.peek().id() == CSSValueAuto)
768 return consumeIdent(range);
769
770 if (range.peek().functionId() != CSSValueRect)
771 return nullptr;
772
773 CSSParserTokenRange args = consumeFunction(range);
774 // rect(t, r, b, l) || rect(t r b l)
775 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = consumeShape(args, cssParserMode );
776 if (!top)
777 return nullptr;
778 bool needsComma = consumeCommaIncludingWhitespace(args);
779 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = consumeShape(args, cssParserMo de);
780 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args)))
781 return nullptr;
782 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = consumeShape(args, cssParserM ode);
783 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args)))
784 return nullptr;
785 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = consumeShape(args, cssParserMod e);
786 if (!left || !args.atEnd())
787 return nullptr;
788 return CSSQuadValue::create(top.release(), right.release(), bottom.release() , left.release(), CSSQuadValue::SerializeAsRect);
789 }
790
757 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId) 791 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId)
758 { 792 {
759 m_range.consumeWhitespace(); 793 m_range.consumeWhitespace();
760 switch (propId) { 794 switch (propId) {
761 case CSSPropertyWillChange: 795 case CSSPropertyWillChange:
762 return consumeWillChange(m_range); 796 return consumeWillChange(m_range);
763 case CSSPropertyPage: 797 case CSSPropertyPage:
764 return consumePage(m_range); 798 return consumePage(m_range);
765 case CSSPropertyQuotes: 799 case CSSPropertyQuotes:
766 return consumeQuotes(m_range); 800 return consumeQuotes(m_range);
(...skipping 23 matching lines...) Expand all
790 case CSSPropertyWebkitBorderHorizontalSpacing: 824 case CSSPropertyWebkitBorderHorizontalSpacing:
791 case CSSPropertyWebkitBorderVerticalSpacing: 825 case CSSPropertyWebkitBorderVerticalSpacing:
792 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); 826 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
793 case CSSPropertyCounterIncrement: 827 case CSSPropertyCounterIncrement:
794 case CSSPropertyCounterReset: 828 case CSSPropertyCounterReset:
795 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0); 829 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0);
796 case CSSPropertySize: 830 case CSSPropertySize:
797 return consumeSize(m_range, m_context.mode()); 831 return consumeSize(m_range, m_context.mode());
798 case CSSPropertyTextIndent: 832 case CSSPropertyTextIndent:
799 return consumeTextIndent(m_range, m_context.mode()); 833 return consumeTextIndent(m_range, m_context.mode());
834 case CSSPropertyClip:
835 return consumeClip(m_range, m_context.mode());
800 default: 836 default:
801 return nullptr; 837 return nullptr;
802 } 838 }
803 } 839 }
804 840
805 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 841 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
806 { 842 {
807 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 843 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
808 844
809 do { 845 do {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 } 1220 }
1185 case CSSPropertyBorderSpacing: 1221 case CSSPropertyBorderSpacing:
1186 return consumeBorderSpacing(important); 1222 return consumeBorderSpacing(important);
1187 default: 1223 default:
1188 m_currentShorthand = oldShorthand; 1224 m_currentShorthand = oldShorthand;
1189 return false; 1225 return false;
1190 } 1226 }
1191 } 1227 }
1192 1228
1193 } // namespace blink 1229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698