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

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

Issue 179293004: Drive SVG Animations via requestAnimationFrame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use AnimationClock. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/graphics/SVGImage.h ('k') | Source/core/svg/graphics/SVGImageChromeClient.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 24 matching lines...) Expand all
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
37 #include "core/loader/FrameLoadRequest.h" 37 #include "core/loader/FrameLoadRequest.h"
38 #include "core/page/Chrome.h" 38 #include "core/page/Chrome.h"
39 #include "core/rendering/style/RenderStyle.h" 39 #include "core/rendering/style/RenderStyle.h"
40 #include "core/rendering/svg/RenderSVGRoot.h" 40 #include "core/rendering/svg/RenderSVGRoot.h"
41 #include "core/svg/SVGDocument.h" 41 #include "core/svg/SVGDocument.h"
42 #include "core/svg/SVGFEImageElement.h" 42 #include "core/svg/SVGFEImageElement.h"
43 #include "core/svg/SVGImageElement.h" 43 #include "core/svg/SVGImageElement.h"
44 #include "core/svg/SVGSVGElement.h" 44 #include "core/svg/SVGSVGElement.h"
45 #include "core/svg/animation/SMILTimeContainer.h"
45 #include "core/svg/graphics/SVGImageChromeClient.h" 46 #include "core/svg/graphics/SVGImageChromeClient.h"
46 #include "platform/LengthFunctions.h" 47 #include "platform/LengthFunctions.h"
47 #include "platform/geometry/IntRect.h" 48 #include "platform/geometry/IntRect.h"
48 #include "platform/graphics/GraphicsContextStateSaver.h" 49 #include "platform/graphics/GraphicsContextStateSaver.h"
49 #include "platform/graphics/ImageBuffer.h" 50 #include "platform/graphics/ImageBuffer.h"
50 #include "platform/graphics/ImageObserver.h" 51 #include "platform/graphics/ImageObserver.h"
51 #include "wtf/PassRefPtr.h" 52 #include "wtf/PassRefPtr.h"
52 53
53 namespace WebCore { 54 namespace WebCore {
54 55
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (!rootElement) 365 if (!rootElement)
365 return; 366 return;
366 rootElement->pauseAnimations(); 367 rootElement->pauseAnimations();
367 } 368 }
368 369
369 void SVGImage::resetAnimation() 370 void SVGImage::resetAnimation()
370 { 371 {
371 stopAnimation(); 372 stopAnimation();
372 } 373 }
373 374
375 bool SVGImage::hasAnimations() const
376 {
377 if (!m_page)
378 return false;
379 LocalFrame* frame = m_page->mainFrame();
380 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
381 if (!rootElement)
382 return false;
383 return rootElement->timeContainer()->hasAnimations();
384 }
385
374 bool SVGImage::dataChanged(bool allDataReceived) 386 bool SVGImage::dataChanged(bool allDataReceived)
375 { 387 {
376 TRACE_EVENT0("webkit", "SVGImage::dataChanged"); 388 TRACE_EVENT0("webkit", "SVGImage::dataChanged");
377 389
378 // Don't do anything if is an empty image. 390 // Don't do anything if is an empty image.
379 if (!data()->size()) 391 if (!data()->size())
380 return true; 392 return true;
381 393
382 if (allDataReceived) { 394 if (allDataReceived) {
383 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderC lient; 395 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderC lient;
384 396
385 Page::PageClients pageClients; 397 Page::PageClients pageClients;
386 fillWithEmptyClients(pageClients); 398 fillWithEmptyClients(pageClients);
387 m_chromeClient = adoptPtr(new SVGImageChromeClient(this)); 399 m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
388 pageClients.chromeClient = m_chromeClient.get(); 400 pageClients.chromeClient = m_chromeClient.get();
389 401
390 // FIXME: If this SVG ends up loading itself, we might leak the world. 402 // FIXME: If this SVG ends up loading itself, we might leak the world.
391 // The Cache code does not know about ImageResources holding Frames and 403 // The Cache code does not know about ImageResources holding Frames and
392 // won't know to break the cycle. 404 // won't know to break the cycle.
393 // This will become an issue when SVGImage will be able to load other 405 // This will become an issue when SVGImage will be able to load other
394 // SVGImage objects, but we're safe now, because SVGImage can only be 406 // SVGImage objects, but we're safe now, because SVGImage can only be
395 // loaded by a top-level document. 407 // loaded by a top-level document.
396 m_page = adoptPtr(new Page(pageClients)); 408 OwnPtr<Page> page = adoptPtr(new Page(pageClients));
397 m_page->settings().setScriptEnabled(false); 409 page->settings().setScriptEnabled(false);
398 m_page->settings().setPluginsEnabled(false); 410 page->settings().setPluginsEnabled(false);
399 m_page->settings().setAcceleratedCompositingEnabled(false); 411 page->settings().setAcceleratedCompositingEnabled(false);
400 412
401 RefPtr<LocalFrame> frame = LocalFrame::create(FrameInit::create(&m_page- >frameHost(), dummyFrameLoaderClient)); 413 RefPtr<LocalFrame> frame = LocalFrame::create(FrameInit::create(&page->f rameHost(), dummyFrameLoaderClient));
402 frame->setView(FrameView::create(frame.get())); 414 frame->setView(FrameView::create(frame.get()));
403 frame->init(); 415 frame->init();
404 FrameLoader& loader = frame->loader(); 416 FrameLoader& loader = frame->loader();
405 loader.forceSandboxFlags(SandboxAll); 417 loader.forceSandboxFlags(SandboxAll);
406 418
407 frame->view()->setScrollbarsSuppressed(true); 419 frame->view()->setScrollbarsSuppressed(true);
408 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy nthesize a viewBox, if it's not available, and thus never see scrollbars. 420 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy nthesize a viewBox, if it's not available, and thus never see scrollbars.
409 frame->view()->setTransparent(true); // SVG Images are transparent. 421 frame->view()->setTransparent(true); // SVG Images are transparent.
410 422
423 m_page = page.release();
424
411 loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "imag e/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad))); 425 loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "imag e/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad)));
412 // Set the intrinsic size before a container size is available. 426 // Set the intrinsic size before a container size is available.
413 m_intrinsicSize = containerSize(); 427 m_intrinsicSize = containerSize();
414 } 428 }
415 429
416 return m_page; 430 return m_page;
417 } 431 }
418 432
419 String SVGImage::filenameExtension() const 433 String SVGImage::filenameExtension() const
420 { 434 {
421 return "svg"; 435 return "svg";
422 } 436 }
423 437
424 } 438 }
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/SVGImage.h ('k') | Source/core/svg/graphics/SVGImageChromeClient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698