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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp

Issue 2503683003: [WIP] Streaming CSS parser (Closed)
Patch Set: rebase Created 3 years, 11 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
Index: third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp b/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
index b3ba93ffe01df2fb729516d921cd07fbdaf35f58..9fba3151c858fa698d5ca179c6610f0a1a363394 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
@@ -238,6 +238,12 @@ void StyleSheetHandler::startRuleBody(unsigned offset) {
}
void StyleSheetHandler::endRuleBody(unsigned offset) {
+ // Pop off data for a previous invalid rule.
+ if (m_currentRuleData) {
+ m_currentRuleData = nullptr;
+ m_currentRuleDataStack.pop_back();
+ }
+
ASSERT(!m_currentRuleDataStack.isEmpty());
m_currentRuleDataStack.back()->ruleBodyRange.end = offset;
RefPtr<CSSRuleSourceData> rule = popRuleData();
@@ -454,15 +460,19 @@ bool verifyKeyframeKeyText(Document* document, const String& keyText) {
CSSParser::parseSheetForInspector(parserContextForDocument(document),
styleSheet, text, handler);
- // Exactly two should be parsed.
+ // Exactly one should be parsed.
unsigned ruleCount = sourceData.size();
- if (ruleCount != 2 || sourceData.at(0)->type != StyleRule::Keyframes ||
- sourceData.at(1)->type != StyleRule::Keyframe)
+ if (ruleCount != 1 || sourceData.at(0)->type != StyleRule::Keyframes)
+ return false;
+
+ const CSSRuleSourceData& keyframesData = *sourceData.at(0);
+ if (keyframesData.childRules.size() != 1 ||
+ keyframesData.childRules.at(0)->type != StyleRule::Keyframe)
return false;
// Exactly one property should be in keyframe rule.
Vector<CSSPropertySourceData>& propertyData =
- sourceData.at(1)->styleSourceData->propertyData;
+ keyframesData.childRules.at(0)->styleSourceData->propertyData;
unsigned propertyCount = propertyData.size();
if (propertyCount != 1)
return false;

Powered by Google App Engine
This is Rietveld 408576698