mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
Bug 1549753 - Add Visit methods for visiting the tree of BrowserParent and BrowserBridgeParent. r=afarre
Differential Revision: https://phabricator.services.mozilla.com/D30215 --HG-- extra : rebase_source : f885c62dc8a24974d67b2c65e19ab42576e8640e extra : histedit_source : f884a8ed29c99bd0e71f78d6adaf61a9f19ce21e
This commit is contained in:
parent
a1f98beaf1
commit
7df4ba7bbf
@ -11,6 +11,7 @@
|
||||
#include "LiveResizeListener.h"
|
||||
#include "mozilla/ContentCache.h"
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "mozilla/dom/BrowserBridgeParent.h"
|
||||
#include "mozilla/dom/PBrowserParent.h"
|
||||
#include "mozilla/dom/PContent.h"
|
||||
#include "mozilla/dom/PFilePickerParent.h"
|
||||
@ -72,7 +73,6 @@ class ClonedMessageData;
|
||||
class ContentParent;
|
||||
class Element;
|
||||
class DataTransfer;
|
||||
class BrowserBridgeParent;
|
||||
|
||||
namespace ipc {
|
||||
class StructuredCloneData;
|
||||
@ -187,6 +187,46 @@ class BrowserParent final : public PBrowserParent,
|
||||
*/
|
||||
bool IsDestroyed() const { return mIsDestroyed; }
|
||||
|
||||
/*
|
||||
* Visit each BrowserParent in the tree formed by PBrowser and
|
||||
* PBrowserBridge, including `this`.
|
||||
*/
|
||||
template <typename Callback>
|
||||
void VisitAll(Callback aCallback) {
|
||||
aCallback(this);
|
||||
VisitAllDescendants(aCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Visit each BrowserParent in the tree formed by PBrowser and
|
||||
* PBrowserBridge, excluding `this`.
|
||||
*/
|
||||
template <typename Callback>
|
||||
void VisitAllDescendants(Callback aCallback) {
|
||||
const auto& browserBridges = ManagedPBrowserBridgeParent();
|
||||
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
BrowserBridgeParent* browserBridge =
|
||||
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
|
||||
BrowserParent* browserParent = browserBridge->GetBrowserParent();
|
||||
|
||||
aCallback(browserParent);
|
||||
browserParent->VisitAllDescendants(aCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Visit each BrowserBridgeParent that is a child of this BrowserParent.
|
||||
*/
|
||||
template <typename Callback>
|
||||
void VisitChildren(Callback aCallback) {
|
||||
const auto& browserBridges = ManagedPBrowserBridgeParent();
|
||||
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
BrowserBridgeParent* browserBridge =
|
||||
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
|
||||
aCallback(browserBridge);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOwnerElement(Element* aElement);
|
||||
|
||||
void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) {
|
||||
|
Loading…
Reference in New Issue
Block a user