OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 void StyleSheetHandler::startRuleBody(unsigned offset) { | 232 void StyleSheetHandler::startRuleBody(unsigned offset) { |
233 m_currentRuleData = nullptr; | 233 m_currentRuleData = nullptr; |
234 ASSERT(!m_currentRuleDataStack.isEmpty()); | 234 ASSERT(!m_currentRuleDataStack.isEmpty()); |
235 if (m_parsedText[offset] == '{') | 235 if (m_parsedText[offset] == '{') |
236 ++offset; // Skip the rule body opening brace. | 236 ++offset; // Skip the rule body opening brace. |
237 m_currentRuleDataStack.back()->ruleBodyRange.start = offset; | 237 m_currentRuleDataStack.back()->ruleBodyRange.start = offset; |
238 } | 238 } |
239 | 239 |
240 void StyleSheetHandler::endRuleBody(unsigned offset) { | 240 void StyleSheetHandler::endRuleBody(unsigned offset) { |
| 241 // Pop off data for a previous invalid rule. |
| 242 if (m_currentRuleData) { |
| 243 m_currentRuleData = nullptr; |
| 244 m_currentRuleDataStack.pop_back(); |
| 245 } |
| 246 |
241 ASSERT(!m_currentRuleDataStack.isEmpty()); | 247 ASSERT(!m_currentRuleDataStack.isEmpty()); |
242 m_currentRuleDataStack.back()->ruleBodyRange.end = offset; | 248 m_currentRuleDataStack.back()->ruleBodyRange.end = offset; |
243 RefPtr<CSSRuleSourceData> rule = popRuleData(); | 249 RefPtr<CSSRuleSourceData> rule = popRuleData(); |
244 | 250 |
245 fixUnparsedPropertyRanges(rule.get()); | 251 fixUnparsedPropertyRanges(rule.get()); |
246 addNewRuleToSourceTree(rule.release()); | 252 addNewRuleToSourceTree(rule.release()); |
247 } | 253 } |
248 | 254 |
249 void StyleSheetHandler::addNewRuleToSourceTree( | 255 void StyleSheetHandler::addNewRuleToSourceTree( |
250 PassRefPtr<CSSRuleSourceData> rule) { | 256 PassRefPtr<CSSRuleSourceData> rule) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 bool verifyKeyframeKeyText(Document* document, const String& keyText) { | 453 bool verifyKeyframeKeyText(Document* document, const String& keyText) { |
448 StyleSheetContents* styleSheet = | 454 StyleSheetContents* styleSheet = |
449 StyleSheetContents::create(strictCSSParserContext()); | 455 StyleSheetContents::create(strictCSSParserContext()); |
450 RuleSourceDataList sourceData; | 456 RuleSourceDataList sourceData; |
451 String text = "@keyframes boguzAnim { " + keyText + | 457 String text = "@keyframes boguzAnim { " + keyText + |
452 " { -webkit-boguz-propertee : none; } }"; | 458 " { -webkit-boguz-propertee : none; } }"; |
453 StyleSheetHandler handler(text, document, &sourceData); | 459 StyleSheetHandler handler(text, document, &sourceData); |
454 CSSParser::parseSheetForInspector(parserContextForDocument(document), | 460 CSSParser::parseSheetForInspector(parserContextForDocument(document), |
455 styleSheet, text, handler); | 461 styleSheet, text, handler); |
456 | 462 |
457 // Exactly two should be parsed. | 463 // Exactly one should be parsed. |
458 unsigned ruleCount = sourceData.size(); | 464 unsigned ruleCount = sourceData.size(); |
459 if (ruleCount != 2 || sourceData.at(0)->type != StyleRule::Keyframes || | 465 if (ruleCount != 1 || sourceData.at(0)->type != StyleRule::Keyframes) |
460 sourceData.at(1)->type != StyleRule::Keyframe) | 466 return false; |
| 467 |
| 468 const CSSRuleSourceData& keyframesData = *sourceData.at(0); |
| 469 if (keyframesData.childRules.size() != 1 || |
| 470 keyframesData.childRules.at(0)->type != StyleRule::Keyframe) |
461 return false; | 471 return false; |
462 | 472 |
463 // Exactly one property should be in keyframe rule. | 473 // Exactly one property should be in keyframe rule. |
464 Vector<CSSPropertySourceData>& propertyData = | 474 Vector<CSSPropertySourceData>& propertyData = |
465 sourceData.at(1)->styleSourceData->propertyData; | 475 keyframesData.childRules.at(0)->styleSourceData->propertyData; |
466 unsigned propertyCount = propertyData.size(); | 476 unsigned propertyCount = propertyData.size(); |
467 if (propertyCount != 1) | 477 if (propertyCount != 1) |
468 return false; | 478 return false; |
469 | 479 |
470 return true; | 480 return true; |
471 } | 481 } |
472 | 482 |
473 bool verifySelectorText(Document* document, const String& selectorText) { | 483 bool verifySelectorText(Document* document, const String& selectorText) { |
474 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); | 484 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); |
475 StyleSheetContents* styleSheet = | 485 StyleSheetContents* styleSheet = |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 return m_element->getAttribute("style").getString(); | 2013 return m_element->getAttribute("style").getString(); |
2004 } | 2014 } |
2005 | 2015 |
2006 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) { | 2016 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) { |
2007 visitor->trace(m_element); | 2017 visitor->trace(m_element); |
2008 visitor->trace(m_inspectorStyle); | 2018 visitor->trace(m_inspectorStyle); |
2009 InspectorStyleSheetBase::trace(visitor); | 2019 InspectorStyleSheetBase::trace(visitor); |
2010 } | 2020 } |
2011 | 2021 |
2012 } // namespace blink | 2022 } // namespace blink |
OLD | NEW |