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

Side by Side Diff: Source/core/css/parser/CSSParserImpl.cpp

Issue 1151893003: Properties labelled !important must be ignored in keyframes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing comments Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParserImpl.h" 6 #include "core/css/parser/CSSParserImpl.h"
7 7
8 #include "core/css/CSSKeyframesRule.h" 8 #include "core/css/CSSKeyframesRule.h"
9 #include "core/css/CSSStyleSheet.h" 9 #include "core/css/CSSStyleSheet.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 654
655 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ e ruleType) 655 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ e ruleType)
656 { 656 {
657 CSSParserTokenRange rangeCopy = range; // For inspector callbacks 657 CSSParserTokenRange rangeCopy = range; // For inspector callbacks
658 658
659 ASSERT(range.peek().type() == IdentToken); 659 ASSERT(range.peek().type() == IdentToken);
660 CSSPropertyID unresolvedProperty = range.consumeIncludingWhitespace().parseA sUnresolvedCSSPropertyID(); 660 CSSPropertyID unresolvedProperty = range.consumeIncludingWhitespace().parseA sUnresolvedCSSPropertyID();
661 if (range.consume().type() != ColonToken) 661 if (range.consume().type() != ColonToken)
662 return; // Parse error 662 return; // Parse error
663 663
664 // FIXME: We shouldn't allow !important in @keyframes or @font-face
665 bool important = false; 664 bool important = false;
666 const CSSParserToken* declarationValueEnd = range.end(); 665 const CSSParserToken* declarationValueEnd = range.end();
667 const CSSParserToken* last = range.end() - 1; 666 const CSSParserToken* last = range.end() - 1;
668 while (last->type() == WhitespaceToken) 667 while (last->type() == WhitespaceToken)
669 --last; 668 --last;
670 if (last->type() == IdentToken && last->valueEqualsIgnoringCase("important") ) { 669 if (last->type() == IdentToken && last->valueEqualsIgnoringCase("important") ) {
671 --last; 670 --last;
672 while (last->type() == WhitespaceToken) 671 while (last->type() == WhitespaceToken)
673 --last; 672 --last;
674 if (last->type() == DelimiterToken && last->delimiter() == '!') { 673 if (last->type() == DelimiterToken && last->delimiter() == '!') {
675 important = true; 674 important = true;
676 declarationValueEnd = last; 675 declarationValueEnd = last;
677 } 676 }
678 } 677 }
679 678
679 if (important && (ruleType == StyleRule::FontFace || ruleType == StyleRule:: Keyframes))
680 return;
681
680 if (m_observerWrapper && ruleType == StyleRule::Style) { 682 if (m_observerWrapper && ruleType == StyleRule::Style) {
681 size_t propertiesCount = m_parsedProperties.size(); 683 size_t propertiesCount = m_parsedProperties.size();
682 if (unresolvedProperty != CSSPropertyInvalid) 684 if (unresolvedProperty != CSSPropertyInvalid)
683 consumeDeclarationValue(range.makeSubRange(&range.peek(), declaratio nValueEnd), unresolvedProperty, important, ruleType); 685 consumeDeclarationValue(range.makeSubRange(&range.peek(), declaratio nValueEnd), unresolvedProperty, important, ruleType);
684 m_observerWrapper->observer().startProperty(m_observerWrapper->startOffs et(rangeCopy)); 686 m_observerWrapper->observer().startProperty(m_observerWrapper->startOffs et(rangeCopy));
685 m_observerWrapper->observer().endProperty(important, 687 m_observerWrapper->observer().endProperty(important,
686 m_parsedProperties.size() != propertiesCount, 688 m_parsedProperties.size() != propertiesCount,
687 m_observerWrapper->endOffset(rangeCopy), NoCSSError); 689 m_observerWrapper->endOffset(rangeCopy), NoCSSError);
688 return; 690 return;
689 } 691 }
(...skipping 30 matching lines...) Expand all
720 else 722 else
721 return nullptr; // Parser error, invalid value in keyframe selector 723 return nullptr; // Parser error, invalid value in keyframe selector
722 if (range.atEnd()) 724 if (range.atEnd())
723 return result.release(); 725 return result.release();
724 if (range.consume().type() != CommaToken) 726 if (range.consume().type() != CommaToken)
725 return nullptr; // Parser error 727 return nullptr; // Parser error
726 } 728 }
727 } 729 }
728 730
729 } // namespace blink 731 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698