From b384d72987d2144e02f3bb75a356ffec06cc678b Mon Sep 17 00:00:00 2001 From: Cameron Kaiser Date: Mon, 29 May 2017 17:46:30 -0700 Subject: [PATCH] #402: M1356601 (M1353312) --- layout/style/crashtests/1356601-1.html | 18 ++++++++++++++++++ layout/style/crashtests/crashtests.list | 1 + layout/style/nsRuleNode.cpp | 20 +++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 layout/style/crashtests/1356601-1.html diff --git a/layout/style/crashtests/1356601-1.html b/layout/style/crashtests/1356601-1.html new file mode 100644 index 000000000..6db6ad1fe --- /dev/null +++ b/layout/style/crashtests/1356601-1.html @@ -0,0 +1,18 @@ + + + +
+ Crash +
+ diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list index 0cca3be99..e2b9d914c 100644 --- a/layout/style/crashtests/crashtests.list +++ b/layout/style/crashtests/crashtests.list @@ -136,3 +136,4 @@ load border-image-visited-link.html load font-face-truncated-src.html load large_border_image_width.html load long-url-list-stack-overflow.html +load 1356601-1.html diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index b82a94317..299b2e434 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -2364,9 +2364,23 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID, if (!highestNode) highestNode = rootNode; - if (!ruleData.mConditions.CacheableWithoutDependencies()) - detail = eRulePartialMixed; // Treat as though some data is specified to avoid - // the optimizations and force data computation. + MOZ_ASSERT(!(aSID == eStyleStruct_Variables && startStruct), + "if we start caching Variables structs in the rule tree, then " + "not forcing detail to eRulePartialMixed just below is no " + "longer valid"); + + if (!ruleData.mConditions.CacheableWithoutDependencies() && + aSID != eStyleStruct_Variables) { + // Treat as though some data is specified to avoid the optimizations and + // force data computation. + // + // We don't need to do this for Variables structs since we know those are + // never cached in the rule tree, and it avoids wasteful computation of a + // new Variables struct when we have no additional variable declarations, + // which otherwise could happen when there is an AnimValuesStyleRule + // (which calls SetUncacheable for style contexts with pseudo data). + detail = eRulePartialMixed; + } if (detail == eRuleNone && startStruct) { // We specified absolutely no rule information, but a parent rule in the tree