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 "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" |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 573 } |
574 | 574 |
575 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range, | 575 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range, |
576 CSSParserMode cssParserMode, | 576 CSSParserMode cssParserMode, |
577 UnitlessQuirk unitless) { | 577 UnitlessQuirk unitless) { |
578 if (range.peek().id() == CSSValueAuto) | 578 if (range.peek().id() == CSSValueAuto) |
579 return consumeIdent(range); | 579 return consumeIdent(range); |
580 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless); | 580 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless); |
581 } | 581 } |
582 | 582 |
583 static bool consumePan(CSSParserTokenRange& range, | |
584 CSSValue*& panX, | |
585 CSSValue*& panY, | |
586 CSSValue*& pinchZoom) { | |
587 CSSValueID id = range.peek().id(); | |
588 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) && | |
589 !panX) { | |
590 if (id != CSSValuePanX && | |
591 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled()) | |
592 return false; | |
593 panX = consumeIdent(range); | |
594 } else if ((id == CSSValuePanY || id == CSSValuePanDown || | |
595 id == CSSValuePanUp) && | |
596 !panY) { | |
597 if (id != CSSValuePanY && | |
598 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled()) | |
599 return false; | |
600 panY = consumeIdent(range); | |
601 } else if (id == CSSValuePinchZoom && !pinchZoom && | |
602 RuntimeEnabledFeatures::cssTouchActionPinchZoomEnabled()) { | |
603 pinchZoom = consumeIdent(range); | |
604 } else { | |
605 return false; | |
606 } | |
607 return true; | |
608 } | |
609 | |
610 static CSSValue* consumeTouchAction(CSSParserTokenRange& range) { | |
611 CSSValueList* list = CSSValueList::createSpaceSeparated(); | |
612 CSSValueID id = range.peek().id(); | |
613 if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation) { | |
614 list->append(*consumeIdent(range)); | |
615 return list; | |
616 } | |
617 | |
618 CSSValue* panX = nullptr; | |
619 CSSValue* panY = nullptr; | |
620 CSSValue* pinchZoom = nullptr; | |
621 if (!consumePan(range, panX, panY, pinchZoom)) | |
622 return nullptr; | |
623 if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom)) | |
624 return nullptr; | |
625 if (!range.atEnd() && !consumePan(range, panX, panY, pinchZoom)) | |
626 return nullptr; | |
627 | |
628 if (panX) | |
629 list->append(*panX); | |
630 if (panY) | |
631 list->append(*panY); | |
632 if (pinchZoom) | |
633 list->append(*pinchZoom); | |
634 return list; | |
635 } | |
636 | |
637 static CSSValue* consumeLocale(CSSParserTokenRange& range) { | 583 static CSSValue* consumeLocale(CSSParserTokenRange& range) { |
638 if (range.peek().id() == CSSValueAuto) | 584 if (range.peek().id() == CSSValueAuto) |
639 return consumeIdent(range); | 585 return consumeIdent(range); |
640 return consumeString(range); | 586 return consumeString(range); |
641 } | 587 } |
642 | 588 |
643 static CSSValue* consumeAnimationIterationCount(CSSParserTokenRange& range) { | 589 static CSSValue* consumeAnimationIterationCount(CSSParserTokenRange& range) { |
644 if (range.peek().id() == CSSValueInfinite) | 590 if (range.peek().id() == CSSValueInfinite) |
645 return consumeIdent(range); | 591 return consumeIdent(range); |
646 return consumeNumber(range, ValueRangeNonNegative); | 592 return consumeNumber(range, ValueRangeNonNegative); |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 case CSSPropertyRight: | 2289 case CSSPropertyRight: |
2344 case CSSPropertyTop: | 2290 case CSSPropertyTop: |
2345 return consumeMarginOrOffset(m_range, m_context->mode(), | 2291 return consumeMarginOrOffset(m_range, m_context->mode(), |
2346 UnitlessQuirk::Allow); | 2292 UnitlessQuirk::Allow); |
2347 case CSSPropertyWebkitMarginStart: | 2293 case CSSPropertyWebkitMarginStart: |
2348 case CSSPropertyWebkitMarginEnd: | 2294 case CSSPropertyWebkitMarginEnd: |
2349 case CSSPropertyWebkitMarginBefore: | 2295 case CSSPropertyWebkitMarginBefore: |
2350 case CSSPropertyWebkitMarginAfter: | 2296 case CSSPropertyWebkitMarginAfter: |
2351 return consumeMarginOrOffset(m_range, m_context->mode(), | 2297 return consumeMarginOrOffset(m_range, m_context->mode(), |
2352 UnitlessQuirk::Forbid); | 2298 UnitlessQuirk::Forbid); |
2353 case CSSPropertyTouchAction: | |
2354 return consumeTouchAction(m_range); | |
2355 case CSSPropertyScrollSnapDestination: | 2299 case CSSPropertyScrollSnapDestination: |
2356 case CSSPropertyObjectPosition: | 2300 case CSSPropertyObjectPosition: |
2357 case CSSPropertyPerspectiveOrigin: | 2301 case CSSPropertyPerspectiveOrigin: |
2358 return consumePosition(m_range, m_context->mode(), UnitlessQuirk::Forbid); | 2302 return consumePosition(m_range, m_context->mode(), UnitlessQuirk::Forbid); |
2359 case CSSPropertyWebkitFontSizeDelta: | 2303 case CSSPropertyWebkitFontSizeDelta: |
2360 return consumeLength(m_range, m_context->mode(), ValueRangeAll, | 2304 return consumeLength(m_range, m_context->mode(), ValueRangeAll, |
2361 UnitlessQuirk::Allow); | 2305 UnitlessQuirk::Allow); |
2362 case CSSPropertyWebkitHyphenateCharacter: | 2306 case CSSPropertyWebkitHyphenateCharacter: |
2363 case CSSPropertyWebkitLocale: | 2307 case CSSPropertyWebkitLocale: |
2364 return consumeLocale(m_range); | 2308 return consumeLocale(m_range); |
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4053 case CSSPropertyGridTemplate: | 3997 case CSSPropertyGridTemplate: |
4054 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); | 3998 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); |
4055 case CSSPropertyGrid: | 3999 case CSSPropertyGrid: |
4056 return consumeGridShorthand(important); | 4000 return consumeGridShorthand(important); |
4057 default: | 4001 default: |
4058 return false; | 4002 return false; |
4059 } | 4003 } |
4060 } | 4004 } |
4061 | 4005 |
4062 } // namespace blink | 4006 } // namespace blink |
OLD | NEW |