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

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

Issue 2647503004: Added CSSPropertyPositionUtils which holds position parsing methods. (Closed)
Patch Set: Merged correctly Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 27 matching lines...) Expand all
38 #include "core/css/HashTools.h" 38 #include "core/css/HashTools.h"
39 #include "core/css/parser/CSSParserFastPaths.h" 39 #include "core/css/parser/CSSParserFastPaths.h"
40 #include "core/css/parser/CSSParserIdioms.h" 40 #include "core/css/parser/CSSParserIdioms.h"
41 #include "core/css/parser/CSSPropertyParserHelpers.h" 41 #include "core/css/parser/CSSPropertyParserHelpers.h"
42 #include "core/css/parser/CSSVariableParser.h" 42 #include "core/css/parser/CSSVariableParser.h"
43 #include "core/css/parser/FontVariantLigaturesParser.h" 43 #include "core/css/parser/FontVariantLigaturesParser.h"
44 #include "core/css/properties/CSSPropertyAlignmentUtils.h" 44 #include "core/css/properties/CSSPropertyAlignmentUtils.h"
45 #include "core/css/properties/CSSPropertyColumnUtils.h" 45 #include "core/css/properties/CSSPropertyColumnUtils.h"
46 #include "core/css/properties/CSSPropertyDescriptor.h" 46 #include "core/css/properties/CSSPropertyDescriptor.h"
47 #include "core/css/properties/CSSPropertyLengthUtils.h" 47 #include "core/css/properties/CSSPropertyLengthUtils.h"
48 #include "core/css/properties/CSSPropertyPositionUtils.h"
48 #include "core/css/properties/CSSPropertyShapeUtils.h" 49 #include "core/css/properties/CSSPropertyShapeUtils.h"
49 #include "core/frame/UseCounter.h" 50 #include "core/frame/UseCounter.h"
50 #include "core/layout/LayoutTheme.h" 51 #include "core/layout/LayoutTheme.h"
51 #include "core/svg/SVGPathUtilities.h" 52 #include "core/svg/SVGPathUtilities.h"
52 #include "wtf/text/StringBuilder.h" 53 #include "wtf/text/StringBuilder.h"
53 #include <memory> 54 #include <memory>
54 55
55 namespace blink { 56 namespace blink {
56 57
57 using namespace CSSPropertyParserHelpers; 58 using namespace CSSPropertyParserHelpers;
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 CSSValue* parsedTransformValue = 1317 CSSValue* parsedTransformValue =
1317 consumeTransformValue(range, context, useLegacyParsing); 1318 consumeTransformValue(range, context, useLegacyParsing);
1318 if (!parsedTransformValue) 1319 if (!parsedTransformValue)
1319 return nullptr; 1320 return nullptr;
1320 list->append(*parsedTransformValue); 1321 list->append(*parsedTransformValue);
1321 } while (!range.atEnd()); 1322 } while (!range.atEnd());
1322 1323
1323 return list; 1324 return list;
1324 } 1325 }
1325 1326
1326 template <CSSValueID start, CSSValueID end>
1327 static CSSValue* consumePositionLonghand(CSSParserTokenRange& range,
1328 CSSParserMode cssParserMode) {
1329 if (range.peek().type() == IdentToken) {
1330 CSSValueID id = range.peek().id();
1331 int percent;
1332 if (id == start)
1333 percent = 0;
1334 else if (id == CSSValueCenter)
1335 percent = 50;
1336 else if (id == end)
1337 percent = 100;
1338 else
1339 return nullptr;
1340 range.consumeIncludingWhitespace();
1341 return CSSPrimitiveValue::create(percent,
1342 CSSPrimitiveValue::UnitType::Percentage);
1343 }
1344 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll);
1345 }
1346
1347 static CSSValue* consumePositionX(CSSParserTokenRange& range,
1348 CSSParserMode cssParserMode) {
1349 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range,
1350 cssParserMode);
1351 }
1352
1353 static CSSValue* consumePositionY(CSSParserTokenRange& range,
1354 CSSParserMode cssParserMode) {
1355 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range,
1356 cssParserMode);
1357 }
1358
1359 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range, 1327 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range,
1360 const CSSParserContext* context) { 1328 const CSSParserContext* context) {
1361 if (range.peek().id() == CSSValueNone) 1329 if (range.peek().id() == CSSValueNone)
1362 return consumeIdent(range); 1330 return consumeIdent(range);
1363 return consumeUrl(range, context); 1331 return consumeUrl(range, context);
1364 } 1332 }
1365 1333
1366 static CSSValue* consumeBaselineShift(CSSParserTokenRange& range) { 1334 static CSSValue* consumeBaselineShift(CSSParserTokenRange& range) {
1367 CSSValueID id = range.peek().id(); 1335 CSSValueID id = range.peek().id();
1368 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) 1336 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper)
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 case CSSPropertyWebkitBackgroundClip: 1724 case CSSPropertyWebkitBackgroundClip:
1757 case CSSPropertyWebkitBackgroundOrigin: 1725 case CSSPropertyWebkitBackgroundOrigin:
1758 case CSSPropertyWebkitMaskClip: 1726 case CSSPropertyWebkitMaskClip:
1759 case CSSPropertyWebkitMaskOrigin: 1727 case CSSPropertyWebkitMaskOrigin:
1760 return consumePrefixedBackgroundBox(unresolvedProperty, range, context); 1728 return consumePrefixedBackgroundBox(unresolvedProperty, range, context);
1761 case CSSPropertyBackgroundImage: 1729 case CSSPropertyBackgroundImage:
1762 case CSSPropertyWebkitMaskImage: 1730 case CSSPropertyWebkitMaskImage:
1763 return consumeImageOrNone(range, context); 1731 return consumeImageOrNone(range, context);
1764 case CSSPropertyBackgroundPositionX: 1732 case CSSPropertyBackgroundPositionX:
1765 case CSSPropertyWebkitMaskPositionX: 1733 case CSSPropertyWebkitMaskPositionX:
1766 return consumePositionX(range, context->mode()); 1734 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft,
1735 CSSValueRight>(
1736 range, context->mode());
1767 case CSSPropertyBackgroundPositionY: 1737 case CSSPropertyBackgroundPositionY:
1768 case CSSPropertyWebkitMaskPositionY: 1738 case CSSPropertyWebkitMaskPositionY:
1769 return consumePositionY(range, context->mode()); 1739 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop,
1740 CSSValueBottom>(
1741 range, context->mode());
1770 case CSSPropertyBackgroundSize: 1742 case CSSPropertyBackgroundSize:
1771 case CSSPropertyAliasWebkitBackgroundSize: 1743 case CSSPropertyAliasWebkitBackgroundSize:
1772 case CSSPropertyWebkitMaskSize: 1744 case CSSPropertyWebkitMaskSize:
1773 return consumeBackgroundSize(unresolvedProperty, range, context->mode()); 1745 return consumeBackgroundSize(unresolvedProperty, range, context->mode());
1774 case CSSPropertyBackgroundColor: 1746 case CSSPropertyBackgroundColor:
1775 return consumeColor(range, context->mode()); 1747 return consumeColor(range, context->mode());
1776 default: 1748 default:
1777 break; 1749 break;
1778 }; 1750 };
1779 return nullptr; 1751 return nullptr;
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 return consumeOffsetRotate(m_range); 2472 return consumeOffsetRotate(m_range);
2501 case CSSPropertyOutlineWidth: 2473 case CSSPropertyOutlineWidth:
2502 return consumeLineWidth(m_range, m_context->mode(), 2474 return consumeLineWidth(m_range, m_context->mode(),
2503 UnitlessQuirk::Forbid); 2475 UnitlessQuirk::Forbid);
2504 case CSSPropertyTransform: 2476 case CSSPropertyTransform:
2505 return consumeTransform( 2477 return consumeTransform(
2506 m_range, m_context, 2478 m_range, m_context,
2507 unresolvedProperty == CSSPropertyAliasWebkitTransform); 2479 unresolvedProperty == CSSPropertyAliasWebkitTransform);
2508 case CSSPropertyWebkitTransformOriginX: 2480 case CSSPropertyWebkitTransformOriginX:
2509 case CSSPropertyWebkitPerspectiveOriginX: 2481 case CSSPropertyWebkitPerspectiveOriginX:
2510 return consumePositionX(m_range, m_context->mode()); 2482 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft,
2483 CSSValueRight>(
2484 m_range, m_context->mode());
2511 case CSSPropertyWebkitTransformOriginY: 2485 case CSSPropertyWebkitTransformOriginY:
2512 case CSSPropertyWebkitPerspectiveOriginY: 2486 case CSSPropertyWebkitPerspectiveOriginY:
2513 return consumePositionY(m_range, m_context->mode()); 2487 return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop,
2488 CSSValueBottom>(
2489 m_range, m_context->mode());
2514 case CSSPropertyMarkerStart: 2490 case CSSPropertyMarkerStart:
2515 case CSSPropertyMarkerMid: 2491 case CSSPropertyMarkerMid:
2516 case CSSPropertyMarkerEnd: 2492 case CSSPropertyMarkerEnd:
2517 case CSSPropertyMask: 2493 case CSSPropertyMask:
2518 return consumeNoneOrURI(m_range, m_context); 2494 return consumeNoneOrURI(m_range, m_context);
2519 case CSSPropertyFlexGrow: 2495 case CSSPropertyFlexGrow:
2520 case CSSPropertyFlexShrink: 2496 case CSSPropertyFlexShrink:
2521 return consumeNumber(m_range, ValueRangeNonNegative); 2497 return consumeNumber(m_range, ValueRangeNonNegative);
2522 case CSSPropertyColumnRuleWidth: 2498 case CSSPropertyColumnRuleWidth:
2523 return consumeColumnRuleWidth(m_range, m_context->mode()); 2499 return consumeColumnRuleWidth(m_range, m_context->mode());
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
4097 case CSSPropertyGridTemplate: 4073 case CSSPropertyGridTemplate:
4098 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); 4074 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
4099 case CSSPropertyGrid: 4075 case CSSPropertyGrid:
4100 return consumeGridShorthand(important); 4076 return consumeGridShorthand(important);
4101 default: 4077 default:
4102 return false; 4078 return false;
4103 } 4079 }
4104 } 4080 }
4105 4081
4106 } // namespace blink 4082 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698