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

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

Issue 2941533002: Break StyleImage dependency on LayoutObject (Closed)
Patch Set: Address reviewer comments Created 3 years, 6 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (cached_to_image_ != old_cached_to_image) { 212 if (cached_to_image_ != old_cached_to_image) {
213 if (old_cached_to_image) 213 if (old_cached_to_image)
214 old_cached_to_image->RemoveObserver(&crossfade_subimage_observer_); 214 old_cached_to_image->RemoveObserver(&crossfade_subimage_observer_);
215 if (cached_to_image_) 215 if (cached_to_image_)
216 cached_to_image_->AddObserver(&crossfade_subimage_observer_); 216 cached_to_image_->AddObserver(&crossfade_subimage_observer_);
217 } 217 }
218 218
219 crossfade_subimage_observer_.SetReady(true); 219 crossfade_subimage_observer_.SetReady(true);
220 } 220 }
221 221
222 PassRefPtr<Image> CSSCrossfadeValue::GetImage(const LayoutObject& layout_object, 222 PassRefPtr<Image> CSSCrossfadeValue::GetImage(
223 const IntSize& size) { 223 const ImageResourceObserver& client,
224 const Document& document,
225 const ComputedStyle&,
226 const IntSize& size) {
224 if (size.IsEmpty()) 227 if (size.IsEmpty())
225 return nullptr; 228 return nullptr;
226 229
227 const Document& document = layout_object.GetDocument();
228 Image* from_image = RenderableImageForCSSValue(from_value_.Get(), document); 230 Image* from_image = RenderableImageForCSSValue(from_value_.Get(), document);
229 Image* to_image = RenderableImageForCSSValue(to_value_.Get(), document); 231 Image* to_image = RenderableImageForCSSValue(to_value_.Get(), document);
230 232
231 if (!from_image || !to_image) 233 if (!from_image || !to_image)
232 return Image::NullImage(); 234 return Image::NullImage();
233 235
234 RefPtr<Image> from_image_ref(from_image); 236 RefPtr<Image> from_image_ref(from_image);
235 RefPtr<Image> to_image_ref(to_image); 237 RefPtr<Image> to_image_ref(to_image);
236 238
237 if (from_image->IsSVGImage()) 239 if (from_image->IsSVGImage())
238 from_image_ref = SVGImageForContainer::Create( 240 from_image_ref = SVGImageForContainer::Create(
239 ToSVGImage(from_image), size, 1, UrlForCSSValue(from_value_.Get())); 241 ToSVGImage(from_image), size, 1, UrlForCSSValue(from_value_.Get()));
240 242
241 if (to_image->IsSVGImage()) 243 if (to_image->IsSVGImage())
242 to_image_ref = SVGImageForContainer::Create( 244 to_image_ref = SVGImageForContainer::Create(
243 ToSVGImage(to_image), size, 1, UrlForCSSValue(to_value_.Get())); 245 ToSVGImage(to_image), size, 1, UrlForCSSValue(to_value_.Get()));
244 246
245 return CrossfadeGeneratedImage::Create( 247 return CrossfadeGeneratedImage::Create(
246 from_image_ref, to_image_ref, percentage_value_->GetFloatValue(), 248 from_image_ref, to_image_ref, percentage_value_->GetFloatValue(),
247 FixedSize(document, FloatSize(size)), size); 249 FixedSize(document, FloatSize(size)), size);
248 } 250 }
249 251
250 void CSSCrossfadeValue::CrossfadeChanged(const IntRect&) { 252 void CSSCrossfadeValue::CrossfadeChanged(const IntRect&) {
251 for (const auto& curr : Clients()) { 253 for (const auto& curr : Clients()) {
252 LayoutObject* client = const_cast<LayoutObject*>(curr.key); 254 ImageResourceObserver* client =
255 const_cast<ImageResourceObserver*>(curr.key);
253 client->ImageChanged(static_cast<WrappedImagePtr>(this)); 256 client->ImageChanged(static_cast<WrappedImagePtr>(this));
254 } 257 }
255 } 258 }
256 259
257 bool CSSCrossfadeValue::WillRenderImage() const { 260 bool CSSCrossfadeValue::WillRenderImage() const {
258 for (const auto& curr : Clients()) { 261 for (const auto& curr : Clients()) {
259 if (const_cast<LayoutObject*>(curr.key)->WillRenderImage()) 262 if (const_cast<ImageResourceObserver*>(curr.key)->WillRenderImage())
260 return true; 263 return true;
261 } 264 }
262 return false; 265 return false;
263 } 266 }
264 267
265 void CSSCrossfadeValue::CrossfadeSubimageObserverProxy::ImageChanged( 268 void CSSCrossfadeValue::CrossfadeSubimageObserverProxy::ImageChanged(
266 ImageResourceContent*, 269 ImageResourceContent*,
267 const IntRect* rect) { 270 const IntRect* rect) {
268 if (ready_) 271 if (ready_)
269 owner_value_->CrossfadeChanged(*rect); 272 owner_value_->CrossfadeChanged(*rect);
(...skipping 23 matching lines...) Expand all
293 visitor->Trace(from_value_); 296 visitor->Trace(from_value_);
294 visitor->Trace(to_value_); 297 visitor->Trace(to_value_);
295 visitor->Trace(percentage_value_); 298 visitor->Trace(percentage_value_);
296 visitor->Trace(cached_from_image_); 299 visitor->Trace(cached_from_image_);
297 visitor->Trace(cached_to_image_); 300 visitor->Trace(cached_to_image_);
298 visitor->Trace(crossfade_subimage_observer_); 301 visitor->Trace(crossfade_subimage_observer_);
299 CSSImageGeneratorValue::TraceAfterDispatch(visitor); 302 CSSImageGeneratorValue::TraceAfterDispatch(visitor);
300 } 303 }
301 304
302 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCrossfadeValue.h ('k') | third_party/WebKit/Source/core/css/CSSGradientValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698