From dac9d5be4c497a51b6e083bc9b232977d8e195c1 Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Fri, 26 Jun 2009 14:06:35 -0700 Subject: Add JavaScript parsing into instrumentation. Also modify css parsing calculations. --- WebCore/css/CSSParser.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++ WebCore/css/CSSStyleSheet.cpp | 10 -------- 2 files changed, 58 insertions(+), 10 deletions(-) (limited to 'WebCore/css') diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index e420a5f..fc431b7 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -88,6 +88,10 @@ using namespace WTF; #include "CSSPropertyNames.cpp" #include "CSSValueKeywords.c" +#ifdef ANDROID_INSTRUMENT +#include "TimeCounter.h" +#endif + namespace WebCore { static bool equal(const CSSParserString& a, const char* b) @@ -217,32 +221,53 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif m_styleSheet = sheet; m_defaultNamespace = starAtom; // Reset the default namespace. setupParser("", string, ""); cssyyparse(this); m_rule = 0; +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif } PassRefPtr CSSParser::parseRule(CSSStyleSheet* sheet, const String& string) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif m_styleSheet = sheet; setupParser("@-webkit-rule{", string, "} "); cssyyparse(this); +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return m_rule.release(); } PassRefPtr CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif m_styleSheet = sheet; setupParser("@-webkit-keyframe-rule{ ", string, "} "); cssyyparse(this); +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return m_keyframe.release(); } bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, const String& string, bool important) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet()); m_styleSheet = static_cast(declaration->stylesheet()); @@ -264,6 +289,9 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, cons clearProperties(); } +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return ok; } @@ -294,6 +322,9 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String& string) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet()); m_styleSheet = static_cast(declaration->stylesheet()); @@ -301,11 +332,17 @@ bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String cssyyparse(this); m_rule = 0; +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return (m_numParsedProperties && m_parsedProperties[0]->m_id == CSSPropertyColor); } void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif RefPtr dummyStyleSheet = CSSStyleSheet::create(doc); m_styleSheet = dummyStyleSheet.get(); @@ -316,10 +353,16 @@ void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorLi cssyyparse(this); m_selectorListForParseSelector = 0; +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif } bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet()); m_styleSheet = static_cast(declaration->stylesheet()); @@ -336,6 +379,9 @@ bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const clearProperties(); } +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return ok; } @@ -344,6 +390,9 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string) if (string.isEmpty()) return true; +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif m_mediaQuery = 0; // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token. // instead insert one " " (which is WHITESPACE in CSSGrammar.y) @@ -357,6 +406,9 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string) m_mediaQuery = 0; } +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return ok; } @@ -4643,6 +4695,9 @@ void CSSParser::clearVariables() bool CSSParser::parseVariable(CSSVariablesDeclaration* declaration, const String& variableName, const String& variableValue) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter); +#endif m_styleSheet = static_cast(declaration->stylesheet()); String nameValuePair = variableName + ": "; @@ -4660,6 +4715,9 @@ bool CSSParser::parseVariable(CSSVariablesDeclaration* declaration, const String clearVariables(); +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__); +#endif return ok; } diff --git a/WebCore/css/CSSStyleSheet.cpp b/WebCore/css/CSSStyleSheet.cpp index 2e9255b..47b2c81 100644 --- a/WebCore/css/CSSStyleSheet.cpp +++ b/WebCore/css/CSSStyleSheet.cpp @@ -31,10 +31,6 @@ #include "TextEncoding.h" #include -#ifdef ANDROID_INSTRUMENT -#include "TimeCounter.h" -#endif - namespace WebCore { CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset) @@ -163,15 +159,9 @@ const AtomicString& CSSStyleSheet::determineNamespace(const AtomicString& prefix bool CSSStyleSheet::parseString(const String &string, bool strict) { -#ifdef ANDROID_INSTRUMENT - android::TimeCounter::start(android::TimeCounter::CSSTimeCounter); -#endif setStrictParsing(strict); CSSParser p(strict); p.parseSheet(this, string); -#ifdef ANDROID_INSTRUMENT - android::TimeCounter::record(android::TimeCounter::CSSTimeCounter, __FUNCTION__); -#endif return true; } -- cgit v1.1