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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/CSSParserImpl.h ('k') | Source/core/inspector/InspectorStyleSheet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSParserImpl.cpp
diff --git a/Source/core/css/parser/CSSParserImpl.cpp b/Source/core/css/parser/CSSParserImpl.cpp
index 9998d53ba617b90460269c363ef4511dde2b1f99..b9df04bc5a5ee5963b7a4878215c8b9f56f9204d 100644
--- a/Source/core/css/parser/CSSParserImpl.cpp
+++ b/Source/core/css/parser/CSSParserImpl.cpp
@@ -176,14 +176,18 @@ void CSSParserImpl::parseDeclarationListForInspector(const String& declaration,
parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style);
}
-void CSSParserImpl::parseStyleSheetForInspector(const String& string, const CSSParserContext& context, CSSParserObserver& observer)
+void CSSParserImpl::parseStyleSheetForInspector(const String& string, const CSSParserContext& context, StyleSheetContents* styleSheet, CSSParserObserver& observer)
{
- RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(strictCSSParserContext());
- CSSParserImpl parser(context, sheet.get());
+ CSSParserImpl parser(context, styleSheet);
CSSParserObserverWrapper wrapper(observer);
parser.m_observerWrapper = &wrapper;
CSSTokenizer::Scope scope(string, wrapper);
- parser.consumeRuleList(scope.tokenRange(), TopLevelRuleList, [](PassRefPtrWillBeRawPtr<StyleRuleBase> rule) { });
+ bool firstRuleValid = parser.consumeRuleList(scope.tokenRange(), TopLevelRuleList, [&styleSheet](PassRefPtrWillBeRawPtr<StyleRuleBase> rule) {
+ if (rule->isCharsetRule())
+ return;
+ styleSheet->parserAppendRule(rule);
+ });
+ styleSheet->setHasSyntacticallyValidCSSHeader(firstRuleValid);
}
static CSSParserImpl::AllowedRulesType computeNewAllowedRules(CSSParserImpl::AllowedRulesType allowedRules, StyleRuleBase* rule)
« 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