Bug 1528199 - Make nsTreeColFrame::InvalidateColumns not flush. r=dholbert
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Feb 2019 19:05:09 +0000
changeset 459584 3f18f4d9dc1e7e0d226267dea1da72765126f809
parent 459583 164ee6cae98400feed3ab1cbb1a8fac8d73163c7
child 459585 95b6997c334afa45b588408bc25b99c9f26b391d
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1528199
milestone67.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 1528199 - Make nsTreeColFrame::InvalidateColumns not flush. r=dholbert That's not sound. Differential Revision: https://phabricator.services.mozilla.com/D19934
dom/xul/XULTreeElement.cpp
dom/xul/XULTreeElement.h
layout/xul/tree/nsTreeColFrame.cpp
--- a/dom/xul/XULTreeElement.cpp
+++ b/dom/xul/XULTreeElement.cpp
@@ -74,41 +74,42 @@ static nsIContent* FindBodyElement(nsICo
       nsIContent* result = FindBodyElement(content);
       if (result) return result;
     }
   }
 
   return nullptr;
 }
 
-nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(bool aFlushLayout) {
+nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(FlushType aFlushType) {
+  MOZ_ASSERT(aFlushType == FlushType::Frames ||
+             aFlushType == FlushType::Layout || aFlushType == FlushType::None);
   nsCOMPtr<nsIContent> kungFuDeathGrip = this;  // keep a reference
   RefPtr<Document> doc = GetUncomposedDoc();
 
   // Make sure our frames are up to date, and layout as needed.  We
   // have to do this before checking for our cached mTreeBody, since
   // it might go away on style flush, and in any case if aFlushLayout
   // is true we need to make sure to flush no matter what.
   // XXXbz except that flushing style when we were not asked to flush
   // layout here breaks things.  See bug 585123.
-  if (aFlushLayout && doc) {
+  if (aFlushType == FlushType::Layout && doc) {
     doc->FlushPendingNotifications(FlushType::Layout);
   }
 
   if (mTreeBody) {
     // Have one cached already.
     return mTreeBody;
   }
 
-  if (!aFlushLayout && doc) {
+  if (aFlushType == FlushType::Frames && doc) {
     doc->FlushPendingNotifications(FlushType::Frames);
   }
 
-  nsCOMPtr<nsIContent> tree = FindBodyElement(this);
-  if (tree) {
+  if (nsCOMPtr<nsIContent> tree = FindBodyElement(this)) {
     mTreeBody = do_QueryFrame(tree->GetPrimaryFrame());
   }
 
   return mTreeBody;
 }
 
 already_AddRefed<nsITreeView> XULTreeElement::GetView() {
   if (!mTreeBody) {
@@ -247,17 +248,17 @@ void XULTreeElement::EnsureCellIsVisible
     nsresult rv = body->EnsureCellIsVisible(aRow, aCol);
     if (NS_FAILED(rv)) {
       aRv.Throw(rv);
     }
   }
 }
 
 void XULTreeElement::ScrollToRow(int32_t aRow) {
-  nsTreeBodyFrame* body = GetTreeBodyFrame(true);
+  nsTreeBodyFrame* body = GetTreeBodyFrame(FlushType::Layout);
   if (!body) {
     return;
   }
 
   body->ScrollToRow(aRow);
 }
 
 void XULTreeElement::ScrollByLines(int32_t aNumLines) {
--- a/dom/xul/XULTreeElement.h
+++ b/dom/xul/XULTreeElement.h
@@ -33,17 +33,17 @@ class XULTreeElement final : public nsXU
         mCachedFirstVisibleRow(0),
         mTreeBody(nullptr) {}
 
   NS_IMPL_FROMNODE_WITH_TAG(XULTreeElement, kNameSpaceID_XUL, tree)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeElement, nsXULElement)
 
-  nsTreeBodyFrame* GetTreeBodyFrame(bool aFlushLayout = false);
+  nsTreeBodyFrame* GetTreeBodyFrame(FlushType = FlushType::Frames);
   nsTreeBodyFrame* GetCachedTreeBodyFrame() { return mTreeBody; }
 
   already_AddRefed<nsTreeColumns> GetColumns();
 
   already_AddRefed<nsITreeView> GetView(CallerType /* unused */) {
     return GetView();
   }
   already_AddRefed<nsITreeView> GetView();
--- a/layout/xul/tree/nsTreeColFrame.cpp
+++ b/layout/xul/tree/nsTreeColFrame.cpp
@@ -10,18 +10,20 @@
 #include "nsIContent.h"
 #include "mozilla/ComputedStyle.h"
 #include "nsNameSpaceManager.h"
 #include "mozilla/ErrorResult.h"
 #include "nsTreeColumns.h"
 #include "nsDisplayList.h"
 #include "nsTreeBodyFrame.h"
 #include "nsXULElement.h"
+#include "mozilla/dom/XULTreeElement.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 //
 // NS_NewTreeColFrame
 //
 // Creates a new col frame
 //
 nsIFrame* NS_NewTreeColFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
   return new (aPresShell) nsTreeColFrame(aStyle, aPresShell->GetPresContext());
@@ -146,23 +148,27 @@ void nsTreeColFrame::SetXULBounds(nsBoxL
 
 XULTreeElement* nsTreeColFrame::GetTree() {
   nsIContent* parent = mContent->GetParent();
   return parent ? XULTreeElement::FromNodeOrNull(parent->GetParent()) : nullptr;
 }
 
 void nsTreeColFrame::InvalidateColumns(bool aCanWalkFrameTree) {
   RefPtr<XULTreeElement> tree = GetTree();
-  if (tree) {
-    RefPtr<nsTreeColumns> columns;
+  if (!tree) {
+    return;
+  }
+
+  nsTreeBodyFrame* body = aCanWalkFrameTree
+                              ? tree->GetTreeBodyFrame(FlushType::None)
+                              : tree->GetCachedTreeBodyFrame();
 
-    if (aCanWalkFrameTree) {
-      columns = tree->GetColumns();
-    } else {
-      nsTreeBodyFrame* body = tree->GetCachedTreeBodyFrame();
-      if (body) {
-        columns = body->Columns();
-      }
-    }
+  if (!body) {
+    return;
+  }
 
-    if (columns) columns->InvalidateColumns();
+  RefPtr<nsTreeColumns> columns = body->Columns();
+  if (!columns) {
+    return;
   }
+
+  columns->InvalidateColumns();
 }