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

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

Issue 2835893002: Refactored out need to pass property to IsValidAnimationPropertyList. (Closed)
Patch Set: Created 3 years, 7 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 | no next file » | 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 <memory> 7 #include <memory>
8 #include "core/StylePropertyShorthand.h" 8 #include "core/StylePropertyShorthand.h"
9 #include "core/css/CSSBasicShapeValues.h" 9 #include "core/css/CSSBasicShapeValues.h"
10 #include "core/css/CSSBorderImage.h" 10 #include "core/css/CSSBorderImage.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return ConsumeTransitionProperty(range); 483 return ConsumeTransitionProperty(range);
484 case CSSPropertyAnimationTimingFunction: 484 case CSSPropertyAnimationTimingFunction:
485 case CSSPropertyTransitionTimingFunction: 485 case CSSPropertyTransitionTimingFunction:
486 return ConsumeAnimationTimingFunction(range); 486 return ConsumeAnimationTimingFunction(range);
487 default: 487 default:
488 NOTREACHED(); 488 NOTREACHED();
489 return nullptr; 489 return nullptr;
490 } 490 }
491 } 491 }
492 492
493 static bool IsValidAnimationPropertyList(CSSPropertyID property, 493 static bool IsValidAnimationPropertyList(const CSSValueList& value_list) {
494 const CSSValueList& value_list) { 494 if (value_list.length() < 2)
495 if (property != CSSPropertyTransitionProperty || value_list.length() < 2)
496 return true; 495 return true;
497 for (auto& value : value_list) { 496 for (auto& value : value_list) {
498 if (value->IsIdentifierValue() && 497 if (value->IsIdentifierValue() &&
499 ToCSSIdentifierValue(*value).GetValueID() == CSSValueNone) 498 ToCSSIdentifierValue(*value).GetValueID() == CSSValueNone)
500 return false; 499 return false;
501 } 500 }
502 return true; 501 return true;
503 } 502 }
504 503
505 static CSSValueList* ConsumeAnimationPropertyList( 504 static CSSValueList* ConsumeAnimationPropertyList(
506 CSSPropertyID property, 505 CSSPropertyID property,
507 CSSParserTokenRange& range, 506 CSSParserTokenRange& range,
508 const CSSParserContext* context, 507 const CSSParserContext* context,
509 bool use_legacy_parsing) { 508 bool use_legacy_parsing) {
510 CSSValueList* list = CSSValueList::CreateCommaSeparated(); 509 CSSValueList* list = CSSValueList::CreateCommaSeparated();
511 do { 510 do {
512 CSSValue* value = 511 CSSValue* value =
513 ConsumeAnimationValue(property, range, context, use_legacy_parsing); 512 ConsumeAnimationValue(property, range, context, use_legacy_parsing);
514 if (!value) 513 if (!value)
515 return nullptr; 514 return nullptr;
516 list->Append(*value); 515 list->Append(*value);
517 } while (ConsumeCommaIncludingWhitespace(range)); 516 } while (ConsumeCommaIncludingWhitespace(range));
518 if (!IsValidAnimationPropertyList(property, *list)) 517 if (property == CSSPropertyTransitionProperty &&
518 !IsValidAnimationPropertyList(*list))
519 return nullptr; 519 return nullptr;
520 DCHECK(list->length()); 520 DCHECK(list->length());
521 return list; 521 return list;
522 } 522 }
523 523
524 bool CSSPropertyParser::ConsumeAnimationShorthand( 524 bool CSSPropertyParser::ConsumeAnimationShorthand(
525 const StylePropertyShorthand& shorthand, 525 const StylePropertyShorthand& shorthand,
526 bool use_legacy_parsing, 526 bool use_legacy_parsing,
527 bool important) { 527 bool important) {
528 const unsigned longhand_count = shorthand.length(); 528 const unsigned longhand_count = shorthand.length();
(...skipping 25 matching lines...) Expand all
554 554
555 // TODO(timloh): This will make invalid longhands, see crbug.com/386459 555 // TODO(timloh): This will make invalid longhands, see crbug.com/386459
556 for (size_t i = 0; i < longhand_count; ++i) { 556 for (size_t i = 0; i < longhand_count; ++i) {
557 if (!parsed_longhand[i]) 557 if (!parsed_longhand[i])
558 longhands[i]->Append(*CSSInitialValue::Create()); 558 longhands[i]->Append(*CSSInitialValue::Create());
559 parsed_longhand[i] = false; 559 parsed_longhand[i] = false;
560 } 560 }
561 } while (ConsumeCommaIncludingWhitespace(range_)); 561 } while (ConsumeCommaIncludingWhitespace(range_));
562 562
563 for (size_t i = 0; i < longhand_count; ++i) { 563 for (size_t i = 0; i < longhand_count; ++i) {
564 if (!IsValidAnimationPropertyList(shorthand.properties()[i], *longhands[i])) 564 // TODO(bugsnash): Refactor out the need to check for
565 // CSSPropertyTransitionProperty here when this is method implemented in the
566 // property APIs
567 if (shorthand.properties()[i] == CSSPropertyTransitionProperty &&
568 !IsValidAnimationPropertyList(*longhands[i]))
565 return false; 569 return false;
566 } 570 }
567 571
568 for (size_t i = 0; i < longhand_count; ++i) 572 for (size_t i = 0; i < longhand_count; ++i)
569 AddProperty(shorthand.properties()[i], shorthand.id(), *longhands[i], 573 AddProperty(shorthand.properties()[i], shorthand.id(), *longhands[i],
570 important); 574 important);
571 575
572 return range_.AtEnd(); 576 return range_.AtEnd();
573 } 577 }
574 578
(...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 case CSSPropertyPlaceItems: 3431 case CSSPropertyPlaceItems:
3428 return ConsumePlaceItemsShorthand(important); 3432 return ConsumePlaceItemsShorthand(important);
3429 case CSSPropertyPlaceSelf: 3433 case CSSPropertyPlaceSelf:
3430 return ConsumePlaceSelfShorthand(important); 3434 return ConsumePlaceSelfShorthand(important);
3431 default: 3435 default:
3432 return false; 3436 return false;
3433 } 3437 }
3434 } 3438 }
3435 3439
3436 } // namespace blink 3440 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698