зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1698662 - Move part of SetupIcon into a new method StartIconLoad. r=harry
Depends on D108541 Differential Revision: https://phabricator.services.mozilla.com/D108542
This commit is contained in:
Родитель
4bace3e954
Коммит
211d67740f
|
@ -44,6 +44,9 @@ class nsMenuItemIconX final : public mozilla::widget::IconLoader::Listener {
|
|||
NSImage* GetIconImage() const { return mIconImage; }
|
||||
|
||||
protected:
|
||||
// Returns whether there should be an icon.
|
||||
bool StartIconLoad(nsIContent* aContent);
|
||||
|
||||
// GetIconURI returns null if the item should not have any icon.
|
||||
already_AddRefed<nsIURI> GetIconURI(nsIContent* aContent);
|
||||
|
||||
|
|
|
@ -59,23 +59,8 @@ nsMenuItemIconX::~nsMenuItemIconX() {
|
|||
void nsMenuItemIconX::SetupIcon(nsIContent* aContent) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
nsCOMPtr<nsIURI> iconURI = GetIconURI(aContent);
|
||||
if (!iconURI) {
|
||||
// There is no icon for this menu item. An icon might have been set
|
||||
// earlier. Clear it.
|
||||
if (mIconImage) {
|
||||
[mIconImage release];
|
||||
mIconImage = nil;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mIconLoader) {
|
||||
mIconLoader = new IconLoader(this);
|
||||
}
|
||||
|
||||
nsresult rv = mIconLoader->LoadIcon(iconURI, aContent);
|
||||
if (NS_FAILED(rv)) {
|
||||
bool shouldHaveIcon = StartIconLoad(aContent);
|
||||
if (!shouldHaveIcon) {
|
||||
// There is no icon for this menu item, as an error occurred while loading it.
|
||||
// An icon might have been set earlier or the place holder icon may have
|
||||
// been set. Clear it.
|
||||
|
@ -96,6 +81,20 @@ void nsMenuItemIconX::SetupIcon(nsIContent* aContent) {
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
bool nsMenuItemIconX::StartIconLoad(nsIContent* aContent) {
|
||||
RefPtr<nsIURI> iconURI = GetIconURI(aContent);
|
||||
if (!iconURI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mIconLoader) {
|
||||
mIconLoader = new IconLoader(this);
|
||||
}
|
||||
|
||||
nsresult rv = mIconLoader->LoadIcon(iconURI, aContent);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI> nsMenuItemIconX::GetIconURI(nsIContent* aContent) {
|
||||
// First, look at the content node's "image" attribute.
|
||||
nsAutoString imageURIString;
|
||||
|
|
Загрузка…
Ссылка в новой задаче