Commit e97a4950 authored by rune@opera.com's avatar rune@opera.com

Revert 201092 "Reland of moved unused CascadeOrder. (patchset #1..."

> Reland of moved unused CascadeOrder. (patchset #1 id:1 of https://codereview.chromium.org/1306693007/ )
> 
> Reason for revert:
> I don't think this contributes any of "too many opened files".
> (as is commented bay jianli
> https://code.google.com/p/chromium/issues/detail?id=524248#c7 )
> 
> Will revert and reland the original patch.
> 
> 
> 
> Original issue's description:
> > Revert of Removed unused CascadeOrder. (patchset #1 id:1 of https://codereview.chromium.org/1291873005/ )
> > 
> > Reason for revert:
> > Speculative revert for causing "Too many opened files in the system".
> > 
> > https://code.google.com/p/chromium/issues/detail?id=523598
> > 
> > 
> > Original issue's description:
> > > Removed unused CascadeOrder.
> > > 
> > > CascadeOrder is always ignoreCascadeOrder after [1] and can be removed.
> > > 
> > > [1] https://codereview.chromium.org/1298173004
> > > 
> > > BUG=487125
> > > 
> > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=201019
> > 
> > TBR=kochi@chromium.org,rune@opera.com
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=487125
> > 
> > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=201082
> 
> TBR=rune@opera.com,jianli@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=487125
> 
> Review URL: https://codereview.chromium.org/1313713005

TBR=kochi@chromium.org

Review URL: https://codereview.chromium.org/1331573002

git-svn-id: svn://svn.chromium.org/blink/trunk@201871 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 505f1e5e
...@@ -129,7 +129,7 @@ static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont ...@@ -129,7 +129,7 @@ static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
} }
template<typename RuleDataListType> template<typename RuleDataListType>
void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* rules, const MatchRequest& matchRequest) void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* rules, CascadeOrder cascadeOrder, const MatchRequest& matchRequest)
{ {
if (!rules) if (!rules)
return; return;
...@@ -177,7 +177,7 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* r ...@@ -177,7 +177,7 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* r
} }
matched++; matched++;
didMatchRule(ruleData, result, matchRequest); didMatchRule(ruleData, result, cascadeOrder, matchRequest);
} }
if (StyleResolver* resolver = m_context.element()->document().styleResolver()) { if (StyleResolver* resolver = m_context.element()->document().styleResolver()) {
...@@ -187,7 +187,7 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* r ...@@ -187,7 +187,7 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleDataListType* r
} }
} }
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, bool matchingTreeBoundaryRules) void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, CascadeOrder cascadeOrder, bool matchingTreeBoundaryRules)
{ {
ASSERT(matchRequest.ruleSet); ASSERT(matchRequest.ruleSet);
ASSERT(m_context.element()); ASSERT(m_context.element());
...@@ -196,11 +196,11 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest ...@@ -196,11 +196,11 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
const AtomicString& pseudoId = element.shadowPseudoId(); const AtomicString& pseudoId = element.shadowPseudoId();
if (!pseudoId.isEmpty()) { if (!pseudoId.isEmpty()) {
ASSERT(element.isStyledElement()); ASSERT(element.isStyledElement());
collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), cascadeOrder, matchRequest);
} }
if (element.isVTTElement()) if (element.isVTTElement())
collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), cascadeOrder, matchRequest);
// Check whether other types of rules are applicable in the current tree scope. Criteria for this: // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
// a) it's a UA rule // a) it's a UA rule
// b) the rules comes from a scoped style sheet within the same tree scope // b) the rules comes from a scoped style sheet within the same tree scope
...@@ -213,23 +213,23 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest ...@@ -213,23 +213,23 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
// We need to collect the rules for id, class, tag, and everything else into a buffer and // We need to collect the rules for id, class, tag, and everything else into a buffer and
// then sort the buffer. // then sort the buffer.
if (element.hasID()) if (element.hasID())
collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForStyleResolution()), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForStyleResolution()), cascadeOrder, matchRequest);
if (element.isStyledElement() && element.hasClass()) { if (element.isStyledElement() && element.hasClass()) {
for (size_t i = 0; i < element.classNames().size(); ++i) for (size_t i = 0; i < element.classNames().size(); ++i)
collectMatchingRulesForList(matchRequest.ruleSet->classRules(element.classNames()[i]), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->classRules(element.classNames()[i]), cascadeOrder, matchRequest);
} }
if (element.isLink()) if (element.isLink())
collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), cascadeOrder, matchRequest);
if (SelectorChecker::matchesFocusPseudoClass(element)) if (SelectorChecker::matchesFocusPseudoClass(element))
collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), cascadeOrder, matchRequest);
collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localNameForSelectorMatching()), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localNameForSelectorMatching()), cascadeOrder, matchRequest);
collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), cascadeOrder, matchRequest);
} }
void ElementRuleCollector::collectMatchingShadowHostRules(const MatchRequest& matchRequest, bool matchingTreeBoundaryRules) void ElementRuleCollector::collectMatchingShadowHostRules(const MatchRequest& matchRequest, CascadeOrder cascadeOrder, bool matchingTreeBoundaryRules)
{ {
collectMatchingRulesForList(matchRequest.ruleSet->shadowHostRules(), matchRequest); collectMatchingRulesForList(matchRequest.ruleSet->shadowHostRules(), cascadeOrder, matchRequest);
} }
template<class CSSRuleCollection> template<class CSSRuleCollection>
...@@ -295,7 +295,7 @@ void ElementRuleCollector::sortAndTransferMatchedRules() ...@@ -295,7 +295,7 @@ void ElementRuleCollector::sortAndTransferMatchedRules()
} }
} }
void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const SelectorChecker::MatchResult& result, const MatchRequest& matchRequest) void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const SelectorChecker::MatchResult& result, CascadeOrder cascadeOrder, const MatchRequest& matchRequest)
{ {
PseudoId dynamicPseudo = result.dynamicPseudo; PseudoId dynamicPseudo = result.dynamicPseudo;
// If we're matching normal rules, set a pseudo bit if // If we're matching normal rules, set a pseudo bit if
...@@ -313,7 +313,7 @@ void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const Selector ...@@ -313,7 +313,7 @@ void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const Selector
if (m_style && ruleData.containsUncommonAttributeSelector()) if (m_style && ruleData.containsUncommonAttributeSelector())
m_style->setUnique(); m_style->setUnique();
m_matchedRules.append(MatchedRule(&ruleData, result.specificity, matchRequest.styleSheetIndex, matchRequest.styleSheet)); m_matchedRules.append(MatchedRule(&ruleData, result.specificity, cascadeOrder, matchRequest.styleSheetIndex, matchRequest.styleSheet));
} }
} }
......
...@@ -39,17 +39,22 @@ class RuleSet; ...@@ -39,17 +39,22 @@ class RuleSet;
class SelectorFilter; class SelectorFilter;
class StaticCSSRuleList; class StaticCSSRuleList;
typedef unsigned CascadeOrder;
const CascadeOrder ignoreCascadeOrder = 0;
class MatchedRule { class MatchedRule {
ALLOW_ONLY_INLINE_ALLOCATION(); ALLOW_ONLY_INLINE_ALLOCATION();
public: public:
MatchedRule(const RuleData* ruleData, unsigned specificity, unsigned styleSheetIndex, const CSSStyleSheet* parentStyleSheet) MatchedRule(const RuleData* ruleData, unsigned specificity, CascadeOrder cascadeOrder, unsigned styleSheetIndex, const CSSStyleSheet* parentStyleSheet)
: m_ruleData(ruleData) : m_ruleData(ruleData)
, m_specificity(specificity) , m_specificity(specificity)
, m_parentStyleSheet(parentStyleSheet) , m_parentStyleSheet(parentStyleSheet)
{ {
ASSERT(m_ruleData); ASSERT(m_ruleData);
static const unsigned BitsForPositionInRuleData = 18; static const unsigned BitsForPositionInRuleData = 18;
m_position = ((uint64_t)styleSheetIndex << BitsForPositionInRuleData) + m_ruleData->position(); static const unsigned BitsForStyleSheetIndex = 32;
m_position = ((uint64_t)cascadeOrder << (BitsForStyleSheetIndex + BitsForPositionInRuleData)) + ((uint64_t)styleSheetIndex << BitsForPositionInRuleData)+ m_ruleData->position();
} }
const RuleData* ruleData() const { return m_ruleData; } const RuleData* ruleData() const { return m_ruleData; }
...@@ -117,8 +122,8 @@ public: ...@@ -117,8 +122,8 @@ public:
PassRefPtrWillBeRawPtr<StyleRuleList> matchedStyleRuleList(); PassRefPtrWillBeRawPtr<StyleRuleList> matchedStyleRuleList();
PassRefPtrWillBeRawPtr<CSSRuleList> matchedCSSRuleList(); PassRefPtrWillBeRawPtr<CSSRuleList> matchedCSSRuleList();
void collectMatchingRules(const MatchRequest&, bool matchingTreeBoundaryRules = false); void collectMatchingRules(const MatchRequest&, CascadeOrder = ignoreCascadeOrder, bool matchingTreeBoundaryRules = false);
void collectMatchingShadowHostRules(const MatchRequest&, bool matchingTreeBoundaryRules = false); void collectMatchingShadowHostRules(const MatchRequest&, CascadeOrder = ignoreCascadeOrder, bool matchingTreeBoundaryRules = false);
void sortAndTransferMatchedRules(); void sortAndTransferMatchedRules();
void clearMatchedRules(); void clearMatchedRules();
void addElementStyleProperties(const StylePropertySet*, bool isCacheable = true); void addElementStyleProperties(const StylePropertySet*, bool isCacheable = true);
...@@ -127,9 +132,9 @@ public: ...@@ -127,9 +132,9 @@ public:
private: private:
template<typename RuleDataListType> template<typename RuleDataListType>
void collectMatchingRulesForList(const RuleDataListType*, const MatchRequest&); void collectMatchingRulesForList(const RuleDataListType*, CascadeOrder, const MatchRequest&);
void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, const MatchRequest&); void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, CascadeOrder, const MatchRequest&);
template<class CSSRuleCollection> template<class CSSRuleCollection>
CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*); CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*);
......
...@@ -143,31 +143,31 @@ void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr ...@@ -143,31 +143,31 @@ void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr
} }
} }
void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& collector, bool includeEmptyRules) void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder)
{ {
ASSERT(!collector.scopeContainsLastMatchedElement()); ASSERT(!collector.scopeContainsLastMatchedElement());
collector.setScopeContainsLastMatchedElement(true); collector.setScopeContainsLastMatchedElement(true);
for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
ASSERT(m_authorStyleSheets[i]->ownerNode()); ASSERT(m_authorStyleSheets[i]->ownerNode());
MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet(), includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet(), includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
collector.collectMatchingRules(matchRequest); collector.collectMatchingRules(matchRequest, cascadeOrder);
} }
collector.setScopeContainsLastMatchedElement(false); collector.setScopeContainsLastMatchedElement(false);
} }
void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& collector, bool includeEmptyRules) void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder)
{ {
ASSERT(!collector.scopeContainsLastMatchedElement()); ASSERT(!collector.scopeContainsLastMatchedElement());
collector.setScopeContainsLastMatchedElement(true); collector.setScopeContainsLastMatchedElement(true);
for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
ASSERT(m_authorStyleSheets[i]->ownerNode()); ASSERT(m_authorStyleSheets[i]->ownerNode());
MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet(), includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i); MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet(), includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], i);
collector.collectMatchingShadowHostRules(matchRequest); collector.collectMatchingShadowHostRules(matchRequest, cascadeOrder);
} }
collector.setScopeContainsLastMatchedElement(false); collector.setScopeContainsLastMatchedElement(false);
} }
void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCollector& collector, bool includeEmptyRules) void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCollector& collector, bool includeEmptyRules, CascadeOrder cascadeOrder)
{ {
if (!m_treeBoundaryCrossingRuleSet) if (!m_treeBoundaryCrossingRuleSet)
return; return;
...@@ -177,7 +177,7 @@ void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo ...@@ -177,7 +177,7 @@ void ScopedStyleResolver::collectMatchingTreeBoundaryCrossingRules(ElementRuleCo
for (const auto& rules : *m_treeBoundaryCrossingRuleSet) { for (const auto& rules : *m_treeBoundaryCrossingRuleSet) {
MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeScope().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex); MatchRequest request(rules->m_ruleSet.get(), includeEmptyRules, &treeScope().rootNode(), rules->m_parentStyleSheet, rules->m_parentIndex);
collector.collectMatchingRules(request, true); collector.collectMatchingRules(request, cascadeOrder, true);
} }
collector.setScopeContainsLastMatchedElement(false); collector.setScopeContainsLastMatchedElement(false);
......
...@@ -57,9 +57,9 @@ public: ...@@ -57,9 +57,9 @@ public:
StyleRuleKeyframes* keyframeStylesForAnimation(const StringImpl* animationName); StyleRuleKeyframes* keyframeStylesForAnimation(const StringImpl* animationName);
void appendCSSStyleSheet(CSSStyleSheet&, const MediaQueryEvaluator&); void appendCSSStyleSheet(CSSStyleSheet&, const MediaQueryEvaluator&);
void collectMatchingAuthorRules(ElementRuleCollector&, bool includeEmptyRules); void collectMatchingAuthorRules(ElementRuleCollector&, bool includeEmptyRules, CascadeOrder = ignoreCascadeOrder);
void collectMatchingShadowHostRules(ElementRuleCollector&, bool includeEmptyRules); void collectMatchingShadowHostRules(ElementRuleCollector&, bool includeEmptyRules, CascadeOrder = ignoreCascadeOrder);
void collectMatchingTreeBoundaryCrossingRules(ElementRuleCollector&, bool includeEmptyRules); void collectMatchingTreeBoundaryCrossingRules(ElementRuleCollector&, bool includeEmptyRules, CascadeOrder = ignoreCascadeOrder);
void matchPageRules(PageRuleCollector&); void matchPageRules(PageRuleCollector&);
void collectFeaturesTo(RuleFeatureSet&, HashSet<const StyleSheetContents*>& visitedSharedStyleSheetContents) const; void collectFeaturesTo(RuleFeatureSet&, HashSet<const StyleSheetContents*>& visitedSharedStyleSheetContents) const;
void resetAuthorStyle(); void resetAuthorStyle();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment