/*ARGSUSED*/ _cf_finalize(struct cf* self, jint op, JMCException* *exception) { /* Release this font object from the fontObjectCache in the Broker */ cfbImpl *fbimpl = cfb2cfbImpl(WF_fbc); FontBrokerObject *fbobj = (FontBrokerObject *)fbimpl->object; WF_TRACEMSG( ("NF: Deleting font object [0x%x].", fbobj) ); fbobj->fontObjectCache.releaseFont((struct nff *)self); /* Delete the font object */ struct cfImpl *oimpl = cf2cfImpl(self); FontObject *fob = (FontObject *)oimpl->object; delete fob; /* Finally, free the memory for the object containter. */ XP_FREEIF(self); }
// // Font stream handler. // This will be called by netlib to when a stream of type FO_FONT // is available. // extern "C" NET_StreamClass* /*ARGSUSED*/ wfNewStream(FO_Present_Types format_out, void* client_data, URL_Struct* urls, MWContext* cx) { struct nffbc *fbc = (struct nffbc *) client_data; struct wf_new_stream_data *inData = (struct wf_new_stream_data *) urls->fe_data; cfbImpl *oimpl = cfb2cfbImpl(fbc); FontBrokerObject *fbobj = (FontBrokerObject *)oimpl->object; const char *mimetype = fbobj->GetMimetype(urls->content_type, urls->address); if (!mimetype || !*mimetype) { return (NULL); } WF_TRACEMSG(("NF: Looking for mimetype: %s.", mimetype)); NET_StreamClass *netStream = NULL; // Find which font Displayer implements the mimetype struct wfListElement *tmp = fbobj->fpPeers.head; for(; tmp; tmp = tmp->next) { FontDisplayerPeerObject *fpp = (FontDisplayerPeerObject *) tmp->item; if (fpp->isMimetypeEnabled(mimetype) > 0) { // Get the font Displayer stream handle WF_TRACEMSG(("NF: fppeer %s supports mimetype %s.", fpp->name(), mimetype)); struct nfstrm *fpStream = fpp->CreateFontStreamHandler(inData->rc, inData->url_of_page); if (!fpStream) { // Error. Cannot create stream from Font Displayer. // We will cycle through other Displayers to see if we can // find any other font Displayer who can service us. WF_TRACEMSG(("NF: fppeer %s cannot create fpStream. " "Continuing...", fpp->name())); fpp = NULL; continue; } // Create a libnet stream netStream = (NET_StreamClass *) WF_ALLOC(sizeof(NET_StreamClass)); if (!netStream) { // Error. No point continuing. WF_TRACEMSG(("NF: Error: Cannot create net stream. No memory.")); nfstrm_release(fpStream, NULL); break; } // Create our stream data object struct stream_data *wfStream = new stream_data; if (!wfStream) { WF_TRACEMSG(("NF: Error: No memory to allocate stream_data.")); nfstrm_release(fpStream, NULL); delete netStream; netStream = NULL; break; } // Fill our stream data wfStream->urls = urls; nffbc_addRef(fbc, NULL); wfStream->fbc = fbc; // fpstream was created here. So no need to addref it as // the creation process would already have incremented the // refcount. //nfstrm_addRef(fpStream, NULL); wfStream->fpStream = fpStream; // Tell the wffpPeer about this new stream fpp->StreamCreated(fpStream); nfdoer_addRef(inData->observer, NULL); wfStream->observer = inData->observer; nff_addRef(inData->f, NULL); wfStream->f = inData->f; wfStream->fpPeer = fpp; // Fill libnet stream netStream->name = "Font Broker"; netStream->abort = wfAbort; netStream->complete = wfComplete; netStream->put_block = (MKStreamWriteFunc)wfWrite; netStream->is_write_ready = wfWriteReady; netStream->data_object = (void *)wfStream; netStream->window_id = cx; break; } } // Cleanup our wf_new_stream_data that was passed in nfdoer_release(inData->observer, NULL); nff_release(inData->f, NULL); nfrc_release(inData->rc, NULL); if (inData->url_of_page) { delete inData->url_of_page; inData->url_of_page = NULL; } delete inData; return (netStream); }