diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 76ffca634588..ba72f0f4aba1 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -35,8 +35,9 @@ #include "nsPIWindowRoot.h" #include "nsFrameManager.h" #include "nsIObserverService.h" -#include "mozilla/Services.h" +#include "mozilla/dom/Element.h" #include "mozilla/LookAndFeel.h" +#include "mozilla/Services.h" using namespace mozilla; @@ -1612,9 +1613,10 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup) // Walk all of the menu's children, checking to see if any of them has a // command attribute. If so, then several attributes must potentially be updated. - nsCOMPtr domDoc(do_QueryInterface(aPopup->GetDocument())); - if (!domDoc) + nsCOMPtr document = aPopup->GetCurrentDoc(); + if (!document) { return; + } for (nsCOMPtr grandChild = aPopup->GetFirstChild(); grandChild; @@ -1625,13 +1627,12 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup) grandChild->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command); if (!command.IsEmpty()) { // We do! Look it up in our document - nsCOMPtr commandElt; - domDoc->GetElementById(command, getter_AddRefs(commandElt)); - nsCOMPtr commandContent(do_QueryInterface(commandElt)); - if (commandContent) { + nsRefPtr commandElement = + document->GetElementById(command); + if (commandElement) { nsAutoString commandValue; // The menu's disabled state needs to be updated to match the command. - if (commandContent->GetAttr(kNameSpaceID_None, nsGkAtoms::disabled, commandValue)) + if (commandElement->GetAttr(kNameSpaceID_None, nsGkAtoms::disabled, commandValue)) grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, commandValue, true); else grandChild->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true); @@ -1639,16 +1640,16 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup) // The menu's label, accesskey checked and hidden states need to be updated // to match the command. Note that unlike the disabled state if the // command has *no* value, we assume the menu is supplying its own. - if (commandContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, commandValue)) + if (commandElement->GetAttr(kNameSpaceID_None, nsGkAtoms::label, commandValue)) grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::label, commandValue, true); - if (commandContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, commandValue)) + if (commandElement->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, commandValue)) grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, commandValue, true); - if (commandContent->GetAttr(kNameSpaceID_None, nsGkAtoms::checked, commandValue)) + if (commandElement->GetAttr(kNameSpaceID_None, nsGkAtoms::checked, commandValue)) grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::checked, commandValue, true); - if (commandContent->GetAttr(kNameSpaceID_None, nsGkAtoms::hidden, commandValue)) + if (commandElement->GetAttr(kNameSpaceID_None, nsGkAtoms::hidden, commandValue)) grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::hidden, commandValue, true); } }