зеркало из https://github.com/mozilla/gecko-dev.git
Bug 807465 - Less QIs in nsXULPopupManager::UpdateMenuItems; r=Enn
This commit is contained in:
Родитель
b903541457
Коммит
4dd22ae85f
|
@ -35,8 +35,9 @@
|
||||||
#include "nsPIWindowRoot.h"
|
#include "nsPIWindowRoot.h"
|
||||||
#include "nsFrameManager.h"
|
#include "nsFrameManager.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/LookAndFeel.h"
|
#include "mozilla/LookAndFeel.h"
|
||||||
|
#include "mozilla/Services.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
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
|
// 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.
|
// command attribute. If so, then several attributes must potentially be updated.
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aPopup->GetDocument()));
|
nsCOMPtr<nsIDocument> document = aPopup->GetCurrentDoc();
|
||||||
if (!domDoc)
|
if (!document) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (nsCOMPtr<nsIContent> grandChild = aPopup->GetFirstChild();
|
for (nsCOMPtr<nsIContent> grandChild = aPopup->GetFirstChild();
|
||||||
grandChild;
|
grandChild;
|
||||||
|
@ -1625,13 +1627,12 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup)
|
||||||
grandChild->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
|
grandChild->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
|
||||||
if (!command.IsEmpty()) {
|
if (!command.IsEmpty()) {
|
||||||
// We do! Look it up in our document
|
// We do! Look it up in our document
|
||||||
nsCOMPtr<nsIDOMElement> commandElt;
|
nsRefPtr<dom::Element> commandElement =
|
||||||
domDoc->GetElementById(command, getter_AddRefs(commandElt));
|
document->GetElementById(command);
|
||||||
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
|
if (commandElement) {
|
||||||
if (commandContent) {
|
|
||||||
nsAutoString commandValue;
|
nsAutoString commandValue;
|
||||||
// The menu's disabled state needs to be updated to match the command.
|
// 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);
|
grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, commandValue, true);
|
||||||
else
|
else
|
||||||
grandChild->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true);
|
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
|
// 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
|
// to match the command. Note that unlike the disabled state if the
|
||||||
// command has *no* value, we assume the menu is supplying its own.
|
// 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);
|
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);
|
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);
|
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);
|
grandChild->SetAttr(kNameSpaceID_None, nsGkAtoms::hidden, commandValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче