OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "core/css/CSSSVGDocumentValue.h" | 27 #include "core/css/CSSSVGDocumentValue.h" |
28 #include "core/style/StyleFetchedImage.h" | 28 #include "core/style/StyleFetchedImage.h" |
29 #include "core/style/StyleFetchedImageSet.h" | 29 #include "core/style/StyleFetchedImageSet.h" |
30 #include "core/style/StyleGeneratedImage.h" | 30 #include "core/style/StyleGeneratedImage.h" |
31 #include "core/style/StyleImage.h" | 31 #include "core/style/StyleImage.h" |
32 #include "core/style/StylePendingImage.h" | 32 #include "core/style/StylePendingImage.h" |
33 #include "platform/graphics/filters/FilterOperation.h" | 33 #include "platform/graphics/filters/FilterOperation.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
| 37 namespace { |
| 38 |
| 39 PassRefPtrWillBeRawPtr<StylePendingImage> createStylePendingImage(const CSSValue
& value) |
| 40 { |
| 41 // TODO(sashab): Remove this const_cast and this function once create() can
take a PassRefPtrWillBeRawPtr<const CSSValue>. |
| 42 return StylePendingImage::create(const_cast<CSSValue*>(&value)); |
| 43 } |
| 44 |
| 45 } // namespace |
| 46 |
37 ElementStyleResources::ElementStyleResources() | 47 ElementStyleResources::ElementStyleResources() |
38 : m_deviceScaleFactor(1) | 48 : m_deviceScaleFactor(1) |
39 { | 49 { |
40 } | 50 } |
41 | 51 |
42 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::styleImage(Document& d
ocument, CSSPropertyID property, const CSSValue& value) | 52 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::styleImage(Document& d
ocument, CSSPropertyID property, const CSSValue& value) |
43 { | 53 { |
44 if (value.isImageValue()) | 54 if (value.isImageValue()) |
45 return cachedOrPendingFromValue(document, property, toCSSImageValue(valu
e)); | 55 return cachedOrPendingFromValue(document, property, toCSSImageValue(valu
e)); |
46 | 56 |
47 if (value.isImageGeneratorValue()) | 57 if (value.isImageGeneratorValue()) |
48 return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(va
lue)); | 58 return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(va
lue)); |
49 | 59 |
50 if (value.isImageSetValue()) | 60 if (value.isImageSetValue()) |
51 return setOrPendingFromValue(property, toCSSImageSetValue(value)); | 61 return setOrPendingFromValue(property, toCSSImageSetValue(value)); |
52 | 62 |
53 if (value.isCursorImageValue()) | 63 if (value.isCursorImageValue()) |
54 return cursorOrPendingFromValue(property, toCSSCursorImageValue(value)); | 64 return cursorOrPendingFromValue(property, toCSSCursorImageValue(value)); |
55 | 65 |
56 return nullptr; | 66 return nullptr; |
57 } | 67 } |
58 | 68 |
59 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::generatedOrPendingFrom
Value(CSSPropertyID property, const CSSImageGeneratorValue& value) | 69 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::generatedOrPendingFrom
Value(CSSPropertyID property, const CSSImageGeneratorValue& value) |
60 { | 70 { |
61 if (value.isPending()) { | 71 if (value.isPending()) { |
62 m_pendingImageProperties.add(property); | 72 m_pendingImageProperties.add(property); |
63 return StylePendingImage::create(value); | 73 return createStylePendingImage(value); |
64 } | 74 } |
65 return StyleGeneratedImage::create(value); | 75 // TODO(sashab): Remove this const_cast once create() can take a PassRefPtrW
illBeRawPtr<const CSSValue>. |
| 76 return StyleGeneratedImage::create(const_cast<CSSImageGeneratorValue*>(&valu
e)); |
66 } | 77 } |
67 | 78 |
68 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::setOrPendingFromValue(
CSSPropertyID property, const CSSImageSetValue& value) | 79 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::setOrPendingFromValue(
CSSPropertyID property, const CSSImageSetValue& value) |
69 { | 80 { |
70 if (value.isCachePending(m_deviceScaleFactor)) { | 81 if (value.isCachePending(m_deviceScaleFactor)) { |
71 m_pendingImageProperties.add(property); | 82 m_pendingImageProperties.add(property); |
72 return StylePendingImage::create(value); | 83 return createStylePendingImage(value); |
73 } | 84 } |
74 return value.cachedImageSet(m_deviceScaleFactor); | 85 return value.cachedImageSet(m_deviceScaleFactor); |
75 } | 86 } |
76 | 87 |
77 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::cachedOrPendingFromVal
ue(Document& document, CSSPropertyID property, const CSSImageValue& value) | 88 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::cachedOrPendingFromVal
ue(Document& document, CSSPropertyID property, const CSSImageValue& value) |
78 { | 89 { |
79 if (value.isCachePending()) { | 90 if (value.isCachePending()) { |
80 m_pendingImageProperties.add(property); | 91 m_pendingImageProperties.add(property); |
81 return StylePendingImage::create(value); | 92 return createStylePendingImage(value); |
82 } | 93 } |
83 value.restoreCachedResourceIfNeeded(document); | 94 value.restoreCachedResourceIfNeeded(document); |
84 return value.cachedImage(); | 95 return value.cachedImage(); |
85 } | 96 } |
86 | 97 |
87 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::cursorOrPendingFromVal
ue(CSSPropertyID property, const CSSCursorImageValue& value) | 98 PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::cursorOrPendingFromVal
ue(CSSPropertyID property, const CSSCursorImageValue& value) |
88 { | 99 { |
89 if (value.isCachePending(m_deviceScaleFactor)) { | 100 if (value.isCachePending(m_deviceScaleFactor)) { |
90 m_pendingImageProperties.add(property); | 101 m_pendingImageProperties.add(property); |
91 return StylePendingImage::create(value); | 102 return createStylePendingImage(value); |
92 } | 103 } |
93 return value.cachedImage(m_deviceScaleFactor); | 104 return value.cachedImage(m_deviceScaleFactor); |
94 } | 105 } |
95 | 106 |
96 void ElementStyleResources::clearPendingImageProperties() | 107 void ElementStyleResources::clearPendingImageProperties() |
97 { | 108 { |
98 m_pendingImageProperties.clear(); | 109 m_pendingImageProperties.clear(); |
99 } | 110 } |
100 | 111 |
101 void ElementStyleResources::clearPendingSVGDocuments() | 112 void ElementStyleResources::clearPendingSVGDocuments() |
102 { | 113 { |
103 m_pendingSVGDocuments.clear(); | 114 m_pendingSVGDocuments.clear(); |
104 } | 115 } |
105 | 116 |
106 void ElementStyleResources::addPendingSVGDocument(FilterOperation* filterOperati
on, CSSSVGDocumentValue* cssSVGDocumentValue) | 117 void ElementStyleResources::addPendingSVGDocument(FilterOperation* filterOperati
on, CSSSVGDocumentValue* cssSVGDocumentValue) |
107 { | 118 { |
108 m_pendingSVGDocuments.set(filterOperation, cssSVGDocumentValue); | 119 m_pendingSVGDocuments.set(filterOperation, cssSVGDocumentValue); |
109 } | 120 } |
110 | 121 |
111 } | 122 } |
OLD | NEW |