From 16314d820b78fd33ad57f3cd8a483b323a652b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 15 Feb 2019 19:05:09 +0000 Subject: [PATCH] Bug 1528199 - Make nsTreeColFrame::InvalidateColumns not flush. r=dholbert That's not sound. Differential Revision: https://phabricator.services.mozilla.com/D19934 --HG-- extra : moz-landing-system : lando --- dom/xul/XULTreeElement.cpp | 13 ++++++------ dom/xul/XULTreeElement.h | 2 +- layout/xul/tree/nsTreeColFrame.cpp | 32 ++++++++++++++++++------------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/dom/xul/XULTreeElement.cpp b/dom/xul/XULTreeElement.cpp index 659887d3f47d..7b030c09e7f1 100644 --- a/dom/xul/XULTreeElement.cpp +++ b/dom/xul/XULTreeElement.cpp @@ -79,7 +79,9 @@ static nsIContent* FindBodyElement(nsIContent* aParent) { return nullptr; } -nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(bool aFlushLayout) { +nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(FlushType aFlushType) { + MOZ_ASSERT(aFlushType == FlushType::Frames || + aFlushType == FlushType::Layout || aFlushType == FlushType::None); nsCOMPtr kungFuDeathGrip = this; // keep a reference RefPtr doc = GetUncomposedDoc(); @@ -89,7 +91,7 @@ nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(bool 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); } @@ -98,12 +100,11 @@ nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(bool aFlushLayout) { return mTreeBody; } - if (!aFlushLayout && doc) { + if (aFlushType == FlushType::Frames && doc) { doc->FlushPendingNotifications(FlushType::Frames); } - nsCOMPtr tree = FindBodyElement(this); - if (tree) { + if (nsCOMPtr tree = FindBodyElement(this)) { mTreeBody = do_QueryFrame(tree->GetPrimaryFrame()); } @@ -252,7 +253,7 @@ void XULTreeElement::EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol, } void XULTreeElement::ScrollToRow(int32_t aRow) { - nsTreeBodyFrame* body = GetTreeBodyFrame(true); + nsTreeBodyFrame* body = GetTreeBodyFrame(FlushType::Layout); if (!body) { return; } diff --git a/dom/xul/XULTreeElement.h b/dom/xul/XULTreeElement.h index eb541b56e0d1..da4a0e52d6a4 100644 --- a/dom/xul/XULTreeElement.h +++ b/dom/xul/XULTreeElement.h @@ -38,7 +38,7 @@ class XULTreeElement final : public nsXULElement { 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 GetColumns(); diff --git a/layout/xul/tree/nsTreeColFrame.cpp b/layout/xul/tree/nsTreeColFrame.cpp index fb61816ee01b..98d04b57539d 100644 --- a/layout/xul/tree/nsTreeColFrame.cpp +++ b/layout/xul/tree/nsTreeColFrame.cpp @@ -15,8 +15,10 @@ #include "nsDisplayList.h" #include "nsTreeBodyFrame.h" #include "nsXULElement.h" +#include "mozilla/dom/XULTreeElement.h" using namespace mozilla; +using namespace mozilla::dom; // // NS_NewTreeColFrame @@ -151,18 +153,22 @@ XULTreeElement* nsTreeColFrame::GetTree() { void nsTreeColFrame::InvalidateColumns(bool aCanWalkFrameTree) { RefPtr tree = GetTree(); - if (tree) { - RefPtr columns; - - if (aCanWalkFrameTree) { - columns = tree->GetColumns(); - } else { - nsTreeBodyFrame* body = tree->GetCachedTreeBodyFrame(); - if (body) { - columns = body->Columns(); - } - } - - if (columns) columns->InvalidateColumns(); + if (!tree) { + return; } + + nsTreeBodyFrame* body = aCanWalkFrameTree + ? tree->GetTreeBodyFrame(FlushType::None) + : tree->GetCachedTreeBodyFrame(); + + if (!body) { + return; + } + + RefPtr columns = body->Columns(); + if (!columns) { + return; + } + + columns->InvalidateColumns(); }