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

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

Issue 1458083002: Support fragment URLs for more kinds of SVG images (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplification wasn't simple enough 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/dom/Element.h"
32 #include "core/layout/LayoutImage.h" 32 #include "core/layout/LayoutImage.h"
33 #include "core/svg/graphics/SVGImageForContainer.h" 33 #include "core/svg/graphics/SVGImageForContainer.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 LayoutImageResource::LayoutImageResource() 37 LayoutImageResource::LayoutImageResource()
38 : m_layoutObject(nullptr) 38 : m_layoutObject(nullptr)
39 , m_cachedImage(nullptr) 39 , m_cachedImage(nullptr)
40 { 40 {
41 } 41 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 LayoutSize size = m_cachedImage->imageSizeForLayoutObject(m_layoutObject, mu ltiplier, ImageResource::IntrinsicSize); 97 LayoutSize size = m_cachedImage->imageSizeForLayoutObject(m_layoutObject, mu ltiplier, ImageResource::IntrinsicSize);
98 if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && siz e.height()) 98 if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && siz e.height())
99 size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio()); 99 size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio());
100 return size; 100 return size;
101 } 101 }
102 102
103 PassRefPtr<Image> LayoutImageResource::image(const IntSize& containerSize, float zoom) const 103 PassRefPtr<Image> LayoutImageResource::image(const IntSize& containerSize, float zoom) const
104 { 104 {
105 RefPtr<Image> image = m_cachedImage ? m_cachedImage->image() : Image::nullIm age(); 105 RefPtr<Image> image = m_cachedImage ? m_cachedImage->image() : Image::nullIm age();
106 if (image->isSVGImage()) { 106 if (image->isSVGImage()) {
107 KURL url;
107 SVGImage* svgImage = toSVGImage(image.get()); 108 SVGImage* svgImage = toSVGImage(image.get());
108 Node* node = m_layoutObject->node(); 109 Node* node = m_layoutObject->node();
109 if (node && isHTMLImageElement(node)) { 110 if (node && node->isElementNode()) {
110 const AtomicString& urlString = toHTMLImageElement(node)->imageSourc eURL(); 111 const AtomicString& urlString = toElement(node)->imageSourceURL();
111 KURL url = node->document().completeURL(urlString); 112 url = node->document().completeURL(urlString);
112 svgImage->setURL(url);
113 } 113 }
114 return SVGImageForContainer::create(svgImage, containerSize, zoom); 114 return SVGImageForContainer::create(svgImage, containerSize, zoom, url);
115 } 115 }
116 return image; 116 return image;
117 } 117 }
118 118
119 bool LayoutImageResource::maybeAnimated() const 119 bool LayoutImageResource::maybeAnimated() const
120 { 120 {
121 Image* image = m_cachedImage ? m_cachedImage->image() : Image::nullImage(); 121 Image* image = m_cachedImage ? m_cachedImage->image() : Image::nullImage();
122 return image->maybeAnimated(); 122 return image->maybeAnimated();
123 } 123 }
124 124
125 } // namespace blink 125 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageValue.cpp ('k') | third_party/WebKit/Source/core/style/StyleFetchedImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698