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

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

Issue 216433003: RFC: Make BisonCSSParser purely stack allocated. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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: Source/core/inspector/InspectorStyleSheet.cpp
diff --git a/Source/core/inspector/InspectorStyleSheet.cpp b/Source/core/inspector/InspectorStyleSheet.cpp
index eb02db38e53f485546e3adfbd35c7160bc447af5..339003c7a359fe1442fb10f70b1138d047891484 100644
--- a/Source/core/inspector/InspectorStyleSheet.cpp
+++ b/Source/core/inspector/InspectorStyleSheet.cpp
@@ -59,11 +59,6 @@ using WebCore::RuleSourceDataList;
using WebCore::CSSRuleSourceData;
using WebCore::CSSStyleSheet;
-static PassOwnPtr<WebCore::BisonCSSParser> createCSSParser(WebCore::Document* document)
-{
- return adoptPtr(new WebCore::BisonCSSParser(document ? WebCore::CSSParserContext(*document, 0) : WebCore::strictCSSParserContext()));
-}
-
namespace {
using namespace WebCore;
@@ -75,6 +70,7 @@ public:
, m_document(document)
, m_styleSheetContents(styleSheetContents)
, m_result(result)
+ , m_commentParser(document)
, m_propertyRangeStart(UINT_MAX)
, m_selectorRangeStart(UINT_MAX)
, m_commentRangeStart(UINT_MAX)
@@ -106,7 +102,7 @@ private:
RuleSourceDataList* m_result;
RuleSourceDataList m_currentRuleDataStack;
RefPtr<CSSRuleSourceData> m_currentRuleData;
- OwnPtr<BisonCSSParser> m_commentParser;
+ BisonCSSParser m_commentParser;
unsigned m_propertyRangeStart;
unsigned m_selectorRangeStart;
unsigned m_commentRangeStart;
@@ -333,15 +329,13 @@ void StyleSheetHandler::endComment(unsigned offset)
return;
// FIXME: Use the actual rule type rather than STYLE_RULE?
- if (!m_commentParser)
- m_commentParser = createCSSParser(m_document);
RuleSourceDataList sourceData;
// FIXME: Use another subclass of BisonCSSParser::SourceDataHandler and assert that
// no comments are encountered (will not need m_document and m_styleSheetContents).
StyleSheetHandler handler(commentText, m_document, m_styleSheetContents, &sourceData);
RefPtrWillBeRawPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertySet::create();
- m_commentParser->parseDeclaration(tempMutableStyle.get(), commentText, &handler, m_styleSheetContents);
+ m_commentParser.parseDeclaration(tempMutableStyle.get(), commentText, &handler, m_styleSheetContents);
Vector<CSSPropertySourceData>& commentPropertyData = sourceData.first()->styleSourceData->propertyData;
if (commentPropertyData.size() != 1)
return;
@@ -419,7 +413,7 @@ bool ParsedStyleSheet::ensureSourceData()
RefPtrWillBeRawPtr<StyleSheetContents> newStyleSheet = StyleSheetContents::create(strictCSSParserContext());
OwnPtr<RuleSourceDataList> result = adoptPtr(new RuleSourceDataList());
StyleSheetHandler handler(text(), m_pageStyleSheet->ownerDocument(), newStyleSheet.get(), result.get());
- createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), text(), TextPosition::minimumPosition(), &handler);
+ BisonCSSParser(m_pageStyleSheet->ownerDocument()).parseSheet(newStyleSheet.get(), text(), TextPosition::minimumPosition(), &handler);
setSourceData(result.release());
return hasSourceData();
}
@@ -556,7 +550,7 @@ bool InspectorStyle::verifyPropertyText(const String& propertyText, bool canOmit
RefPtrWillBeRawPtr<StyleSheetContents> styleSheetContents = StyleSheetContents::create(strictCSSParserContext());
String declarationText = propertyText + (canOmitSemicolon ? ";" : " ") + bogusPropertyName + ": none";
StyleSheetHandler handler(declarationText, ownerDocument(), styleSheetContents.get(), &sourceData);
- createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get(), declarationText, &handler, styleSheetContents.get());
+ BisonCSSParser(ownerDocument()).parseDeclaration(tempMutableStyle.get(), declarationText, &handler, styleSheetContents.get());
Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleSourceData->propertyData;
unsigned propertyCount = propertyData.size();
@@ -994,7 +988,7 @@ bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String
static bool checkStyleRuleSelector(Document* document, const String& selector)
{
CSSSelectorList selectorList;
- createCSSParser(document)->parseSelector(selector, selectorList);
+ BisonCSSParser(document).parseSelector(selector, selectorList);
return selectorList.isValid();
}
@@ -1596,7 +1590,7 @@ PassRefPtr<CSSRuleSourceData> InspectorStyleSheetForInlineStyle::getStyleAttribu
RefPtrWillBeRawPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::create();
RuleSourceDataList ruleSourceDataResult;
StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->document().elementSheet().contents(), &ruleSourceDataResult);
- createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.get(), m_styleText, &handler, m_element->document().elementSheet().contents());
+ BisonCSSParser(&m_element->document()).parseDeclaration(tempDeclaration.get(), m_styleText, &handler, m_element->document().elementSheet().contents());
return ruleSourceDataResult.first().release();
}
« Source/core/css/parser/BisonCSSParser-in.cpp ('K') | « Source/core/css/parser/CSSParserObserver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698