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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutImageResource.cpp

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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) 1999 Lars Knoll <knoll@kde.org> 2 * Copyright (C) 1999 Lars Knoll <knoll@kde.org>
3 * Copyright (C) 1999 Antti Koivisto <koivisto@kde.org> 3 * Copyright (C) 1999 Antti Koivisto <koivisto@kde.org>
4 * Copyright (C) 2000 Dirk Mueller <mueller@kde.org> 4 * Copyright (C) 2000 Dirk Mueller <mueller@kde.org>
5 * Copyright (C) 2006 Allan Sandfeld Jensen <kde@carewolf.com> 5 * Copyright (C) 2006 Allan Sandfeld Jensen <kde@carewolf.com>
6 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 6 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 9 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
10 * 10 *
(...skipping 18 matching lines...) Expand all
29 29
30 #include "core/dom/Element.h" 30 #include "core/dom/Element.h"
31 #include "core/layout/LayoutImage.h" 31 #include "core/layout/LayoutImage.h"
32 #include "core/svg/graphics/SVGImageForContainer.h" 32 #include "core/svg/graphics/SVGImageForContainer.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 LayoutImageResource::LayoutImageResource() 36 LayoutImageResource::LayoutImageResource()
37 : m_layoutObject(nullptr) 37 : m_layoutObject(nullptr)
38 , m_cachedImage(nullptr) 38 , m_cachedImage(nullptr)
39 , m_client(nullptr)
39 { 40 {
40 } 41 }
41 42
42 LayoutImageResource::~LayoutImageResource() 43 LayoutImageResource::~LayoutImageResource()
43 { 44 {
44 } 45 }
45 46
46 void LayoutImageResource::initialize(LayoutObject* layoutObject) 47 void LayoutImageResource::initialize(LayoutObject* layoutObject, ResourceClient* client)
47 { 48 {
48 ASSERT(!m_layoutObject); 49 ASSERT(!m_layoutObject);
49 ASSERT(layoutObject); 50 ASSERT(layoutObject);
50 m_layoutObject = layoutObject; 51 m_layoutObject = layoutObject;
52 m_client = client;
51 } 53 }
52 54
53 void LayoutImageResource::shutdown() 55 void LayoutImageResource::shutdown()
54 { 56 {
55 ASSERT(m_layoutObject); 57 ASSERT(m_layoutObject);
56 58
57 if (m_cachedImage) 59 if (!m_cachedImage)
58 m_cachedImage->removeClient(m_layoutObject); 60 return;
61 if (m_client)
62 m_cachedImage->removeClient(m_client);
63 m_cachedImage->removeObserver(m_layoutObject);
59 } 64 }
60 65
61 void LayoutImageResource::setImageResource(ImageResource* newImage) 66 void LayoutImageResource::setImageResource(ImageResource* newImage)
62 { 67 {
63 ASSERT(m_layoutObject); 68 ASSERT(m_layoutObject);
64 69
65 if (m_cachedImage == newImage) 70 if (m_cachedImage == newImage)
66 return; 71 return;
67 72
68 if (m_cachedImage) 73 if (m_cachedImage) {
69 m_cachedImage->removeClient(m_layoutObject); 74 if (m_client)
75 m_cachedImage->removeClient(m_client);
76 m_cachedImage->removeObserver(m_layoutObject);
77 }
70 m_cachedImage = newImage; 78 m_cachedImage = newImage;
71 if (m_cachedImage) { 79 if (m_cachedImage) {
72 m_cachedImage->addClient(m_layoutObject); 80 if (m_client)
81 m_cachedImage->addClient(m_client);
82 m_cachedImage->addObserver(m_layoutObject);
73 if (m_cachedImage->errorOccurred()) 83 if (m_cachedImage->errorOccurred())
74 m_layoutObject->imageChanged(m_cachedImage.get()); 84 m_layoutObject->imageChanged(m_cachedImage.get());
75 } else { 85 } else {
76 m_layoutObject->imageChanged(m_cachedImage.get()); 86 m_layoutObject->imageChanged(m_cachedImage.get());
77 } 87 }
78 } 88 }
79 89
80 void LayoutImageResource::resetAnimation() 90 void LayoutImageResource::resetAnimation()
81 { 91 {
82 ASSERT(m_layoutObject); 92 ASSERT(m_layoutObject);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return SVGImageForContainer::create(svgImage, containerSize, zoom, url); 127 return SVGImageForContainer::create(svgImage, containerSize, zoom, url);
118 } 128 }
119 129
120 bool LayoutImageResource::maybeAnimated() const 130 bool LayoutImageResource::maybeAnimated() const
121 { 131 {
122 Image* image = m_cachedImage ? m_cachedImage->getImage() : Image::nullImage( ); 132 Image* image = m_cachedImage ? m_cachedImage->getImage() : Image::nullImage( );
123 return image->maybeAnimated(); 133 return image->maybeAnimated();
124 } 134 }
125 135
126 } // namespace blink 136 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698