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

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

Issue 339563004: Add UseCounter for web components related CSS selectors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for Elliott's comment Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/frame/UseCounter.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 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 RefPtrWillBeRawPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); 1750 RefPtrWillBeRawPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create();
1751 for (size_t i = 0; i < keyframes->size(); ++i) 1751 for (size_t i = 0; i < keyframes->size(); ++i)
1752 rule->parserAppendKeyframe(keyframes->at(i)); 1752 rule->parserAppendKeyframe(keyframes->at(i));
1753 rule->setName(name); 1753 rule->setName(name);
1754 rule->setVendorPrefixed(isPrefixed); 1754 rule->setVendorPrefixed(isPrefixed);
1755 StyleRuleKeyframes* rulePtr = rule.get(); 1755 StyleRuleKeyframes* rulePtr = rule.get();
1756 m_parsedRules.append(rule.release()); 1756 m_parsedRules.append(rule.release());
1757 return rulePtr; 1757 return rulePtr;
1758 } 1758 }
1759 1759
1760 static void recordSelectorStats(const CSSParserContext& context, const CSSSelect orList& selectorList)
1761 {
1762 if (!context.useCounter())
1763 return;
1764
1765 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) {
1766 for ( ; ; selector = selector->tagHistory()) {
1767 UseCounter::Feature feature = UseCounter::NumberOfFeatures;
1768 switch (selector->pseudoType()) {
1769 case CSSSelector::PseudoUnresolved:
1770 feature = UseCounter::CSSSelectorPseudoUnresolved;
1771 break;
1772 case CSSSelector::PseudoShadow:
1773 feature = UseCounter::CSSSelectorPseudoShadow;
1774 break;
1775 case CSSSelector::PseudoContent:
1776 feature = UseCounter::CSSSelectorPseudoContent;
1777 break;
1778 case CSSSelector::PseudoHost:
1779 feature = UseCounter::CSSSelectorPseudoHost;
1780 break;
1781 case CSSSelector::PseudoHostContext:
1782 feature = UseCounter::CSSSelectorPseudoHostContext;
1783 break;
1784 default:
1785 break;
1786 }
1787 if (feature != UseCounter::NumberOfFeatures)
1788 context.useCounter()->count(feature);
1789 if (selector->relation() == CSSSelector::ShadowDeep)
kochi 2014/06/18 09:03:31 I noticed that some pseudo element can be combined
1790 context.useCounter()->count(UseCounter::CSSDeepCombinator);
1791 if (selector->selectorList())
1792 recordSelectorStats(context, *selector->selectorList());
1793 if (selector->isLastInTagHistory())
esprehn 2014/06/18 11:13:25 I don't think you should need this check and break
kochi 2014/06/18 16:30:23 This was unintentionally tricky... The |selector|
1794 break;
1795 }
1796 }
1797 }
1798
1760 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors) 1799 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors)
1761 { 1800 {
1762 StyleRule* result = 0; 1801 StyleRule* result = 0;
1763 if (selectors) { 1802 if (selectors) {
1764 m_allowImportRules = m_allowNamespaceDeclarations = false; 1803 m_allowImportRules = m_allowNamespaceDeclarations = false;
1765 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create(); 1804 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create();
1766 rule->parserAdoptSelectorVector(*selectors); 1805 rule->parserAdoptSelectorVector(*selectors);
1767 rule->setProperties(createStylePropertySet()); 1806 rule->setProperties(createStylePropertySet());
1768 result = rule.get(); 1807 result = rule.get();
1769 m_parsedRules.append(rule.release()); 1808 m_parsedRules.append(rule.release());
1809 recordSelectorStats(m_context, result->selectorList());
1770 } 1810 }
1771 clearProperties(); 1811 clearProperties();
1772 return result; 1812 return result;
1773 } 1813 }
1774 1814
1775 StyleRuleBase* BisonCSSParser::createFontFaceRule() 1815 StyleRuleBase* BisonCSSParser::createFontFaceRule()
1776 { 1816 {
1777 m_allowImportRules = m_allowNamespaceDeclarations = false; 1817 m_allowImportRules = m_allowNamespaceDeclarations = false;
1778 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 1818 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
1779 CSSProperty& property = m_parsedProperties[i]; 1819 CSSProperty& property = m_parsedProperties[i];
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 rule->setProperties(createStylePropertySet()); 2113 rule->setProperties(createStylePropertySet());
2074 clearProperties(); 2114 clearProperties();
2075 2115
2076 StyleRuleViewport* result = rule.get(); 2116 StyleRuleViewport* result = rule.get();
2077 m_parsedRules.append(rule.release()); 2117 m_parsedRules.append(rule.release());
2078 2118
2079 return result; 2119 return result;
2080 } 2120 }
2081 2121
2082 } 2122 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698