Пример #1
0
nsresult NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aInstancePtrResult,
                                   mozilla::dom::EventTarget* aOwner,
                                   nsPresContext* aPresContext,
                                   nsEvent *aEvent,
                                   uint32_t aEventType,
                                   nsInvalidateRequestList* aInvalidateRequests) 
{
  nsDOMNotifyPaintEvent* it =
    new nsDOMNotifyPaintEvent(aOwner, aPresContext, aEvent, aEventType,
                              aInvalidateRequests);
  if (nullptr == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  return CallQueryInterface(it, aInstancePtrResult);
}
Пример #2
0
static inline void CheckExpandoObject(JSObject* proxy,
                                      const JS::Value& expando) {
#ifdef DEBUG
  JSObject* obj = &expando.toObject();
  MOZ_ASSERT(!js::gc::EdgeNeedsSweepUnbarriered(&obj));
  MOZ_ASSERT(js::GetObjectCompartment(proxy) == js::GetObjectCompartment(obj));

  // When we create an expando object in EnsureExpandoObject below, we preserve
  // the wrapper. The wrapper is released when the object is unlinked, but we
  // should never call these functions after that point.
  nsISupports* native = UnwrapDOMObject<nsISupports>(proxy);
  nsWrapperCache* cache;
  CallQueryInterface(native, &cache);
  MOZ_ASSERT(cache->PreservingWrapper());
#endif
}
Пример #3
0
nsresult
NS_NewCSSImportRule(nsICSSImportRule** aInstancePtrResult, 
                    const nsString& aURLSpec,
                    nsMediaList* aMedia)
{
  NS_ENSURE_ARG_POINTER(aInstancePtrResult);

  CSSImportRuleImpl* it = new CSSImportRuleImpl(aMedia);

  if (! it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  it->SetURLSpec(aURLSpec);
  return CallQueryInterface(it, aInstancePtrResult);
}
Пример #4
0
nsresult
nsXMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
{
  NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
               "Can't import this document into another document!");

  nsRefPtr<nsXMLDocument> clone = new nsXMLDocument();
  NS_ENSURE_TRUE(clone, NS_ERROR_OUT_OF_MEMORY);
  nsresult rv = CloneDocHelper(clone);
  NS_ENSURE_SUCCESS(rv, rv);

  // State from nsXMLDocument
  clone->mAsync = mAsync;

  return CallQueryInterface(clone.get(), aResult);
}
Пример #5
0
/* void openMenu (in boolean openFlag); */
NS_IMETHODIMP nsMenuBoxObject::OpenMenu(PRBool aOpenFlag)
{
  nsIFrame* frame = GetFrame();
  if (!frame)
    return NS_OK;

  if (!nsPopupSetFrame::MayOpenPopup(frame))
    return NS_OK;

  nsIMenuFrame* menuFrame;
  CallQueryInterface(frame, &menuFrame);
  if (!menuFrame)
    return NS_OK;

  return menuFrame->OpenMenu(aOpenFlag);
}
Пример #6
0
nsresult nsMailboxService::CopyMessages(PRUint32 aNumKeys,
                                        nsMsgKey* aMsgKeys,
                                        nsIMsgFolder *srcFolder,
                                        nsIStreamListener * aMailboxCopyHandler,
                                        bool moveMessage,
                                        nsIUrlListener * aUrlListener,
                                        nsIMsgWindow *aMsgWindow,
                                        nsIURI **aURL)
{
  nsresult rv = NS_OK;
  NS_ENSURE_ARG(srcFolder);
  NS_ENSURE_ARG(aMsgKeys);
  nsCOMPtr<nsIMailboxUrl> mailboxurl;

  nsMailboxAction actionToUse = nsIMailboxUrl::ActionMoveMessage;
  if (!moveMessage)
     actionToUse = nsIMailboxUrl::ActionCopyMessage;

  nsCOMPtr <nsIMsgDBHdr> msgHdr;
  nsCOMPtr <nsIMsgDatabase> db;
  srcFolder->GetMsgDatabase(getter_AddRefs(db));
  if (db)
  {
    db->GetMsgHdrForKey(aMsgKeys[0], getter_AddRefs(msgHdr));
    if (msgHdr)
    {
      nsCString uri;
      srcFolder->GetUriForMsg(msgHdr, uri);
      rv = PrepareMessageUrl(uri.get(), aUrlListener, actionToUse , getter_AddRefs(mailboxurl), aMsgWindow);

      if (NS_SUCCEEDED(rv))
      {
        nsCOMPtr<nsIURI> url = do_QueryInterface(mailboxurl);
        nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(url));
        nsCOMPtr<nsIMailboxUrl> mailboxUrl (do_QueryInterface(url));
        msgUrl->SetMsgWindow(aMsgWindow);

        mailboxUrl->SetMoveCopyMsgKeys(aMsgKeys, aNumKeys);
        rv = RunMailboxUrl(url, aMailboxCopyHandler);
      }
    }
  }
  if (aURL && mailboxurl)
    CallQueryInterface(mailboxurl, aURL);

  return rv;
}
already_AddRefed<nsISupports>
CanvasRenderingContextHelper::GetContext(JSContext* aCx,
                                         const nsAString& aContextId,
                                         JS::Handle<JS::Value> aContextOptions,
                                         ErrorResult& aRv)
{
  CanvasContextType contextType;
  if (!CanvasUtils::GetCanvasContextType(aContextId, &contextType))
    return nullptr;

  if (!mCurrentContext) {
    // This canvas doesn't have a context yet.
    RefPtr<nsICanvasRenderingContextInternal> context;
    context = CreateContext(contextType);
    if (!context) {
      return nullptr;
    }

    // Ensure that the context participates in CC.  Note that returning a
    // CC participant from QI doesn't addref.
    nsXPCOMCycleCollectionParticipant* cp = nullptr;
    CallQueryInterface(context, &cp);
    if (!cp) {
      aRv.Throw(NS_ERROR_FAILURE);
      return nullptr;
    }

    mCurrentContext = context.forget();
    mCurrentContextType = contextType;

    nsresult rv = UpdateContext(aCx, aContextOptions, aRv);
    if (NS_FAILED(rv)) {
      // See bug 645792 and bug 1215072.
      // We want to throw only if dictionary initialization fails,
      // so only in case aRv has been set to some error value.
      return nullptr;
    }
  } else {
    // We already have a context of some type.
    if (contextType != mCurrentContextType)
      return nullptr;
  }

  nsCOMPtr<nsICanvasRenderingContextInternal> context = mCurrentContext;
  return context.forget();
}
already_AddRefed<nsIModelElementPrivate>
nsXFormsInstanceElement::GetModel()
{
  if (!mElement)
  {
    NS_WARNING("The XTF wrapper element has been destroyed");
    return nsnull;
  }

  nsCOMPtr<nsIDOMNode> parentNode;
  mElement->GetParentNode(getter_AddRefs(parentNode));

  nsIModelElementPrivate *model = nsnull;
  if (parentNode)
    CallQueryInterface(parentNode, &model);
  return model;
}
Пример #9
0
already_AddRefed<nsIDocShellTreeItem>
nsCoreUtils::GetDocShellTreeItemFor(nsINode *aNode)
{
  if (!aNode)
    return nsnull;

  nsIDocument *doc = aNode->GetOwnerDoc();
  NS_ASSERTION(doc, "No document for node passed in");
  NS_ENSURE_TRUE(doc, nsnull);

  nsCOMPtr<nsISupports> container = doc->GetContainer();
  nsIDocShellTreeItem *docShellTreeItem = nsnull;
  if (container)
    CallQueryInterface(container, &docShellTreeItem);

  return docShellTreeItem;
}
Пример #10
0
NS_IMETHODIMP
nsFileProtocolHandler::NewFileURI(nsIFile *file, nsIURI **result)
{
    NS_ENSURE_ARG_POINTER(file);
    nsresult rv;

    nsCOMPtr<nsIFileURL> url = new nsStandardURL(true);
    if (!url)
        return NS_ERROR_OUT_OF_MEMORY;

    // NOTE: the origin charset is assigned the value of the platform
    // charset by the SetFile method.
    rv = url->SetFile(file);
    if (NS_FAILED(rv)) return rv;

    return CallQueryInterface(url, result);
}
Пример #11
0
NS_IMETHODIMP 
nsSHEnumerator::GetNext(nsISupports **aItem)
{
  NS_ENSURE_ARG_POINTER(aItem);
  PRInt32 cnt= 0;

  nsresult  result = NS_ERROR_FAILURE;
  mSHistory->GetCount(&cnt);
  if (mIndex < (cnt-1)) {
    mIndex++;
    nsCOMPtr<nsIHistoryEntry> hEntry;
    result = mSHistory->GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(hEntry));
    if (hEntry)
      result = CallQueryInterface(hEntry, aItem);
  }
  return result;
}
Пример #12
0
NS_IMETHODIMP
nsSVGPatternFrame::DidModifySVGObservable(nsISVGValue* observable, 
                                          nsISVGValue::modificationType aModType)
{
  nsIFrame *pattern = nsnull;
  CallQueryInterface(observable, &pattern);
  // Is this a pattern we are observing that is going away?
  if (mNextPattern && aModType == nsISVGValue::mod_die && pattern) {
    // Yes, we need to handle this differently
    if (mNextPattern == pattern) {
      mNextPattern = nsnull;
    }
  }
  // Something we depend on was modified -- pass it on!
  DidModify(aModType);
  return NS_OK;
}
// static
JSObject*
DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
{
    NS_ASSERTION(IsDOMProxy(obj), "expected a DOM proxy object");
    JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
    if (v.isObject()) {
        return &v.toObject();
    }

    js::ExpandoAndGeneration* expandoAndGeneration;
    if (!v.isUndefined()) {
        expandoAndGeneration = static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
        if (expandoAndGeneration->expando.isObject()) {
            return &expandoAndGeneration->expando.toObject();
        }
    } else {
        expandoAndGeneration = nullptr;
    }

    JS::Rooted<JSObject*> expando(cx,
                                  JS_NewObjectWithGivenProto(cx, nullptr, nullptr, js::GetObjectParent(obj)));
    if (!expando) {
        return nullptr;
    }

    nsISupports* native = UnwrapDOMObject<nsISupports>(obj);
    nsWrapperCache* cache;
    CallQueryInterface(native, &cache);
    if (expandoAndGeneration) {
        cache->PreserveWrapper(native);
        expandoAndGeneration->expando.setObject(*expando);

        return expando;
    }

    XPCWrappedNativeScope* scope = xpc::GetObjectScope(obj);
    if (!scope->RegisterDOMExpandoObject(obj)) {
        return nullptr;
    }

    cache->SetPreservingWrapper(true);
    js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));

    return expando;
}
Пример #14
0
NS_IMETHODIMP
nsPopupSetFrame::DestroyPopup(nsIFrame* aPopup, PRBool aDestroyEntireChain)
{
  if (!mPopupList)
    return NS_OK; // No active popups

  nsPopupFrameList* entry = mPopupList->GetEntryByFrame(aPopup);

  if (entry && entry->mCreateHandlerSucceeded) {    // ensure the popup was created before we try to destroy it
    nsWeakFrame weakFrame(this);
    OpenPopup(entry, PR_FALSE);
    nsCOMPtr<nsIContent> popupContent = entry->mPopupContent;
    if (weakFrame.IsAlive()) {
      if (aDestroyEntireChain && entry->mElementContent && entry->mPopupType.EqualsLiteral("context")) {
        // If we are a context menu, and if we are attached to a
        // menupopup, then destroying us should also dismiss the parent
        // menu popup.
        if (entry->mElementContent->Tag() == nsXULAtoms::menupopup) {
          nsIFrame* popupFrame = nsnull;
          mPresContext->PresShell()->GetPrimaryFrameFor(entry->mElementContent,
                                                        &popupFrame);
          if (popupFrame) {
            nsIMenuParent *menuParent;
            if (NS_SUCCEEDED(CallQueryInterface(popupFrame, &menuParent))) {
              menuParent->DismissChain();
            }
          }
        }
      }
  
      // clear things out for next time
      entry->mPopupType.Truncate();
      entry->mCreateHandlerSucceeded = PR_FALSE;
      entry->mElementContent = nsnull;
      entry->mXPos = entry->mYPos = 0;
      entry->mLastPref.width = -1;
      entry->mLastPref.height = -1;
    }

    // ungenerate the popup.
    popupContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, PR_TRUE);
  }

  return NS_OK;
}
NS_IMETHODIMP
sbDirectoryProvider::GetFile(const char *aProp,
                             PRBool *aPersistent,
                             nsIFile **_retval)
{
  NS_ENSURE_ARG(aProp);
  NS_ENSURE_ARG_POINTER(aPersistent);
  NS_ENSURE_ARG_POINTER(_retval);

  nsCOMPtr<nsILocalFile> localFile;
  nsresult rv = NS_ERROR_FAILURE;

  *_retval = nsnull;
  *aPersistent = PR_TRUE;

#if defined (XP_WIN)
  if (strcmp(aProp, NS_WIN_COMMON_DOCUMENTS) == 0)
    rv = GetWindowsFolder(CSIDL_COMMON_DOCUMENTS, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_COMMON_PICTURES) == 0)
    rv = GetWindowsFolder(CSIDL_COMMON_PICTURES, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_COMMON_MUSIC) == 0)
    rv = GetWindowsFolder(CSIDL_COMMON_MUSIC, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_COMMON_VIDEO) == 0)
    rv = GetWindowsFolder(CSIDL_COMMON_VIDEO, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_DOCUMENTS) == 0)
    rv = GetWindowsFolder(CSIDL_MYDOCUMENTS, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_PICTURES) == 0)
    rv = GetWindowsFolder(CSIDL_MYPICTURES, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_MUSIC) == 0)
    rv = GetWindowsFolder(CSIDL_MYMUSIC, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_VIDEO) == 0)
    rv = GetWindowsFolder(CSIDL_MYVIDEO, getter_AddRefs(localFile));
  else if (strcmp(aProp, NS_WIN_DISCBURNING) == 0)
    rv = GetWindowsFolder(CSIDL_CDBURN_AREA, getter_AddRefs(localFile));
#endif // XP_WIN

  if (NS_SUCCEEDED(rv)) {
    if (localFile)
      rv = CallQueryInterface(localFile, _retval);
    else
      rv = NS_ERROR_FAILURE;
  }

  return rv;
}
Пример #16
0
nsresult
WSPProxy::WrapInPropertyBag(nsISupports* aInstance,
                            nsIInterfaceInfo* aInterfaceInfo,
                            nsIPropertyBag** aPropertyBag)
{
  *aPropertyBag = nsnull;
  nsresult rv;
  nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper =
    do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }
  rv = wrapper->Init(aInstance, aInterfaceInfo);
  if (NS_FAILED(rv)) {
    return rv;
  }
  return CallQueryInterface(wrapper, aPropertyBag);
}
Пример #17
0
nsresult
NS_NewCSSNameSpaceRule(nsICSSNameSpaceRule** aInstancePtrResult, 
                       nsIAtom* aPrefix, const nsString& aURLSpec)
{
  if (! aInstancePtrResult) {
    return NS_ERROR_NULL_POINTER;
  }

  CSSNameSpaceRuleImpl* it = new CSSNameSpaceRuleImpl();

  if (! it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  it->SetPrefix(aPrefix);
  it->SetURLSpec(aURLSpec);
  return CallQueryInterface(it, aInstancePtrResult);
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::GetSelectedMediaItems(nsISimpleEnumerator * *aSelectedMediaItems)
{
  NS_ENSURE_ARG_POINTER(aSelectedMediaItems);
  nsresult rv;
  
  // just create an indexed enumerator and wrap it; this makes sure we reuse
  // the code and the two enumerator implementations are kept in sync.
  nsCOMPtr<nsISimpleEnumerator> indexedEnumerator;
  rv = GetSelectedIndexedMediaItems(getter_AddRefs(indexedEnumerator));
  NS_ENSURE_SUCCESS(rv, rv);
  
  nsRefPtr<sbIndexedToUnindexedMediaItemEnumerator> unwrapper =
    new sbIndexedToUnindexedMediaItemEnumerator(indexedEnumerator);
  NS_ENSURE_TRUE(unwrapper, NS_ERROR_OUT_OF_MEMORY);
  
  return CallQueryInterface(unwrapper.get(), aSelectedMediaItems);
}
nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
                     nsIDocument* aDoc,
                     nsIURI* aURI,
                     nsISupports* aContainer)
{
  NS_ENSURE_ARG_POINTER(aResult);

  nsXBLContentSink* it;
  NS_NEWXPCOM(it, nsXBLContentSink);
  NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);

  nsCOMPtr<nsIXMLContentSink> kungFuDeathGrip = it;
  nsresult rv = it->Init(aDoc, aURI, aContainer);
  NS_ENSURE_SUCCESS(rv, rv);

  return CallQueryInterface(it, aResult);
}
Пример #20
0
/*static*/ nsresult
ImageEncoder::GetInputStream(int32_t aWidth,
                             int32_t aHeight,
                             uint8_t* aImageBuffer,
                             int32_t aFormat,
                             imgIEncoder* aEncoder,
                             const char16_t* aEncoderOptions,
                             nsIInputStream** aStream)
{
  nsresult rv =
    aEncoder->InitFromData(aImageBuffer,
                           aWidth * aHeight * 4, aWidth, aHeight, aWidth * 4,
                           aFormat,
                           nsDependentString(aEncoderOptions));
  NS_ENSURE_SUCCESS(rv, rv);

  return CallQueryInterface(aEncoder, aStream);
}
NS_IMETHODIMP
sbTemporaryMediaItem::GetPropertyIDs(nsIStringEnumerator** aPropertyIDs)
{
  // Validate arguments.
  NS_ENSURE_ARG_POINTER(aPropertyIDs);

  // Function variables.
  nsresult rv;

  // Create an empty property ID enumerator.
  nsCOMPtr<nsISimpleEnumerator> propertyIDs;
  rv = NS_NewEmptyEnumerator(getter_AddRefs(propertyIDs));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = CallQueryInterface(propertyIDs, aPropertyIDs);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Пример #22
0
NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult)
{
  *aResult = nsnull;

  nsIFrame *frame = GetFrame(false);

  if (frame) {
    nsSubDocumentFrame *subDocFrame = do_QueryFrame(frame);
    if (subDocFrame) {
      // Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
      // to reach the docshell, so ask it...

      return subDocFrame->GetDocShell(aResult);
    }
  }

  if (!mContent) {
    return NS_OK;
  }
  
  // No nsSubDocumentFrame available for mContent, try if there's a mapping
  // between mContent's document to mContent's subdocument.

  // XXXbz sXBL/XBL2 issue -- ownerDocument or currentDocument?
  nsIDocument *doc = mContent->GetDocument();

  if (!doc) {
    return NS_OK;
  }
  
  nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);

  if (!sub_doc) {
    return NS_OK;
  }

  nsCOMPtr<nsISupports> container = sub_doc->GetContainer();

  if (!container) {
    return NS_OK;
  }

  return CallQueryInterface(container, aResult);
}
/*virtual*/ nsresult 
sbGStreamerMediacoreFactory::OnCreate(const nsAString &aInstanceName, 
                                    sbIMediacore **_retval)
{
  nsRefPtr<sbGStreamerMediacore> mediacore;
  NS_NEWXPCOM(mediacore, sbGStreamerMediacore);
  NS_ENSURE_TRUE(mediacore, NS_ERROR_OUT_OF_MEMORY);

  nsresult rv = mediacore->Init();
  NS_ENSURE_SUCCESS(rv, rv);

  rv = mediacore->SetInstanceName(aInstanceName);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = CallQueryInterface(mediacore.get(), _retval);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Пример #24
0
NS_IMETHODIMP
nsPopupSetFrame::Init(nsPresContext*  aPresContext,
                     nsIContent*      aContent,
                     nsIFrame*        aParent,
                     nsStyleContext*  aContext,
                     nsIFrame*        aPrevInFlow)
{
  mPresContext = aPresContext; // Don't addref it.  Our lifetime is shorter.
  nsresult  rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);

  nsIRootBox *rootBox;
  nsresult res = CallQueryInterface(aParent->GetParent(), &rootBox);
  NS_ASSERTION(NS_SUCCEEDED(res), "grandparent should be root box");
  if (NS_SUCCEEDED(res)) {
    rootBox->SetPopupSetFrame(this);
  }

  return rv;
}
Пример #25
0
NS_IMETHODIMP
nsWindowMediator::GetZOrderXULWindowEnumerator(
            const PRUnichar *aWindowType, PRBool aFrontToBack,
            nsISimpleEnumerator **_retval)
{
  if (!_retval)
    return NS_ERROR_INVALID_ARG;

  nsAutoLock lock(mListLock);
  nsAppShellWindowEnumerator *enumerator;
  if (aFrontToBack)
    enumerator = new nsASXULWindowFrontToBackEnumerator(aWindowType, *this);
  else
    enumerator = new nsASXULWindowBackToFrontEnumerator(aWindowType, *this);
  if (enumerator)
    return CallQueryInterface(enumerator, _retval);

  return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsHTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
{
  NS_ENSURE_ARG_POINTER(aContentDocument);

  *aContentDocument = nsnull;

  if (!IsInDoc()) {
    return NS_OK;
  }

  // XXXbz should this use GetCurrentDoc()?  sXBL/XBL2 issue!
  nsIDocument *sub_doc = GetOwnerDoc()->GetSubDocumentFor(this);
  if (!sub_doc) {
    return NS_OK;
  }

  return CallQueryInterface(sub_doc, aContentDocument);
}
Пример #27
0
already_AddRefed<nsIDOMNode>
nsCoreUtils::GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer)
{
  nsCOMPtr<nsIDocShell> shell = do_QueryInterface(aContainer);

  nsCOMPtr<nsIContentViewer> cv;
  shell->GetContentViewer(getter_AddRefs(cv));

  if (!cv)
    return nsnull;

  nsIDocument* doc = cv->GetDocument();
  if (!doc)
    return nsnull;

  nsIDOMNode* node = nsnull;
  CallQueryInterface(doc, &node);
  return node;
}
Пример #28
0
NS_IMETHODIMP nsAbLDAPDirectory::GetLDAPURL(nsILDAPURL** aResult)
{
    NS_ENSURE_ARG_POINTER(aResult);

    // Rather than using GetURI here we call GetStringValue directly so
    // we can handle the case where the URI isn't specified (see comments
    // below)
    nsCAutoString URI;
    nsresult rv = GetStringValue("uri", EmptyCString(), URI);
    if (NS_FAILED(rv) || URI.IsEmpty())
    {
        /*
         * A recent change in Mozilla now means that the LDAP Address Book
         * RDF Resource URI is based on the unique preference name value i.e.
         * [moz-abldapdirectory://prefName]
         * Prior to this valid change it was based on the actual uri i.e.
         * [moz-abldapdirectory://host:port/basedn]
         * Basing the resource on the prefName allows these attributes to
         * change.
         *
         * But the uri value was also the means by which third-party
         * products could integrate with Mozilla's LDAP Address Books
         * without necessarily having an entry in the preferences file
         * or more importantly needing to be able to change the
         * preferences entries. Thus to set the URI Spec now, it is
         * only necessary to read the uri pref entry, while in the
         * case where it is not a preference, we need to replace the
         * "moz-abldapdirectory".
         */
        URI = mURINoQuery;
        if (StringBeginsWith(URI, NS_LITERAL_CSTRING(kLDAPDirectoryRoot)))
            URI.Replace(0, kLDAPDirectoryRootLen, NS_LITERAL_CSTRING("ldap://"));
    }

    nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIURI> result;
    rv = ioService->NewURI(URI, nsnull, nsnull, getter_AddRefs(result));
    NS_ENSURE_SUCCESS(rv, rv);

    return CallQueryInterface(result, aResult);
}
NS_IMETHODIMP
nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
    NS_ENSURE_ARG_POINTER(aContentDocument);

    *aContentDocument = nsnull;

    if (!mDocument) {
        return NS_OK;
    }

    nsIDocument *sub_doc = mDocument->GetSubDocumentFor(this);

    if (!sub_doc) {
        return NS_OK;
    }

    return CallQueryInterface(sub_doc, aContentDocument);
}
Пример #30
0
/* static */ void
nsMathMLFrame::GetEmbellishDataFrom(nsIFrame*        aFrame,
                                    nsEmbellishData& aEmbellishData)
{
  // initialize OUT params
  aEmbellishData.flags = 0;
  aEmbellishData.coreFrame = nsnull;
  aEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
  aEmbellishData.leftSpace = 0;
  aEmbellishData.rightSpace = 0;

  if (aFrame && aFrame->IsFrameOfType(nsIFrame::eMathML)) {
    nsIMathMLFrame* mathMLFrame;
    CallQueryInterface(aFrame, &mathMLFrame);
    if (mathMLFrame) {
      mathMLFrame->GetEmbellishData(aEmbellishData);
    }
  }
}