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

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

Issue 26390004: Rework SVG sizing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix mishap during rebase in svg.css Created 6 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // If a container size is available it has precedence. 156 // If a container size is available it has precedence.
157 IntSize containerSize = renderer->containerSize(); 157 IntSize containerSize = renderer->containerSize();
158 if (!containerSize.isEmpty()) 158 if (!containerSize.isEmpty())
159 return containerSize; 159 return containerSize;
160 160
161 // Assure that a container size is always given for a non-identity zoom leve l. 161 // Assure that a container size is always given for a non-identity zoom leve l.
162 ASSERT(renderer->style()->effectiveZoom() == 1); 162 ASSERT(renderer->style()->effectiveZoom() == 1);
163 163
164 FloatSize currentSize; 164 FloatSize currentSize;
165 if (rootElement->intrinsicWidth().isFixed() && rootElement->intrinsicHeight( ).isFixed()) 165 if (rootElement->hasIntrinsicWidth() && rootElement->hasIntrinsicHeight())
166 currentSize = rootElement->currentViewportSize(); 166 currentSize = rootElement->currentViewportSize();
167 else 167 else
168 currentSize = rootElement->currentViewBoxRect().size(); 168 currentSize = rootElement->currentViewBoxRect().size();
169 169
170 if (!currentSize.isEmpty()) 170 if (!currentSize.isEmpty())
171 return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast <int>(ceilf(currentSize.height()))); 171 return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast <int>(ceilf(currentSize.height())));
172 172
173 // As last resort, use CSS default intrinsic size. 173 // As last resort, use CSS default intrinsic size.
174 return IntSize(300, 150); 174 return IntSize(300, 150);
175 } 175 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 FrameView* SVGImage::frameView() const 306 FrameView* SVGImage::frameView() const
307 { 307 {
308 if (!m_page) 308 if (!m_page)
309 return 0; 309 return 0;
310 310
311 return m_page->mainFrame()->view(); 311 return m_page->mainFrame()->view();
312 } 312 }
313 313
314 bool SVGImage::hasRelativeWidth() const
315 {
316 SVGSVGElement* rootElement = svgRootElement(m_page.get());
317 if (!rootElement)
318 return false;
319 return rootElement->intrinsicWidth().isPercent();
320 }
321
322 bool SVGImage::hasRelativeHeight() const
323 {
324 SVGSVGElement* rootElement = svgRootElement(m_page.get());
325 if (!rootElement)
326 return false;
327 return rootElement->intrinsicHeight().isPercent();
328 }
329
330 void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin sicHeight, FloatSize& intrinsicRatio) 314 void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin sicHeight, FloatSize& intrinsicRatio)
331 { 315 {
332 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 316 SVGSVGElement* rootElement = svgRootElement(m_page.get());
333 if (!rootElement) 317 if (!rootElement)
334 return; 318 return;
335 319
336 intrinsicWidth = rootElement->intrinsicWidth(); 320 intrinsicWidth = rootElement->intrinsicWidth();
337 intrinsicHeight = rootElement->intrinsicHeight(); 321 intrinsicHeight = rootElement->intrinsicHeight();
338 if (rootElement->preserveAspectRatio()->currentValue()->align() == SVGPreser veAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) 322 if (rootElement->preserveAspectRatio()->currentValue()->align() == SVGPreser veAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
339 return; 323 return;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 407
424 return m_page; 408 return m_page;
425 } 409 }
426 410
427 String SVGImage::filenameExtension() const 411 String SVGImage::filenameExtension() const
428 { 412 {
429 return "svg"; 413 return "svg";
430 } 414 }
431 415
432 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698