| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/inspector/InspectorStyleSheet.h" | 26 #include "core/inspector/InspectorStyleSheet.h" |
| 27 | 27 |
| 28 #include "CSSPropertyNames.h" | 28 #include "CSSPropertyNames.h" |
| 29 #include "HTMLNames.h" | 29 #include "HTMLNames.h" |
| 30 #include "SVGNames.h" | 30 #include "SVGNames.h" |
| 31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 32 #include "bindings/v8/ExceptionStatePlaceholder.h" | 32 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 33 #include "bindings/v8/ScriptRegexp.h" | 33 #include "bindings/v8/ScriptRegexp.h" |
| 34 #include "core/css/CSSKeyframesRule.h" | 34 #include "core/css/CSSKeyframesRule.h" |
| 35 #include "core/css/CSSMediaRule.h" | 35 #include "core/css/CSSMediaRule.h" |
| 36 #include "core/css/parser/BisonCSSParser.h" | 36 #include "core/css/parser/CSSParser.h" |
| 37 #include "core/css/CSSRuleList.h" | 37 #include "core/css/CSSRuleList.h" |
| 38 #include "core/css/CSSStyleRule.h" | 38 #include "core/css/CSSStyleRule.h" |
| 39 #include "core/css/CSSStyleSheet.h" | 39 #include "core/css/CSSStyleSheet.h" |
| 40 #include "core/css/CSSSupportsRule.h" | 40 #include "core/css/CSSSupportsRule.h" |
| 41 #include "core/css/StylePropertySet.h" | 41 #include "core/css/StylePropertySet.h" |
| 42 #include "core/css/StyleRule.h" | 42 #include "core/css/StyleRule.h" |
| 43 #include "core/css/StyleSheetContents.h" | 43 #include "core/css/StyleSheetContents.h" |
| 44 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
| 45 #include "core/dom/Element.h" | 45 #include "core/dom/Element.h" |
| 46 #include "core/frame/PageConsole.h" | 46 #include "core/frame/PageConsole.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 PassRefPtr<WebCore::CSSRuleSourceData> ParsedStyleSheet::ruleSourceDataAt(unsign
ed index) const | 125 PassRefPtr<WebCore::CSSRuleSourceData> ParsedStyleSheet::ruleSourceDataAt(unsign
ed index) const |
| 126 { | 126 { |
| 127 if (!hasSourceData() || index >= m_sourceData->size()) | 127 if (!hasSourceData() || index >= m_sourceData->size()) |
| 128 return 0; | 128 return 0; |
| 129 | 129 |
| 130 return m_sourceData->at(index); | 130 return m_sourceData->at(index); |
| 131 } | 131 } |
| 132 | 132 |
| 133 namespace WebCore { | 133 namespace WebCore { |
| 134 | 134 |
| 135 static PassOwnPtr<BisonCSSParser> createCSSParser(Document* document) | 135 static PassOwnPtr<CSSParser> createCSSParser(Document* document) |
| 136 { | 136 { |
| 137 UseCounter* counter = 0; | 137 UseCounter* counter = 0; |
| 138 return adoptPtr(new BisonCSSParser(document ? CSSParserContext(*document) :
strictCSSParserContext(), counter)); | 138 return adoptPtr(new CSSParser(document ? CSSParserContext(*document) : stric
tCSSParserContext(), counter)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 namespace { | 141 namespace { |
| 142 | 142 |
| 143 class StyleSheetHandler FINAL : public CSSParserObserver { | 143 class StyleSheetHandler FINAL : public CSSParserObserver { |
| 144 public: | 144 public: |
| 145 StyleSheetHandler(const String& parsedText, Document* document, StyleSheetCo
ntents* styleSheetContents, RuleSourceDataList* result) | 145 StyleSheetHandler(const String& parsedText, Document* document, StyleSheetCo
ntents* styleSheetContents, RuleSourceDataList* result) |
| 146 : m_parsedText(parsedText) | 146 : m_parsedText(parsedText) |
| 147 , m_document(document) | 147 , m_document(document) |
| 148 , m_styleSheetContents(styleSheetContents) | 148 , m_styleSheetContents(styleSheetContents) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 171 PassRefPtr<CSSRuleSourceData> popRuleData(); | 171 PassRefPtr<CSSRuleSourceData> popRuleData(); |
| 172 template <typename CharacterType> inline void setRuleHeaderEnd(const Charact
erType*, unsigned); | 172 template <typename CharacterType> inline void setRuleHeaderEnd(const Charact
erType*, unsigned); |
| 173 void fixUnparsedPropertyRanges(CSSRuleSourceData*); | 173 void fixUnparsedPropertyRanges(CSSRuleSourceData*); |
| 174 | 174 |
| 175 const String& m_parsedText; | 175 const String& m_parsedText; |
| 176 Document* m_document; | 176 Document* m_document; |
| 177 StyleSheetContents* m_styleSheetContents; | 177 StyleSheetContents* m_styleSheetContents; |
| 178 RuleSourceDataList* m_result; | 178 RuleSourceDataList* m_result; |
| 179 RuleSourceDataList m_currentRuleDataStack; | 179 RuleSourceDataList m_currentRuleDataStack; |
| 180 RefPtr<CSSRuleSourceData> m_currentRuleData; | 180 RefPtr<CSSRuleSourceData> m_currentRuleData; |
| 181 OwnPtr<BisonCSSParser> m_commentParser; | 181 OwnPtr<CSSParser> m_commentParser; |
| 182 unsigned m_propertyRangeStart; | 182 unsigned m_propertyRangeStart; |
| 183 unsigned m_selectorRangeStart; | 183 unsigned m_selectorRangeStart; |
| 184 unsigned m_commentRangeStart; | 184 unsigned m_commentRangeStart; |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 void StyleSheetHandler::startRuleHeader(CSSRuleSourceData::Type type, unsigned o
ffset) | 187 void StyleSheetHandler::startRuleHeader(CSSRuleSourceData::Type type, unsigned o
ffset) |
| 188 { | 188 { |
| 189 // Pop off data for a previous invalid rule. | 189 // Pop off data for a previous invalid rule. |
| 190 if (m_currentRuleData) | 190 if (m_currentRuleData) |
| 191 m_currentRuleDataStack.removeLast(); | 191 m_currentRuleDataStack.removeLast(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 return; | 402 return; |
| 403 commentText = commentText.substring(0, commentText.length() - 2).stripWhiteS
pace(); | 403 commentText = commentText.substring(0, commentText.length() - 2).stripWhiteS
pace(); |
| 404 if (commentText.isEmpty()) | 404 if (commentText.isEmpty()) |
| 405 return; | 405 return; |
| 406 | 406 |
| 407 // FIXME: Use the actual rule type rather than STYLE_RULE? | 407 // FIXME: Use the actual rule type rather than STYLE_RULE? |
| 408 if (!m_commentParser) | 408 if (!m_commentParser) |
| 409 m_commentParser = createCSSParser(m_document); | 409 m_commentParser = createCSSParser(m_document); |
| 410 RuleSourceDataList sourceData; | 410 RuleSourceDataList sourceData; |
| 411 | 411 |
| 412 // FIXME: Use another subclass of BisonCSSParser::SourceDataHandler and asse
rt that | 412 // FIXME: Use another subclass of CSSParserObserver and assert that |
| 413 // no comments are encountered (will not need m_document and m_styleSheetCon
tents). | 413 // no comments are encountered (will not need m_document and m_styleSheetCon
tents). |
| 414 StyleSheetHandler handler(commentText, m_document, m_styleSheetContents, &so
urceData); | 414 StyleSheetHandler handler(commentText, m_document, m_styleSheetContents, &so
urceData); |
| 415 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertySet::
create(); | 415 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertySet::
create(); |
| 416 m_commentParser->parseDeclaration(tempMutableStyle.get(), commentText, &hand
ler, m_styleSheetContents); | 416 m_commentParser->parseDeclaration(tempMutableStyle.get(), commentText, &hand
ler, m_styleSheetContents); |
| 417 Vector<CSSPropertySourceData>& commentPropertyData = sourceData.first()->sty
leSourceData->propertyData; | 417 Vector<CSSPropertySourceData>& commentPropertyData = sourceData.first()->sty
leSourceData->propertyData; |
| 418 if (commentPropertyData.size() != 1) | 418 if (commentPropertyData.size() != 1) |
| 419 return; | 419 return; |
| 420 CSSPropertySourceData& propertyData = commentPropertyData.at(0); | 420 CSSPropertySourceData& propertyData = commentPropertyData.at(0); |
| 421 if (propertyData.range.length() != commentText.length()) | 421 if (propertyData.range.length() != commentText.length()) |
| 422 return; | 422 return; |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 | 1801 |
| 1802 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1802 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
| 1803 RuleSourceDataList ruleSourceDataResult; | 1803 RuleSourceDataList ruleSourceDataResult; |
| 1804 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet()->contents(), &ruleSourceDataResult); | 1804 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet()->contents(), &ruleSourceDataResult); |
| 1805 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet()->contents()); | 1805 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet()->contents()); |
| 1806 return ruleSourceDataResult.first().release(); | 1806 return ruleSourceDataResult.first().release(); |
| 1807 } | 1807 } |
| 1808 | 1808 |
| 1809 } // namespace WebCore | 1809 } // namespace WebCore |
| 1810 | 1810 |
| OLD | NEW |