Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: Source/core/css/CSSCrossfadeValue.cpp

Issue 1105103003: Update renderer in core/css. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 29 matching lines...) Expand all
40 return toCSSImageValue(value)->cachedOrPendingImage()->isPendingImage(); 40 return toCSSImageValue(value)->cachedOrPendingImage()->isPendingImage();
41 41
42 if (value->isImageGeneratorValue()) 42 if (value->isImageGeneratorValue())
43 return toCSSImageGeneratorValue(value)->isPending(); 43 return toCSSImageGeneratorValue(value)->isPending();
44 44
45 ASSERT_NOT_REACHED(); 45 ASSERT_NOT_REACHED();
46 46
47 return false; 47 return false;
48 } 48 }
49 49
50 static bool subimageKnownToBeOpaque(CSSValue* value, const LayoutObject* rendere r) 50 static bool subimageKnownToBeOpaque(CSSValue* value, const LayoutObject* layoutO bject)
51 { 51 {
52 if (value->isImageValue()) 52 if (value->isImageValue())
53 return toCSSImageValue(value)->knownToBeOpaque(renderer); 53 return toCSSImageValue(value)->knownToBeOpaque(layoutObject);
54 54
55 if (value->isImageGeneratorValue()) 55 if (value->isImageGeneratorValue())
56 return toCSSImageGeneratorValue(value)->knownToBeOpaque(renderer); 56 return toCSSImageGeneratorValue(value)->knownToBeOpaque(layoutObject);
57 57
58 ASSERT_NOT_REACHED(); 58 ASSERT_NOT_REACHED();
59 59
60 return false; 60 return false;
61 } 61 }
62 62
63 static ImageResource* cachedImageForCSSValue(CSSValue* value, Document* document ) 63 static ImageResource* cachedImageForCSSValue(CSSValue* value, Document* document )
64 { 64 {
65 if (!value) 65 if (!value)
66 return 0; 66 return 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 result.appendLiteral("-webkit-cross-fade("); 98 result.appendLiteral("-webkit-cross-fade(");
99 result.append(m_fromValue->cssText()); 99 result.append(m_fromValue->cssText());
100 result.appendLiteral(", "); 100 result.appendLiteral(", ");
101 result.append(m_toValue->cssText()); 101 result.append(m_toValue->cssText());
102 result.appendLiteral(", "); 102 result.appendLiteral(", ");
103 result.append(m_percentageValue->cssText()); 103 result.append(m_percentageValue->cssText());
104 result.append(')'); 104 result.append(')');
105 return result.toString(); 105 return result.toString();
106 } 106 }
107 107
108 IntSize CSSCrossfadeValue::fixedSize(const LayoutObject* renderer) 108 IntSize CSSCrossfadeValue::fixedSize(const LayoutObject* layoutObject)
109 { 109 {
110 float percentage = m_percentageValue->getFloatValue(); 110 float percentage = m_percentageValue->getFloatValue();
111 float inversePercentage = 1 - percentage; 111 float inversePercentage = 1 - percentage;
112 112
113 Document* document = &renderer->document(); 113 Document* document = &layoutObject->document();
114 ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), d ocument); 114 ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), d ocument);
115 ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), docum ent); 115 ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), docum ent);
116 116
117 if (!cachedFromImage || !cachedToImage) 117 if (!cachedFromImage || !cachedToImage)
118 return IntSize(); 118 return IntSize();
119 119
120 IntSize fromImageSize = cachedFromImage->imageForLayoutObject(renderer)->siz e(); 120 IntSize fromImageSize = cachedFromImage->imageForLayoutObject(layoutObject)- >size();
121 IntSize toImageSize = cachedToImage->imageForLayoutObject(renderer)->size(); 121 IntSize toImageSize = cachedToImage->imageForLayoutObject(layoutObject)->siz e();
122 122
123 // Rounding issues can cause transitions between images of equal size to ret urn 123 // Rounding issues can cause transitions between images of equal size to ret urn
124 // a different fixed size; avoid performing the interpolation if the images are the same size. 124 // a different fixed size; avoid performing the interpolation if the images are the same size.
125 if (fromImageSize == toImageSize) 125 if (fromImageSize == toImageSize)
126 return fromImageSize; 126 return fromImageSize;
127 127
128 return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width () * percentage, 128 return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width () * percentage,
129 fromImageSize.height() * inversePercentage + toImageSize.height() * perc entage); 129 fromImageSize.height() * inversePercentage + toImageSize.height() * perc entage);
130 } 130 }
131 131
132 bool CSSCrossfadeValue::isPending() const 132 bool CSSCrossfadeValue::isPending() const
133 { 133 {
134 return subimageIsPending(m_fromValue.get()) || subimageIsPending(m_toValue.g et()); 134 return subimageIsPending(m_fromValue.get()) || subimageIsPending(m_toValue.g et());
135 } 135 }
136 136
137 bool CSSCrossfadeValue::knownToBeOpaque(const LayoutObject* renderer) const 137 bool CSSCrossfadeValue::knownToBeOpaque(const LayoutObject* layoutObject) const
138 { 138 {
139 return subimageKnownToBeOpaque(m_fromValue.get(), renderer) && subimageKnown ToBeOpaque(m_toValue.get(), renderer); 139 return subimageKnownToBeOpaque(m_fromValue.get(), layoutObject) && subimageK nownToBeOpaque(m_toValue.get(), layoutObject);
140 } 140 }
141 141
142 void CSSCrossfadeValue::loadSubimages(Document* document) 142 void CSSCrossfadeValue::loadSubimages(Document* document)
143 { 143 {
144 ResourcePtr<ImageResource> oldCachedFromImage = m_cachedFromImage; 144 ResourcePtr<ImageResource> oldCachedFromImage = m_cachedFromImage;
145 ResourcePtr<ImageResource> oldCachedToImage = m_cachedToImage; 145 ResourcePtr<ImageResource> oldCachedToImage = m_cachedToImage;
146 146
147 m_cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document); 147 m_cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document);
148 m_cachedToImage = cachedImageForCSSValue(m_toValue.get(), document); 148 m_cachedToImage = cachedImageForCSSValue(m_toValue.get(), document);
149 149
150 if (m_cachedFromImage != oldCachedFromImage) { 150 if (m_cachedFromImage != oldCachedFromImage) {
151 if (oldCachedFromImage) 151 if (oldCachedFromImage)
152 oldCachedFromImage->removeClient(&m_crossfadeSubimageObserver); 152 oldCachedFromImage->removeClient(&m_crossfadeSubimageObserver);
153 if (m_cachedFromImage) 153 if (m_cachedFromImage)
154 m_cachedFromImage->addClient(&m_crossfadeSubimageObserver); 154 m_cachedFromImage->addClient(&m_crossfadeSubimageObserver);
155 } 155 }
156 156
157 if (m_cachedToImage != oldCachedToImage) { 157 if (m_cachedToImage != oldCachedToImage) {
158 if (oldCachedToImage) 158 if (oldCachedToImage)
159 oldCachedToImage->removeClient(&m_crossfadeSubimageObserver); 159 oldCachedToImage->removeClient(&m_crossfadeSubimageObserver);
160 if (m_cachedToImage) 160 if (m_cachedToImage)
161 m_cachedToImage->addClient(&m_crossfadeSubimageObserver); 161 m_cachedToImage->addClient(&m_crossfadeSubimageObserver);
162 } 162 }
163 163
164 m_crossfadeSubimageObserver.setReady(true); 164 m_crossfadeSubimageObserver.setReady(true);
165 } 165 }
166 166
167 PassRefPtr<Image> CSSCrossfadeValue::image(LayoutObject* renderer, const IntSize & size) 167 PassRefPtr<Image> CSSCrossfadeValue::image(LayoutObject* layoutObject, const Int Size& size)
168 { 168 {
169 if (size.isEmpty()) 169 if (size.isEmpty())
170 return nullptr; 170 return nullptr;
171 171
172 Document* document = &renderer->document(); 172 Document* document = &layoutObject->document();
173 ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), d ocument); 173 ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), d ocument);
174 ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), docum ent); 174 ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), docum ent);
175 175
176 if (!cachedFromImage || !cachedToImage) 176 if (!cachedFromImage || !cachedToImage)
177 return Image::nullImage(); 177 return Image::nullImage();
178 178
179 Image* fromImage = cachedFromImage->imageForLayoutObject(renderer); 179 Image* fromImage = cachedFromImage->imageForLayoutObject(layoutObject);
180 Image* toImage = cachedToImage->imageForLayoutObject(renderer); 180 Image* toImage = cachedToImage->imageForLayoutObject(layoutObject);
181 181
182 if (!fromImage || !toImage) 182 if (!fromImage || !toImage)
183 return Image::nullImage(); 183 return Image::nullImage();
184 184
185 m_generatedImage = CrossfadeGeneratedImage::create(fromImage, toImage, m_per centageValue->getFloatValue(), fixedSize(renderer), size); 185 m_generatedImage = CrossfadeGeneratedImage::create(fromImage, toImage, m_per centageValue->getFloatValue(), fixedSize(layoutObject), size);
186 186
187 return m_generatedImage.release(); 187 return m_generatedImage.release();
188 } 188 }
189 189
190 void CSSCrossfadeValue::crossfadeChanged(const IntRect&) 190 void CSSCrossfadeValue::crossfadeChanged(const IntRect&)
191 { 191 {
192 for (const auto& curr : clients()) { 192 for (const auto& curr : clients()) {
193 LayoutObject* client = const_cast<LayoutObject*>(curr.key); 193 LayoutObject* client = const_cast<LayoutObject*>(curr.key);
194 client->imageChanged(static_cast<WrappedImagePtr>(this)); 194 client->imageChanged(static_cast<WrappedImagePtr>(this));
195 } 195 }
(...skipping 23 matching lines...) Expand all
219 219
220 DEFINE_TRACE_AFTER_DISPATCH(CSSCrossfadeValue) 220 DEFINE_TRACE_AFTER_DISPATCH(CSSCrossfadeValue)
221 { 221 {
222 visitor->trace(m_fromValue); 222 visitor->trace(m_fromValue);
223 visitor->trace(m_toValue); 223 visitor->trace(m_toValue);
224 visitor->trace(m_percentageValue); 224 visitor->trace(m_percentageValue);
225 CSSImageGeneratorValue::traceAfterDispatch(visitor); 225 CSSImageGeneratorValue::traceAfterDispatch(visitor);
226 } 226 }
227 227
228 } // namespace blink 228 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSDefaultStyleSheets.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698