Bug 1364360 part 2. Make Element::GetScrollFrame take a flush type, not a "should I flush?" boolean. r=ehsan
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 25 May 2017 13:39:44 -0400
changeset 584699 e670c0dcaa9ff160c053ba0846752be348c83b4b
parent 584698 3c315bd6cf00e3f2a7439cd36d4f55be6ae012db
child 584700 dd1c5aecc373a8bbba824c445a4a8c4e127adda0
push id60843
push userbschouten@mozilla.com
push dateThu, 25 May 2017 21:57:22 +0000
reviewersehsan
bugs1364360
milestone55.0a1
Bug 1364360 part 2. Make Element::GetScrollFrame take a flush type, not a "should I flush?" boolean. r=ehsan
dom/base/Element.cpp
dom/base/Element.h
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -658,29 +658,28 @@ Element::GetElementsByTagName(const nsAS
 nsIFrame*
 Element::GetStyledFrame()
 {
   nsIFrame *frame = GetPrimaryFrame(FlushType::Layout);
   return frame ? nsLayoutUtils::GetStyleFrame(frame) : nullptr;
 }
 
 nsIScrollableFrame*
-Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout)
+Element::GetScrollFrame(nsIFrame **aStyledFrame, FlushType aFlushType)
 {
   // it isn't clear what to return for SVG nodes, so just return nothing
   if (IsSVGElement()) {
     if (aStyledFrame) {
       *aStyledFrame = nullptr;
     }
     return nullptr;
   }
 
-  // Inline version of GetStyledFrame to use FlushType::None if needed.
-  nsIFrame* frame =
-    GetPrimaryFrame(aFlushLayout ? FlushType::Layout : FlushType::None);
+  // Inline version of GetStyledFrame to use the given FlushType.
+  nsIFrame* frame = GetPrimaryFrame(aFlushType);
   if (frame) {
     frame = nsLayoutUtils::GetStyleFrame(frame);
   }
 
   if (aStyledFrame) {
     *aStyledFrame = frame;
   }
   if (frame) {
@@ -890,17 +889,17 @@ Element::SetScrollLeft(int32_t aScrollLe
                           scrollMode);
   }
 }
 
 
 bool
 Element::ScrollByNoFlush(int32_t aDx, int32_t aDy)
 {
-  nsIScrollableFrame* sf = GetScrollFrame(nullptr, false);
+  nsIScrollableFrame* sf = GetScrollFrame(nullptr, FlushType::None);
   if (!sf) {
     return false;
   }
 
   AutoWeakFrame weakRef(sf->GetScrolledFrame());
 
   CSSIntPoint before = sf->GetScrollPositionCSSPixels();
   sf->ScrollToCSSPixelsApproximate(CSSIntPoint(before.x + aDx, before.y + aDy));
@@ -912,17 +911,17 @@ Element::ScrollByNoFlush(int32_t aDx, in
 
   CSSIntPoint after = sf->GetScrollPositionCSSPixels();
   return (before != after);
 }
 
 void
 Element::MozScrollSnap()
 {
-  nsIScrollableFrame* sf = GetScrollFrame(nullptr, false);
+  nsIScrollableFrame* sf = GetScrollFrame(nullptr, FlushType::None);
   if (sf) {
     sf->ScrollSnap();
   }
 }
 
 static nsSize GetScrollRectSizeForOverflowVisibleFrame(nsIFrame* aFrame)
 {
   if (!aFrame) {
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1588,17 +1588,17 @@ private:
 
   /**
    * Get this element's client area rect in app units.
    * @return the frame's client area
    */
   nsRect GetClientAreaRect();
 
   nsIScrollableFrame* GetScrollFrame(nsIFrame **aStyledFrame = nullptr,
-                                     bool aFlushLayout = true);
+                                     FlushType aFlushType = FlushType::Layout);
 
   // Data members
   EventStates mState;
   // Per-node data managed by Servo.
   mozilla::ServoCell<ServoNodeData*> mServoData;
 };
 
 class RemoveFromBindingManagerRunnable : public mozilla::Runnable