OLD | NEW |
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 Loading... |
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 if (!rootElement) | 410 if (!rootElement) |
410 return; | 411 return; |
411 rootElement->pauseAnimations(); | 412 rootElement->pauseAnimations(); |
412 } | 413 } |
413 | 414 |
414 void SVGImage::resetAnimation() | 415 void SVGImage::resetAnimation() |
415 { | 416 { |
416 stopAnimation(); | 417 stopAnimation(); |
417 } | 418 } |
418 | 419 |
| 420 bool SVGImage::hasAnimations() const |
| 421 { |
| 422 if (!m_page) |
| 423 return false; |
| 424 LocalFrame* frame = m_page->mainFrame(); |
| 425 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement()
; |
| 426 if (!rootElement) |
| 427 return false; |
| 428 return rootElement->timeContainer()->hasAnimations(); |
| 429 } |
| 430 |
419 bool SVGImage::dataChanged(bool allDataReceived) | 431 bool SVGImage::dataChanged(bool allDataReceived) |
420 { | 432 { |
421 TRACE_EVENT0("webkit", "SVGImage::dataChanged"); | 433 TRACE_EVENT0("webkit", "SVGImage::dataChanged"); |
422 | 434 |
423 // Don't do anything if is an empty image. | 435 // Don't do anything if is an empty image. |
424 if (!data()->size()) | 436 if (!data()->size()) |
425 return true; | 437 return true; |
426 | 438 |
427 if (allDataReceived) { | 439 if (allDataReceived) { |
428 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderC
lient; | 440 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderC
lient; |
429 | 441 |
430 Page::PageClients pageClients; | 442 Page::PageClients pageClients; |
431 fillWithEmptyClients(pageClients); | 443 fillWithEmptyClients(pageClients); |
432 m_chromeClient = adoptPtr(new SVGImageChromeClient(this)); | 444 m_chromeClient = adoptPtr(new SVGImageChromeClient(this)); |
433 pageClients.chromeClient = m_chromeClient.get(); | 445 pageClients.chromeClient = m_chromeClient.get(); |
434 | 446 |
435 // FIXME: If this SVG ends up loading itself, we might leak the world. | 447 // FIXME: If this SVG ends up loading itself, we might leak the world. |
436 // The Cache code does not know about ImageResources holding Frames and | 448 // The Cache code does not know about ImageResources holding Frames and |
437 // won't know to break the cycle. | 449 // won't know to break the cycle. |
438 // This will become an issue when SVGImage will be able to load other | 450 // This will become an issue when SVGImage will be able to load other |
439 // SVGImage objects, but we're safe now, because SVGImage can only be | 451 // SVGImage objects, but we're safe now, because SVGImage can only be |
440 // loaded by a top-level document. | 452 // loaded by a top-level document. |
441 m_page = adoptPtr(new Page(pageClients)); | 453 OwnPtr<Page> page = adoptPtr(new Page(pageClients)); |
442 m_page->settings().setScriptEnabled(false); | 454 page->settings().setScriptEnabled(false); |
443 m_page->settings().setPluginsEnabled(false); | 455 page->settings().setPluginsEnabled(false); |
444 m_page->settings().setAcceleratedCompositingEnabled(false); | 456 page->settings().setAcceleratedCompositingEnabled(false); |
445 | 457 |
446 RefPtr<LocalFrame> frame = LocalFrame::create(dummyFrameLoaderClient, &m
_page->frameHost(), 0); | 458 RefPtr<LocalFrame> frame = LocalFrame::create(dummyFrameLoaderClient, &p
age->frameHost(), 0); |
447 frame->setView(FrameView::create(frame.get())); | 459 frame->setView(FrameView::create(frame.get())); |
448 frame->init(); | 460 frame->init(); |
449 FrameLoader& loader = frame->loader(); | 461 FrameLoader& loader = frame->loader(); |
450 loader.forceSandboxFlags(SandboxAll); | 462 loader.forceSandboxFlags(SandboxAll); |
451 | 463 |
452 frame->view()->setScrollbarsSuppressed(true); | 464 frame->view()->setScrollbarsSuppressed(true); |
453 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy
nthesize a viewBox, if it's not available, and thus never see scrollbars. | 465 frame->view()->setCanHaveScrollbars(false); // SVG Images will always sy
nthesize a viewBox, if it's not available, and thus never see scrollbars. |
454 frame->view()->setTransparent(true); // SVG Images are transparent. | 466 frame->view()->setTransparent(true); // SVG Images are transparent. |
455 | 467 |
| 468 m_page = page.release(); |
| 469 |
456 loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "imag
e/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad))); | 470 loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "imag
e/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad))); |
457 // Set the intrinsic size before a container size is available. | 471 // Set the intrinsic size before a container size is available. |
458 m_intrinsicSize = containerSize(); | 472 m_intrinsicSize = containerSize(); |
459 } | 473 } |
460 | 474 |
461 return m_page; | 475 return m_page; |
462 } | 476 } |
463 | 477 |
464 String SVGImage::filenameExtension() const | 478 String SVGImage::filenameExtension() const |
465 { | 479 { |
466 return "svg"; | 480 return "svg"; |
467 } | 481 } |
468 | 482 |
469 } | 483 } |
OLD | NEW |