| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
| 27 #include "core/fetch/CrossOriginAccessControl.h" | 27 #include "core/fetch/CrossOriginAccessControl.h" |
| 28 #include "core/fetch/FetchRequest.h" | 28 #include "core/fetch/FetchRequest.h" |
| 29 #include "core/fetch/ImageResource.h" | 29 #include "core/fetch/ImageResource.h" |
| 30 #include "core/rendering/style/StyleFetchedImage.h" | 30 #include "core/rendering/style/StyleFetchedImage.h" |
| 31 #include "core/rendering/style/StylePendingImage.h" | 31 #include "core/rendering/style/StylePendingImage.h" |
| 32 #include "platform/weborigin/KURL.h" | 32 #include "platform/weborigin/KURL.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 CSSImageValue::CSSImageValue(const KURL& url) | 36 CSSImageValue::CSSImageValue(const String& rawValue, const KURL& url, StyleImage
* image) |
| 37 : CSSValue(ImageClass) | 37 : CSSValue(ImageClass) |
| 38 , m_url(url.string()) | 38 , m_relativeURL(rawValue) |
| 39 , m_accessedImage(false) | 39 , m_absoluteURL(url.string()) |
| 40 , m_image(image) |
| 41 , m_accessedImage(image) |
| 40 { | 42 { |
| 41 } | 43 } |
| 42 | 44 |
| 43 CSSImageValue::CSSImageValue(const KURL& url, StyleImage* image) | |
| 44 : CSSValue(ImageClass) | |
| 45 , m_url(url.string()) | |
| 46 , m_image(image) | |
| 47 , m_accessedImage(true) | |
| 48 { | |
| 49 } | |
| 50 | |
| 51 CSSImageValue::~CSSImageValue() | 45 CSSImageValue::~CSSImageValue() |
| 52 { | 46 { |
| 53 } | 47 } |
| 54 | 48 |
| 55 StyleImage* CSSImageValue::cachedOrPendingImage() | 49 StyleImage* CSSImageValue::cachedOrPendingImage() |
| 56 { | 50 { |
| 57 if (!m_image) | 51 if (!m_image) |
| 58 m_image = StylePendingImage::create(this); | 52 m_image = StylePendingImage::create(this); |
| 59 | 53 |
| 60 return m_image.get(); | 54 return m_image.get(); |
| 61 } | 55 } |
| 62 | 56 |
| 63 StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const Re
sourceLoaderOptions& options) | 57 StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const Re
sourceLoaderOptions& options) |
| 64 { | 58 { |
| 65 ASSERT(fetcher); | 59 ASSERT(fetcher); |
| 66 | 60 |
| 67 if (!m_accessedImage) { | 61 if (!m_accessedImage) { |
| 68 m_accessedImage = true; | 62 m_accessedImage = true; |
| 69 | 63 |
| 70 FetchRequest request(ResourceRequest(m_url), m_initiatorName.isEmpty() ?
FetchInitiatorTypeNames::css : m_initiatorName, options); | 64 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options); |
| 71 | 65 |
| 72 if (options.corsEnabled == IsCORSEnabled) | 66 if (options.corsEnabled == IsCORSEnabled) |
| 73 request.setCrossOriginAccessControl(fetcher->document()->securityOri
gin(), options.allowCredentials); | 67 request.setCrossOriginAccessControl(fetcher->document()->securityOri
gin(), options.allowCredentials); |
| 74 | 68 |
| 75 if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request
)) | 69 if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request
)) |
| 76 m_image = StyleFetchedImage::create(cachedImage.get()); | 70 m_image = StyleFetchedImage::create(cachedImage.get()); |
| 77 } | 71 } |
| 78 | 72 |
| 79 return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image
) : 0; | 73 return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image
) : 0; |
| 80 } | 74 } |
| 81 | 75 |
| 82 bool CSSImageValue::hasFailedOrCanceledSubresources() const | 76 bool CSSImageValue::hasFailedOrCanceledSubresources() const |
| 83 { | 77 { |
| 84 if (!m_image || !m_image->isImageResource()) | 78 if (!m_image || !m_image->isImageResource()) |
| 85 return false; | 79 return false; |
| 86 if (Resource* cachedResource = toStyleFetchedImage(m_image)->cachedImage()) | 80 if (Resource* cachedResource = toStyleFetchedImage(m_image)->cachedImage()) |
| 87 return cachedResource->loadFailedOrCanceled(); | 81 return cachedResource->loadFailedOrCanceled(); |
| 88 return true; | 82 return true; |
| 89 } | 83 } |
| 90 | 84 |
| 91 bool CSSImageValue::equals(const CSSImageValue& other) const | 85 bool CSSImageValue::equals(const CSSImageValue& other) const |
| 92 { | 86 { |
| 93 return m_url == other.m_url; | 87 return m_absoluteURL == other.m_absoluteURL; |
| 94 } | 88 } |
| 95 | 89 |
| 96 String CSSImageValue::customCSSText() const | 90 String CSSImageValue::customCSSText() const |
| 97 { | 91 { |
| 98 return "url(" + quoteCSSURLIfNeeded(m_url) + ")"; | 92 return "url(" + quoteCSSURLIfNeeded(m_absoluteURL) + ")"; |
| 99 } | 93 } |
| 100 | 94 |
| 101 PassRefPtrWillBeRawPtr<CSSValue> CSSImageValue::cloneForCSSOM() const | 95 PassRefPtrWillBeRawPtr<CSSValue> CSSImageValue::cloneForCSSOM() const |
| 102 { | 96 { |
| 103 // NOTE: We expose CSSImageValues as URI primitive values in CSSOM to mainta
in old behavior. | 97 // NOTE: We expose CSSImageValues as URI primitive values in CSSOM to mainta
in old behavior. |
| 104 RefPtrWillBeRawPtr<CSSPrimitiveValue> uriValue = CSSPrimitiveValue::create(m
_url, CSSPrimitiveValue::CSS_URI); | 98 RefPtrWillBeRawPtr<CSSPrimitiveValue> uriValue = CSSPrimitiveValue::create(m
_absoluteURL, CSSPrimitiveValue::CSS_URI); |
| 105 uriValue->setCSSOMSafe(); | 99 uriValue->setCSSOMSafe(); |
| 106 return uriValue.release(); | 100 return uriValue.release(); |
| 107 } | 101 } |
| 108 | 102 |
| 109 bool CSSImageValue::knownToBeOpaque(const RenderObject* renderer) const | 103 bool CSSImageValue::knownToBeOpaque(const RenderObject* renderer) const |
| 110 { | 104 { |
| 111 return m_image ? m_image->knownToBeOpaque(renderer) : false; | 105 return m_image ? m_image->knownToBeOpaque(renderer) : false; |
| 112 } | 106 } |
| 113 | 107 |
| 114 void CSSImageValue::traceAfterDispatch(Visitor* visitor) | 108 void CSSImageValue::traceAfterDispatch(Visitor* visitor) |
| 115 { | 109 { |
| 116 CSSValue::traceAfterDispatch(visitor); | 110 CSSValue::traceAfterDispatch(visitor); |
| 117 } | 111 } |
| 118 | 112 |
| 113 void CSSImageValue::reResolveURLInternal(const KURL& url) |
| 114 { |
| 115 if (url == m_absoluteURL) |
| 116 return; |
| 117 m_absoluteURL = url.string(); |
| 118 m_accessedImage = false; |
| 119 m_image.clear(); |
| 120 } |
| 121 |
| 119 } // namespace WebCore | 122 } // namespace WebCore |
| OLD | NEW |