Detect ComputedStyle::IsRunningXXXAnimationOnCompositor changes

Bug: 937929
Change-Id: Ifb417e824f5f0971c78553e296ea087fe6f741a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1509649
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638879}
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc
index a60ac38..2a763d8 100644
--- a/third_party/blink/renderer/core/dom/document.cc
+++ b/third_party/blink/renderer/core/dom/document.cc
@@ -2391,7 +2391,7 @@
     if (layout_object->HasLayer()) {
       ToLayoutBoxModelObject(layout_object)
           ->Layer()
-          ->SetNeeedsCompositingReasonsUpdate();
+          ->SetNeedsCompositingReasonsUpdate();
     }
   }
 }
diff --git a/third_party/blink/renderer/core/paint/paint_layer.h b/third_party/blink/renderer/core/paint/paint_layer.h
index 7934510b..f4e706b 100644
--- a/third_party/blink/renderer/core/paint/paint_layer.h
+++ b/third_party/blink/renderer/core/paint/paint_layer.h
@@ -1064,7 +1064,7 @@
   // for the definition of a replaced normal-flow stacking element.
   bool IsReplacedNormalFlowStacking() const;
 
-  void SetNeeedsCompositingReasonsUpdate() {
+  void SetNeedsCompositingReasonsUpdate() {
     needs_compositing_reasons_update_ = true;
   }
 
diff --git a/third_party/blink/renderer/core/style/computed_style.cc b/third_party/blink/renderer/core/style/computed_style.cc
index 152e7ec1..9eacec8 100644
--- a/third_party/blink/renderer/core/style/computed_style.cc
+++ b/third_party/blink/renderer/core/style/computed_style.cc
@@ -883,6 +883,15 @@
       HasCurrentFilterAnimation() != other.HasCurrentFilterAnimation() ||
       HasCurrentBackdropFilterAnimation() !=
           other.HasCurrentBackdropFilterAnimation() ||
+      IsRunningTransformAnimationOnCompositor() !=
+          other.IsRunningTransformAnimationOnCompositor() ||
+      IsRunningOpacityAnimationOnCompositor() !=
+          other.IsRunningOpacityAnimationOnCompositor() ||
+      IsRunningFilterAnimationOnCompositor() !=
+          other.IsRunningFilterAnimationOnCompositor() ||
+      IsRunningBackdropFilterAnimationOnCompositor() !=
+          other.IsRunningBackdropFilterAnimationOnCompositor() ||
+      SubtreeWillChangeContents() != other.SubtreeWillChangeContents() ||
       BackfaceVisibility() != other.BackfaceVisibility() ||
       HasWillChangeCompositingHint() != other.HasWillChangeCompositingHint() ||
       UsedTransformStyle3D() != other.UsedTransformStyle3D() ||
diff --git a/third_party/blink/renderer/core/style/computed_style.h b/third_party/blink/renderer/core/style/computed_style.h
index fa33f59..5af2e920 100644
--- a/third_party/blink/renderer/core/style/computed_style.h
+++ b/third_party/blink/renderer/core/style/computed_style.h
@@ -282,8 +282,9 @@
     // flat tree in the presence of display:contents.
     kDisplayAffectingDescendantStyles,
   };
-  static Difference ComputeDifference(const ComputedStyle* old_style,
-                                      const ComputedStyle* new_style);
+  CORE_EXPORT static Difference ComputeDifference(
+      const ComputedStyle* old_style,
+      const ComputedStyle* new_style);
 
   // Returns true if the ComputedStyle change requires a LayoutObject re-attach.
   static bool NeedsReattachLayoutTree(const ComputedStyle* old_style,
@@ -317,8 +318,8 @@
   StyleContentAlignmentData ResolvedJustifyContent(
       const StyleContentAlignmentData& normal_behaviour) const;
 
-  StyleDifference VisualInvalidationDiff(const Document&,
-                                         const ComputedStyle&) const;
+  CORE_EXPORT StyleDifference
+  VisualInvalidationDiff(const Document&, const ComputedStyle&) const;
 
   CORE_EXPORT void InheritFrom(const ComputedStyle& inherit_parent,
                                IsAtShadowBoundary = kNotAtShadowBoundary);
diff --git a/third_party/blink/renderer/core/style/computed_style_extra_fields.json5 b/third_party/blink/renderer/core/style/computed_style_extra_fields.json5
index 4279172..9846eb76 100644
--- a/third_party/blink/renderer/core/style/computed_style_extra_fields.json5
+++ b/third_party/blink/renderer/core/style/computed_style_extra_fields.json5
@@ -783,7 +783,6 @@
       field_template: "primitive",
       type_name: "bool",
       field_group: "*",
-      custom_compare: true,
       default_value: "false",
     },
     {
@@ -791,7 +790,6 @@
       field_template: "primitive",
       type_name: "bool",
       field_group: "*",
-      custom_compare: true,
       default_value: "false",
     },
     {
@@ -799,7 +797,6 @@
       field_template: "primitive",
       type_name: "bool",
       field_group: "*",
-      custom_compare: true,
       default_value: "false",
     },
     {
@@ -807,7 +804,6 @@
       field_template: "primitive",
       type_name: "bool",
       field_group: "*",
-      custom_compare: true,
       default_value: "false",
     },
     // A stacking context is painted atomically and defines a stacking order,
diff --git a/third_party/blink/renderer/core/style/computed_style_test.cc b/third_party/blink/renderer/core/style/computed_style_test.cc
index a2e26f8..b05fbee5 100644
--- a/third_party/blink/renderer/core/style/computed_style_test.cc
+++ b/third_party/blink/renderer/core/style/computed_style_test.cc
@@ -7,6 +7,7 @@
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/blink/renderer/core/css/css_gradient_value.h"
+#include "third_party/blink/renderer/core/dom/document.h"
 #include "third_party/blink/renderer/core/style/clip_path_operation.h"
 #include "third_party/blink/renderer/core/style/shape_clip_path_operation.h"
 #include "third_party/blink/renderer/core/style/shape_value.h"
@@ -401,4 +402,33 @@
   EXPECT_TRUE(style->BorderSizeEquals(*other));
 }
 
+#define TEST_ANIMATION_FLAG(flag, inherited)                               \
+  do {                                                                     \
+    auto style = ComputedStyle::Create();                                  \
+    auto other = ComputedStyle::Create();                                  \
+    EXPECT_FALSE(style->flag());                                           \
+    EXPECT_FALSE(other->flag());                                           \
+    style->Set##flag(true);                                                \
+    EXPECT_TRUE(style->flag());                                            \
+    EXPECT_EQ(ComputedStyle::Difference::inherited,                        \
+              ComputedStyle::ComputeDifference(style.get(), other.get())); \
+    auto diff = style->VisualInvalidationDiff(*document, *other);          \
+    EXPECT_TRUE(diff.HasDifference());                                     \
+    EXPECT_TRUE(diff.CompositingReasonsChanged());                         \
+  } while (false)
+
+TEST(ComputedStyleTest, AnimationFlags) {
+  Persistent<Document> document = Document::CreateForTest();
+  TEST_ANIMATION_FLAG(HasCurrentTransformAnimation, kNonInherited);
+  TEST_ANIMATION_FLAG(HasCurrentOpacityAnimation, kNonInherited);
+  TEST_ANIMATION_FLAG(HasCurrentFilterAnimation, kNonInherited);
+  TEST_ANIMATION_FLAG(HasCurrentBackdropFilterAnimation, kNonInherited);
+  TEST_ANIMATION_FLAG(IsRunningTransformAnimationOnCompositor, kNonInherited);
+  TEST_ANIMATION_FLAG(IsRunningOpacityAnimationOnCompositor, kNonInherited);
+  TEST_ANIMATION_FLAG(IsRunningFilterAnimationOnCompositor, kNonInherited);
+  TEST_ANIMATION_FLAG(IsRunningBackdropFilterAnimationOnCompositor,
+                      kNonInherited);
+  TEST_ANIMATION_FLAG(SubtreeWillChangeContents, kInherited);
+}
+
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/style/style_difference.h b/third_party/blink/renderer/core/style/style_difference.h
index e5a387a6..4e80373 100644
--- a/third_party/blink/renderer/core/style/style_difference.h
+++ b/third_party/blink/renderer/core/style/style_difference.h
@@ -40,13 +40,13 @@
         visual_rect_update_(false),
         property_specific_differences_(0),
         scroll_anchor_disabling_property_changed_(false),
-        composited_reasons_changed_(false) {}
+        compositing_reasons_changed_(false) {}
 
   bool HasDifference() const {
     return paint_invalidation_type_ || layout_type_ ||
            property_specific_differences_ || recompute_overflow_ ||
            visual_rect_update_ || scroll_anchor_disabling_property_changed_ ||
-           composited_reasons_changed_;
+           compositing_reasons_changed_;
   }
 
   bool HasAtMostPropertySpecificDifferences(
@@ -167,8 +167,10 @@
   void SetScrollAnchorDisablingPropertyChanged() {
     scroll_anchor_disabling_property_changed_ = true;
   }
-  bool CompositingReasonsChanged() const { return composited_reasons_changed_; }
-  void SetCompositingReasonsChanged() { composited_reasons_changed_ = true; }
+  bool CompositingReasonsChanged() const {
+    return compositing_reasons_changed_;
+  }
+  void SetCompositingReasonsChanged() { compositing_reasons_changed_ = true; }
 
  private:
   static constexpr int kPropertyDifferenceCount = 10;
@@ -189,7 +191,7 @@
   unsigned visual_rect_update_ : 1;
   unsigned property_specific_differences_ : kPropertyDifferenceCount;
   unsigned scroll_anchor_disabling_property_changed_ : 1;
-  unsigned composited_reasons_changed_ : 1;
+  unsigned compositing_reasons_changed_ : 1;
 };
 
 CORE_EXPORT std::ostream& operator<<(std::ostream&, const StyleDifference&);