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

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 1890613002: Support createImageBitmap from a SVG image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments, update layout tests results Created 4 years, 8 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) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 static float resolveWidthForRatio(float height, const FloatSize& intrinsicRatio) 161 static float resolveWidthForRatio(float height, const FloatSize& intrinsicRatio)
162 { 162 {
163 return height * intrinsicRatio.width() / intrinsicRatio.height(); 163 return height * intrinsicRatio.width() / intrinsicRatio.height();
164 } 164 }
165 165
166 static float resolveHeightForRatio(float width, const FloatSize& intrinsicRatio) 166 static float resolveHeightForRatio(float width, const FloatSize& intrinsicRatio)
167 { 167 {
168 return width * intrinsicRatio.height() / intrinsicRatio.width(); 168 return width * intrinsicRatio.height() / intrinsicRatio.width();
169 } 169 }
170 170
171 bool SVGImage::hasIntrinsicSize()
172 {
173 SVGSVGElement* svg = svgRootElement(m_page.get());
174 if (!svg)
175 return false;
176
177 LayoutSVGRoot* layoutObject = toLayoutSVGRoot(svg->layoutObject());
178 if (!layoutObject)
179 return false;
180
181 LayoutReplaced::IntrinsicSizingInfo intrinsicSizingInfo;
182 layoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo);
183
184 if (intrinsicSizingInfo.hasWidth && intrinsicSizingInfo.hasHeight)
185 return true;
186 return false;
187 }
188
171 FloatSize SVGImage::concreteObjectSize(const FloatSize& defaultObjectSize) const 189 FloatSize SVGImage::concreteObjectSize(const FloatSize& defaultObjectSize) const
172 { 190 {
173 SVGSVGElement* svg = svgRootElement(m_page.get()); 191 SVGSVGElement* svg = svgRootElement(m_page.get());
174 if (!svg) 192 if (!svg)
175 return FloatSize(); 193 return FloatSize();
176 194
177 LayoutSVGRoot* layoutObject = toLayoutSVGRoot(svg->layoutObject()); 195 LayoutSVGRoot* layoutObject = toLayoutSVGRoot(svg->layoutObject());
178 if (!layoutObject) 196 if (!layoutObject)
179 return FloatSize(); 197 return FloatSize();
180 198
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 554
537 return m_page; 555 return m_page;
538 } 556 }
539 557
540 String SVGImage::filenameExtension() const 558 String SVGImage::filenameExtension() const
541 { 559 {
542 return "svg"; 560 return "svg";
543 } 561 }
544 562
545 } // namespace blink 563 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698