当前位置: 首页>>代码示例>>C++>>正文


C++ docShell函数代码示例

本文整理汇总了C++中docShell函数的典型用法代码示例。如果您正苦于以下问题:C++ docShell函数的具体用法?C++ docShell怎么用?C++ docShell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了docShell函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
                                                   nsICommandParams *aParams,
                                                   nsISupports *refCon)
{
  NS_ENSURE_ARG_POINTER(aParams);
  NS_ENSURE_ARG_POINTER(refCon);

  // The base editor owns most state info
  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
  if (!editor) return NS_ERROR_INVALID_ARG;

  // Always get the enabled state
  PRBool outCmdEnabled = PR_FALSE;
  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
  nsresult rv = aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
  NS_ENSURE_SUCCESS(rv, rv);

  // get pres context
  nsCOMPtr<nsPresContext> presContext;
  rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
  if (NS_FAILED(rv)) return rv;
  if (!presContext) return NS_ERROR_FAILURE;

  PRInt32 animationMode;
  rv = aParams->GetLongValue("imageAnimation", &animationMode);
  if (NS_SUCCEEDED(rv))
  {
    // for possible values of animation mode, see
    // http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/public/imgIContainer.idl
    rv = aParams->SetLongValue("imageAnimation",
                               presContext->ImageAnimationMode());
    if (NS_FAILED(rv)) return rv;
  }

  PRBool allowPlugins; 
  rv = aParams->GetBooleanValue("plugins", &allowPlugins);
  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsISupports> container = presContext->GetContainer();
    if (!container) return NS_ERROR_FAILURE;

    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
    if (NS_FAILED(rv)) return rv;
    if (!docShell) return NS_ERROR_FAILURE;

    rv = docShell->GetAllowPlugins(&allowPlugins);
    if (NS_FAILED(rv)) return rv;

    rv = aParams->SetBooleanValue("plugins", allowPlugins);
    if (NS_FAILED(rv)) return rv;
  }

  return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:55,代码来源:nsComposerDocumentCommands.cpp

示例2: docShell

nsresult
nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
                            PRBool aReplace)
{
  nsresult result;
  nsCOMPtr<nsIURI> newUri;

  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));

  nsCAutoString docCharset;
  if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset)))
    result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase);
  else
    result = NS_NewURI(getter_AddRefs(newUri), aHref, nsnull, aBase);

  if (newUri) {
    /* Check with the scriptContext if it is currently processing a script tag.
     * If so, this must be a <script> tag with a location.href in it.
     * we want to do a replace load, in such a situation. 
     * In other cases, for example if a event handler or a JS timer
     * had a location.href in it, we want to do a normal load,
     * so that the new url will be appended to Session History.
     * This solution is tricky. Hopefully it isn't going to bite
     * anywhere else. This is part of solution for bug # 39938, 72197
     * 
     */
    PRBool inScriptTag=PR_FALSE;
    // Get JSContext from stack.
    nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1", &result));

    if (stack) {
      JSContext *cx;

      result = GetContextFromStack(stack, &cx);
      if (cx) {
        nsIScriptContext *scriptContext =
          nsJSUtils::GetDynamicScriptContext(cx);

        if (scriptContext) {
          if (scriptContext->GetProcessingScriptTag()) {
            // Now check to make sure that the script is running in our window,
            // since we only want to replace if the location is set by a
            // <script> tag in the same window.  See bug 178729.
            nsCOMPtr<nsIScriptGlobalObject> ourGlobal(do_GetInterface(docShell));
            inScriptTag = (ourGlobal == scriptContext->GetGlobalObject());
          }
        }  
      } //cx
    }  // stack

    return SetURI(newUri, aReplace || inScriptTag);
  }

  return result;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:55,代码来源:nsLocation.cpp

示例3: docShell

NS_IMETHODIMP
nsLocation::Reload(bool aForceget)
{
  if (!CallerSubsumes())
    return NS_ERROR_DOM_SECURITY_ERR;

  nsresult rv;
  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
  nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
  nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(docShell));

  if (window && window->IsHandlingResizeEvent()) {
    // location.reload() was called on a window that is handling a
    // resize event. Sites do this since Netscape 4.x needed it, but
    // we don't, and it's a horrible experience for nothing. In stead
    // of reloading the page, just clear style data and reflow the
    // page since some sites may use this trick to work around gecko
    // reflow bugs, and this should have the same effect.

    nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));

    nsIPresShell *shell;
    nsPresContext *pcx;
    if (doc && (shell = doc->GetShell()) && (pcx = shell->GetPresContext())) {
      pcx->RebuildAllStyleData(NS_STYLE_HINT_REFLOW);
    }

    return NS_OK;
  }

  if (webNav) {
    uint32_t reloadFlags = nsIWebNavigation::LOAD_FLAGS_NONE;

    if (aForceget) {
      reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | 
                    nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
    }
    rv = webNav->Reload(reloadFlags);
    if (rv == NS_BINDING_ABORTED) {
      // This happens when we attempt to reload a POST result and the user says
      // no at the "do you want to reload?" prompt.  Don't propagate this one
      // back to callers.
      rv = NS_OK;
    }
  } else {
    rv = NS_ERROR_FAILURE;
  }

  return rv;
}
开发者ID:kusl,项目名称:releases-mozilla-release,代码行数:50,代码来源:nsLocation.cpp

示例4: docShell

nsresult
MediaDocument::StartDocumentLoad(const char*         aCommand,
                                 nsIChannel*         aChannel,
                                 nsILoadGroup*       aLoadGroup,
                                 nsISupports*        aContainer,
                                 nsIStreamListener** aDocListener,
                                 bool                aReset,
                                 nsIContentSink*     aSink)
{
  nsresult rv = nsDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
                                              aContainer, aDocListener, aReset,
                                              aSink);
  if (NS_FAILED(rv)) {
    return rv;
  }

  // We try to set the charset of the current document to that of the 
  // 'genuine' (as opposed to an intervening 'chrome') parent document 
  // that may be in a different window/tab. Even if we fail here,
  // we just return NS_OK because another attempt is made in 
  // |UpdateTitleAndCharset| and the worst thing possible is a mangled 
  // filename in the titlebar and the file picker.

  // Note that we
  // exclude UTF-8 as 'invalid' because UTF-8 is likely to be the charset 
  // of a chrome document that has nothing to do with the actual content 
  // whose charset we want to know. Even if "the actual content" is indeed 
  // in UTF-8, we don't lose anything because the default empty value is 
  // considered synonymous with UTF-8. 
    
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));

  // not being able to set the charset is not critical.
  NS_ENSURE_TRUE(docShell, NS_OK); 

  nsAutoCString charset;
  int32_t source;
  nsCOMPtr<nsIPrincipal> principal;
  // opening in a new tab
  docShell->GetParentCharset(charset, &source, getter_AddRefs(principal));

  if (!charset.IsEmpty() &&
      !charset.Equals("UTF-8") &&
      NodePrincipal()->Equals(principal)) {
    SetDocumentCharacterSetSource(source);
    SetDocumentCharacterSet(charset);
  }

  return NS_OK;
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:50,代码来源:MediaDocument.cpp

示例5: docShell

float
ImageDocument::GetZoomLevel()
{
  float zoomLevel = mOriginalZoomLevel;
  nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
  if (docShell) {
    nsCOMPtr<nsIContentViewer> cv;
    docShell->GetContentViewer(getter_AddRefs(cv));
    if (cv) {
      cv->GetFullZoom(&zoomLevel);
    }
  }
  return zoomLevel;
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:14,代码来源:ImageDocument.cpp

示例6: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
                                                   nsICommandParams *aParams,
                                                   nsISupports *refCon)
{
  NS_ENSURE_ARG_POINTER(aParams);
  NS_ENSURE_ARG_POINTER(refCon);

  // The base editor owns most state info
  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
  NS_ENSURE_TRUE(editor, NS_ERROR_INVALID_ARG);

  // Always get the enabled state
  bool outCmdEnabled = false;
  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
  nsresult rv = aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
  NS_ENSURE_SUCCESS(rv, rv);

  // get pres context
  nsRefPtr<nsPresContext> presContext;
  rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);

  int32_t animationMode;
  rv = aParams->GetLongValue("imageAnimation", &animationMode);
  if (NS_SUCCEEDED(rv))
  {
    // for possible values of animation mode, see
    // http://lxr.mozilla.org/seamonkey/source/image/public/imgIContainer.idl
    rv = aParams->SetLongValue("imageAnimation",
                               presContext->ImageAnimationMode());
    NS_ENSURE_SUCCESS(rv, rv);
  }

  bool allowPlugins = false; 
  rv = aParams->GetBooleanValue("plugins", &allowPlugins);
  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
    NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);

    allowPlugins = docShell->PluginsAllowedInCurrentDoc();

    rv = aParams->SetBooleanValue("plugins", allowPlugins);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:50,代码来源:nsComposerDocumentCommands.cpp

示例7: docShell

nsresult
Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
                            bool aReplace)
{
  nsresult result;
  nsCOMPtr<nsIURI> newUri;

  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));

  nsAutoCString docCharset;
  if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset)))
    result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase);
  else
    result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase);

  if (newUri) {
    /* Check with the scriptContext if it is currently processing a script tag.
     * If so, this must be a <script> tag with a location.href in it.
     * we want to do a replace load, in such a situation. 
     * In other cases, for example if a event handler or a JS timer
     * had a location.href in it, we want to do a normal load,
     * so that the new url will be appended to Session History.
     * This solution is tricky. Hopefully it isn't going to bite
     * anywhere else. This is part of solution for bug # 39938, 72197
     * 
     */
    bool inScriptTag = false;
    nsIScriptContext* scriptContext = nullptr;
    nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(GetEntryGlobal());
    if (win) {
      scriptContext = nsGlobalWindow::Cast(win)->GetContextInternal();
    }

    if (scriptContext) {
      if (scriptContext->GetProcessingScriptTag()) {
        // Now check to make sure that the script is running in our window,
        // since we only want to replace if the location is set by a
        // <script> tag in the same window.  See bug 178729.
        nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
          docShell ? docShell->GetScriptGlobalObject() : nullptr;
        inScriptTag = (ourGlobal == scriptContext->GetGlobalObject());
      }
    }

    return SetURI(newUri, aReplace || inScriptTag);
  }

  return result;
}
开发者ID:OS2World,项目名称:APP-INTERNET-mozilla-os2,代码行数:49,代码来源:Location.cpp

示例8: NS_PRECONDITION

NS_IMETHODIMP
nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
                                     nsIWebNavigation* aWebNav,
                                     uint32_t* aIsTypeSupported)
{
  NS_PRECONDITION(aIsTypeSupported, "null out param?");

  // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
  // an nsSHistory, but not much we can do with that).  So if we start using
  // it here, we need to be careful to get to the docshell correctly.
  
  // For now just report what the Gecko-Content-Viewers category has
  // to say for itself.
  *aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;

  const nsCString& flatType = PromiseFlatCString(aType);
  nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported);
  NS_ENSURE_SUCCESS(rv, rv);

  if (*aIsTypeSupported) {
    return rv;
  }

  // If this request is for a docShell that isn't going to allow plugins,
  // there's no need to try and find a plugin to handle it.
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
  bool allowed;
  if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
    return NS_OK;
  }

  // Try reloading plugins in case they've changed.
  nsCOMPtr<nsIPluginHost> pluginHost =
    do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
  if (pluginHost) {
    // false will ensure that currently running plugins will not
    // be shut down
    rv = pluginHost->ReloadPlugins();
    if (NS_SUCCEEDED(rv)) {
      // OK, we reloaded plugins and there were new ones
      // (otherwise NS_ERROR_PLUGINS_PLUGINSNOTCHANGED would have
      // been returned).  Try checking whether we can handle the
      // content now.
      return IsTypeSupportedInternal(flatType, aIsTypeSupported);
    }
  }

  return NS_OK;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:49,代码来源:nsWebNavigationInfo.cpp

示例9: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
                                             nsICommandParams *aParams,
                                             nsISupports *refCon)
{
  NS_ENSURE_ARG_POINTER(aParams);

  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
  NS_ENSURE_TRUE(editor, NS_ERROR_INVALID_ARG);

  nsRefPtr<nsPresContext> presContext;
  nsresult rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);

  PRInt32 animationMode; 
  rv = aParams->GetLongValue("imageAnimation", &animationMode);
  if (NS_SUCCEEDED(rv))
  {
    // for possible values of animation mode, see:
    // http://lxr.mozilla.org/seamonkey/source/image/public/imgIContainer.idl
    presContext->SetImageAnimationMode(animationMode);
  }

  bool allowPlugins; 
  rv = aParams->GetBooleanValue("plugins", &allowPlugins);
  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsISupports> container = presContext->GetContainer();
    NS_ENSURE_TRUE(container, NS_ERROR_FAILURE);

    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
    NS_ENSURE_SUCCESS(rv, rv);
    NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);

    rv = docShell->SetAllowPlugins(allowPlugins);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}
开发者ID:PriceTseng,项目名称:mozilla-central,代码行数:41,代码来源:nsComposerDocumentCommands.cpp

示例10: urlString

NS_IMETHODIMP MailEwsMsgMessageService::OpenAttachment(const char *aContentType, 
                                                       const char *aFileName,
                                                       const char *aUrl, 
                                                       const char *aMessageUri, 
                                                       nsISupports *aDisplayConsumer, 
                                                       nsIMsgWindow *aMsgWindow, 
                                                       nsIUrlListener *aUrlListener)
{
  nsCOMPtr <nsIURI> URL;
  nsresult rv;

  nsAutoCString urlString(aUrl);
  urlString += "&type=";
  urlString += aContentType;
  urlString += "&filename=";
  urlString += aFileName;

  nsCOMPtr<nsIMailboxUrl> aMailboxUrl;
  
	URL = do_CreateInstance(MAIL_EWS_MSG_URL_CONTRACTID, &rv);
	NS_ENSURE_SUCCESS(rv, rv);

  URL->SetSpec(urlString);
  
  // try to run the url in the docshell...
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
  // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
  if (NS_SUCCEEDED(rv) && docShell)
  {
    nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
    // DIRTY LITTLE HACK --> since we are opening an attachment we want the docshell to
    // treat this load as if it were a user click event. Then the dispatching stuff will be much
    // happier.
    docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
    loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
    return docShell->LoadURI(URL, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
  }
  return RunMailboxUrl(URL, aDisplayConsumer);
}
开发者ID:stonewell,项目名称:exchange-ews-thunderbird,代码行数:39,代码来源:MailEwsMsgMessageService.cpp

示例11: GetEntryDocument

nsresult
Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
{
  *sourceURL = nullptr;
  nsIDocument* doc = GetEntryDocument();
  // If there's no entry document, we either have no Script Entry Point or one
  // that isn't a DOM Window.  This doesn't generally happen with the DOM, but
  // can sometimes happen with extension code in certain IPC configurations.  If
  // this happens, try falling back on the current document associated with the
  // docshell. If that fails, just return null and hope that the caller passed
  // an absolute URI.
  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
  if (!doc && docShell) {
    nsCOMPtr<nsPIDOMWindowOuter> docShellWin =
      do_QueryInterface(docShell->GetScriptGlobalObject());
    if (docShellWin) {
      doc = docShellWin->GetDoc();
    }
  }
  NS_ENSURE_TRUE(doc, NS_OK);
  *sourceURL = doc->GetBaseURI().take();
  return NS_OK;
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:23,代码来源:Location.cpp

示例12: IsImageLoadInEditorAppType

static bool IsImageLoadInEditorAppType(nsILoadInfo* aLoadInfo)
{
    // Editor apps get special treatment here, editors can load images
    // from anywhere.  This allows editor to insert images from file://
    // into documents that are being edited.
    nsContentPolicyType type = aLoadInfo->InternalContentPolicyType();
    if (type != nsIContentPolicy::TYPE_INTERNAL_IMAGE  &&
            type != nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD &&
            type != nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON &&
            type != nsIContentPolicy::TYPE_IMAGESET) {
        return false;
    }

    uint32_t appType = nsIDocShell::APP_TYPE_UNKNOWN;
    nsINode* node = aLoadInfo->LoadingNode();
    if (!node) {
        return false;
    }
    nsIDocument* doc = node->OwnerDoc();
    if (!doc) {
        return false;
    }

    nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = doc->GetDocShell();
    if (!docShellTreeItem) {
        return false;
    }

    nsCOMPtr<nsIDocShellTreeItem> root;
    docShellTreeItem->GetRootTreeItem(getter_AddRefs(root));
    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(root));
    if (!docShell || NS_FAILED(docShell->GetAppType(&appType))) {
        appType = nsIDocShell::APP_TYPE_UNKNOWN;
    }

    return appType == nsIDocShell::APP_TYPE_EDITOR;
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:37,代码来源:nsContentSecurityManager.cpp

示例13: urlString

NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType,
                                               const char *aFileName,
                                               const char *aUrl,
                                               const char *aMessageUri,
                                               nsISupports *aDisplayConsumer,
                                               nsIMsgWindow *aMsgWindow,
                                               nsIUrlListener *aUrlListener)
{
  nsCOMPtr <nsIURI> URL;
  nsCAutoString urlString(aUrl);
  urlString += "&type=";
  urlString += aContentType;
  urlString += "&filename=";
  urlString += aFileName;
  CreateStartupUrl(urlString.get(), getter_AddRefs(URL));
  nsresult rv;

  nsCOMPtr<nsIMsgMailNewsUrl> mailboxUrl(do_QueryInterface(URL, &rv));
  if (NS_SUCCEEDED(rv) && mailboxUrl)
    mailboxUrl->SetMsgWindow(aMsgWindow);

  // try to run the url in the docshell...
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
  // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
  if (NS_SUCCEEDED(rv) && docShell)
  {
    nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
    // DIRTY LITTLE HACK --> since we are opening an attachment we want the docshell to
    // treat this load as if it were a user click event. Then the dispatching stuff will be much
    // happier.
    docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
    loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
    return docShell->LoadURI(URL, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);
  }
  return RunMailboxUrl(URL, aDisplayConsumer);

}
开发者ID:mikeconley,项目名称:comm-central,代码行数:37,代码来源:nsMailboxService.cpp

示例14: docShell

NS_IMETHODIMP nsMsgWindow::GetMessageWindowDocShell(nsIDocShell ** aDocShell)
{
  *aDocShell = nullptr;
  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mMessageWindowDocShellWeak));
  if (!docShell)
  {
    // if we don't have a docshell, then we need to look up the message pane docshell
    nsCOMPtr<nsIDocShell> rootShell(do_QueryReferent(mRootDocShellWeak));
    if (rootShell)
    {
      nsCOMPtr<nsIDocShellTreeItem> msgDocShellItem;
      if(rootShell)
         rootShell->FindChildWithName(MOZ_UTF16("messagepane"),
                                      true, false, nullptr, nullptr,
                                      getter_AddRefs(msgDocShellItem));
      NS_ENSURE_TRUE(msgDocShellItem, NS_ERROR_FAILURE);
      docShell = do_QueryInterface(msgDocShellItem);
      // we don't own mMessageWindowDocShell so don't try to keep a reference to it!
      mMessageWindowDocShellWeak = do_GetWeakReference(docShell);
    }
  }
  docShell.swap(*aDocShell);
  return NS_OK;
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:24,代码来源:nsMsgWindow.cpp

示例15: docShell

NS_IMETHODIMP
nsLocation::SetHref(const nsAString& aHref)
{
  nsAutoString oldHref;
  nsresult rv = NS_OK;

  JSContext *cx = nsContentUtils::GetCurrentJSContext();

  // According to HTML5 spec, |location.href = ...| must act as if
  // it were |location.replace(...)| before the page load finishes.
  //
  // http://www.w3.org/TR/2011/WD-html5-20110113/history.html#location
  //
  // > The href attribute must return the current address of the
  // > associated Document object, as an absolute URL.
  // >
  // > On setting, if the Location object's associated Document
  // > object has completely loaded, then the user agent must act
  // > as if the assign() method had been called with the new value
  // > as its argument. Otherwise, the user agent must act as if
  // > the replace() method had been called with the new value as its
  // > argument.
  //
  // Note: The spec says the condition is "Document object has completely
  //       loaded", but that may break some websites. If the user was
  //       willing to move from one page to another, and was able to do
  //       so, we should not overwrite the session history entry even
  //       if the loading has not finished yet.
  //
  //       https://www.w3.org/Bugs/Public/show_bug.cgi?id=17041 
  //
  // See bug 39938, bug 72197, bug 178729 and bug 754029.
  // About other browsers:
  // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-July/027372.html

  bool replace = false;
  if (!nsEventStateManager::IsHandlingUserInput()) {
    // "completely loaded" is defined at:
    //
    // http://www.w3.org/TR/2012/WD-html5-20120329/the-end.html#completely-loaded
    //
    // > 7.  document readiness to "complete", and fire "load".
    // >
    // > 8.  "pageshow"
    // >
    // > 9.  ApplicationCache
    // >
    // > 10. Print in the pending list.
    // >
    // > 12. Queue a task to mark the Document as completely loaded.
    //
    // Since Gecko doesn't (yet) have a flag corresponding to no. "12.
    // ... completely loaded", here the logic is a little tricky.

    nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
    nsCOMPtr<nsIDocument> document(do_GetInterface(docShell));
    if (document) {
      replace =
        nsIDocument::READYSTATE_COMPLETE != document->GetReadyStateEnum();

      // nsIDocShell::isExecutingOnLoadHandler is true while
      // the document is handling "load", "pageshow",
      // "readystatechange" for "complete" and "beforeprint"/"afterprint".
      //
      // Maybe this API property needs a better name.
      if (!replace) {
        docShell->GetIsExecutingOnLoadHandler(&replace);
      }
    }
  }

  if (cx) {
    rv = SetHrefWithContext(cx, aHref, replace);
  } else {
    rv = GetHref(oldHref);

    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIURI> oldUri;

      rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);

      if (oldUri) {
        rv = SetHrefWithBase(aHref, oldUri, replace);
      }
    }
  }

  return rv;
}
开发者ID:KWierso,项目名称:releases-mozilla-central,代码行数:89,代码来源:nsLocation.cpp


注:本文中的docShell函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。