コード例 #1
0
/* FE should call XP_FindNamedAnchor before getting a URL 
 * that is going into an HTML window (output_format is FO_CACHE_AND_PRESENT
 *
 * if named anchor is found:
 * XP_FindNamedAnchor 
 *					- updates context history, and global history properly
 * if it is not found, we do not touch any arguments
 *
 * Usage:
 * In your GetURL routine
 * if (XP_FindNamedAnchor(context, url, &x, &y))
 *  {
 * 		SetDocPosition(x,y);
 *		if (url->history_num == 0)	// if you are not handling go back this way, do not do this
 *			SHIST_AddDocument( &fContext, SHIST_CreateHistoryEntry( url, he->title) );
 *		else
 *			SHIST_SetCurrent(&fContext->hist, url->history_num);
 *      SetURLTextField(url->address);
 *      SetURLTextFieldTitle( ... url->is_netsite ... );
 *		NET_FreeURLStruct(url);
 *      RegenerateHistoryMenuAndDialogBoxContents()
 *  }
 * else
 *		NET_GetURL
 */
Bool XP_FindNamedAnchor(MWContext * context, URL_Struct * url, 
							int32 *xpos, int32 *ypos)
{
	History_entry *he;
	
	if (!context)
		return FALSE;

	he = SHIST_GetCurrent (&context->hist);
	
	if (he
		&& he->address
		&& url
		&& url->address
		&& XP_STRCHR(url->address, '#') /* it must have a named hash */
		&& url->method == URL_GET_METHOD
		&& url->force_reload == NET_DONT_RELOAD
		&& LO_LocateNamedAnchor(context, url, xpos, ypos))
	{
		GH_UpdateGlobalHistory( url );
		/* don't do this - jwz. */
		/* NET_FreeURLStruct( url ); */
		return TRUE;
	}
	return FALSE;	
}
コード例 #2
0
static const char *
get_url_string(JSContext *cx, JSObject *obj)
{
    JSURL *url;
    MochaDecoder *decoder;
    MWContext *context;
    History_entry *he;
    const char *url_string;

    url = JS_GetInstancePrivate(cx, obj, &lm_location_class, NULL);
    if (!url)
	return NULL;
    decoder = url->url_decoder;

    context = decoder->window_context;
    if (!context)
	return NULL;
    he = SHIST_GetCurrent(&context->hist);
    if (he) {
	url_string = he->address;
	if (NET_URL_Type(url_string) == WYSIWYG_TYPE_URL &&
	    !(url_string = LM_SkipWysiwygURLPrefix(url_string))) {
	    url_string = he->address;
        }
        return url_string;
    }
    return NULL;
}
コード例 #3
0
ファイル: nsfont.cpp プロジェクト: vicamo/b2g_mozilla-central
// this function allocate space, the destructor for m_pRenderableFont,
// need to free the space.
int	CyaFont::CreateNetscapeFontWithFMI(
	MWContext *pContext,
	HDC hDC, struct nffmi *pWantedFmi, double fontHeight )
{
	struct nff      *genericFontHandle;

	if( m_pRenderableFont != NULL )
        nfrf_release( m_pRenderableFont, NULL);
    m_pRenderableFont = NULL;
	
	if( UpdateDisplayRC( hDC ) ) 
		return(1);			// error

  	// Create a FMI for the font of interest 
    // Not really used by Displayer, because it has hardcoded the font and don't do any matching.
	
	if (pWantedFmi == NULL)
		return( FONTERR_CreateFontMatchInfoFailed );
	
	/* Find the url that is loading this font */
    const char *accessing_url_str = NULL;
	if( pContext ) {
		History_entry *he = SHIST_GetCurrent(&(pContext->hist));
		if( he )
			accessing_url_str = he->address;
	}

	// Look for a font 
	genericFontHandle = nffbc_LookupFont(
		   theGlobalNSFont.getFontBrokerConsumerInterface(), 
		   m_displayRC,
		   pWantedFmi,
		   accessing_url_str, /* XXX GetContext()->url */
		   NULL /* exception */);

	if (genericFontHandle == NULL) {
		// failed
		theGlobalNSFont.LookupFailed( pContext, m_displayRC, pWantedFmi);
		return( FONTERR_nffbc_LookupFontFailed );

	}

	if( fontHeight < 0 )
		fontHeight = - fontHeight;		// webfont use positive size, see winfp.cpp

	/* Create a rendering font */
	m_pRenderableFont = nff_GetRenderableFont( genericFontHandle, m_displayRC, fontHeight, NULL /* exception */);
	
    // clean up 
    nff_release( genericFontHandle , NULL );


    return( FONTERR_OK );
}   // int	CyaFont::CreateNetscapeFontWithFMI( HDC hDC )
コード例 #4
0
void
lm_ReplaceURL(MWContext *context, URL_Struct *url_struct)
{
    History_entry *he;

    he = SHIST_GetCurrent(&context->hist);
    if (!he)
	return;
    he->history_num = SHIST_GetIndex(&context->hist, he);
    he->replace = TRUE;
    url_struct->history_num = he->history_num;
}
コード例 #5
0
ファイル: cfe.cpp プロジェクト: vicamo/b2g_mozilla-central
void CFE_FinishedLayout(MWContext *pContext)	{
	if(ABSTRACTCX(pContext)->IsDestroyed())	{
		//	Don't allow this to happen if the context has been destroyed...
		TRACE("Context %p Destroyed :: FinishedLayout Blocking\n", pContext);
		return;
	}

	//	Let the image library no that the page is no longer loading.
//	IL_EndPage(pContext);
    ABSTRACTCX(pContext)->FinishedLayout(pContext);

	//	See if the history title has been set yet.
	History_entry *pHist = SHIST_GetCurrent(&(pContext->hist));

    // Message compose window title is set by msglib. We don't want to overwrite
    // it here. - kamal
	if (pHist != NULL && pHist->title == NULL && 
	   ( pContext->type == MWContextBrowser || pContext->type == MWContextEditor || pContext->type == MWContextPane) )	{
		//	Make the URL the window title if there was none supplied.
        //  unless its a new document -- leave that one blank
		if(pContext->title == NULL)	{
#ifdef EDITOR
            if ( EDT_IS_EDITOR( pContext ) && 
                 _stricmp(pHist->address, EDT_NEW_DOC_NAME) != 0 ){
                // Let CWinCX::SetDocTitle() do name condensing for display,
                //  so editor can detect cases where Title = Address
    			FE_SetDocTitle(pContext, pHist->address);
                return;
            }
#endif //EDITOR
			CString csTitle = pHist->address;
			WFE_CondenseURL(csTitle, 50, FALSE);
			FE_SetDocTitle(pContext, (char *)(const char *)csTitle);
		}
	}
}
コード例 #6
0
/*
 *	Will return the lowest security status of the context
 *		and it's children.
 *	Lowest means lowest in security, not in numberic value.
 *
 *	Possible returns are:
 *	SSL_SECURITY_STATUS_NOOPT
 *	SSL_SECURITY_STATUS_OFF
 *	SSL_SECURITY_STATUS_ON_HIGH
 *	SSL_SECURITY_STATUS_ON_LOW
 */
int XP_GetSecurityStatus(MWContext *pContext)	{
	History_entry *pHistEnt;
	MWContext *pChild;
	int iRetval, iIndex;

	/*
	 *	No context, no security.
	 */
	if(pContext == NULL)	{
		return(SSL_SECURITY_STATUS_NOOPT);
	}

	/*
	 *	Obtain the context's current history entry (it holds
	 *		security info).
	 */
	pHistEnt = SHIST_GetCurrent(&(pContext->hist));
	if(pHistEnt == NULL)	{
		/*
		 *	Nothing loaded, Confusion ensues here.
		 *	If we've a parent context, then our security
		 *		is a noopt (shouldn't be counted towards
		 *		the whole).
		 *	If we've no parent context, then our security
		 *		is off.
		 *	This allows grids to have empty panes, but to
		 *		still be secure if all grids which have
		 *		something loaded are secure.
		 */
		if(pContext->grid_parent == NULL)	{
			return(SSL_SECURITY_STATUS_OFF);
		}
		else	{
			return(SSL_SECURITY_STATUS_NOOPT);
		}
	}

	/*
	 *	Our security status.
	 */
	iRetval = pHistEnt->security_on;

	/*
	 *	If we're a grid parent, our security status
	 *		is a noopt (doesn't affect the whole).
	 *	This allows the parent grid document to be non
	 *		secure, and all the inner grids to be secure,
	 *		and therefore the document should still be
	 *		considered secure as a whole.
	 */
	if(XP_ListIsEmpty(pContext->grid_children))	{
		return(iRetval);
	}
	iRetval = SSL_SECURITY_STATUS_NOOPT;

	/*
	 *	Go through each child, getting it's security status.
	 *	We combine them all and return that value.
	 */
	iIndex = 1;
	while((pChild = (MWContext *)XP_ListGetObjectNum(
		pContext->grid_children, iIndex++)))	{

		switch(XP_GetSecurityStatus(pChild))	{
		case SSL_SECURITY_STATUS_NOOPT:
			/*
			 *	No definable security status.  Don't
			 *		change our current value.
			 */
			break;
		case SSL_SECURITY_STATUS_OFF:
			/*
			 *	No need in continuing if we're turning
			 *		off security altogether.
			 */
			return(SSL_SECURITY_STATUS_OFF);
			break;
		case SSL_SECURITY_STATUS_ON_LOW:
			/*
			 *	Change the return value to lower security.
			 */
			iRetval = SSL_SECURITY_STATUS_ON_LOW;
			break;
		case SSL_SECURITY_STATUS_ON_HIGH:
			/*
			 *	If we're currently noopt, then we should
			 *		change the security status to HIGH.
			 *	Otherwise, don't change the cumulative status
			 *		which could be lower than HIGH.
			 */
			if(iRetval == SSL_SECURITY_STATUS_NOOPT)	{
				iRetval = SSL_SECURITY_STATUS_ON_HIGH;
			}
			break;
#ifdef FORTEZZA
		case SSL_SECURITY_STATUS_FORTEZZA:
			/*
			 * If any fortezza, set to fortezza..
			 */
			iRetval = SSL_SECURITY_STATUS_FORTEZZA;
			break;
#endif
		default:
			/*
			 *	Shouldn't be here, unless new security status
			 *		introduced.
			 */
			XP_ASSERT(0);
			break;
		}
	}

	/*
	 *	Context is somewhat secure, either high or low.
	 *	This could also be noopt, meaning no definable security,
	 *		so turn off your UI as if SSL_SECURITY_STATUS_OFF.
	 *	We can't just change the return value of
	 *		SSL_SECURITY_STATUS_NOOPT to OFF because this
	 *		breaks the recursive correctness of this routine.
	 *	Handle it accordingly.
	 */
	return(iRetval);
}
コード例 #7
0
ファイル: gendoc.cpp プロジェクト: vicamo/b2g_mozilla-central
void CGenericDoc::Serialize(CArchive& ar)
{
	TRACE("CGenericDoc::Serialize called\n");

    BOOL bCanSerialize = TRUE;
    if(ar.IsLoading())  {
#ifdef XP_WIN32
        //  Determine name of actual document.
        CFile *pFile = ar.GetFile();
        CString csFile;
        if(pFile)   {
            csFile = pFile->GetFilePath();
        }

        //  Determine if this is the same file that was passed into the
        //      OnOpenDocument function.
        //  If so, then we can not read our OLE format.
        bCanSerialize = (csFile.CompareNoCase(m_csOpenDocumentFile) != 0);

        //  However, if they're both empty, then we need to allow this.
        if(csFile.IsEmpty() && m_csOpenDocumentFile.IsEmpty())  {
            bCanSerialize = TRUE;
        }
        TRACE("%d = !(%s==%s)\n", bCanSerialize, (const char *)csFile, (const char *)m_csOpenDocumentFile);
#else
        //  16 bit can not turn a file handle into a file name.
        //  If our document name is set, then say we can't serialize.
        bCanSerialize = !(m_bOpenDocumentFileSet && !m_csOpenDocumentFile.IsEmpty());
        TRACE("%d = !(%d && !%d)\n", m_bOpenDocumentFileSet, !m_csOpenDocumentFile.IsEmpty());
#endif
    }

    //  We can only serialize if we're not looking at a local file which we've opened up.
    if(bCanSerialize)   {
	    //	Fleshed out for OLE server work.
	    //	The below is the common implementation that should work across the
	    //		board for all versions of the navigator.
	    //	All it does is either read in or write out a URL.
	    if(GetContext() && GetContext()->IsDestroyed() == FALSE)	{
	        if (ar.IsStoring())
	        {
			    TRACE("Storing\n");
			    //	Just shove our current URL into the file.
			    //	Get the current history entry.
			    History_entry *pHist = SHIST_GetCurrent(&(GetContext()->GetContext()->hist));
			    if(pHist != NULL && pHist->address != NULL)	{
				    CString csAddress = pHist->address;
				    ar << csAddress;
				    TRACE("URL is %s\n", (const char *)csAddress);
			    }
			    else	{
				    TRACE("no history!\n");
				    CString csEmpty;
				    ar << csEmpty;
			    }
	        }
	        else
	        {
			    TRACE("Reading\n");

			    //	Pretty much just read this in as internet shortcut
			    //		format and load it.
			    CString csLoadMe;
			    ar >> csLoadMe;

			    //	Do it.
			    TRACE("URL is %s\n", (const char *)csLoadMe);
			    GetContext()->NormalGetUrl(csLoadMe);
	        }
	    }
	    else	{
		    TRACE("no context!\n");
	        if (ar.IsStoring())
	        {
			    TRACE("Storing\n");
			    //	Hope that ephemeral data were cached, otherwise, no real
			    //		harm done.
			    ar << m_csEphemeralHistoryAddress;
	        }
	        else
	        {
			    TRACE("Reading\n");
			    CString csDontcare;
			    ar >> csDontcare;
	        }
	    }

	    //	Next in line should be a string identifying the client which wrote
	    //		out the information.
        //  ALL NUMBERS TO BE CONVERTED TO NETWORK BYTE ORDER, SO WORKS ACROSS PLATFORMS.
	    CString csNetscapeVersion;
	    if(ar.IsStoring())	{
		    //	Write out our document version number.
		    //	This is initially 2.0
		    ar << theApp.ResolveAppVersion();
		    TRACE("App version is %s\n", (const char *)theApp.ResolveAppVersion());

		    //	Write out any other information for a particular version here,
		    //		prepended by the amount of total bytes to be written.
		    //	Hold all integer values (all XP values) to a size that will
		    //		translate between win16 and win32.
		    TRACE("Writing version specific information.\n");

            //  Figure up the size of extra info we'll be writing out.
            u_long arExtraBytes = 0;

            //  3.0 beta 6 has some extra information
            arExtraBytes += sizeof(u_long); //  extent.cx
            arExtraBytes += sizeof(u_long); //  extent.cy
            arExtraBytes += sizeof(u_long); //  extent.cx
            arExtraBytes += sizeof(u_long); //  extent.cy

		    //	For version 2.0, there was no extra information.
		    ar << htonl(arExtraBytes);

            //  Now, begin writing out extra information.

            //  3.0 beta 6
            TRACE("3.0 beta 6 and later information being written\n");
            ar << htonl((u_long)m_csViewExtent.cx);
            ar << htonl((u_long)m_csViewExtent.cy);
            TRACE("Write cx=%lu cy=%lu\n", (uint32)m_csViewExtent.cx, (uint32)m_csViewExtent.cy);
            ar << htonl((u_long)m_csDocumentExtent.cx);
            ar << htonl((u_long)m_csDocumentExtent.cy);
            TRACE("Write cx=%lu cy=%lu\n", (uint32)m_csDocumentExtent.cx, (uint32)m_csDocumentExtent.cy);
	    }
	    else	{
		    //	Read in our document version number.
		    ar >> csNetscapeVersion;
		    TRACE("App version is %s\n", (const char *)csNetscapeVersion);

		    //	Next, read in the amount of bytes that are stored.
		    u_long lBytes;
		    ar >> lBytes;
            lBytes = ntohl(lBytes);

		    if(lBytes != 0)	{
			    //	Now, depending on which version we're reading from,
			    //		figure out the information in the file if we understand
			    //		that particular version's file format.
			    //	2.0 won't understand anything, so just read in the number of
			    //		extra bytes and continue.
			    //	Let the caller of serialize handle thrown exceptions.
			    TRACE("Reading version specific information of %lu bytes.\n", lBytes);
			    char *pBuf = new char[lBytes];
			    if(pBuf == NULL)	{
				    AfxThrowMemoryException();
			    }
			    ar.Read((void *)pBuf, CASTUINT(lBytes));

                //  Use and increment this pointer appropriately to read in
                //      extra information.
                char *va_start = pBuf;

                //  If and only if there are extra bytes, decide what was written out.
                //  In 3.0 beta 6, we wrote out two uint32's first.
                u_long arVersion30b6 = 0;
                arVersion30b6 += sizeof(u_long);
                arVersion30b6 += sizeof(u_long);
                arVersion30b6 += sizeof(u_long);
                arVersion30b6 += sizeof(u_long);

                //  Read in this information, otherwise, use a default.
                if(lBytes >= arVersion30b6) {
                    TRACE("3.0 beta 6 information being retrieved\n");
                    m_csViewExtent.cx = CASTINT(ntohl(*((u_long *)va_start)));
                    va_start += sizeof(u_long);
                    m_csViewExtent.cy = CASTINT(ntohl(*((u_long *)va_start)));
                    va_start += sizeof(u_long);
                    TRACE("Read cx=%lu cy=%lu\n", (uint32)m_csViewExtent.cx, (uint32)m_csViewExtent.cy);
                    m_csDocumentExtent.cx = CASTINT(ntohl(*((u_long *)va_start)));
                    va_start += sizeof(u_long);
                    m_csDocumentExtent.cy = CASTINT(ntohl(*((u_long *)va_start)));
                    va_start += sizeof(u_long);
                    TRACE("Read cx=%lu cy=%lu\n", (uint32)m_csDocumentExtent.cx, (uint32)m_csDocumentExtent.cy);
                }
                else    {
                    TRACE("Using default 3.0 beta 6 information\n");
                    m_csViewExtent = CSize(HIX, HIY);
                    m_csDocumentExtent = CSize(HIX, HIY);
                }

                delete[] pBuf;
		    }
	    }

        //  Calling the base class CGenericDoc enables serialization
        //      of the conainer document's COleclientItem objects.
	    TRACE("Calling base serialize\n");
        COleServerDoc::Serialize(ar);
    }