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

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

Issue 1756763004: Merge image sizing algorithms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unused variable 'styleImage' in release Created 4 years, 9 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
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 152 {
153 RefPtrWillBeRawPtr<CSSValue> fromValue = m_fromValue; 153 RefPtrWillBeRawPtr<CSSValue> fromValue = m_fromValue;
154 if (m_fromValue->isImageValue()) 154 if (m_fromValue->isImageValue())
155 fromValue = toCSSImageValue(*m_fromValue).valueWithURLMadeAbsolute(); 155 fromValue = toCSSImageValue(*m_fromValue).valueWithURLMadeAbsolute();
156 RefPtrWillBeRawPtr<CSSValue> toValue = m_toValue; 156 RefPtrWillBeRawPtr<CSSValue> toValue = m_toValue;
157 if (m_toValue->isImageValue()) 157 if (m_toValue->isImageValue())
158 toValue = toCSSImageValue(*m_toValue).valueWithURLMadeAbsolute(); 158 toValue = toCSSImageValue(*m_toValue).valueWithURLMadeAbsolute();
159 return CSSCrossfadeValue::create(fromValue.release(), toValue.release(), m_p ercentageValue); 159 return CSSCrossfadeValue::create(fromValue.release(), toValue.release(), m_p ercentageValue);
160 } 160 }
161 161
162 IntSize CSSCrossfadeValue::fixedSize(const LayoutObject* layoutObject) 162 IntSize CSSCrossfadeValue::fixedSize(const LayoutObject* layoutObject, const Flo atSize& defaultObjectSize)
163 { 163 {
164 Image* fromImage = renderableImageForCSSValue(m_fromValue.get(), layoutObjec t); 164 Image* fromImage = renderableImageForCSSValue(m_fromValue.get(), layoutObjec t);
165 Image* toImage = renderableImageForCSSValue(m_toValue.get(), layoutObject); 165 Image* toImage = renderableImageForCSSValue(m_toValue.get(), layoutObject);
166 166
167 if (!fromImage || !toImage) 167 if (!fromImage || !toImage)
168 return IntSize(); 168 return IntSize();
169 169
170 IntSize fromImageSize = fromImage->size(); 170 IntSize fromImageSize = fromImage->size();
171 IntSize toImageSize = toImage->size(); 171 IntSize toImageSize = toImage->size();
172 172
173 if (fromImage->isSVGImage())
174 fromImageSize = roundedIntSize(toSVGImage(fromImage)->concreteObjectSize (defaultObjectSize));
175
176 if (toImage->isSVGImage())
177 toImageSize = roundedIntSize(toSVGImage(toImage)->concreteObjectSize(def aultObjectSize));
178
173 // Rounding issues can cause transitions between images of equal size to ret urn 179 // Rounding issues can cause transitions between images of equal size to ret urn
174 // a different fixed size; avoid performing the interpolation if the images are the same size. 180 // a different fixed size; avoid performing the interpolation if the images are the same size.
175 if (fromImageSize == toImageSize) 181 if (fromImageSize == toImageSize)
176 return fromImageSize; 182 return fromImageSize;
177 183
178 float percentage = m_percentageValue->getFloatValue(); 184 float percentage = m_percentageValue->getFloatValue();
179 float inversePercentage = 1 - percentage; 185 float inversePercentage = 1 - percentage;
180 186
181 return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width () * percentage, 187 return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width () * percentage,
182 fromImageSize.height() * inversePercentage + toImageSize.height() * perc entage); 188 fromImageSize.height() * inversePercentage + toImageSize.height() * perc entage);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 236
231 RefPtr<Image> fromImageRef(fromImage); 237 RefPtr<Image> fromImageRef(fromImage);
232 RefPtr<Image> toImageRef(toImage); 238 RefPtr<Image> toImageRef(toImage);
233 239
234 if (fromImage->isSVGImage()) 240 if (fromImage->isSVGImage())
235 fromImageRef = SVGImageForContainer::create(toSVGImage(fromImage), size, 1, urlForCSSValue(m_fromValue.get())); 241 fromImageRef = SVGImageForContainer::create(toSVGImage(fromImage), size, 1, urlForCSSValue(m_fromValue.get()));
236 242
237 if (toImage->isSVGImage()) 243 if (toImage->isSVGImage())
238 toImageRef = SVGImageForContainer::create(toSVGImage(toImage), size, 1, urlForCSSValue(m_toValue.get())); 244 toImageRef = SVGImageForContainer::create(toSVGImage(toImage), size, 1, urlForCSSValue(m_toValue.get()));
239 245
240 m_generatedImage = CrossfadeGeneratedImage::create(fromImageRef, toImageRef, m_percentageValue->getFloatValue(), fixedSize(layoutObject), size); 246 m_generatedImage = CrossfadeGeneratedImage::create(fromImageRef, toImageRef, m_percentageValue->getFloatValue(), fixedSize(layoutObject, FloatSize(size)), s ize);
241 247
242 return m_generatedImage.release(); 248 return m_generatedImage.release();
243 } 249 }
244 250
245 void CSSCrossfadeValue::crossfadeChanged(const IntRect&) 251 void CSSCrossfadeValue::crossfadeChanged(const IntRect&)
246 { 252 {
247 for (const auto& curr : clients()) { 253 for (const auto& curr : clients()) {
248 LayoutObject* client = const_cast<LayoutObject*>(curr.key); 254 LayoutObject* client = const_cast<LayoutObject*>(curr.key);
249 client->imageChanged(static_cast<WrappedImagePtr>(this)); 255 client->imageChanged(static_cast<WrappedImagePtr>(this));
250 } 256 }
(...skipping 26 matching lines...) Expand all
277 visitor->trace(m_fromValue); 283 visitor->trace(m_fromValue);
278 visitor->trace(m_toValue); 284 visitor->trace(m_toValue);
279 visitor->trace(m_percentageValue); 285 visitor->trace(m_percentageValue);
280 visitor->trace(m_cachedFromImage); 286 visitor->trace(m_cachedFromImage);
281 visitor->trace(m_cachedToImage); 287 visitor->trace(m_cachedToImage);
282 visitor->trace(m_crossfadeSubimageObserver); 288 visitor->trace(m_crossfadeSubimageObserver);
283 CSSImageGeneratorValue::traceAfterDispatch(visitor); 289 CSSImageGeneratorValue::traceAfterDispatch(visitor);
284 } 290 }
285 291
286 } // namespace blink 292 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCrossfadeValue.h ('k') | third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698