Bug 1631865: Add a layout flush to getGridFragments and getAsFlexContainer. r=emilio
authorBrad Werth <bwerth@mozilla.com>
Wed, 22 Apr 2020 23:45:22 +0000
changeset 525499 bebd73d523a396f9d84b3bf55ab238cba2f69b4b
parent 525498 3b3fd54478388e8b849fd9d7b8cd364cf9eb4c0c
child 525500 b90b0b363ba32d3ef6cf3f0c59a475cd905531c0
push id37339
push usernerli@mozilla.com
push dateThu, 23 Apr 2020 09:52:48 +0000
treeherdermozilla-central@47426d145e24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1631865
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1631865: Add a layout flush to getGridFragments and getAsFlexContainer. r=emilio This will correctly handle the case of "display:grid" or "display:flex" being added or removed from the Element frame right before the call to getGridFragments or getAsFlexContainer on the Element. Differential Revision: https://phabricator.services.mozilla.com/D71806
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3181,45 +3181,45 @@ already_AddRefed<Promise> Element::Reque
   return promise.forget();
 }
 
 void Element::RequestPointerLock(CallerType aCallerType) {
   OwnerDoc()->RequestPointerLock(this, aCallerType);
 }
 
 already_AddRefed<Flex> Element::GetAsFlexContainer() {
-  nsIFrame* frame = GetPrimaryFrame();
-
   // We need the flex frame to compute additional info, and use
   // that annotated version of the frame.
   nsFlexContainerFrame* flexFrame =
-      nsFlexContainerFrame::GetFlexFrameWithComputedInfo(frame);
+      nsFlexContainerFrame::GetFlexFrameWithComputedInfo(
+          GetPrimaryFrame(FlushType::Layout));
 
   if (flexFrame) {
     RefPtr<Flex> flex = new Flex(this, flexFrame);
     return flex.forget();
   }
   return nullptr;
 }
 
 void Element::GetGridFragments(nsTArray<RefPtr<Grid>>& aResult) {
   nsGridContainerFrame* frame =
-      nsGridContainerFrame::GetGridFrameWithComputedInfo(GetPrimaryFrame());
+      nsGridContainerFrame::GetGridFrameWithComputedInfo(
+          GetPrimaryFrame(FlushType::Layout));
 
   // If we get a nsGridContainerFrame from the prior call,
   // all the next-in-flow frames will also be nsGridContainerFrames.
   while (frame) {
     aResult.AppendElement(new Grid(this, frame));
     frame = static_cast<nsGridContainerFrame*>(frame->GetNextInFlow());
   }
 }
 
 bool Element::HasGridFragments() {
   return !!nsGridContainerFrame::GetGridFrameWithComputedInfo(
-      GetPrimaryFrame());
+      GetPrimaryFrame(FlushType::Layout));
 }
 
 already_AddRefed<DOMMatrixReadOnly> Element::GetTransformToAncestor(
     Element& aAncestor) {
   nsIFrame* primaryFrame = GetPrimaryFrame();
   nsIFrame* ancestorFrame = aAncestor.GetPrimaryFrame();
 
   Matrix4x4 transform;