Bug 807465 - Less QIs in nsXULPopupManager::UpdateMenuItems; r=Enn
authorMs2ger <ms2ger@gmail.com>
Sun, 04 Nov 2012 09:05:25 +0100
changeset 120894 cac8275e885b7fddee60e0545f4d34cbc52aefda
parent 120893 8e21cdfce89c43fd00429f35d81b238da2ca96c1
child 120895 5c6b71348e20c46089baa600a1b508d0326bdacd
push id273
push userlsblakk@mozilla.com
push dateThu, 14 Feb 2013 23:19:38 +0000
treeherdermozilla-release@c5e807a3f8b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs807465
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 807465 - Less QIs in nsXULPopupManager::UpdateMenuItems; r=Enn
layout/xul/base/src/nsXULPopupManager.cpp
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -30,18 +30,19 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIBaseWindow.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsCaret.h"
 #include "nsIDocument.h"
 #include "nsPIWindowRoot.h"
 #include "nsFrameManager.h"
 #include "nsIObserverService.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/LookAndFeel.h"
 #include "mozilla/Services.h"
-#include "mozilla/LookAndFeel.h"
 
 using namespace mozilla;
 
 const nsNavigationDirection DirectionFromKeyCodeTable[2][6] = {
   {
     eNavigationDirection_Last,   // NS_VK_END
     eNavigationDirection_First,  // NS_VK_HOME
     eNavigationDirection_Start,  // NS_VK_LEFT
@@ -1607,53 +1608,53 @@ nsXULPopupManager::UpdateKeyboardListene
 }
 
 void
 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<nsIDOMDocument> domDoc(do_QueryInterface(aPopup->GetDocument()));
-  if (!domDoc)
+  nsCOMPtr<nsIDocument> document = aPopup->GetCurrentDoc();
+  if (!document) {
     return;
+  }
 
   for (nsCOMPtr<nsIContent> grandChild = aPopup->GetFirstChild();
        grandChild;
        grandChild = grandChild->GetNextSibling()) {
     if (grandChild->NodeInfo()->Equals(nsGkAtoms::menuitem, kNameSpaceID_XUL)) {
       // See if we have a command attribute.
       nsAutoString command;
       grandChild->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
       if (!command.IsEmpty()) {
         // We do! Look it up in our document
-        nsCOMPtr<nsIDOMElement> commandElt;
-        domDoc->GetElementById(command, getter_AddRefs(commandElt));
-        nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
-        if (commandContent) {
+        nsRefPtr<dom::Element> 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);
 
           // 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);
         }
       }
     }
   }
 }
 
 // Notify