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

Side by Side Diff: Source/core/css/CSSParser.cpp

Issue 13943004: Avoid reparsing keyframe selectors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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 11003 matching lines...) Expand 10 before | Expand all | Expand 10 after
11014 { 11014 {
11015 PageConsole* console = m_styleSheet->singleOwnerDocument()->page()->console( ); 11015 PageConsole* console = m_styleSheet->singleOwnerDocument()->page()->console( );
11016 console->addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleS heet->baseURL().string(), lineNumber + 1); 11016 console->addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleS heet->baseURL().string(), lineNumber + 1);
11017 } 11017 }
11018 11018
11019 StyleRuleKeyframes* CSSParser::createKeyframesRule(const String& name, PassOwnPt r<Vector<RefPtr<StyleKeyframe> > > popKeyframes) 11019 StyleRuleKeyframes* CSSParser::createKeyframesRule(const String& name, PassOwnPt r<Vector<RefPtr<StyleKeyframe> > > popKeyframes)
11020 { 11020 {
11021 OwnPtr<Vector<RefPtr<StyleKeyframe> > > keyframes = popKeyframes; 11021 OwnPtr<Vector<RefPtr<StyleKeyframe> > > keyframes = popKeyframes;
11022 m_allowImportRules = m_allowNamespaceDeclarations = false; 11022 m_allowImportRules = m_allowNamespaceDeclarations = false;
11023 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); 11023 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create();
11024 for (size_t i = 0; i < keyframes->size(); ++i) 11024 for (size_t i = 0; i < keyframes->size(); ++i) {
11025 rule->parserAppendKeyframe(keyframes->at(i)); 11025 RefPtr<StyleKeyframe> keyframe = keyframes->at(i);
11026 if (keyframe->isValid()) {
11027 rule->parserAppendKeyframe(keyframe);
11028 continue;
11029 }
11030 return 0;
11031 }
11032
11026 rule->setName(name); 11033 rule->setName(name);
11027 StyleRuleKeyframes* rulePtr = rule.get(); 11034 StyleRuleKeyframes* rulePtr = rule.get();
11028 m_parsedRules.append(rule.release()); 11035 m_parsedRules.append(rule.release());
11029 endRuleBody(); 11036 endRuleBody();
11030 return rulePtr; 11037 return rulePtr;
11031 } 11038 }
11032 11039
11033 StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se lectors) 11040 StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se lectors)
11034 { 11041 {
11035 StyleRule* result = 0; 11042 StyleRule* result = 0;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
11269 if (property.id() == CSSPropertyFontVariant && property.value()->isValue List()) { 11276 if (property.id() == CSSPropertyFontVariant && property.value()->isValue List()) {
11270 m_parsedProperties.remove(i); 11277 m_parsedProperties.remove(i);
11271 continue; 11278 continue;
11272 } 11279 }
11273 ++i; 11280 ++i;
11274 } 11281 }
11275 } 11282 }
11276 11283
11277 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) 11284 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
11278 { 11285 {
11279 // Create a key string from the passed keys 11286 Vector<float> keyframeKeys;
11280 StringBuilder keyString; 11287 unsigned keyCount = keys->size();
11281 for (unsigned i = 0; i < keys->size(); ++i) { 11288 for (unsigned i = 0; i < keyCount; ++i) {
11282 float key = static_cast<float>(keys->valueAt(i)->fValue); 11289 CSSParserValue* value = keys->valueAt(i);
11283 if (i != 0) 11290 if (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) {
11284 keyString.append(','); 11291 keyframeKeys.append(static_cast<float>(value->fValue / 100));
11285 keyString.append(String::number(key)); 11292 continue;
11286 keyString.append('%'); 11293 }
11294 keyframeKeys.clear();
11295 break;
11287 } 11296 }
11288 11297
11289 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); 11298 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
11290 keyframe->setKeyText(keyString.toString()); 11299 keyframe->setKeys(keyframeKeys);
11291 keyframe->setProperties(createStylePropertySet()); 11300 keyframe->setProperties(createStylePropertySet());
11292 11301
11293 clearProperties(); 11302 clearProperties();
11294 11303
11295 StyleKeyframe* keyframePtr = keyframe.get(); 11304 StyleKeyframe* keyframePtr = keyframe.get();
11296 m_parsedKeyframes.append(keyframe.release()); 11305 m_parsedKeyframes.append(keyframe.release());
11297 return keyframePtr; 11306 return keyframePtr;
11298 } 11307 }
11299 11308
11300 void CSSParser::invalidBlockHit() 11309 void CSSParser::invalidBlockHit()
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
11716 { 11725 {
11717 // The tokenizer checks for the construct of an+b. 11726 // The tokenizer checks for the construct of an+b.
11718 // However, since the {ident} rule precedes the {nth} rule, some of those 11727 // However, since the {ident} rule precedes the {nth} rule, some of those
11719 // tokens are identified as string literal. Furthermore we need to accept 11728 // tokens are identified as string literal. Furthermore we need to accept
11720 // "odd" and "even" which does not match to an+b. 11729 // "odd" and "even" which does not match to an+b.
11721 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11730 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11722 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11731 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11723 } 11732 }
11724 11733
11725 } 11734 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698