Bug 686281 - Expands will-change of a shorthand prop to longhand ones; r=dbaron. draft
authorCJKu <cku@mozilla.com>
Mon, 21 Dec 2015 11:32:35 +0800
changeset 316598 03668c0a201afa025ce4f349d6c38fbad800afaf
parent 316597 d5d913f06024b73868569fbfe60358ede30bf5a2
child 316599 ce9056784fadba83cb0b37c37bfc4faaca2aa49a
push id8575
push usercku@mozilla.com
push dateMon, 21 Dec 2015 03:33:13 +0000
reviewersdbaron
bugs686281
milestone45.0a1
Bug 686281 - Expands will-change of a shorthand prop to longhand ones; r=dbaron.
layout/style/nsRuleNode.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -6084,21 +6084,35 @@ nsRuleNode::ComputeDisplayData(void* aSt
         if (buffer.EqualsLiteral("scroll-position")) {
           display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL;
         }
 
         nsCSSProperty prop =
           nsCSSProps::LookupProperty(buffer,
                                      nsCSSProps::eEnabledForAllContent);
         if (prop != eCSSProperty_UNKNOWN &&
-            prop != eCSSPropertyExtra_variable &&
-            nsCSSProps::PropHasFlags(prop,
-                                     CSS_PROPERTY_CREATES_STACKING_CONTEXT))
-        {
-          display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
+            prop != eCSSPropertyExtra_variable) {
+          // If the property given is a shorthand, it indicates the expectation
+          // for all the longhands the shorthand expands to.
+          if (nsCSSProps::IsShorthand(prop)) {
+            for (const nsCSSProperty* shorthands =
+                   nsCSSProps::SubpropertyEntryFor(prop);
+                 *shorthands != eCSSProperty_UNKNOWN; ++shorthands) {
+              if (nsCSSProps::PropHasFlags(*shorthands,
+                                      CSS_PROPERTY_CREATES_STACKING_CONTEXT)) {
+                display->mWillChangeBitField |=
+                  NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
+                break;
+              }
+            }
+          } else if (nsCSSProps::PropHasFlags(prop,
+                                      CSS_PROPERTY_CREATES_STACKING_CONTEXT)) {
+            display->mWillChangeBitField |=
+              NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
+          }
         }
       }
     }
     break;
   }
 
   case eCSSUnit_Inherit:
     display->mWillChange = parentDisplay->mWillChange;