Bug 512566. Changes based on review comments. r=bz,jfkthame
authorJohn Daggett <jdaggett@mozilla.com>
Fri, 16 Mar 2012 12:31:01 +0900
changeset 92879 52c8bd0a1bf99d77346563c69a0744f2719eb50a
parent 92878 d0caad830e14d049d9cef4abadd0500dbe03595a
child 92881 fcf369a4f12b04781b92dc114cad6817fc4171ef
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jfkthame
bugs512566
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 512566. Changes based on review comments. r=bz,jfkthame
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxUserFontSet.h
layout/style/nsFontFaceLoader.cpp
layout/style/nsFontFaceLoader.h
netwerk/base/public/nsIProtocolHandler.idl
netwerk/protocol/data/nsDataHandler.cpp
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -457,16 +457,17 @@ gfxUserFontSet::CopyWOFFMetadata(const P
 bool
 gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
                                const PRUint8 *aFontData, PRUint32 aLength,
                                nsresult aDownloadStatus)
 {
     // download successful, make platform font using font data
     if (NS_SUCCEEDED(aDownloadStatus)) {
         gfxFontEntry *fe = LoadFont(aProxy, aFontData, aLength);
+        aFontData = nsnull;
 
         if (fe) {
             IncrementGeneration();
             return true;
         }
 
     } else {
         // download failed
@@ -541,31 +542,29 @@ gfxUserFontSet::LoadNext(gfxProxyFontEnt
         // src url ==> start the load process
         else {
             if (gfxPlatform::GetPlatform()->IsFontFormatSupported(currSrc.mURI,
                     currSrc.mFormatFlags)) {
 
                 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;
 
                     // sync load font immediately
                     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",
                                    nsIScriptError::errorFlag, rv);
                     }
 
                 } else {
                     // otherwise load font async
@@ -619,17 +618,17 @@ gfxUserFontSet::IncrementGeneration()
     if (LL_IS_ZERO(sFontSetGeneration))
         LL_ADD(sFontSetGeneration, sFontSetGeneration, 1);
     mGeneration = sFontSetGeneration;
 }
 
 
 gfxFontEntry*
 gfxUserFontSet::LoadFont(gfxProxyFontEntry *aProxy,
-                         const PRUint8* &aFontData, PRUint32 &aLength)
+                         const PRUint8 *aFontData, PRUint32 &aLength)
 {
     gfxFontEntry *fe = nsnull;
 
     gfxUserFontType fontType =
         gfxFontUtils::DetermineFontDataType(aFontData, aLength);
 
     // Save a copy of the metadata block (if present) for nsIDOMFontFace
     // to use if required. Ownership of the metadata block will be passed
@@ -726,30 +725,27 @@ gfxUserFontSet::LoadFont(gfxProxyFontEnt
             aProxy->mSrcList[aProxy->mSrcIndex].mURI->GetSpec(fontURI);
             LOG(("userfonts (%p) [src %d] loaded uri: (%s) for (%s) gen: %8.8x\n",
                  this, aProxy->mSrcIndex, fontURI.get(),
                  NS_ConvertUTF16toUTF8(aProxy->mFamily->Name()).get(),
                  PRUint32(mGeneration)));
         }
 #endif
         ReplaceFontEntry(aProxy, fe);
-
     } else {
-
 #ifdef PR_LOGGING
         if (LOG_ENABLED()) {
             nsCAutoString fontURI;
             aProxy->mSrcList[aProxy->mSrcIndex].mURI->GetSpec(fontURI);
             LOG(("userfonts (%p) [src %d] failed uri: (%s) for (%s)"
                  " error making platform font\n",
                  this, aProxy->mSrcIndex, fontURI.get(),
                  NS_ConvertUTF16toUTF8(aProxy->mFamily->Name()).get()));
         }
 #endif
-
     }
 
     return fe;
 }
 
 gfxMixedFontFamily*
 gfxUserFontSet::GetFamily(const nsAString& aFamilyName) const
 {
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -267,17 +267,17 @@ protected:
     // in the src list
     LoadStatus LoadNext(gfxProxyFontEntry *aProxyEntry);
 
     // helper method for creating a platform font
     // returns font entry if platform font creation successful
     // 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,
                                       const gfxFontFaceSrc *aFontFaceSrc,
                                       PRUint8* &aBuffer,
                                       PRUint32 &aBufferLength)
     {
         // implemented in nsUserFontSet
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -336,19 +336,19 @@ nsUserFontSet::RemoveLoader(nsFontFaceLo
   mLoaders.RemoveEntry(aLoader);
 }
 
 nsresult
 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();
   if (!ps)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIStreamLoader> streamLoader;
   nsCOMPtr<nsILoadGroup> loadGroup(ps->GetDocument()->GetDocumentLoadGroup());
@@ -809,17 +809,17 @@ nsUserFontSet::LogMessage(gfxProxyFontEn
   }
 
   return NS_OK;
 }
 
 nsresult
 nsUserFontSet::CheckFontLoad(gfxProxyFontEntry *aFontToLoad,
                              const gfxFontFaceSrc *aFontFaceSrc,
-                             nsCOMPtr<nsIPrincipal>& aPrincipal)
+                             nsIPrincipal **aPrincipal)
 {
   nsresult rv;
 
   // check same-site origin
   nsIPresShell *ps = mPresContext->PresShell();
   if (!ps)
     return NS_ERROR_FAILURE;
 
@@ -827,43 +827,45 @@ nsUserFontSet::CheckFontLoad(gfxProxyFon
                "bad font face url passed to fontloader");
   NS_ASSERTION(aFontFaceSrc->mURI, "null font uri");
   if (!aFontFaceSrc->mURI)
     return NS_ERROR_FAILURE;
 
   // 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;
 }
 
 nsresult
 nsUserFontSet::SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
                                 const gfxFontFaceSrc *aFontFaceSrc,
                                 PRUint8* &aBuffer,
                                 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;
   // get Content Security Policy from principal to pass into channel
   nsCOMPtr<nsIChannelPolicy> channelPolicy;
   nsCOMPtr<nsIContentSecurityPolicy> csp;
   rv = principal->GetCsp(getter_AddRefs(csp));
   NS_ENSURE_SUCCESS(rv, rv);
--- a/layout/style/nsFontFaceLoader.h
+++ b/layout/style/nsFontFaceLoader.h
@@ -104,17 +104,17 @@ protected:
 
   virtual nsresult LogMessage(gfxProxyFontEntry *aProxy,
                               const char *aMessage,
                               PRUint32 aFlags = nsIScriptError::errorFlag,
                               nsresult aStatus = 0);
 
   nsresult CheckFontLoad(gfxProxyFontEntry *aFontToLoad,
                          const gfxFontFaceSrc *aFontFaceSrc,
-                         nsCOMPtr<nsIPrincipal>& aPrincipal);
+                         nsIPrincipal **aPrincipal);
 
   virtual nsresult SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
                                     const gfxFontFaceSrc *aFontFaceSrc,
                                     PRUint8* &aBuffer,
                                     PRUint32 &aBufferLength);
 
   nsPresContext *mPresContext;  // weak reference
 
--- a/netwerk/base/public/nsIProtocolHandler.idl
+++ b/netwerk/base/public/nsIProtocolHandler.idl
@@ -240,17 +240,17 @@ interface nsIProtocolHandler : nsISuppor
     const unsigned long URI_OPENING_EXECUTES_SCRIPT = (1<<13);
 
     // Note that 1 << 14 is used above
 
     /**
      * 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)
      * (e.g., irc, smtp, http, etc.).  If the protocol supports transparent
      * proxying, the handler should implement nsIProxiedProtocolHandler.
      *
      * If it supports only HTTP proxying, then it need not support
      * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP
--- a/netwerk/protocol/data/nsDataHandler.cpp
+++ b/netwerk/protocol/data/nsDataHandler.cpp
@@ -87,17 +87,17 @@ nsDataHandler::GetDefaultPort(PRInt32 *r
     *result = -1;
     return NS_OK;
 }
 
 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;
 }
 
 NS_IMETHODIMP
 nsDataHandler::NewURI(const nsACString &aSpec,
                       const char *aCharset, // ignore charset info
                       nsIURI *aBaseURI,
                       nsIURI **result) {