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