Bug 1499863 - Honor will-change: position dynamic changes. r=dbaron
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 17 Oct 2018 22:13:51 +0000
changeset 490212 2dd8df3604ef3a4130daea876a25efe6db16536f
parent 490211 7e125b229e2990eeeae27927415ca5ea4a9ed77e
child 490213 320f407a7677d7cef64f6e2213fc2e1449511da1
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdbaron
bugs1499863
milestone64.0a1
Bug 1499863 - Honor will-change: position dynamic changes. r=dbaron Differential Revision: https://phabricator.services.mozilla.com/D9032
layout/style/nsStyleStruct.cpp
testing/web-platform/tests/css/css-will-change/will-change-abspos-cb-dynamic-001.html
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3850,17 +3850,18 @@ nsStyleDisplay::CalcDifference(const nsS
   uint8_t willChangeBitsChanged =
     mWillChangeBitField ^ aNewData.mWillChangeBitField;
   if (willChangeBitsChanged & (NS_STYLE_WILL_CHANGE_STACKING_CONTEXT |
                                NS_STYLE_WILL_CHANGE_SCROLL |
                                NS_STYLE_WILL_CHANGE_OPACITY)) {
     hint |= nsChangeHint_RepaintFrame;
   }
 
-  if (willChangeBitsChanged & NS_STYLE_WILL_CHANGE_FIXPOS_CB) {
+  if (willChangeBitsChanged & (NS_STYLE_WILL_CHANGE_FIXPOS_CB |
+                               NS_STYLE_WILL_CHANGE_ABSPOS_CB)) {
     hint |= nsChangeHint_UpdateContainingBlock;
   }
 
   // If touch-action is changed, we need to regenerate the event regions on
   // the layers and send it over to the compositor for APZ to handle.
   if (mTouchAction != aNewData.mTouchAction) {
     hint |= nsChangeHint_RepaintFrame;
   }
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-will-change/will-change-abspos-cb-dynamic-001.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Test: will-change: position turns an element in an abspos containing block when changed dynamically.</title>
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1499863">
+<link rel="help" href="https://drafts.csswg.org/css-will-change/#will-change">
+<link rel="match" href="will-change-abspos-cb-001-ref.html">
+<style>
+  .container {
+    border: 1px solid green;
+    width: 100px;
+    height: 100px;
+    margin-top: 100px;
+  }
+  .abspos {
+    position: absolute;
+    top: 0;
+    left: 0;
+    background: orange;
+    height: 20px;
+    width: 20px;
+  }
+</style>
+<div class="container">
+  <div class="abspos"></div>
+</div>
+<script>
+onload = function() {
+  let container = document.querySelector(".container");
+  container.offsetTop;
+  container.style.willChange = "position";
+}
+</script>