Skip to content

Commit

Permalink
Bug 1691861 - Rename IconLoader::Helper to IconLoader::Listener. r=mc…
Browse files Browse the repository at this point in the history
…onley

Differential Revision: https://phabricator.services.mozilla.com/D104627
  • Loading branch information
mstange committed Feb 12, 2021
1 parent 4dd280f commit 78f08ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
10 changes: 5 additions & 5 deletions widget/IconLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace mozilla::widget {

NS_IMPL_ISUPPORTS(IconLoader, imgINotificationObserver)

IconLoader::IconLoader(Helper* aHelper, const nsIntRect& aImageRegionRect)
IconLoader::IconLoader(Listener* aListener, const nsIntRect& aImageRegionRect)
: mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE),
mImageRegionRect(aImageRegionRect),
mLoadedIcon(false),
mHelper(aHelper) {}
mListener(aListener) {}

IconLoader::~IconLoader() { Destroy(); }

Expand All @@ -31,7 +31,7 @@ void IconLoader::Destroy() {
mIconRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
mIconRequest = nullptr;
}
mHelper = nullptr;
mListener = nullptr;
}

nsresult IconLoader::LoadIcon(nsIURI* aIconURI, nsINode* aNode,
Expand Down Expand Up @@ -120,8 +120,8 @@ void IconLoader::Notify(imgIRequest* aRequest, int32_t aType,
aRequest->GetImage(getter_AddRefs(image));
MOZ_ASSERT(image);

if (mHelper) {
mHelper->OnComplete(image, mImageRegionRect);
if (mListener) {
mListener->OnComplete(image, mImageRegionRect);
}
return;
}
Expand Down
24 changes: 10 additions & 14 deletions widget/IconLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,19 @@ namespace mozilla::widget {

class IconLoader : public imgINotificationObserver {
public:
/**
* IconLoader itself is cross-platform, but each platform needs to supply
* it with a Helper that does the platform-specific conversion work. The
* Helper needs to implement the OnComplete method in order to handle the
* imgIContainer of the loaded icon.
*/
class Helper {
// This is the interface that our listeners need to implement so that they can
// be notified when the icon is loaded.
class Listener {
public:
virtual nsresult OnComplete(imgIContainer* aContainer,
const nsIntRect& aRect) = 0;
};

// Create the loader.
// aHelper will be notified when the load is complete.
// The loader does not keep an owning reference to the helper. Call Destroy
// before the helper goes away.
IconLoader(Helper* aHelper, const nsIntRect& aImageRegionRect);
// aListener will be notified when the load is complete.
// The loader does not keep an owning reference to the listener. Call Destroy
// before the listener goes away.
IconLoader(Listener* aListener, const nsIntRect& aImageRegionRect);

public:
NS_DECL_ISUPPORTS
Expand All @@ -69,11 +65,11 @@ class IconLoader : public imgINotificationObserver {
nsIntRect mImageRegionRect;
bool mLoadedIcon;

// The helper, which is notified when loading completes.
// The listener, which is notified when loading completes.
// Can be null, after a call to Destroy.
// This is a non-owning reference and needs to be cleared with a call to
// Destroy before the helper goes away.
Helper* mHelper;
// Destroy before the listener goes away.
Listener* mListener;
};

} // namespace mozilla::widget
Expand Down
4 changes: 2 additions & 2 deletions widget/cocoa/IconLoaderHelperCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class IconLoaderListenerCocoa {
};

/**
* This is a Helper used with mozilla::widget::IconLoader that implements the
* This is a helper used with mozilla::widget::IconLoader that implements the
* macOS-specific functionality for converting a loaded icon into an NSImage*.
*/
class IconLoaderHelperCocoa final : public mozilla::widget::IconLoader::Helper {
class IconLoaderHelperCocoa final : public IconLoader::Listener {
public:
// Create the helper and install aLoadListener as a listener.
// The helper does not keep a strong reference to the listener. Call Destroy
Expand Down
2 changes: 1 addition & 1 deletion widget/windows/IconLoaderHelperWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IconLoaderListenerWin : public nsISupports {
* This is a Helper used with mozilla::widget::IconLoader that implements the
* Windows-specific functionality for converting a loaded icon into an HICON.
*/
class IconLoaderHelperWin final : public mozilla::widget::IconLoader::Helper {
class IconLoaderHelperWin final : public IconLoader::Listener {
public:
// Create the helper and install aLoadListener as a listener.
// The helper does not keep a strong reference to the listener. Call Destroy
Expand Down

0 comments on commit 78f08ff

Please sign in to comment.