void
nsSVGImageElement::MaybeLoadSVGImage()
{
  if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href) &&
      (NS_FAILED(LoadSVGImage(PR_FALSE, PR_TRUE)) ||
       !LoadingEnabled())) {
    CancelImageRequests(PR_TRUE);
  }
}
nsresult
nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
                                const nsAString* aValue, PRBool aNotify)
{
  if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
    // If caller is not chrome and dom.disable_image_src_set is true,
    // prevent setting image.src by exiting early
    if (nsContentUtils::GetBoolPref("dom.disable_image_src_set") &&
        !nsContentUtils::IsCallerChrome()) {
      return NS_OK;
    }

    if (aValue) {
      LoadSVGImage(PR_TRUE, aNotify);
    } else {
      CancelImageRequests(aNotify);
    }
  }
  return nsSVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
                                             aValue, aNotify);
}
Example #3
0
File: image.c Project: Miteam/jwm
/** Load an image from the specified file. */
ImageNode *LoadImage(const char *fileName, int width, int height,
                     char preserveAspect)
{
   unsigned nameLength;
   ImageNode *result = NULL;
   if(!fileName) {
      return result;
   }

   nameLength = strlen(fileName);
   if(JUNLIKELY(nameLength == 0)) {
      return result;
   }

   /* Attempt to load the file as a PNG image. */
#ifdef USE_PNG
   if(nameLength >= 4
      && !StrCmpNoCase(&fileName[nameLength - 4], ".png")) {
      result = LoadPNGImage(fileName);
      if(result) {
         return result;
      }
   }
#endif

   /* Attempt to load the file as a JPEG image. */
#ifdef USE_JPEG
   if(   (nameLength >= 4
            && !StrCmpNoCase(&fileName[nameLength - 4], ".jpg"))
      || (nameLength >= 5
            && !StrCmpNoCase(&fileName[nameLength - 5], ".jpeg"))) {
      result = LoadJPEGImage(fileName, width, height);
      if(result) {
         return result;
      }
   }
#endif

   /* Attempt to load the file as an SVG image. */
#if defined USE_RSVG || defined USE_NANOSVG 
   if(nameLength >= 4
      && !StrCmpNoCase(&fileName[nameLength - 4], ".svg")) {
      result = LoadSVGImage(fileName, width, height, preserveAspect);
      if(result) {
         return result;
      }
   }
#endif

   /* Attempt to load the file as an XPM image. */
#ifdef USE_XPM
   if(nameLength >= 4
      && !StrCmpNoCase(&fileName[nameLength - 4], ".xpm")) {
      result = LoadXPMImage(fileName);
      if(result) {
         return result;
      }
   }
#endif

   /* Attempt to load the file as an XBM image. */
#ifdef USE_XBM
   if(nameLength >= 4
      && !StrCmpNoCase(&fileName[nameLength - 4], ".xbm")) {
      result = LoadXBMImage(fileName);
      if(result) {
         return result;
      }
   }
#endif

   /* Attempt to load a PNG, JPEG, GIf, TGA, BMP, PNM, PSD or PIC image. */
#ifdef USE_STB_IMAGE
   result = LoadstbImage(fileName);
#endif

   return result;

}