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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.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 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return true; 428 return true;
429 429
430 bool validPrimitive = false; 430 bool validPrimitive = false;
431 Units unitless = FUnknown; 431 Units unitless = FUnknown;
432 432
433 switch (propId) { 433 switch (propId) {
434 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at tr(X) | open-quote | 434 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at tr(X) | open-quote |
435 // close-quote | no-open-quote | no-close-quote ]+ | inherit 435 // close-quote | no-open-quote | no-close-quote ]+ | inherit
436 parsedValue = parseContent(); 436 parsedValue = parseContent();
437 break; 437 break;
438 case CSSPropertyClip: // <shape> | auto | inherit
439 if (id == CSSValueAuto)
440 validPrimitive = true;
441 else if (value->m_unit == CSSParserValue::Function)
442 parsedValue = parseClipShape();
443 break;
444 438
445 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work 439 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work
446 * correctly and allows optimization in blink::applyRule(..) 440 * correctly and allows optimization in blink::applyRule(..)
447 */ 441 */
448 442
449 case CSSPropertyTextAlign: 443 case CSSPropertyTextAlign:
450 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent 444 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent
451 // | start | end | <string> | inherit | -webkit-auto (converted to start ) 445 // | start | end | <string> | inherit | -webkit-auto (converted to start )
452 // FIXME: <string> not supported right now 446 // FIXME: <string> not supported right now
453 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) { 447 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) {
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 case CSSPropertyLineHeight: 1338 case CSSPropertyLineHeight:
1345 case CSSPropertyRotate: 1339 case CSSPropertyRotate:
1346 case CSSPropertyFont: 1340 case CSSPropertyFont:
1347 case CSSPropertyWebkitBorderHorizontalSpacing: 1341 case CSSPropertyWebkitBorderHorizontalSpacing:
1348 case CSSPropertyWebkitBorderVerticalSpacing: 1342 case CSSPropertyWebkitBorderVerticalSpacing:
1349 case CSSPropertyBorderSpacing: 1343 case CSSPropertyBorderSpacing:
1350 case CSSPropertyCounterIncrement: 1344 case CSSPropertyCounterIncrement:
1351 case CSSPropertyCounterReset: 1345 case CSSPropertyCounterReset:
1352 case CSSPropertySize: 1346 case CSSPropertySize:
1353 case CSSPropertyTextIndent: 1347 case CSSPropertyTextIndent:
1348 case CSSPropertyClip:
1354 validPrimitive = false; 1349 validPrimitive = false;
1355 break; 1350 break;
1356 1351
1357 case CSSPropertyScrollSnapPointsX: 1352 case CSSPropertyScrollSnapPointsX:
1358 case CSSPropertyScrollSnapPointsY: 1353 case CSSPropertyScrollSnapPointsY:
1359 parsedValue = parseScrollSnapPoints(); 1354 parsedValue = parseScrollSnapPoints();
1360 break; 1355 break;
1361 case CSSPropertyScrollSnapCoordinate: 1356 case CSSPropertyScrollSnapCoordinate:
1362 parsedValue = parseScrollSnapCoordinate(); 1357 parsedValue = parseScrollSnapCoordinate();
1363 break; 1358 break;
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 listStyleID = i->id; 3713 listStyleID = i->id;
3719 else 3714 else
3720 return nullptr; 3715 return nullptr;
3721 3716
3722 listStyle = cssValuePool().createIdentifierValue(listStyleID); 3717 listStyle = cssValuePool().createIdentifierValue(listStyleID);
3723 } 3718 }
3724 3719
3725 return CSSCounterValue::create(identifier.release(), listStyle.release(), se parator.release()); 3720 return CSSCounterValue::create(identifier.release(), listStyle.release(), se parator.release());
3726 } 3721 }
3727 3722
3728 PassRefPtrWillBeRawPtr<CSSQuadValue> CSSPropertyParser::parseClipShape()
3729 {
3730 CSSParserValue* value = m_valueList->current();
3731 CSSParserValueList* args = value->function->args.get();
3732
3733 if (value->function->id != CSSValueRect || !args)
3734 return nullptr;
3735
3736 // rect(t, r, b, l) || rect(t r b l)
3737 if (args->size() != 4 && args->size() != 7)
3738 return nullptr;
3739 int i = 0;
3740 CSSParserValue* a = args->current();
3741
3742 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = nullptr;
3743 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = nullptr;
3744 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = nullptr;
3745 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = nullptr;
3746 while (a) {
3747 if (a->id != CSSValueAuto && !validUnit(a, FLength | FUnitlessQuirk))
3748 return nullptr;
3749 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ?
3750 cssValuePool().createIdentifierValue(CSSValueAuto) :
3751 createPrimitiveNumericValue(a);
3752 if (i == 0)
3753 top = length;
3754 else if (i == 1)
3755 right = length;
3756 else if (i == 2)
3757 bottom = length;
3758 else
3759 left = length;
3760 a = args->next();
3761 if (a && args->size() == 7) {
3762 if (!consumeComma(args))
3763 return nullptr;
3764 a = args->current();
3765 }
3766 i++;
3767 }
3768 m_valueList->next();
3769 return CSSQuadValue::create(top.release(), right.release(), bottom.release() , left.release(), CSSQuadValue::SerializeAsRect);
3770 }
3771
3772 static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]) 3723 static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4])
3773 { 3724 {
3774 if (radii[3]) 3725 if (radii[3])
3775 return; 3726 return;
3776 if (!radii[2]) { 3727 if (!radii[2]) {
3777 if (!radii[1]) 3728 if (!radii[1])
3778 radii[1] = radii[0]; 3729 radii[1] = radii[0];
3779 radii[2] = radii[0]; 3730 radii[2] = radii[0];
3780 } 3731 }
3781 radii[3] = radii[1]; 3732 radii[3] = radii[1];
(...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after
6949 } 6900 }
6950 } 6901 }
6951 6902
6952 if (!list->length()) 6903 if (!list->length())
6953 return nullptr; 6904 return nullptr;
6954 6905
6955 return list.release(); 6906 return list.release();
6956 } 6907 }
6957 6908
6958 } // namespace blink 6909 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698