OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #include "core/style/StyleFetchedImage.h" | 24 #include "core/style/StyleFetchedImage.h" |
25 | 25 |
26 #include "core/css/CSSImageValue.h" | 26 #include "core/css/CSSImageValue.h" |
27 #include "core/fetch/ImageResource.h" | 27 #include "core/fetch/ImageResourceContent.h" |
28 #include "core/layout/LayoutObject.h" | 28 #include "core/layout/LayoutObject.h" |
29 #include "core/svg/graphics/SVGImage.h" | 29 #include "core/svg/graphics/SVGImage.h" |
30 #include "core/svg/graphics/SVGImageForContainer.h" | 30 #include "core/svg/graphics/SVGImageForContainer.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 StyleFetchedImage::StyleFetchedImage(ImageResource* image, | 34 StyleFetchedImage::StyleFetchedImage(ImageResourceContent* image, |
35 const Document& document, | 35 const Document& document, |
36 const KURL& url) | 36 const KURL& url) |
37 : m_image(image), m_document(&document), m_url(url) { | 37 : m_image(image), m_document(&document), m_url(url) { |
38 m_isImageResource = true; | 38 m_isImageResource = true; |
39 m_image->addObserver(this); | 39 m_image->addObserver(this); |
40 // ResourceFetcher is not determined from StyleFetchedImage and it is | 40 // ResourceFetcher is not determined from StyleFetchedImage and it is |
41 // impossible to send a request for refetching. | 41 // impossible to send a request for refetching. |
42 m_image->setNotRefetchableDataFromDiskCache(); | 42 m_image->setNotRefetchableDataFromDiskCache(); |
43 ThreadState::current()->registerPreFinalizer(this); | 43 ThreadState::current()->registerPreFinalizer(this); |
44 } | 44 } |
45 | 45 |
46 StyleFetchedImage::~StyleFetchedImage() {} | 46 StyleFetchedImage::~StyleFetchedImage() {} |
47 | 47 |
48 void StyleFetchedImage::dispose() { | 48 void StyleFetchedImage::dispose() { |
49 m_image->removeObserver(this); | 49 m_image->removeObserver(this); |
50 m_image = nullptr; | 50 m_image = nullptr; |
51 } | 51 } |
52 | 52 |
53 WrappedImagePtr StyleFetchedImage::data() const { | 53 WrappedImagePtr StyleFetchedImage::data() const { |
54 return m_image.get(); | 54 return m_image.get(); |
55 } | 55 } |
56 | 56 |
57 ImageResource* StyleFetchedImage::cachedImage() const { | 57 ImageResourceContent* StyleFetchedImage::cachedImage() const { |
58 return m_image.get(); | 58 return m_image.get(); |
59 } | 59 } |
60 | 60 |
61 CSSValue* StyleFetchedImage::cssValue() const { | 61 CSSValue* StyleFetchedImage::cssValue() const { |
62 return CSSImageValue::create(m_url, const_cast<StyleFetchedImage*>(this)); | 62 return CSSImageValue::create(m_url, const_cast<StyleFetchedImage*>(this)); |
63 } | 63 } |
64 | 64 |
65 CSSValue* StyleFetchedImage::computedCSSValue() const { | 65 CSSValue* StyleFetchedImage::computedCSSValue() const { |
66 return cssValue(); | 66 return cssValue(); |
67 } | 67 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 void StyleFetchedImage::addClient(LayoutObject* layoutObject) { | 105 void StyleFetchedImage::addClient(LayoutObject* layoutObject) { |
106 m_image->addObserver(layoutObject); | 106 m_image->addObserver(layoutObject); |
107 } | 107 } |
108 | 108 |
109 void StyleFetchedImage::removeClient(LayoutObject* layoutObject) { | 109 void StyleFetchedImage::removeClient(LayoutObject* layoutObject) { |
110 m_image->removeObserver(layoutObject); | 110 m_image->removeObserver(layoutObject); |
111 } | 111 } |
112 | 112 |
113 void StyleFetchedImage::imageNotifyFinished(ImageResource*) { | 113 void StyleFetchedImage::imageNotifyFinished(ImageResourceContent*) { |
114 if (m_document && m_image && m_image->getImage() && | 114 if (m_document && m_image && m_image->getImage() && |
115 m_image->getImage()->isSVGImage()) | 115 m_image->getImage()->isSVGImage()) |
116 toSVGImage(m_image->getImage())->updateUseCounters(*m_document); | 116 toSVGImage(m_image->getImage())->updateUseCounters(*m_document); |
117 // Oilpan: do not prolong the Document's lifetime. | 117 // Oilpan: do not prolong the Document's lifetime. |
118 m_document.clear(); | 118 m_document.clear(); |
119 } | 119 } |
120 | 120 |
121 PassRefPtr<Image> StyleFetchedImage::image(const LayoutObject&, | 121 PassRefPtr<Image> StyleFetchedImage::image(const LayoutObject&, |
122 const IntSize& containerSize, | 122 const IntSize& containerSize, |
123 float zoom) const { | 123 float zoom) const { |
(...skipping 13 matching lines...) Expand all Loading... |
137 Image::PreCacheMetadata); | 137 Image::PreCacheMetadata); |
138 } | 138 } |
139 | 139 |
140 DEFINE_TRACE(StyleFetchedImage) { | 140 DEFINE_TRACE(StyleFetchedImage) { |
141 visitor->trace(m_image); | 141 visitor->trace(m_image); |
142 visitor->trace(m_document); | 142 visitor->trace(m_document); |
143 StyleImage::trace(visitor); | 143 StyleImage::trace(visitor); |
144 } | 144 } |
145 | 145 |
146 } // namespace blink | 146 } // namespace blink |
OLD | NEW |