mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1563295 - Only rebuild native menu when specific elements added. r=mstange
The menuitem custom element inserts nodes when rendered. These nodes are not related to the structure of the menu, but were causing nsMenuItemX to mark the menu as needing a rebuild. The rebuild would remove all items from the menu which caused the removal of the special menu items "Start Dictation" and "Emoji and Symbols" that are automatically added by MacOS. Differential Revision: https://phabricator.services.mozilla.com/D45420 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9a41a4d559
commit
c077f5df49
@ -331,19 +331,30 @@ void nsMenuItemX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent*
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
bool IsMenuStructureElement(nsIContent* aContent) {
|
||||
return aContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem,
|
||||
nsGkAtoms::menuseparator);
|
||||
}
|
||||
|
||||
void nsMenuItemX::ObserveContentRemoved(dom::Document* aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, nsIContent* aPreviousSibling) {
|
||||
if (aChild == mCommandElement) {
|
||||
mMenuGroupOwner->UnregisterForContentChanges(mCommandElement);
|
||||
mCommandElement = nullptr;
|
||||
}
|
||||
|
||||
mMenuParent->SetRebuild(true);
|
||||
if (IsMenuStructureElement(aChild)) {
|
||||
mMenuParent->SetRebuild(true);
|
||||
}
|
||||
}
|
||||
|
||||
void nsMenuItemX::ObserveContentInserted(dom::Document* aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild) {
|
||||
mMenuParent->SetRebuild(true);
|
||||
// The child node could come from the custom element that is for display, so
|
||||
// only rebuild the menu if the child is related to the structure of the
|
||||
// menu.
|
||||
if (IsMenuStructureElement(aChild)) {
|
||||
mMenuParent->SetRebuild(true);
|
||||
}
|
||||
}
|
||||
|
||||
void nsMenuItemX::SetupIcon() {
|
||||
|
Loading…
Reference in New Issue
Block a user