diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/css/CSSImageValue.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/css/CSSImageValue.cpp')
-rw-r--r-- | Source/WebCore/css/CSSImageValue.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/Source/WebCore/css/CSSImageValue.cpp b/Source/WebCore/css/CSSImageValue.cpp index bdb8d9e5a..d0b62747f 100644 --- a/Source/WebCore/css/CSSImageValue.cpp +++ b/Source/WebCore/css/CSSImageValue.cpp @@ -28,6 +28,7 @@ #include "CachedResourceLoader.h" #include "CachedResourceRequest.h" #include "CachedResourceRequestInitiators.h" +#include "CrossOriginAccessControl.h" #include "Document.h" #include "Element.h" #include "MemoryCache.h" @@ -53,8 +54,8 @@ CSSImageValue::CSSImageValue(const String& url, StyleImage* image) inline void CSSImageValue::detachPendingImage() { - if (m_image && m_image->isPendingImage()) - static_cast<StylePendingImage&>(*m_image).detachFromCSSValue(); + if (is<StylePendingImage>(m_image.get())) + downcast<StylePendingImage>(*m_image).detachFromCSSValue(); } CSSImageValue::~CSSImageValue() @@ -70,40 +71,36 @@ StyleImage* CSSImageValue::cachedOrPendingImage() return m_image.get(); } -StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const ResourceLoaderOptions& options) +StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options) { - ASSERT(loader); - if (!m_accessedImage) { m_accessedImage = true; - CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)), options); + CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)), options); if (m_initiatorName.isEmpty()) request.setInitiator(cachedResourceRequestInitiators().css); else request.setInitiator(m_initiatorName); - if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request)) { + + if (options.requestOriginPolicy() == PotentiallyCrossOriginEnabled) + updateRequestForAccessControl(request.mutableResourceRequest(), loader.document()->securityOrigin(), options.allowCredentials()); + + if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) { detachPendingImage(); m_image = StyleCachedImage::create(cachedImage.get()); } } - return (m_image && m_image->isCachedImage()) ? static_cast<StyleCachedImage*>(m_image.get()) : 0; -} - -StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader) -{ - return cachedImage(loader, CachedResourceLoader::defaultCachedResourceOptions()); + return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr; } -bool CSSImageValue::hasFailedOrCanceledSubresources() const +bool CSSImageValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const { - if (!m_image || !m_image->isCachedImage()) + if (!is<StyleCachedImage>(m_image.get())) return false; - CachedResource* cachedResource = static_cast<StyleCachedImage*>(m_image.get())->cachedImage(); - if (!cachedResource) - return true; - return cachedResource->loadFailedOrCanceled(); + CachedResource* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage(); + ASSERT(cachedResource); + return handler(*cachedResource); } bool CSSImageValue::equals(const CSSImageValue& other) const @@ -111,20 +108,20 @@ bool CSSImageValue::equals(const CSSImageValue& other) const return m_url == other.m_url; } -String CSSImageValue::customCssText() const +String CSSImageValue::customCSSText() const { return "url(" + quoteCSSURLIfNeeded(m_url) + ')'; } -PassRefPtr<CSSValue> CSSImageValue::cloneForCSSOM() const +Ref<CSSValue> CSSImageValue::cloneForCSSOM() const { // NOTE: We expose CSSImageValues as URI primitive values in CSSOM to maintain old behavior. - RefPtr<CSSPrimitiveValue> uriValue = CSSPrimitiveValue::create(m_url, CSSPrimitiveValue::CSS_URI); + Ref<CSSPrimitiveValue> uriValue = CSSPrimitiveValue::create(m_url, CSSPrimitiveValue::CSS_URI); uriValue->setCSSOMSafe(); - return uriValue.release(); + return WTFMove(uriValue); } -bool CSSImageValue::knownToBeOpaque(const RenderObject* renderer) const +bool CSSImageValue::knownToBeOpaque(const RenderElement* renderer) const { return m_image ? m_image->knownToBeOpaque(renderer) : false; } |