Bug 1288608 - Ensure the normal position is stored on a property before setting the relative position. r=jfkthame, a=ritu
authorMats Palmgren <mats@mozilla.com>
Fri, 19 Aug 2016 19:56:20 +0200
changeset 347842 65d572272708ae8e623e60022119536e2626eab7
parent 347841 b7595b0e873652d31aaf1018193dde1f031b33d6
child 347843 cb7323bec3e585dbcf1ec19dc636c76dce96c599
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame, ritu
bugs1288608
milestone50.0a2
Bug 1288608 - Ensure the normal position is stored on a property before setting the relative position. r=jfkthame, a=ritu
layout/base/RestyleManager.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -461,17 +461,24 @@ RestyleManager::RecomputePosition(nsIFra
         ReflowInput::ComputeRelativeOffsets(wm, cont, size, newOffsets);
         NS_ASSERTION(newOffsets.left == -newOffsets.right &&
                      newOffsets.top == -newOffsets.bottom,
                      "ComputeRelativeOffsets should return valid results");
 
         // ReflowInput::ApplyRelativePositioning would work here, but
         // since we've already checked mPosition and aren't changing the frame's
         // normal position, go ahead and add the offsets directly.
-        cont->SetPosition(cont->GetNormalPosition() +
+        // First, we need to ensure that the normal position is stored though.
+        nsPoint normalPosition = cont->GetNormalPosition();
+        auto props = cont->Properties();
+        const auto& prop = nsIFrame::NormalPositionProperty();
+        if (!props.Get(prop)) {
+          props.Set(prop, new nsPoint(normalPosition));
+        }
+        cont->SetPosition(normalPosition +
                           nsPoint(newOffsets.left, newOffsets.top));
       }
     }
 
     return true;
   }
 
   // For the absolute positioning case, set up a fake HTML reflow state for