Commit 266c6f17 authored by Blake Kaplan's avatar Blake Kaplan
Browse files

Bug 971222 - Small cleanup around prompt code. r=bzbarsky

parent 27af4d42
Loading
Loading
Loading
Loading
+8 −29
Original line number Diff line number Diff line
@@ -2917,21 +2917,6 @@ nsGlobalWindow::UpdateParentTarget()
  mParentTarget = eventTarget;
}

bool
nsGlobalWindow::GetIsTabModalPromptAllowed()
{
  MOZ_ASSERT(IsOuterWindow());

  bool allowTabModal = true;
  if (mDocShell) {
    nsCOMPtr<nsIContentViewer> cv;
    mDocShell->GetContentViewer(getter_AddRefs(cv));
    cv->GetIsTabModalPromptAllowed(&allowTabModal);
  }

  return allowTabModal;
}

EventTarget*
nsGlobalWindow::GetTargetForDOMEvent()
{
@@ -6166,10 +6151,6 @@ nsGlobalWindow::AlertOrConfirm(bool aAlert,
  nsAutoString final;
  nsContentUtils::StripNullChars(aMessage, final);

  // Check if we're being called at a point where we can't use tab-modal
  // prompts, because something doesn't want reentrancy.
  bool allowTabModal = GetIsTabModalPromptAllowed();

  nsresult rv;
  nsCOMPtr<nsIPromptFactory> promptFac =
    do_GetService("@mozilla.org/prompter;1", &rv);
@@ -6185,9 +6166,10 @@ nsGlobalWindow::AlertOrConfirm(bool aAlert,
    return false;
  }

  nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt);
  if (promptBag)
    promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), allowTabModal);
  // Always allow tab modal prompts for alert and confirm.
  if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
    promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), true);
  }

  bool result = false;
  nsAutoSyncOperation sync(mDoc);
@@ -6281,10 +6263,6 @@ nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
  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.
  bool allowTabModal = GetIsTabModalPromptAllowed();

  nsresult rv;
  nsCOMPtr<nsIPromptFactory> promptFac =
    do_GetService("@mozilla.org/prompter;1", &rv);
@@ -6300,9 +6278,10 @@ nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
    return;
  }

  nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt);
  if (promptBag)
    promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), allowTabModal);
  // Always allow tab modal prompts for prompt.
  if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
    promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), true);
  }

  // Pass in the default value, if any.
  char16_t *inoutValue = ToNewUnicode(fixedInitial);
+0 −3
Original line number Diff line number Diff line
@@ -1299,9 +1299,6 @@ protected:

  virtual void UpdateParentTarget();

  // Outer windows only.
  bool GetIsTabModalPromptAllowed();

  inline int32_t DOMMinTimeoutValue() const;

  nsresult CloneStorageEvent(const nsAString& aType,
+2 −1
Original line number Diff line number Diff line
@@ -458,7 +458,8 @@ ModalPrompter.prototype = {
    allowTabModal : false,

    QueryInterface : XPCOMUtils.generateQI([Ci.nsIPrompt, Ci.nsIAuthPrompt,
Ci.nsIAuthPrompt2, Ci.nsIWritablePropertyBag2]),
                                            Ci.nsIAuthPrompt2,
                                            Ci.nsIWritablePropertyBag2]),


    /* ---------- internal methods ---------- */