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

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

Issue 1211813002: DevTools: allow injecting CSS rules without breaking styles sidebar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed. Created 5 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/parser/CSSParserImpl.h ('k') | Source/core/inspector/InspectorStyleSheet.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 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 { 169 {
170 CSSParserImpl parser(context); 170 CSSParserImpl parser(context);
171 CSSParserObserverWrapper wrapper(observer); 171 CSSParserObserverWrapper wrapper(observer);
172 parser.m_observerWrapper = &wrapper; 172 parser.m_observerWrapper = &wrapper;
173 CSSTokenizer::Scope scope(declaration, wrapper); 173 CSSTokenizer::Scope scope(declaration, wrapper);
174 observer.startRuleHeader(StyleRule::Style, 0); 174 observer.startRuleHeader(StyleRule::Style, 0);
175 observer.endRuleHeader(1); 175 observer.endRuleHeader(1);
176 parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style); 176 parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style);
177 } 177 }
178 178
179 void CSSParserImpl::parseStyleSheetForInspector(const String& string, const CSSP arserContext& context, CSSParserObserver& observer) 179 void CSSParserImpl::parseStyleSheetForInspector(const String& string, const CSSP arserContext& context, StyleSheetContents* styleSheet, CSSParserObserver& observ er)
180 { 180 {
181 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(st rictCSSParserContext()); 181 CSSParserImpl parser(context, styleSheet);
182 CSSParserImpl parser(context, sheet.get());
183 CSSParserObserverWrapper wrapper(observer); 182 CSSParserObserverWrapper wrapper(observer);
184 parser.m_observerWrapper = &wrapper; 183 parser.m_observerWrapper = &wrapper;
185 CSSTokenizer::Scope scope(string, wrapper); 184 CSSTokenizer::Scope scope(string, wrapper);
186 parser.consumeRuleList(scope.tokenRange(), TopLevelRuleList, [](PassRefPtrWi llBeRawPtr<StyleRuleBase> rule) { }); 185 bool firstRuleValid = parser.consumeRuleList(scope.tokenRange(), TopLevelRul eList, [&styleSheet](PassRefPtrWillBeRawPtr<StyleRuleBase> rule) {
186 if (rule->isCharsetRule())
187 return;
188 styleSheet->parserAppendRule(rule);
189 });
190 styleSheet->setHasSyntacticallyValidCSSHeader(firstRuleValid);
187 } 191 }
188 192
189 static CSSParserImpl::AllowedRulesType computeNewAllowedRules(CSSParserImpl::All owedRulesType allowedRules, StyleRuleBase* rule) 193 static CSSParserImpl::AllowedRulesType computeNewAllowedRules(CSSParserImpl::All owedRulesType allowedRules, StyleRuleBase* rule)
190 { 194 {
191 if (!rule || allowedRules == CSSParserImpl::KeyframeRules || allowedRules == CSSParserImpl::NoRules) 195 if (!rule || allowedRules == CSSParserImpl::KeyframeRules || allowedRules == CSSParserImpl::NoRules)
192 return allowedRules; 196 return allowedRules;
193 ASSERT(allowedRules <= CSSParserImpl::RegularRules); 197 ASSERT(allowedRules <= CSSParserImpl::RegularRules);
194 if (rule->isCharsetRule() || rule->isImportRule()) 198 if (rule->isCharsetRule() || rule->isImportRule())
195 return CSSParserImpl::AllowImportRules; 199 return CSSParserImpl::AllowImportRules;
196 if (rule->isNamespaceRule()) 200 if (rule->isNamespaceRule())
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 else 724 else
721 return nullptr; // Parser error, invalid value in keyframe selector 725 return nullptr; // Parser error, invalid value in keyframe selector
722 if (range.atEnd()) 726 if (range.atEnd())
723 return result.release(); 727 return result.release();
724 if (range.consume().type() != CommaToken) 728 if (range.consume().type() != CommaToken)
725 return nullptr; // Parser error 729 return nullptr; // Parser error
726 } 730 }
727 } 731 }
728 732
729 } // namespace blink 733 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserImpl.h ('k') | Source/core/inspector/InspectorStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698