void wfComplete(NET_StreamClass *stream) { struct stream_data *data = (struct stream_data *) stream->data_object; void *fh = nfstrm_Complete((nfstrm *)data->fpStream, NULL); cfImpl *oimpl = cf2cfImpl(data->f); FontObject *fob = (FontObject *)oimpl->object; if (fh) { // Include this fh in the correct FontObject fob->addFontHandle(data->fpPeer, fh); WF_TRACEMSG( ("NF: Stream done. Fonthandle created. Setting font state to COMPLETE.") ); fob->setState(NF_FONT_COMPLETE); } else { // This font will never become ok as the fonthandle // that we got was 0. We will assume that the data // that we streamed didn't make a valid font. WF_TRACEMSG( ("NF: Stream done. Fonthandle NOT CREATED. Setting font state to ERROR.") ); fob->setState(NF_FONT_ERROR); } // Notify the nfdoer on the status of Complete wf_NotifyObserver(data); wf_ReleaseStreamData(data); return; }
int FontDisplayerPeerObject::load(void) { // Check for generic preconditions if (deleted || disabled) { return (0); } if (fontDisplayer || fpType == FontDisplayerPeerObject::WF_FP_STATIC) { return (0); } dlm.load(); if (dlm.status() < 0) { return (-1); } fontDisplayer = dlm.createDisplayerObject(WF_fbp); if (!fontDisplayer) { WF_TRACEMSG(("NF: dlm (%s) Couldn't create fontdisplayer object. Skipping dlm.", dlm.filename())); dlm.unload(); return (-1); } return (0); }
int wfFontObjectCache::releaseRf(struct nfrf *rf) { #ifdef DEBUG WF_TRACEMSG( ("NF: Deleting rf (0x%x).", rf) ); #endif /* DEBUG */ struct wfListElement *tmp = head; int nrelease = 0; while(tmp) { struct font_store *ele = (struct font_store *) tmp->item; // We know that this Font object was created by us. So we can // snoop into its implementation to call implementation specific // methods. cfImpl *oimpl = cf2cfImpl(ele->f); FontObject *fob = (FontObject *)oimpl->object; // // WARNING: Before calling FontObject::releaseRf we need to get the // next item in the list. This is because the FontObject could turn // around and decide to remove itself from our list. // tmp = tmp->next; int n = fob->releaseRf(rf); if (n) { // Run the garbage collector since some rf was released. This // could even cause the font object to be deleted. if (!fob->GC()) { struct nff *f_to_delete = (struct nff *) ele->f; // Delete the FontObject. Deleting the FontObject will turn // around and delete the element in the fontObjectCache list // by calling FontObjectCache::releaseFont(). // // So DONT REMOVE THE ELEMENT. It will be removed. // wfList::remove(ele); nff_addRef(f_to_delete, NULL); nff_release(f_to_delete, NULL); } } nrelease += n; } if (nrelease) { // Some font had this rf. It is not possbile then for the same rf // exist with webfonts. Skip looking into the webfonts. return(nrelease); } return (nrelease); }
extern "C" void /*ARGSUSED*/ wfUrlExit(URL_Struct *urls, int status, MWContext *cx) { if (status < 0 && urls->error_msg) { WF_TRACEMSG (("NF: Font downloading unsuccessful : %s.", urls->error_msg)); } if (status != MK_CHANGING_CONTEXT) { NET_FreeURLStruct (urls); } }
/*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); }
FontMatchInfoObject:: FontMatchInfoObject(const char *iname, const char *icharset, const char *iencoding, jint iweight, jint ipitch, jint istyle, jint iunderline, jint istrikeOut, jint resX, jint resY) : wfList(free_fmi_attr_store), stringRepresentation(NULL), stringLen(0), stringMaxLen(0) { addAttribute(nfFmiName, iname); addAttribute(nfFmiCharset, icharset); addAttribute(nfFmiEncoding, iencoding); addAttribute(nfFmiWeight, iweight); addAttribute(nfFmiPitch, ipitch); addAttribute(nfFmiStyle, istyle); addAttribute(nfFmiUnderline, iunderline); addAttribute(nfFmiStrikeOut, istrikeOut); addAttribute(nfFmiResolutionX, resX); addAttribute(nfFmiResolutionY, resY); WF_TRACEMSG( ("NF: Created fmi (%s).", describe()) ); }
// // This gets called when a font object is going away. // Remove all references to the font object in our font object cache. int wfFontObjectCache::releaseFont(struct nff *f) { // The caller can specify either fmi or f struct wfListElement *tmp; wfList::ERROR_CODE err; int ret = 0; if (!f) { return (0); } tmp = head; while (tmp) { struct font_store *ele = (struct font_store *) tmp->item; // This could cause the element to be deleted. So move to the next // element before proceeding with the delete. tmp=tmp->next; if (f == ele->f) { WF_TRACEMSG( ("NF: Removing font (0x%x) created for fmi (%s).", this, nffmi_toString(ele->fmi, NULL)) ); err = wfList::remove(ele); if (err != wfList::SUCCESS) { // Remove of this failed. Fail the overall remove. ret += -1; } } } return (ret); }
// // 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); }
FontMatchInfoObject:: ~FontMatchInfoObject() { WF_TRACEMSG( ("NF: Destroying fmi (%s).", describe()) ); releaseStringRepresentation(); }