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

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

Issue 13008026: Merge 146227 "Separate SVG image size and container size" (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 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
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.h ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 Frame* frame = m_page->mainFrame(); 68 Frame* frame = m_page->mainFrame();
69 SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->r ootElement(); 69 SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->r ootElement();
70 if (!rootElement) 70 if (!rootElement)
71 return; 71 return;
72 RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer()); 72 RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
73 if (!renderer) 73 if (!renderer)
74 return; 74 return;
75 75
76 FrameView* view = frameView(); 76 FrameView* view = frameView();
77 view->resize(this->size()); 77 view->resize(this->containerSize());
78 78
79 renderer->setContainerSize(size); 79 renderer->setContainerSize(size);
80 } 80 }
81 81
82 IntSize SVGImage::size() const 82 IntSize SVGImage::containerSize() const
83 { 83 {
84 if (!m_page) 84 if (!m_page)
85 return IntSize(); 85 return IntSize();
86 Frame* frame = m_page->mainFrame(); 86 Frame* frame = m_page->mainFrame();
87 SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->r ootElement(); 87 SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->r ootElement();
88 if (!rootElement) 88 if (!rootElement)
89 return IntSize(); 89 return IntSize();
90 90
91 RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer()); 91 RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
92 if (!renderer) 92 if (!renderer)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height()); 185 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height());
186 186
187 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left 187 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left
188 // of the image would be if we were drawing without clipping, and translate accordingly. 188 // of the image would be if we were drawing without clipping, and translate accordingly.
189 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height()); 189 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height());
190 FloatPoint destOffset = dstRect.location() - topLeftOffset; 190 FloatPoint destOffset = dstRect.location() - topLeftOffset;
191 191
192 context->translate(destOffset.x(), destOffset.y()); 192 context->translate(destOffset.x(), destOffset.y());
193 context->scale(scale); 193 context->scale(scale);
194 194
195 view->resize(size()); 195 view->resize(containerSize());
196 196
197 if (view->needsLayout()) 197 if (view->needsLayout())
198 view->layout(); 198 view->layout();
199 199
200 view->paint(context, IntRect(0, 0, view->width(), view->height())); 200 view->paint(context, IntRect(0, 0, view->width(), view->height()));
201 201
202 if (compositeOp != CompositeSourceOver) 202 if (compositeOp != CompositeSourceOver)
203 context->endTransparencyLayer(); 203 context->endTransparencyLayer();
204 204
205 stateSaver.restore(); 205 stateSaver.restore();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 loader->forceSandboxFlags(SandboxAll); 329 loader->forceSandboxFlags(SandboxAll);
330 330
331 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy nthesize a viewBox, if it's not available, and thus never see scrollbars. 331 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy nthesize a viewBox, if it's not available, and thus never see scrollbars.
332 frame->view()->setTransparent(true); // SVG Images are transparent. 332 frame->view()->setTransparent(true); // SVG Images are transparent.
333 333
334 ASSERT(loader->activeDocumentLoader()); // DocumentLoader should have be en created by frame->init(). 334 ASSERT(loader->activeDocumentLoader()); // DocumentLoader should have be en created by frame->init().
335 loader->activeDocumentLoader()->writer()->setMIMEType("image/svg+xml"); 335 loader->activeDocumentLoader()->writer()->setMIMEType("image/svg+xml");
336 loader->activeDocumentLoader()->writer()->begin(KURL()); // create the e mpty document 336 loader->activeDocumentLoader()->writer()->begin(KURL()); // create the e mpty document
337 loader->activeDocumentLoader()->writer()->addData(data()->data(), data() ->size()); 337 loader->activeDocumentLoader()->writer()->addData(data()->data(), data() ->size());
338 loader->activeDocumentLoader()->writer()->end(); 338 loader->activeDocumentLoader()->writer()->end();
339
340 // Set the intrinsic size before a container size is available.
341 m_intrinsicSize = containerSize();
339 } 342 }
340 343
341 return m_page; 344 return m_page;
342 } 345 }
343 346
344 String SVGImage::filenameExtension() const 347 String SVGImage::filenameExtension() const
345 { 348 {
346 return "svg"; 349 return "svg";
347 } 350 }
348 351
349 void SVGImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 352 void SVGImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
350 { 353 {
351 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage); 354 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage);
352 Image::reportMemoryUsage(memoryObjectInfo); 355 Image::reportMemoryUsage(memoryObjectInfo);
353 info.addMember(m_chromeClient, "chromeClient"); 356 info.addMember(m_chromeClient, "chromeClient");
354 info.addMember(m_page, "page"); 357 info.addMember(m_page, "page");
355 } 358 }
356 359
357 } 360 }
358 361
359 #endif // ENABLE(SVG) 362 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.h ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698