Bug 1705842 - Make sure that items that are un-hidden while the menu is open get their icon set up. r=harry

Before, we were only calling SetUpIcon if the item was visible during menu
construction on menu opening, but not if the item became visible after menu
opening.

Differential Revision: https://phabricator.services.mozilla.com/D112452
This commit is contained in:
Markus Stange 2021-04-19 23:08:34 +00:00
parent 25ac7914a4
commit 7c3e29a98e
2 changed files with 14 additions and 4 deletions

View File

@ -97,6 +97,10 @@ nsMenuItemX::nsMenuItemX(nsMenuX* aParent, const nsString& aLabel, EMenuItemType
mNativeMenuItem.representedObject = mMenuGroupOwner->GetRepresentedObject();
mNativeMenuItem.tag = mMenuGroupOwner->RegisterForCommand(this);
if (mIsVisible) {
SetupIcon();
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -307,6 +311,9 @@ void nsMenuItemX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent*
RefPtr<nsMenuItemX> self = this;
mMenuParent->MenuChildChangedVisibility(nsMenuParentX::MenuChild(self), isVisible);
mIsVisible = isVisible;
if (mIsVisible) {
SetupIcon();
}
}
mMenuParent->SetRebuild(true);
} else if (aAttribute == nsGkAtoms::label) {

View File

@ -122,6 +122,10 @@ nsMenuX::nsMenuX(nsMenuParentX* aParent, nsMenuGroupOwnerX* aMenuGroupOwner, nsI
mIcon = MakeUnique<nsMenuItemIconX>(this);
if (mVisible) {
SetupIcon();
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -208,8 +212,6 @@ void nsMenuX::AddMenuItem(RefPtr<nsMenuItemX>&& aMenuItem) {
[mNativeMenu addItem:aMenuItem->NativeNSMenuItem()];
++mVisibleItemsCount;
aMenuItem->SetupIcon();
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -232,8 +234,6 @@ void nsMenuX::AddMenu(RefPtr<nsMenuX>&& aMenu) {
newNativeMenuItem.submenu = aMenu->NativeNSMenu();
}
aMenu->SetupIcon();
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -845,6 +845,9 @@ void nsMenuX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent* aCon
RefPtr<nsMenuX> self = this;
mParent->MenuChildChangedVisibility(MenuChild(self), newVisible);
}
if (mVisible) {
SetupIcon();
}
mVisible = newVisible;
} else if (aAttribute == nsGkAtoms::image) {
SetupIcon();