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

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

Issue 1427943002: Wrap SVGImage for container during paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IntSize for SVGImageForContainer Created 5 years, 1 month 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 10 matching lines...) Expand all
21 * You should have received a copy of the GNU Library General Public License 21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to 22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA. 24 * Boston, MA 02110-1301, USA.
25 * 25 *
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/layout/LayoutImageResource.h" 29 #include "core/layout/LayoutImageResource.h"
30 30
31 #include "core/html/HTMLImageElement.h"
31 #include "core/layout/LayoutImage.h" 32 #include "core/layout/LayoutImage.h"
33 #include "core/svg/graphics/SVGImageForContainer.h"
32 34
33 namespace blink { 35 namespace blink {
34 36
35 LayoutImageResource::LayoutImageResource() 37 LayoutImageResource::LayoutImageResource()
36 : m_layoutObject(nullptr) 38 : m_layoutObject(nullptr)
37 , m_cachedImage(nullptr) 39 , m_cachedImage(nullptr)
38 { 40 {
39 } 41 }
40 42
41 LayoutImageResource::~LayoutImageResource() 43 LayoutImageResource::~LayoutImageResource()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 ASSERT(m_layoutObject); 83 ASSERT(m_layoutObject);
82 84
83 if (!m_cachedImage) 85 if (!m_cachedImage)
84 return; 86 return;
85 87
86 m_cachedImage->image()->resetAnimation(); 88 m_cachedImage->image()->resetAnimation();
87 89
88 m_layoutObject->setShouldDoFullPaintInvalidation(); 90 m_layoutObject->setShouldDoFullPaintInvalidation();
89 } 91 }
90 92
91 void LayoutImageResource::setContainerSizeForLayoutObject(const IntSize& imageCo ntainerSize) 93 LayoutSize LayoutImageResource::imageSize(float multiplier) const
92 {
93 ASSERT(m_layoutObject);
94 if (m_cachedImage)
95 m_cachedImage->setContainerSizeForLayoutObject(m_layoutObject, imageCont ainerSize, m_layoutObject->style()->effectiveZoom());
96 }
97
98 LayoutSize LayoutImageResource::getImageSize(float multiplier, ImageResource::Si zeType type) const
99 { 94 {
100 if (!m_cachedImage) 95 if (!m_cachedImage)
101 return LayoutSize(); 96 return LayoutSize();
102 LayoutSize size = m_cachedImage->imageSizeForLayoutObject(m_layoutObject, mu ltiplier, type); 97 LayoutSize size = m_cachedImage->imageSizeForLayoutObject(m_layoutObject, mu ltiplier, ImageResource::IntrinsicSize);
103 if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && siz e.height()) 98 if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && siz e.height())
104 size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio()); 99 size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio());
105 return size; 100 return size;
106 } 101 }
107 102
103 PassRefPtr<Image> LayoutImageResource::image(const IntSize& containerSize, float zoom) const
104 {
105 RefPtr<Image> image = m_cachedImage ? m_cachedImage->image() : Image::nullIm age();
106 if (image->isSVGImage()) {
107 SVGImage* svgImage = toSVGImage(image.get());
108 Node* node = m_layoutObject->node();
109 if (node && isHTMLImageElement(node)) {
110 const AtomicString& urlString = toHTMLImageElement(node)->imageSourc eURL();
111 KURL url = node->document().completeURL(urlString);
112 svgImage->setURL(url);
113 }
114 return SVGImageForContainer::create(svgImage, containerSize, zoom);
115 }
116 return image;
117 }
118
108 bool LayoutImageResource::maybeAnimated() const 119 bool LayoutImageResource::maybeAnimated() const
109 { 120 {
110 Image* image = m_cachedImage ? m_cachedImage->image() : Image::nullImage(); 121 Image* image = m_cachedImage ? m_cachedImage->image() : Image::nullImage();
111 return image->maybeAnimated(); 122 return image->maybeAnimated();
112 } 123 }
113 124
114 } // namespace blink 125 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698