static bool checkShapeImageOrigin(Document& document, const StyleImage& styleImage) { if (styleImage.isGeneratedImage()) return true; ASSERT(styleImage.cachedImage()); ImageResource& imageResource = *(styleImage.cachedImage()); if (imageResource.isAccessAllowed(document.securityOrigin())) return true; const KURL& url = imageResource.url(); String urlString = url.isNull() ? "''" : url.elidedString(); document.addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Unsafe attempt to load URL " + urlString + "."); return false; }
static inline bool checkShapeImageOrigin(Document& document, const StyleImage& styleImage) { if (styleImage.isGeneratedImage()) return true; ASSERT(styleImage.cachedImage()); CachedImage& cachedImage = *(styleImage.cachedImage()); if (cachedImage.isOriginClean(document.securityOrigin())) return true; const URL& url = cachedImage.url(); String urlString = url.isNull() ? "''" : url.stringCenterEllipsizedToLength(); document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, "Unsafe attempt to load URL " + urlString + "."); return false; }
static void getShapeImageAndRect(const ShapeValue& shapeValue, const RenderBox& renderBox, const LayoutSize& referenceBoxSize, Image*& image, LayoutRect& rect) { ASSERT(shapeValue.isImageValid()); StyleImage* styleImage = shapeValue.image(); const LayoutSize& imageSize = renderBox.calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom); styleImage->setContainerSizeForRenderer(&renderBox, imageSize, renderBox.style().effectiveZoom()); image = nullptr; if (styleImage->isCachedImage() || styleImage->isCachedImageSet()) image = styleImage->cachedImage()->imageForRenderer(&renderBox); else if (styleImage->isGeneratedImage()) image = styleImage->image(const_cast<RenderBox*>(&renderBox), imageSize).get(); if (renderBox.isRenderImage()) rect = toRenderImage(&renderBox)->replacedContentRect(renderBox.intrinsicSize()); else rect = LayoutRect(LayoutPoint(), imageSize); }