Followup for bug 613800, address review comments. r=jst, a=blocks-final
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 16 Feb 2011 10:27:25 -0800
changeset 62677 104a6d17e013c1115adb10e365c8a73f8ba79c2f
parent 62676 9c0a81f71fbc37cac5da4a6674f03e9bef73f413
child 62678 4599855d0cbd9f26d02fc24fee8e9310478318ca
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersjst, blocks-final
bugs613800
milestone2.0b12pre
Followup for bug 613800, address review comments. r=jst, a=blocks-final
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2486,16 +2486,31 @@ nsGlobalWindow::UpdateParentTarget()
       mParentTarget = fl->GetTabChildGlobalAsEventTarget();
     }
   }
   if (!mParentTarget) {
     mParentTarget = mChromeEventHandler;
   }
 }
 
+PRBool
+nsGlobalWindow::GetIsTabModalPromptAllowed()
+{
+  PRBool allowTabModal = PR_TRUE;
+  if (mDocShell) {
+    nsCOMPtr<nsIContentViewer> cv;
+    mDocShell->GetContentViewer(getter_AddRefs(cv));
+    nsCOMPtr<nsIContentViewer_MOZILLA_2_0_BRANCH> cv2 = do_QueryInterface(cv);
+    if (cv2)
+      cv2->GetIsTabModalPromptAllowed(&allowTabModal);
+  }
+
+  return allowTabModal;
+}
+
 nsresult
 nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
 {
   NS_PRECONDITION(IsInnerWindow(), "PreHandleEvent is used on outer window!?");
   static PRUint32 count = 0;
   PRUint32 msg = aVisitor.mEvent->message;
 
   aVisitor.mCanHandle = PR_TRUE;
@@ -4628,24 +4643,17 @@ nsGlobalWindow::Alert(const nsAString& a
 
   // Remove non-terminating null characters from the 
   // string. See bug #310037. 
   nsAutoString final;
   nsContentUtils::StripNullChars(*str, final);
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
-  PRBool allowTabModal = PR_TRUE;
-  if (mDocShell) {
-    nsCOMPtr<nsIContentViewer> cv;
-    mDocShell->GetContentViewer(getter_AddRefs(cv));
-    nsCOMPtr<nsIContentViewer_MOZILLA_2_0_BRANCH> cv2 = do_QueryInterface(cv);
-    if (cv2)
-      cv2->GetIsTabModalPromptAllowed(&allowTabModal);
-  }
+  PRBool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
   rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
@@ -4701,24 +4709,17 @@ nsGlobalWindow::Confirm(const nsAString&
 
   // Remove non-terminating null characters from the 
   // string. See bug #310037. 
   nsAutoString final;
   nsContentUtils::StripNullChars(aString, final);
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
-  PRBool allowTabModal = PR_TRUE;
-  if (mDocShell) {
-    nsCOMPtr<nsIContentViewer> cv;
-    mDocShell->GetContentViewer(getter_AddRefs(cv));
-    nsCOMPtr<nsIContentViewer_MOZILLA_2_0_BRANCH> cv2 = do_QueryInterface(cv);
-    if (cv2)
-      cv2->GetIsTabModalPromptAllowed(&allowTabModal);
-  }
+  PRBool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
   rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
@@ -4777,24 +4778,17 @@ nsGlobalWindow::Prompt(const nsAString& 
   // Remove non-terminating null characters from the 
   // string. See bug #310037. 
   nsAutoString fixedMessage, fixedInitial;
   nsContentUtils::StripNullChars(aMessage, fixedMessage);
   nsContentUtils::StripNullChars(aInitial, fixedInitial);
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
-  PRBool allowTabModal = PR_TRUE;
-  if (mDocShell) {
-    nsCOMPtr<nsIContentViewer> cv;
-    mDocShell->GetContentViewer(getter_AddRefs(cv));
-    nsCOMPtr<nsIContentViewer_MOZILLA_2_0_BRANCH> cv2 = do_QueryInterface(cv);
-    if (cv2)
-      cv2->GetIsTabModalPromptAllowed(&allowTabModal);
-  }
+  PRBool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
   rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -815,16 +815,18 @@ protected:
 
   static void NotifyDOMWindowDestroyed(nsGlobalWindow* aWindow);
   void NotifyWindowIDDestroyed(const char* aTopic);
   
   void ClearStatus();
 
   virtual void UpdateParentTarget();
 
+  PRBool GetIsTabModalPromptAllowed();
+
   // When adding new member variables, be careful not to create cycles
   // through JavaScript.  If there is any chance that a member variable
   // could own objects that are implemented in JavaScript, then those
   // objects will keep the global object (this object) alive.  To prevent
   // these cycles, ownership of such members must be released in
   // |CleanUp| and |SetDocShell|.
 
   // This member is also used on both inner and outer windows, but