зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1312331 - Build up list of applicable rules in reverse to avoid quadratic time array manipulations. r=erahm
MozReview-Commit-ID: HAjtxQVZo8X
This commit is contained in:
Родитель
aec865dde5
Коммит
6e3f0feaaa
|
@ -247,8 +247,14 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoTArray<nsRuleNode*, 16> ruleNodes;
|
||||
while (!ruleNode->IsRoot()) {
|
||||
ruleNodes.AppendElement(ruleNode);
|
||||
ruleNode = ruleNode->GetParent();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMutableArray> rules = nsArray::Create();
|
||||
for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) {
|
||||
for (nsRuleNode* ruleNode : Reversed(ruleNodes)) {
|
||||
RefPtr<Declaration> decl = do_QueryObject(ruleNode->GetRule());
|
||||
if (decl) {
|
||||
RefPtr<mozilla::css::StyleRule> styleRule =
|
||||
|
@ -256,7 +262,7 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
|||
if (styleRule) {
|
||||
nsCOMPtr<nsIDOMCSSRule> domRule = styleRule->GetDOMRule();
|
||||
if (domRule) {
|
||||
rules->InsertElementAt(domRule, 0, /*weak =*/ false);
|
||||
rules->AppendElement(domRule, /*weak =*/ false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче