mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 512566. Changes based on review comments. r=bz,jfkthame
This commit is contained in:
parent
a068d45dbb
commit
f6d4d913cf
@ -462,6 +462,7 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
|
||||
// download successful, make platform font using font data
|
||||
if (NS_SUCCEEDED(aDownloadStatus)) {
|
||||
gfxFontEntry *fe = LoadFont(aProxy, aFontData, aLength);
|
||||
aFontData = nsnull;
|
||||
|
||||
if (fe) {
|
||||
IncrementGeneration();
|
||||
@ -546,11 +547,10 @@ gfxUserFontSet::LoadNext(gfxProxyFontEntry *aProxyEntry)
|
||||
nsresult rv;
|
||||
bool loadDoesntSpin = false;
|
||||
rv = NS_URIChainHasFlags(currSrc.mURI,
|
||||
nsIProtocolHandler::URI_SYNC_LOAD_DOESNT_SPIN_EVENT_LOOP,
|
||||
nsIProtocolHandler::URI_SYNC_LOAD_IS_OK,
|
||||
&loadDoesntSpin);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && loadDoesntSpin)
|
||||
{
|
||||
if (NS_SUCCEEDED(rv) && loadDoesntSpin) {
|
||||
PRUint8 *buffer = nsnull;
|
||||
PRUint32 bufferLength = 0;
|
||||
|
||||
@ -558,9 +558,8 @@ gfxUserFontSet::LoadNext(gfxProxyFontEntry *aProxyEntry)
|
||||
rv = SyncLoadFontData(aProxyEntry, &currSrc, buffer,
|
||||
bufferLength);
|
||||
|
||||
const PRUint8 *buf2 = buffer;
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
LoadFont(aProxyEntry, buf2, bufferLength)) {
|
||||
LoadFont(aProxyEntry, buffer, bufferLength)) {
|
||||
return STATUS_LOADED;
|
||||
} else {
|
||||
LogMessage(aProxyEntry, "font load failed",
|
||||
@ -624,7 +623,7 @@ gfxUserFontSet::IncrementGeneration()
|
||||
|
||||
gfxFontEntry*
|
||||
gfxUserFontSet::LoadFont(gfxProxyFontEntry *aProxy,
|
||||
const PRUint8* &aFontData, PRUint32 &aLength)
|
||||
const PRUint8 *aFontData, PRUint32 &aLength)
|
||||
{
|
||||
gfxFontEntry *fe = nsnull;
|
||||
|
||||
@ -731,9 +730,7 @@ gfxUserFontSet::LoadFont(gfxProxyFontEntry *aProxy,
|
||||
}
|
||||
#endif
|
||||
ReplaceFontEntry(aProxy, fe);
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (LOG_ENABLED()) {
|
||||
nsCAutoString fontURI;
|
||||
@ -744,7 +741,6 @@ gfxUserFontSet::LoadFont(gfxProxyFontEntry *aProxy,
|
||||
NS_ConvertUTF16toUTF8(aProxy->mFamily->Name()).get()));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return fe;
|
||||
|
@ -272,7 +272,7 @@ protected:
|
||||
// Ownership of aFontData is passed in here; the font set must
|
||||
// ensure that it is eventually deleted with NS_Free().
|
||||
gfxFontEntry* LoadFont(gfxProxyFontEntry *aProxy,
|
||||
const PRUint8* &aFontData, PRUint32 &aLength);
|
||||
const PRUint8 *aFontData, PRUint32 &aLength);
|
||||
|
||||
// parse data for a data URL
|
||||
virtual nsresult SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
|
||||
|
@ -341,9 +341,9 @@ nsUserFontSet::StartLoad(gfxProxyFontEntry *aProxy,
|
||||
const gfxFontFaceSrc *aFontFaceSrc)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsIPrincipal *principal = nsnull;
|
||||
|
||||
rv = CheckFontLoad(aProxy, aFontFaceSrc, principal);
|
||||
rv = CheckFontLoad(aProxy, aFontFaceSrc, &principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIPresShell *ps = mPresContext->PresShell();
|
||||
@ -814,7 +814,7 @@ nsUserFontSet::LogMessage(gfxProxyFontEntry *aProxy,
|
||||
nsresult
|
||||
nsUserFontSet::CheckFontLoad(gfxProxyFontEntry *aFontToLoad,
|
||||
const gfxFontFaceSrc *aFontFaceSrc,
|
||||
nsCOMPtr<nsIPrincipal>& aPrincipal)
|
||||
nsIPrincipal **aPrincipal)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -832,18 +832,20 @@ nsUserFontSet::CheckFontLoad(gfxProxyFontEntry *aFontToLoad,
|
||||
// use document principal, original principal if flag set
|
||||
// this enables user stylesheets to load font files via
|
||||
// @font-face rules
|
||||
aPrincipal = ps->GetDocument()->NodePrincipal();
|
||||
*aPrincipal = ps->GetDocument()->NodePrincipal();
|
||||
|
||||
NS_ASSERTION(aFontFaceSrc->mOriginPrincipal,
|
||||
"null origin principal in @font-face rule");
|
||||
if (aFontFaceSrc->mUseOriginPrincipal) {
|
||||
aPrincipal = do_QueryInterface(aFontFaceSrc->mOriginPrincipal);
|
||||
nsCOMPtr<nsIPrincipal> p = do_QueryInterface(aFontFaceSrc->mOriginPrincipal);
|
||||
*aPrincipal = p;
|
||||
}
|
||||
|
||||
rv = nsFontFaceLoader::CheckLoadAllowed(aPrincipal, aFontFaceSrc->mURI,
|
||||
rv = nsFontFaceLoader::CheckLoadAllowed(*aPrincipal, aFontFaceSrc->mURI,
|
||||
ps->GetDocument());
|
||||
if (NS_FAILED(rv)) {
|
||||
LogMessage(aFontToLoad, "download not allowed", nsIScriptError::errorFlag, rv);
|
||||
LogMessage(aFontToLoad, "download not allowed",
|
||||
nsIScriptError::errorFlag, rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -856,9 +858,9 @@ nsUserFontSet::SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
|
||||
PRUint32 &aBufferLength)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsIPrincipal *principal = nsnull;
|
||||
|
||||
rv = CheckFontLoad(aFontToLoad, aFontFaceSrc, principal);
|
||||
rv = CheckFontLoad(aFontToLoad, aFontFaceSrc, &principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
@ -109,7 +109,7 @@ protected:
|
||||
|
||||
nsresult CheckFontLoad(gfxProxyFontEntry *aFontToLoad,
|
||||
const gfxFontFaceSrc *aFontFaceSrc,
|
||||
nsCOMPtr<nsIPrincipal>& aPrincipal);
|
||||
nsIPrincipal **aPrincipal);
|
||||
|
||||
virtual nsresult SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
|
||||
const gfxFontFaceSrc *aFontFaceSrc,
|
||||
|
@ -245,7 +245,7 @@ interface nsIProtocolHandler : nsISupports
|
||||
* Channels for this protocol don't need to spin the event loop to handle
|
||||
* Open() and reads on the resulting stream.
|
||||
*/
|
||||
const unsigned long URI_SYNC_LOAD_DOESNT_SPIN_EVENT_LOOP = (1<<15);
|
||||
const unsigned long URI_SYNC_LOAD_IS_OK = (1<<15);
|
||||
|
||||
/**
|
||||
* This protocol handler can be proxied via a proxy (socks or http)
|
||||
|
@ -92,7 +92,7 @@ NS_IMETHODIMP
|
||||
nsDataHandler::GetProtocolFlags(PRUint32 *result) {
|
||||
*result = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT |
|
||||
URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE |
|
||||
URI_SYNC_LOAD_DOESNT_SPIN_EVENT_LOOP;
|
||||
URI_SYNC_LOAD_IS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user