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

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 UseCounter conflict. 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 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 RefPtrWillBeRawPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); 1749 RefPtrWillBeRawPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create();
1750 for (size_t i = 0; i < keyframes->size(); ++i) 1750 for (size_t i = 0; i < keyframes->size(); ++i)
1751 rule->parserAppendKeyframe(keyframes->at(i)); 1751 rule->parserAppendKeyframe(keyframes->at(i));
1752 rule->setName(name); 1752 rule->setName(name);
1753 rule->setVendorPrefixed(isPrefixed); 1753 rule->setVendorPrefixed(isPrefixed);
1754 StyleRuleKeyframes* rulePtr = rule.get(); 1754 StyleRuleKeyframes* rulePtr = rule.get();
1755 m_parsedRules.append(rule.release()); 1755 m_parsedRules.append(rule.release());
1756 return rulePtr; 1756 return rulePtr;
1757 } 1757 }
1758 1758
1759 static void recordSelectorStats(const CSSParserContext& context, const CSSSelect orList& selectorList)
1760 {
1761 if (!context.useCounter())
1762 return;
1763
1764 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) {
1765 for (const CSSSelector* current = selector; current ; current = current- >tagHistory()) {
1766 UseCounter::Feature feature = UseCounter::NumberOfFeatures;
1767 switch (current->pseudoType()) {
1768 case CSSSelector::PseudoUnresolved:
1769 feature = UseCounter::CSSSelectorPseudoUnresolved;
1770 break;
1771 case CSSSelector::PseudoShadow:
1772 feature = UseCounter::CSSSelectorPseudoShadow;
1773 break;
1774 case CSSSelector::PseudoContent:
1775 feature = UseCounter::CSSSelectorPseudoContent;
1776 break;
1777 case CSSSelector::PseudoHost:
1778 feature = UseCounter::CSSSelectorPseudoHost;
1779 break;
1780 case CSSSelector::PseudoHostContext:
1781 feature = UseCounter::CSSSelectorPseudoHostContext;
1782 break;
1783 default:
1784 break;
1785 }
1786 if (feature != UseCounter::NumberOfFeatures)
1787 context.useCounter()->count(feature);
1788 if (current->relation() == CSSSelector::ShadowDeep)
1789 context.useCounter()->count(UseCounter::CSSDeepCombinator);
1790 if (current->selectorList())
1791 recordSelectorStats(context, *current->selectorList());
1792 }
1793 }
1794 }
1795
1759 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors) 1796 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors)
1760 { 1797 {
1761 StyleRule* result = 0; 1798 StyleRule* result = 0;
1762 if (selectors) { 1799 if (selectors) {
1763 m_allowImportRules = m_allowNamespaceDeclarations = false; 1800 m_allowImportRules = m_allowNamespaceDeclarations = false;
1764 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create(); 1801 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create();
1765 rule->parserAdoptSelectorVector(*selectors); 1802 rule->parserAdoptSelectorVector(*selectors);
1766 rule->setProperties(createStylePropertySet()); 1803 rule->setProperties(createStylePropertySet());
1767 result = rule.get(); 1804 result = rule.get();
1768 m_parsedRules.append(rule.release()); 1805 m_parsedRules.append(rule.release());
1806 recordSelectorStats(m_context, result->selectorList());
1769 } 1807 }
1770 clearProperties(); 1808 clearProperties();
1771 return result; 1809 return result;
1772 } 1810 }
1773 1811
1774 StyleRuleBase* BisonCSSParser::createFontFaceRule() 1812 StyleRuleBase* BisonCSSParser::createFontFaceRule()
1775 { 1813 {
1776 m_allowImportRules = m_allowNamespaceDeclarations = false; 1814 m_allowImportRules = m_allowNamespaceDeclarations = false;
1777 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 1815 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
1778 CSSProperty& property = m_parsedProperties[i]; 1816 CSSProperty& property = m_parsedProperties[i];
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 rule->setProperties(createStylePropertySet()); 2110 rule->setProperties(createStylePropertySet());
2073 clearProperties(); 2111 clearProperties();
2074 2112
2075 StyleRuleViewport* result = rule.get(); 2113 StyleRuleViewport* result = rule.get();
2076 m_parsedRules.append(rule.release()); 2114 m_parsedRules.append(rule.release());
2077 2115
2078 return result; 2116 return result;
2079 } 2117 }
2080 2118
2081 } 2119 }
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