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

Side by Side Diff: sky/engine/core/css/parser/BisonCSSParser-in.cpp

Issue 867903002: Remove UseCounter (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/parser/BisonCSSParser.h ('k') | sky/engine/core/css/parser/CSSParserMode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "sky/engine/core/css/StyleRule.h" 63 #include "sky/engine/core/css/StyleRule.h"
64 #include "sky/engine/core/css/StyleKeyframe.h" 64 #include "sky/engine/core/css/StyleKeyframe.h"
65 #include "sky/engine/core/css/StyleRuleKeyframes.h" 65 #include "sky/engine/core/css/StyleRuleKeyframes.h"
66 #include "sky/engine/core/css/StyleSheetContents.h" 66 #include "sky/engine/core/css/StyleSheetContents.h"
67 #include "sky/engine/core/css/parser/CSSParserIdioms.h" 67 #include "sky/engine/core/css/parser/CSSParserIdioms.h"
68 #include "sky/engine/core/dom/Document.h" 68 #include "sky/engine/core/dom/Document.h"
69 #include "sky/engine/core/frame/FrameConsole.h" 69 #include "sky/engine/core/frame/FrameConsole.h"
70 #include "sky/engine/core/frame/FrameHost.h" 70 #include "sky/engine/core/frame/FrameHost.h"
71 #include "sky/engine/core/frame/LocalFrame.h" 71 #include "sky/engine/core/frame/LocalFrame.h"
72 #include "sky/engine/core/frame/Settings.h" 72 #include "sky/engine/core/frame/Settings.h"
73 #include "sky/engine/core/frame/UseCounter.h"
74 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" 73 #include "sky/engine/core/html/parser/HTMLParserIdioms.h"
75 #include "sky/engine/core/inspector/ConsoleMessage.h" 74 #include "sky/engine/core/inspector/ConsoleMessage.h"
76 #include "sky/engine/core/rendering/RenderTheme.h" 75 #include "sky/engine/core/rendering/RenderTheme.h"
77 #include "sky/engine/platform/FloatConversion.h" 76 #include "sky/engine/platform/FloatConversion.h"
78 #include "sky/engine/wtf/BitArray.h" 77 #include "sky/engine/wtf/BitArray.h"
79 #include "sky/engine/wtf/HexNumber.h" 78 #include "sky/engine/wtf/HexNumber.h"
80 #include "sky/engine/wtf/text/StringBuffer.h" 79 #include "sky/engine/wtf/text/StringBuffer.h"
81 #include "sky/engine/wtf/text/StringBuilder.h" 80 #include "sky/engine/wtf/text/StringBuilder.h"
82 #include "sky/engine/wtf/text/StringImpl.h" 81 #include "sky/engine/wtf/text/StringImpl.h"
83 #include "sky/engine/wtf/text/TextEncoding.h" 82 #include "sky/engine/wtf/text/TextEncoding.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 CSSValueList* valueList = toCSSValueList(value.get()); 785 CSSValueList* valueList = toCSSValueList(value.get());
787 if (valueList->length() > 1) 786 if (valueList->length() > 1)
788 return nullptr; 787 return nullptr;
789 return valueList->item(0); 788 return valueList->item(0);
790 } 789 }
791 790
792 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, const Document& document) 791 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, const Document& document)
793 { 792 {
794 ASSERT(!string.isEmpty()); 793 ASSERT(!string.isEmpty());
795 794
796 CSSParserContext context(document, UseCounter::getFrom(&document)); 795 CSSParserContext context(document);
797 796
798 if (parseSimpleLengthValue(declaration, propertyID, string, context.mode())) 797 if (parseSimpleLengthValue(declaration, propertyID, string, context.mode()))
799 return true; 798 return true;
800 if (parseColorValue(declaration, propertyID, string, context.mode())) 799 if (parseColorValue(declaration, propertyID, string, context.mode()))
801 return true; 800 return true;
802 if (parseKeywordValue(declaration, propertyID, string, context)) 801 if (parseKeywordValue(declaration, propertyID, string, context))
803 return true; 802 return true;
804 803
805 BisonCSSParser parser(context); 804 BisonCSSParser parser(context);
806 return parser.parseValue(declaration, propertyID, string, static_cast<StyleS heetContents*>(0)); 805 return parser.parseValue(declaration, propertyID, string, static_cast<StyleS heetContents*>(0));
807 } 806 }
808 807
809 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, CSSParserMode cssParserMode, StyleSheetCon tents* contextStyleSheet) 808 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, CSSParserMode cssParserMode, StyleSheetCon tents* contextStyleSheet)
810 { 809 {
811 ASSERT(!string.isEmpty()); 810 ASSERT(!string.isEmpty());
812 if (parseSimpleLengthValue(declaration, propertyID, string, cssParserMode)) 811 if (parseSimpleLengthValue(declaration, propertyID, string, cssParserMode))
813 return true; 812 return true;
814 if (parseColorValue(declaration, propertyID, string, cssParserMode)) 813 if (parseColorValue(declaration, propertyID, string, cssParserMode))
815 return true; 814 return true;
816 815
817 CSSParserContext context(0); // FIXME: Why does this not have a UseCounter? 816 CSSParserContext context;
818 if (contextStyleSheet) { 817 if (contextStyleSheet)
819 context = contextStyleSheet->parserContext(); 818 context = contextStyleSheet->parserContext();
820 }
821 819
822 if (parseKeywordValue(declaration, propertyID, string, context)) 820 if (parseKeywordValue(declaration, propertyID, string, context))
823 return true; 821 return true;
824 if (parseSimpleTransform(declaration, propertyID, string)) 822 if (parseSimpleTransform(declaration, propertyID, string))
825 return true; 823 return true;
826 824
827 BisonCSSParser parser(context); 825 BisonCSSParser parser(context);
828 return parser.parseValue(declaration, propertyID, string, contextStyleSheet) ; 826 return parser.parseValue(declaration, propertyID, string, contextStyleSheet) ;
829 } 827 }
830 828
831 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, StyleSheetContents* contextStyleSheet) 829 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, StyleSheetContents* contextStyleSheet)
832 { 830 {
833 if (m_context.useCounter())
834 m_context.useCounter()->count(m_context, propertyID);
835
836 setStyleSheet(contextStyleSheet); 831 setStyleSheet(contextStyleSheet);
837 832
838 setupParser("@-internal-value ", string, ""); 833 setupParser("@-internal-value ", string, "");
839 834
840 m_id = propertyID; 835 m_id = propertyID;
841 836
842 cssyyparse(this); 837 cssyyparse(this);
843 838
844 m_rule = nullptr; 839 m_rule = nullptr;
845 m_id = CSSPropertyInvalid; 840 m_id = CSSPropertyInvalid;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 setupParser("@-internal-selector ", string, ""); 914 setupParser("@-internal-selector ", string, "");
920 915
921 cssyyparse(this); 916 cssyyparse(this);
922 917
923 m_selectorListForParseSelector = 0; 918 m_selectorListForParseSelector = 0;
924 } 919 }
925 920
926 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseInlineStyleDeclaratio n(const String& string, Element* element) 921 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseInlineStyleDeclaratio n(const String& string, Element* element)
927 { 922 {
928 Document& document = element->document(); 923 Document& document = element->document();
929 CSSParserContext context = CSSParserContext(document.elementSheet().contents ()->parserContext(), UseCounter::getFrom(&document)); 924 CSSParserContext context = CSSParserContext(document.elementSheet().contents ()->parserContext());
930 return BisonCSSParser(context).parseDeclaration(string, document.elementShee t().contents()); 925 return BisonCSSParser(context).parseDeclaration(string, document.elementShee t().contents());
931 } 926 }
932 927
933 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseDeclaration(const Str ing& string, StyleSheetContents* contextStyleSheet) 928 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseDeclaration(const Str ing& string, StyleSheetContents* contextStyleSheet)
934 { 929 {
935 setStyleSheet(contextStyleSheet); 930 setStyleSheet(contextStyleSheet);
936 931
937 setupParser("@-internal-decls ", string, ""); 932 setupParser("@-internal-decls ", string, "");
938 cssyyparse(this); 933 cssyyparse(this);
939 m_rule = nullptr; 934 m_rule = nullptr;
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); 1491 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create();
1497 for (size_t i = 0; i < keyframes->size(); ++i) 1492 for (size_t i = 0; i < keyframes->size(); ++i)
1498 rule->parserAppendKeyframe(keyframes->at(i)); 1493 rule->parserAppendKeyframe(keyframes->at(i));
1499 rule->setName(name); 1494 rule->setName(name);
1500 rule->setVendorPrefixed(isPrefixed); 1495 rule->setVendorPrefixed(isPrefixed);
1501 StyleRuleKeyframes* rulePtr = rule.get(); 1496 StyleRuleKeyframes* rulePtr = rule.get();
1502 m_parsedRules.append(rule.release()); 1497 m_parsedRules.append(rule.release());
1503 return rulePtr; 1498 return rulePtr;
1504 } 1499 }
1505 1500
1506 static void recordSelectorStats(const CSSParserContext& context, const CSSSelect orList& selectorList)
1507 {
1508 if (!context.useCounter())
1509 return;
1510
1511 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) {
1512 for (const CSSSelector* current = selector; current ; current = current- >tagHistory()) {
1513 UseCounter::Feature feature = UseCounter::NumberOfFeatures;
1514 switch (current->pseudoType()) {
1515 case CSSSelector::PseudoHost:
1516 feature = UseCounter::CSSSelectorPseudoHost;
1517 break;
1518 default:
1519 break;
1520 }
1521 if (feature != UseCounter::NumberOfFeatures)
1522 context.useCounter()->count(feature);
1523 if (current->selectorList())
1524 recordSelectorStats(context, *current->selectorList());
1525 }
1526 }
1527 }
1528
1529 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors) 1501 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors)
1530 { 1502 {
1531 StyleRule* result = 0; 1503 StyleRule* result = 0;
1532 if (selectors) { 1504 if (selectors) {
1533 m_allowImportRules = m_allowNamespaceDeclarations = false; 1505 m_allowImportRules = m_allowNamespaceDeclarations = false;
1534 RefPtr<StyleRule> rule = StyleRule::create(); 1506 RefPtr<StyleRule> rule = StyleRule::create();
1535 rule->parserAdoptSelectorVector(*selectors); 1507 rule->parserAdoptSelectorVector(*selectors);
1536 rule->setProperties(createStylePropertySet()); 1508 rule->setProperties(createStylePropertySet());
1537 result = rule.get(); 1509 result = rule.get();
1538 m_parsedRules.append(rule.release()); 1510 m_parsedRules.append(rule.release());
1539 recordSelectorStats(m_context, result->selectorList());
1540 } 1511 }
1541 clearProperties(); 1512 clearProperties();
1542 return result; 1513 return result;
1543 } 1514 }
1544 1515
1545 StyleRuleBase* BisonCSSParser::createFontFaceRule() 1516 StyleRuleBase* BisonCSSParser::createFontFaceRule()
1546 { 1517 {
1547 m_allowImportRules = m_allowNamespaceDeclarations = false; 1518 m_allowImportRules = m_allowNamespaceDeclarations = false;
1548 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 1519 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
1549 CSSProperty& property = m_parsedProperties[i]; 1520 CSSProperty& property = m_parsedProperties[i];
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 m_observer->endProperty(isPropertyParsed, m_tokenizer.safeUserStringToke nOffset(), errorType); 1662 m_observer->endProperty(isPropertyParsed, m_tokenizer.safeUserStringToke nOffset(), errorType);
1692 } 1663 }
1693 1664
1694 void BisonCSSParser::startEndUnknownRule() 1665 void BisonCSSParser::startEndUnknownRule()
1695 { 1666 {
1696 if (m_observer) 1667 if (m_observer)
1697 m_observer->startEndUnknownRule(); 1668 m_observer->startEndUnknownRule();
1698 } 1669 }
1699 1670
1700 } 1671 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/BisonCSSParser.h ('k') | sky/engine/core/css/parser/CSSParserMode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698