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

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

Issue 1782833008: Add paint() function as valid CSS <image> type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: name->customCSSText 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"
11 #include "core/css/CSSCounterValue.h" 11 #include "core/css/CSSCounterValue.h"
12 #include "core/css/CSSCrossfadeValue.h" 12 #include "core/css/CSSCrossfadeValue.h"
13 #include "core/css/CSSCursorImageValue.h" 13 #include "core/css/CSSCursorImageValue.h"
14 #include "core/css/CSSCustomIdentValue.h" 14 #include "core/css/CSSCustomIdentValue.h"
15 #include "core/css/CSSFontFaceSrcValue.h" 15 #include "core/css/CSSFontFaceSrcValue.h"
16 #include "core/css/CSSFontFeatureValue.h" 16 #include "core/css/CSSFontFeatureValue.h"
17 #include "core/css/CSSFunctionValue.h" 17 #include "core/css/CSSFunctionValue.h"
18 #include "core/css/CSSGradientValue.h" 18 #include "core/css/CSSGradientValue.h"
19 #include "core/css/CSSImageSetValue.h" 19 #include "core/css/CSSImageSetValue.h"
20 #include "core/css/CSSPaintValue.h"
20 #include "core/css/CSSPathValue.h" 21 #include "core/css/CSSPathValue.h"
21 #include "core/css/CSSPrimitiveValueMappings.h" 22 #include "core/css/CSSPrimitiveValueMappings.h"
22 #include "core/css/CSSQuadValue.h" 23 #include "core/css/CSSQuadValue.h"
23 #include "core/css/CSSReflectValue.h" 24 #include "core/css/CSSReflectValue.h"
24 #include "core/css/CSSSVGDocumentValue.h" 25 #include "core/css/CSSSVGDocumentValue.h"
25 #include "core/css/CSSShadowValue.h" 26 #include "core/css/CSSShadowValue.h"
26 #include "core/css/CSSStringValue.h" 27 #include "core/css/CSSStringValue.h"
27 #include "core/css/CSSTimingFunctionValue.h" 28 #include "core/css/CSSTimingFunctionValue.h"
28 #include "core/css/CSSURIValue.h" 29 #include "core/css/CSSURIValue.h"
29 #include "core/css/CSSUnicodeRangeValue.h" 30 #include "core/css/CSSUnicodeRangeValue.h"
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionX(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode) 1911 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionX(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode)
1911 { 1912 {
1912 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser Mode); 1913 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser Mode);
1913 } 1914 }
1914 1915
1915 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionY(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode) 1916 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionY(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode)
1916 { 1917 {
1917 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser Mode); 1918 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser Mode);
1918 } 1919 }
1919 1920
1920 static PassRefPtrWillBeRawPtr<CSSValue> consumePaint(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1921 static PassRefPtrWillBeRawPtr<CSSValue> consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cssParserMode)
1921 { 1922 {
1922 if (range.peek().id() == CSSValueNone) 1923 if (range.peek().id() == CSSValueNone)
1923 return consumeIdent(range); 1924 return consumeIdent(range);
1924 String url = consumeUrl(range); 1925 String url = consumeUrl(range);
1925 if (!url.isNull()) { 1926 if (!url.isNull()) {
1926 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 1927 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
1927 if (range.peek().id() == CSSValueNone) 1928 if (range.peek().id() == CSSValueNone)
1928 parsedValue = consumeIdent(range); 1929 parsedValue = consumeIdent(range);
1929 else 1930 else
1930 parsedValue = consumeColor(range, cssParserMode); 1931 parsedValue = consumeColor(range, cssParserMode);
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 if (percentageArg.type() == PercentageToken) 2445 if (percentageArg.type() == PercentageToken)
2445 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu mericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::Number); 2446 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu mericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::Number);
2446 else if (percentageArg.type() == NumberToken) 2447 else if (percentageArg.type() == NumberToken)
2447 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu mericValue(), 0, 1), CSSPrimitiveValue::UnitType::Number); 2448 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu mericValue(), 0, 1), CSSPrimitiveValue::UnitType::Number);
2448 2449
2449 if (!percentage) 2450 if (!percentage)
2450 return nullptr; 2451 return nullptr;
2451 return CSSCrossfadeValue::create(fromImageValue, toImageValue, percentage); 2452 return CSSCrossfadeValue::create(fromImageValue, toImageValue, percentage);
2452 } 2453 }
2453 2454
2455 static PassRefPtrWillBeRawPtr<CSSValue> consumePaint(CSSParserTokenRange& args, CSSParserContext context)
2456 {
2457 ASSERT(RuntimeEnabledFeatures::cssPaintAPIEnabled());
2458
2459 RefPtrWillBeRawPtr<CSSCustomIdentValue> name = consumeCustomIdent(args);
2460 if (!name)
2461 return nullptr;
2462
2463 return CSSPaintValue::create(name.release());
2464 }
2465
2454 static PassRefPtrWillBeRawPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRang e& range, CSSParserContext context) 2466 static PassRefPtrWillBeRawPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRang e& range, CSSParserContext context)
2455 { 2467 {
2456 CSSValueID id = range.peek().functionId(); 2468 CSSValueID id = range.peek().functionId();
2457 CSSParserTokenRange rangeCopy = range; 2469 CSSParserTokenRange rangeCopy = range;
2458 CSSParserTokenRange args = consumeFunction(rangeCopy); 2470 CSSParserTokenRange args = consumeFunction(rangeCopy);
2459 RefPtrWillBeRawPtr<CSSValue> result = nullptr; 2471 RefPtrWillBeRawPtr<CSSValue> result = nullptr;
2460 if (id == CSSValueRadialGradient) { 2472 if (id == CSSValueRadialGradient) {
2461 result = consumeRadialGradient(args, context.mode(), NonRepeating); 2473 result = consumeRadialGradient(args, context.mode(), NonRepeating);
2462 } else if (id == CSSValueRepeatingRadialGradient) { 2474 } else if (id == CSSValueRepeatingRadialGradient) {
2463 result = consumeRadialGradient(args, context.mode(), Repeating); 2475 result = consumeRadialGradient(args, context.mode(), Repeating);
(...skipping 20 matching lines...) Expand all
2484 // FIXME: This should send a deprecation message. 2496 // FIXME: This should send a deprecation message.
2485 if (context.useCounter()) 2497 if (context.useCounter())
2486 context.useCounter()->count(UseCounter::DeprecatedWebKitRadialGradie nt); 2498 context.useCounter()->count(UseCounter::DeprecatedWebKitRadialGradie nt);
2487 result = consumeDeprecatedRadialGradient(args, context.mode(), NonRepeat ing); 2499 result = consumeDeprecatedRadialGradient(args, context.mode(), NonRepeat ing);
2488 } else if (id == CSSValueWebkitRepeatingRadialGradient) { 2500 } else if (id == CSSValueWebkitRepeatingRadialGradient) {
2489 if (context.useCounter()) 2501 if (context.useCounter())
2490 context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingRad ialGradient); 2502 context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingRad ialGradient);
2491 result = consumeDeprecatedRadialGradient(args, context.mode(), Repeating ); 2503 result = consumeDeprecatedRadialGradient(args, context.mode(), Repeating );
2492 } else if (id == CSSValueWebkitCrossFade) { 2504 } else if (id == CSSValueWebkitCrossFade) {
2493 result = consumeCrossFade(args, context); 2505 result = consumeCrossFade(args, context);
2506 } else if (id == CSSValuePaint) {
2507 result = RuntimeEnabledFeatures::cssPaintAPIEnabled() ? consumePaint(arg s, context) : nullptr;
2494 } 2508 }
2495 if (!result || !args.atEnd()) 2509 if (!result || !args.atEnd())
2496 return nullptr; 2510 return nullptr;
2497 range = rangeCopy; 2511 range = rangeCopy;
2498 return result; 2512 return result;
2499 } 2513 }
2500 2514
2501 static bool isGeneratedImage(CSSValueID id) 2515 static bool isGeneratedImage(CSSValueID id)
2502 { 2516 {
2503 return id == CSSValueLinearGradient || id == CSSValueRadialGradient 2517 return id == CSSValueLinearGradient || id == CSSValueRadialGradient
2504 || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadia lGradient 2518 || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadia lGradient
2505 || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradi ent 2519 || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradi ent
2506 || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRe peatingRadialGradient 2520 || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRe peatingRadialGradient
2507 || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade; 2521 || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id = = CSSValuePaint;
2508 } 2522 }
2509 2523
2510 static PassRefPtrWillBeRawPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContext context) 2524 static PassRefPtrWillBeRawPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContext context)
2511 { 2525 {
2512 if (range.peek().id() == CSSValueNone) 2526 if (range.peek().id() == CSSValueNone)
2513 return consumeIdent(range); 2527 return consumeIdent(range);
2514 2528
2515 AtomicString uri(consumeUrl(range)); 2529 AtomicString uri(consumeUrl(range));
2516 if (!uri.isNull()) 2530 if (!uri.isNull())
2517 return createCSSImageValueWithReferrer(uri, context); 2531 return createCSSImageValueWithReferrer(uri, context);
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 case CSSPropertyWebkitTransformOriginX: 3504 case CSSPropertyWebkitTransformOriginX:
3491 case CSSPropertyWebkitPerspectiveOriginX: 3505 case CSSPropertyWebkitPerspectiveOriginX:
3492 return consumePositionX(m_range, m_context.mode()); 3506 return consumePositionX(m_range, m_context.mode());
3493 case CSSPropertyWebkitTransformOriginY: 3507 case CSSPropertyWebkitTransformOriginY:
3494 case CSSPropertyWebkitPerspectiveOriginY: 3508 case CSSPropertyWebkitPerspectiveOriginY:
3495 return consumePositionY(m_range, m_context.mode()); 3509 return consumePositionY(m_range, m_context.mode());
3496 case CSSPropertyWebkitTransformOriginZ: 3510 case CSSPropertyWebkitTransformOriginZ:
3497 return consumeLength(m_range, m_context.mode(), ValueRangeAll); 3511 return consumeLength(m_range, m_context.mode(), ValueRangeAll);
3498 case CSSPropertyFill: 3512 case CSSPropertyFill:
3499 case CSSPropertyStroke: 3513 case CSSPropertyStroke:
3500 return consumePaint(m_range, m_context.mode()); 3514 return consumePaintStroke(m_range, m_context.mode());
3501 case CSSPropertyPaintOrder: 3515 case CSSPropertyPaintOrder:
3502 return consumePaintOrder(m_range); 3516 return consumePaintOrder(m_range);
3503 case CSSPropertyMarkerStart: 3517 case CSSPropertyMarkerStart:
3504 case CSSPropertyMarkerMid: 3518 case CSSPropertyMarkerMid:
3505 case CSSPropertyMarkerEnd: 3519 case CSSPropertyMarkerEnd:
3506 case CSSPropertyClipPath: 3520 case CSSPropertyClipPath:
3507 case CSSPropertyFilter: 3521 case CSSPropertyFilter:
3508 case CSSPropertyMask: 3522 case CSSPropertyMask:
3509 return consumeNoneOrURI(m_range); 3523 return consumeNoneOrURI(m_range);
3510 case CSSPropertyFlexBasis: 3524 case CSSPropertyFlexBasis:
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
4567 m_currentShorthand = oldShorthand; 4581 m_currentShorthand = oldShorthand;
4568 CSSParserValueList valueList(m_range); 4582 CSSParserValueList valueList(m_range);
4569 if (!valueList.size()) 4583 if (!valueList.size())
4570 return false; 4584 return false;
4571 m_valueList = &valueList; 4585 m_valueList = &valueList;
4572 return legacyParseShorthand(unresolvedProperty, important); 4586 return legacyParseShorthand(unresolvedProperty, important);
4573 } 4587 }
4574 } 4588 }
4575 4589
4576 } // namespace blink 4590 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSValueKeywords.in ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698